1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 03:00:04 +08:00

fix(projectmanager): fix :OpenProject command

This commit is contained in:
wsdjeg 2023-03-31 00:01:47 +08:00
parent 7b1f0b5d3a
commit a9c4268f8b
2 changed files with 13 additions and 6 deletions

View File

@ -10,7 +10,7 @@
if has('nvim-0.5.0') if has('nvim-0.5.0')
function! SpaceVim#plugins#projectmanager#complete_project(ArgLead, CmdLine, CursorPos) abort function! SpaceVim#plugins#projectmanager#complete_project(ArgLead, CmdLine, CursorPos) abort
return luaeval('require("spacevim.plugin.projectmanager").complete(' return luaeval('require("spacevim.plugin.projectmanager").complete_project('
\ .'require("spacevim").eval("a:ArgLead"),' \ .'require("spacevim").eval("a:ArgLead"),'
\ .'require("spacevim").eval("a:CmdLine"),' \ .'require("spacevim").eval("a:CmdLine"),'
\ .'require("spacevim").eval("a:CursorPos"))') \ .'require("spacevim").eval("a:CursorPos"))')
@ -268,8 +268,11 @@ else
endfunction endfunction
function! SpaceVim#plugins#projectmanager#OpenProject(p) abort function! SpaceVim#plugins#projectmanager#OpenProject(p) abort
let dir = get(g:, 'spacevim_src_root', '~') . a:p let dir = get(g:, 'spacevim_src_root', '~')
exe 'CtrlP '. dir let project_root = s:FILE.unify_path(dir, ':p') . a:p
if isdirectory(project_root)
call execute('tabnew | cd ' . project_root . ' | Startify')
endif
endfunction endfunction
" this function will use fuzzy find layer, now only denite and unite are " this function will use fuzzy find layer, now only denite and unite are
" supported. " supported.

View File

@ -366,10 +366,10 @@ function M.kill_project()
end end
function M.complete_project(arglead, cmdline, cursorpos) function M.complete_project(arglead, cmdline, cursorpos)
local dir = '~' local dir = vim.g.spacevim_src_root or '~'
local result = fn.split(fn.globpath(dir, '*'), '\n') local result = fn.split(fn.globpath(dir, '*'), '\n')
local ps = {} local ps = {}
for p in result do for _, p in pairs(result) do
if fn.isdirectory(p) == 1 and fn.isdirectory(p .. sp_file.separator .. '.git') == 1 then if fn.isdirectory(p) == 1 and fn.isdirectory(p .. sp_file.separator .. '.git') == 1 then
table.insert(ps, fn.fnamemodify(p, ':t')) table.insert(ps, fn.fnamemodify(p, ':t'))
end end
@ -378,7 +378,11 @@ function M.complete_project(arglead, cmdline, cursorpos)
end end
function M.OpenProject(p) function M.OpenProject(p)
sp.cmd('CtrlP ' .. dir) local dir = vim.g.spacevim_src_root or '~'
local project_root = sp_file.unify_path(dir, ':p') .. p
if vim.fn.isdirectory(project_root) == 1 then
sp.cmd('tabnew | cd ' .. project_root .. ' | Startify')
end
end end
function M.current_root() function M.current_root()