mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 15:19:12 +08:00
Tabmanager name (#4427)
This commit is contained in:
parent
d7ccf9370c
commit
12e19d8db0
@ -66,6 +66,16 @@ else
|
||||
let s:LIST = SpaceVim#api#import('data#list')
|
||||
let s:VIM = SpaceVim#api#import('vim')
|
||||
|
||||
" use cd or lcd or tcd
|
||||
"
|
||||
if exists(':tcd')
|
||||
let s:cd = 'tcd'
|
||||
elseif exists(':lcd')
|
||||
let s:cd = 'lcd'
|
||||
else
|
||||
let s:cd = 'cd'
|
||||
endif
|
||||
|
||||
function! s:update_rooter_patterns() abort
|
||||
let s:project_rooter_patterns = filter(copy(g:spacevim_project_rooter_patterns), 'v:val !~# "^!"')
|
||||
let s:project_rooter_ignores = map(filter(copy(g:spacevim_project_rooter_patterns), 'v:val =~# "^!"'), 'v:val[1:]')
|
||||
@ -160,7 +170,7 @@ else
|
||||
call s:LOGGER.info('same as current directory, no need to change.')
|
||||
else
|
||||
call s:LOGGER.info('change to root: ' . a:dir)
|
||||
exe 'cd ' . fnameescape(fnamemodify(a:dir, ':p'))
|
||||
exe s:cd fnameescape(fnamemodify(a:dir, ':p'))
|
||||
try
|
||||
let b:git_dir = fugitive#extract_git_dir(expand('%:p'))
|
||||
catch
|
||||
@ -281,7 +291,7 @@ else
|
||||
function! SpaceVim#plugins#projectmanager#open(project) abort
|
||||
let path = s:project_paths[a:project]['path']
|
||||
tabnew
|
||||
exe 'lcd ' . path
|
||||
exe s:cd path
|
||||
if g:spacevim_filemanager ==# 'vimfiler'
|
||||
Startify | VimFiler
|
||||
elseif g:spacevim_filemanager ==# 'nerdtree'
|
||||
|
@ -69,6 +69,17 @@ function! s:init_buffer() abort
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! s:workspace_directory(tabnr) abort
|
||||
if exists(':tcd')
|
||||
return getcwd(-1, str2nr(a:tabnr))
|
||||
elseif exists('*win_getid')
|
||||
return getcwd(win_getid(tabpagewinnr(a:tabnr)))
|
||||
elseif exists(':lcd')
|
||||
let bufnr = tabpagebuflist(a:tabnr)[tabpagewinnr(a:tabnr) - 1]
|
||||
return getbufvar('%', 'rootDir', '')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:update_context() abort
|
||||
setl modifiable
|
||||
silent! normal! gg"_dG
|
||||
@ -79,7 +90,7 @@ function! s:update_context() abort
|
||||
call add(ctx,
|
||||
\ '▼ ' . (page == tabpagenr() ? '*' : ' ')
|
||||
\ . 'Tab ' . page
|
||||
\ . ' ' . gettabvar(page, '_spacevim_tab_name', bufname(tabpagebuflist(page)[tabpagewinnr(page) - 1]))
|
||||
\ . ' ' . gettabvar(page, '_spacevim_tab_name', fnamemodify(s:workspace_directory(page), ':t'))
|
||||
\ )
|
||||
let winid = 1
|
||||
for _buf in tree[page]
|
||||
@ -94,7 +105,7 @@ function! s:update_context() abort
|
||||
call add(ctx,
|
||||
\ '▷ ' . (page == tabpagenr() ? '*' : ' ')
|
||||
\ . 'Tab ' . page
|
||||
\ . ' ' . gettabvar(page, '_spacevim_tab_name', bufname(tabpagebuflist(page)[tabpagewinnr(page) - 1]))
|
||||
\ . ' ' . gettabvar(page, '_spacevim_tab_name', fnamemodify(s:workspace_directory(page), ':t'))
|
||||
\ )
|
||||
endif
|
||||
endfor
|
||||
|
@ -20,6 +20,14 @@ local project_rooter_patterns = {}
|
||||
local project_rooter_ignores = {}
|
||||
local project_callback = {}
|
||||
|
||||
|
||||
local cd = 'cd'
|
||||
if fn.exists(':tcd') then
|
||||
cd = 'tcd'
|
||||
elseif fn.exists(':lcd') then
|
||||
cd = 'lcd'
|
||||
end
|
||||
|
||||
local function update_rooter_patterns()
|
||||
project_rooter_patterns = {}
|
||||
project_rooter_ignores = {}
|
||||
@ -35,8 +43,8 @@ local function is_ignored_dir(dir)
|
||||
for _,v in pairs(project_rooter_ignores) do
|
||||
if string.match(dir, v) ~= nil then
|
||||
logger.debug('this is an ignored dir:' .. dir)
|
||||
return true
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -109,7 +117,7 @@ local function change_dir(dir)
|
||||
else
|
||||
if dir ~= nil then
|
||||
logger.info('change to root: ' .. dir)
|
||||
sp.cmd('cd ' .. sp.fn.fnameescape(sp.fn.fnamemodify(dir, ':p')))
|
||||
sp.cmd(cd .. ' ' .. sp.fn.fnameescape(sp.fn.fnamemodify(dir, ':p')))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -239,7 +247,7 @@ end
|
||||
function M.open(project)
|
||||
local path = project_paths[project]['path']
|
||||
sp.cmd('tabnew')
|
||||
sp.cmd('lcd ' .. path)
|
||||
sp.cmd(cd .. ' ' .. path)
|
||||
if sp_opt.filemanager == 'vimfiler' then
|
||||
sp.cmd('Startify | VimFiler')
|
||||
elseif sp_opt.filemanager == 'nerdtree' then
|
||||
|
Loading…
x
Reference in New Issue
Block a user