-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlighttree.vim
57 lines (47 loc) · 1.35 KB
/
lighttree.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function! lighttree#echo(msg)
redraw
echomsg "LightTree: " . a:msg
endfunction
function! lighttree#echoError(msg)
echohl errormsg
call lighttree#echo(a:msg)
echohl normal
endfunction
function! lighttree#echoWarning(msg)
echohl warningmsg
call lighttree#echo(a:msg)
echohl normal
endfunction
function! lighttree#find_and_reveal_path()
try
let p = g:NERDTreePath.New(expand("%:p"))
catch /^NERDTree.InvalidArgumentsError/
call lighttree#echo("no file for the current buffer")
return
endtry
if p.isUnixHiddenPath()
let showhidden=g:LightTreeShowHidden
let g:LightTreeShowHidden = 1
endif
try
let rootDir = g:NERDTreePath.New(getcwd())
catch /^NERDTree.InvalidArgumentsError/
call lighttree#echo("current directory does not exist.")
let rootDir = p.getParent()
endtry
if p.isUnder(rootDir)
call lighttree#buffer#restore_or_create(rootDir.str())
else
call lighttree#buffer#restore_or_create(p.getParent().str())
endif
let node = b:tree.root.reveal(p)
if node == {}
call lighttree#ui_glue#refreshRoot()
let node = b:tree.root.reveal(p)
end
call b:tree.ui.render()
call node.putCursorHere(1)
if p.isUnixHiddenFile()
let g:LightTreeShowHidden = showhidden
endif
endfunction