mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:50:04 +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()
|
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 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 . "')"
|
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
|
endfor
|
||||||
if g:spacevim_enable_projects_cache
|
if g:spacevim_enable_projects_cache
|
||||||
call s:cache()
|
call s:cache()
|
||||||
|
@ -70,6 +70,11 @@ you need to change `project_rooter_outermost` to `false`.
|
|||||||
project_rooter_outermost = 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
|
### Fuzzy finder
|
||||||
|
|
||||||
SpaceVim provides 5 fuzzy finder layer, they are unite, denite, fzf, leaderf and ctrlp.
|
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 finders = require("telescope.finders")
|
||||||
local pickers = require("telescope.pickers")
|
local pickers = require("telescope.pickers")
|
||||||
|
|
||||||
local function prepare_output_table()
|
local function get_all_projects()
|
||||||
local lines = {}
|
local p = {}
|
||||||
local projects = vim.api.nvim_eval('g:unite_source_menu_menus.Projects.command_candidates')
|
local projects = vim.api.nvim_eval('g:unite_source_menu_menus.Projects.command_candidates')
|
||||||
|
|
||||||
for _, project in pairs(projects) do
|
for _, project in pairs(projects) do
|
||||||
table.insert(lines, project)
|
table.insert(p, project)
|
||||||
end
|
end
|
||||||
return lines
|
return p
|
||||||
end
|
end
|
||||||
|
|
||||||
local function show_changes(opts)
|
local function show_changes(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
-- local displayer = entry_display.create({
|
local displayer = entry_display.create({
|
||||||
-- separator = ' ',
|
separator = ' ',
|
||||||
-- items = {
|
items = {
|
||||||
-- { width = 4 },
|
{ width = 20 },
|
||||||
-- { remaining = true },
|
{ width = vim.api.nvim_win_get_width(0) - 60 },
|
||||||
-- { remaining = true },
|
{ remaining = true },
|
||||||
-- },
|
},
|
||||||
-- })
|
})
|
||||||
-- local function make_display(entry)
|
local function make_display(entry)
|
||||||
-- return displayer({
|
-- print(vim.inspect(entry))
|
||||||
-- { entry.value.type, 'TelescopeResultsVariable' },
|
return displayer({
|
||||||
-- { entry.value.name, 'TelescopeResultsFunction' },
|
{ '[' .. entry.value.name .. ']', 'TelescopeResultsVariable' },
|
||||||
-- { '[' .. entry.value.line .. ']', 'TelescopeResultsComment' },
|
{ entry.value.path, 'TelescopeResultsFunction' },
|
||||||
-- })
|
{ '<' .. vim.fn.strftime('%Y-%m-%d %T', entry.value.opened_time) .. '>', 'TelescopeResultsComment' },
|
||||||
-- end
|
})
|
||||||
-- local function make_display(v)
|
end
|
||||||
--
|
|
||||||
-- end
|
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
prompt_title = "Projects",
|
prompt_title = "Projects",
|
||||||
finder = finders.new_table {
|
finder = finders.new_table {
|
||||||
results = prepare_output_table(),
|
results = get_all_projects(),
|
||||||
entry_maker = function(entry)
|
entry_maker = function(entry)
|
||||||
return {
|
return {
|
||||||
value = entry,
|
value = entry[3],
|
||||||
command = entry[2],
|
command = entry[2],
|
||||||
display = entry[1],
|
display = make_display,
|
||||||
ordinal = entry[1]
|
ordinal = entry[1]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user