Skip to content

Commit

Permalink
Extract s:current_file()
Browse files Browse the repository at this point in the history
  • Loading branch information
airblade committed Apr 23, 2024
1 parent 1353fa4 commit f3b4aba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions plugin/rooter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,19 @@ endfunction

" Returns full path of directory of current file name (which may be a directory).
function! s:current()
let fn = expand('%:p', 1)
if fn =~ 'NERD_tree_\d\+$' | let fn = b:NERDTree.root.path.str().'/' | endif
let fn = s:current_file()
if empty(fn) | return getcwd() | endif " opening vim without a file
if g:rooter_resolve_links | let fn = resolve(fn) | endif
return fnamemodify(fn, ':h')
endfunction

" Returns full path of current file name
function s:current_file()
let fn = expand('%:p', 1)
if fn =~ 'NERD_tree_\d\+$' | let fn = b:NERDTree.root.path.str().'/' | endif
if fn[:5] == 'oil://' | let fn = fn[5:] | endif
if g:rooter_resolve_links | let fn = resolve(fn) | endif
return fn
endfunction

" Returns full path of dir's parent directory.
function! s:parent(dir)
Expand Down

0 comments on commit f3b4aba

Please sign in to comment.