mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 10:30:05 +08:00
feat(project): add SPC p p
for telescope layer
This commit is contained in:
parent
1ff70c5873
commit
8deb3918cc
@ -283,6 +283,8 @@ else
|
|||||||
FzfMenu Projects
|
FzfMenu Projects
|
||||||
elseif SpaceVim#layers#isLoaded('leaderf')
|
elseif SpaceVim#layers#isLoaded('leaderf')
|
||||||
call SpaceVim#layers#leaderf#run_menu('Projects')
|
call SpaceVim#layers#leaderf#run_menu('Projects')
|
||||||
|
elseif SpaceVim#layers#isLoaded('telescope')
|
||||||
|
Telescope project
|
||||||
else
|
else
|
||||||
call SpaceVim#logger#warn('fuzzy find layer is needed to find project!')
|
call SpaceVim#logger#warn('fuzzy find layer is needed to find project!')
|
||||||
endif
|
endif
|
||||||
|
@ -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('project')
|
||||||
lua require('telescope').load_extension('scriptnames')
|
lua require('telescope').load_extension('scriptnames')
|
||||||
lua <<EOF
|
lua <<EOF
|
||||||
local actions = require("telescope.actions")
|
local actions = require("telescope.actions")
|
||||||
|
54
lua/telescope/_extensions/project.lua
Normal file
54
lua/telescope/_extensions/project.lua
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
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 function prepare_output_table()
|
||||||
|
local lines = {}
|
||||||
|
local projects = vim.api.nvim_eval('g:unite_source_menu_menus.Projects.command_candidates')
|
||||||
|
|
||||||
|
for _, project in pairs(projects) do
|
||||||
|
table.insert(lines, project)
|
||||||
|
end
|
||||||
|
return lines
|
||||||
|
end
|
||||||
|
|
||||||
|
local function show_changes(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
pickers.new(opts, {
|
||||||
|
prompt_title = "Projects",
|
||||||
|
finder = finders.new_table {
|
||||||
|
results = prepare_output_table(),
|
||||||
|
entry_maker = function(entry)
|
||||||
|
return {
|
||||||
|
value = entry,
|
||||||
|
display = entry[1],
|
||||||
|
command = entry[2],
|
||||||
|
}
|
||||||
|
end
|
||||||
|
},
|
||||||
|
sorter = conf.generic_sorter(opts),
|
||||||
|
attach_mappings = function(prompt_bufnr)
|
||||||
|
actions.select_default:replace(function()
|
||||||
|
local entry = action_state.get_selected_entry()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
print(entry.display, entry.command)
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}):find()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function run()
|
||||||
|
show_changes()
|
||||||
|
end
|
||||||
|
|
||||||
|
return require("telescope").register_extension({
|
||||||
|
exports = {
|
||||||
|
-- Default when to argument is given, i.e. :Telescope project
|
||||||
|
project = run,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user