mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:30:05 +08:00
feat(projectmanager): improve Telescope project extension
This commit is contained in:
parent
3c8514f611
commit
d69df0a152
@ -129,7 +129,7 @@ else
|
||||
for key in s:sort_by_opened_time()
|
||||
let desc = '[' . s:project_paths[key].name . '] ' . s:project_paths[key].path . ' <' . strftime('%Y-%m-%d %T', s:project_paths[key].opened_time) . '>'
|
||||
let cmd = "call SpaceVim#plugins#projectmanager#open('" . s:project_paths[key].path . "')"
|
||||
call add(g:unite_source_menu_menus.Projects.command_candidates, [desc,cmd])
|
||||
call add(g:unite_source_menu_menus.Projects.command_candidates, [desc, cmd, s:project_paths[key]])
|
||||
endfor
|
||||
if g:spacevim_enable_projects_cache
|
||||
call s:cache()
|
||||
|
@ -70,6 +70,11 @@ you need to change `project_rooter_outermost` to `false`.
|
||||
project_rooter_outermost = false
|
||||
```
|
||||
|
||||
If you want to list all recent opened project, you need to load a fuzzy finder layer.
|
||||
for example `telescope` layer, the the key binding `SPC p p` is available for you.
|
||||
|
||||
![image](https://user-images.githubusercontent.com/13142418/169195419-329a1b58-850d-40a8-ba02-d0e1f9367305.png)
|
||||
|
||||
### Fuzzy finder
|
||||
|
||||
SpaceVim provides 5 fuzzy finder layer, they are unite, denite, fzf, leaderf and ctrlp.
|
||||
|
@ -5,45 +5,43 @@ 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 function get_all_projects()
|
||||
local p = {}
|
||||
local projects = vim.api.nvim_eval('g:unite_source_menu_menus.Projects.command_candidates')
|
||||
|
||||
for _, project in pairs(projects) do
|
||||
table.insert(lines, project)
|
||||
table.insert(p, project)
|
||||
end
|
||||
return lines
|
||||
return p
|
||||
end
|
||||
|
||||
local function show_changes(opts)
|
||||
opts = opts or {}
|
||||
-- local displayer = entry_display.create({
|
||||
-- separator = ' ',
|
||||
-- items = {
|
||||
-- { width = 4 },
|
||||
-- { remaining = true },
|
||||
-- { remaining = true },
|
||||
-- },
|
||||
-- })
|
||||
-- local function make_display(entry)
|
||||
-- return displayer({
|
||||
-- { entry.value.type, 'TelescopeResultsVariable' },
|
||||
-- { entry.value.name, 'TelescopeResultsFunction' },
|
||||
-- { '[' .. entry.value.line .. ']', 'TelescopeResultsComment' },
|
||||
-- })
|
||||
-- end
|
||||
-- local function make_display(v)
|
||||
--
|
||||
-- end
|
||||
local displayer = entry_display.create({
|
||||
separator = ' ',
|
||||
items = {
|
||||
{ width = 20 },
|
||||
{ width = vim.api.nvim_win_get_width(0) - 60 },
|
||||
{ remaining = true },
|
||||
},
|
||||
})
|
||||
local function make_display(entry)
|
||||
-- print(vim.inspect(entry))
|
||||
return displayer({
|
||||
{ '[' .. entry.value.name .. ']', 'TelescopeResultsVariable' },
|
||||
{ entry.value.path, 'TelescopeResultsFunction' },
|
||||
{ '<' .. vim.fn.strftime('%Y-%m-%d %T', entry.value.opened_time) .. '>', 'TelescopeResultsComment' },
|
||||
})
|
||||
end
|
||||
pickers.new(opts, {
|
||||
prompt_title = "Projects",
|
||||
finder = finders.new_table {
|
||||
results = prepare_output_table(),
|
||||
results = get_all_projects(),
|
||||
entry_maker = function(entry)
|
||||
return {
|
||||
value = entry,
|
||||
value = entry[3],
|
||||
command = entry[2],
|
||||
display = entry[1],
|
||||
display = make_display,
|
||||
ordinal = entry[1]
|
||||
}
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user