diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index da63c8ea5..1c0da2e88 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -10,7 +10,7 @@ if has('nvim-0.5.0') 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:CmdLine"),' \ .'require("spacevim").eval("a:CursorPos"))') @@ -268,8 +268,11 @@ else endfunction function! SpaceVim#plugins#projectmanager#OpenProject(p) abort - let dir = get(g:, 'spacevim_src_root', '~') . a:p - exe 'CtrlP '. dir + let dir = get(g:, 'spacevim_src_root', '~') + let project_root = s:FILE.unify_path(dir, ':p') . a:p + if isdirectory(project_root) + call execute('tabnew | cd ' . project_root . ' | Startify') + endif endfunction " this function will use fuzzy find layer, now only denite and unite are " supported. diff --git a/lua/spacevim/plugin/projectmanager.lua b/lua/spacevim/plugin/projectmanager.lua index daabddb00..b72bf34fc 100644 --- a/lua/spacevim/plugin/projectmanager.lua +++ b/lua/spacevim/plugin/projectmanager.lua @@ -366,10 +366,10 @@ function M.kill_project() end 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 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 table.insert(ps, fn.fnamemodify(p, ':t')) end @@ -378,7 +378,11 @@ function M.complete_project(arglead, cmdline, cursorpos) end 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 function M.current_root()