mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 22:30:04 +08:00
feat(mapping): add SPC f v s
to view scriptnames
This commit is contained in:
parent
076c0fe4a6
commit
3daea9e7ae
@ -297,6 +297,17 @@ function! s:defind_fuzzy_finder() abort
|
|||||||
\ ]
|
\ ]
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
|
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 's'], 'Telescope scriptnames',
|
||||||
|
\ ['open-custom-configuration',
|
||||||
|
\ [
|
||||||
|
\ '[SPC f v d] is to open the custom configuration file for SpaceVim',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ]
|
||||||
|
\ , 1)
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" function() wrapper
|
" function() wrapper
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
lua require('telescope').load_extension('menu')
|
lua require('telescope').load_extension('menu')
|
||||||
lua require('telescope').load_extension('messages')
|
lua require('telescope').load_extension('messages')
|
||||||
|
lua require('telescope').load_extension('scriptnames')
|
||||||
lua <<EOF
|
lua <<EOF
|
||||||
local actions = require("telescope.actions")
|
local actions = require("telescope.actions")
|
||||||
require("telescope").setup{
|
require("telescope").setup{
|
||||||
|
@ -1502,9 +1502,10 @@ The first item is the name of the tool, the second one is the default searching
|
|||||||
Convenient key bindings are located under the prefix `SPC f v` to quickly navigate between Vim and SpaceVim specific files.
|
Convenient key bindings are located under the prefix `SPC f v` to quickly navigate between Vim and SpaceVim specific files.
|
||||||
|
|
||||||
| Key Bindings | Descriptions |
|
| Key Bindings | Descriptions |
|
||||||
| ------------ | --------------------------------------- |
|
| ------------ | ------------------------------------------------ |
|
||||||
| `SPC f v v` | display and copy SpaceVim version |
|
| `SPC f v v` | display and copy SpaceVim version |
|
||||||
| `SPC f v d` | open SpaceVim custom configuration file |
|
| `SPC f v d` | open SpaceVim custom configuration file |
|
||||||
|
| `SPC f v s` | list all loaded vim scripts, like `:scriptnames` |
|
||||||
|
|
||||||
### Available layers
|
### Available layers
|
||||||
|
|
||||||
|
49
lua/telescope/_extensions/scriptnames.lua
Normal file
49
lua/telescope/_extensions/scriptnames.lua
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
local action_state = require("telescope.actions.state")
|
||||||
|
local actions = require("telescope.actions")
|
||||||
|
local conf = require("telescope.config").values
|
||||||
|
local entry_display = require("telescope.pickers.entry_display")
|
||||||
|
local finders = require("telescope.finders")
|
||||||
|
local pickers = require("telescope.pickers")
|
||||||
|
local sp_file = require('spacevim.api').import('file')
|
||||||
|
|
||||||
|
local function prepare_output_table()
|
||||||
|
local lines = {}
|
||||||
|
local scripts = vim.api.nvim_command_output("scriptnames")
|
||||||
|
|
||||||
|
for script in scripts:gmatch("[^\r\n]+") do
|
||||||
|
table.insert(lines, script)
|
||||||
|
end
|
||||||
|
return lines
|
||||||
|
end
|
||||||
|
|
||||||
|
local function show_script_names(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
pickers.new(opts, {
|
||||||
|
prompt_title = "Script Names",
|
||||||
|
finder = finders.new_table {
|
||||||
|
results = prepare_output_table()
|
||||||
|
},
|
||||||
|
sorter = conf.generic_sorter(opts),
|
||||||
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
|
actions.select_default:replace(function()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
local entry = action_state.get_selected_entry()
|
||||||
|
-- print(vim.inspect(selection))
|
||||||
|
-- vim.cmd("e " + entry.value)
|
||||||
|
vim.cmd('e ' .. vim.fn.split(entry.value, ": ")[2])
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}):find()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function run()
|
||||||
|
show_script_names()
|
||||||
|
end
|
||||||
|
|
||||||
|
return require("telescope").register_extension({
|
||||||
|
exports = {
|
||||||
|
-- Default when to argument is given, i.e. :Telescope scriptnames
|
||||||
|
scriptnames = run,
|
||||||
|
},
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user