New option: g:startify_change_to_vcs_root
This commit is contained in:
parent
519609d26e
commit
a64ee097d8
|
@ -432,6 +432,9 @@ function! s:check_user_options() abort
|
|||
" autoload session
|
||||
if get(g:, 'startify_session_autoload') && filereadable(session)
|
||||
execute 'source' session
|
||||
" change to VCS root directory
|
||||
elseif get(g:, 'startify_change_to_vcs_root')
|
||||
call s:cd_to_vcs_root(path)
|
||||
" change directory
|
||||
elseif get(g:, 'startify_change_to_dir', 1)
|
||||
if isdirectory(path)
|
||||
|
@ -442,6 +445,18 @@ function! s:check_user_options() abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:cd_to_vcs_root {{{1
|
||||
function! s:cd_to_vcs_root(path) abort
|
||||
let dir = fnamemodify(a:path, ':p:h')
|
||||
for vcs in [ '.git', '.hg', '.bzr', '.svn' ]
|
||||
let root = finddir(vcs, dir .';')
|
||||
if !empty(root)
|
||||
execute 'cd '. fnamemodify(root, ':h')
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Function: s:close {{{1
|
||||
function! s:close() abort
|
||||
if len(filter(range(0, bufnr('$')), 'buflisted(v:val)'))
|
||||
|
|
|
@ -185,6 +185,14 @@ Automatically update sessions before exiting Vim.
|
|||
When opening a file or bookmark, change to its directory.
|
||||
|
||||
|
||||
============- *g:startify_change_to_vcs_root*
|
||||
|
||||
let g:startify_change_to_vcs_root = 0
|
||||
|
||||
When opening a file or bookmark, seek and change to the root directory of the
|
||||
VCS (if there is one).
|
||||
|
||||
|
||||
============- *g:startify_skiplist*
|
||||
|
||||
let g:startify_skiplist = []
|
||||
|
|
Loading…
Reference in a new issue