New option: g:startify_change_cmd

Different people prefer different values. Can be set to 'cd', 'lcd', or 'tcd'.

Closes https://github.com/mhinz/vim-startify/issues/425
This commit is contained in:
Marco Hinz 2020-10-07 14:37:48 +02:00 committed by Marco Hinz
parent e18fa54e64
commit aa6b82783b
2 changed files with 27 additions and 3 deletions

View file

@ -953,11 +953,11 @@ function! s:check_user_options(path) abort
if get(g:, 'startify_change_to_dir', 1)
if isdirectory(a:path)
execute 'lcd' a:path
execute s:cd_cmd() a:path
else
let dir = fnamemodify(a:path, ':h')
if isdirectory(dir)
execute 'lcd' dir
execute s:cd_cmd() dir
else
" Do nothing. E.g. a:path == `scp://foo/bar`
endif
@ -971,13 +971,23 @@ function! s:cd_to_vcs_root(path) abort
for vcs in [ '.git', '.hg', '.bzr', '.svn' ]
let root = finddir(vcs, dir .';')
if !empty(root)
execute 'lcd' fnameescape(fnamemodify(root, ':h'))
execute s:cd_cmd() fnameescape(fnamemodify(root, ':h'))
return 1
endif
endfor
return 0
endfunction
" Function: s:cd_cmd {{{1
function! s:cd_cmd() abort
let g:startify_change_cmd = get(g:, 'startify_change_cmd', 'lcd')
if g:startify_change_cmd !~# '^[lt]\?cd$'
call s:warn('Invalid value for g:startify_change_cmd. Defaulting to :lcd')
let g:startify_change_cmd = 'lcd'
endif
return g:startify_change_cmd
endfunction
" Function: s:close {{{1
function! s:close() abort
if len(filter(range(0, bufnr('$')), 'buflisted(v:val)')) - &buflisted