Skip to content

Commit 915e36a

Browse files
author
skywind3000
committed
Add detection for file paths in NvimTree and defx plugins, and adjust handling for oil file paths in asyncrun#locator#nofile_buffer_path function
1 parent 44a5e8a commit 915e36a

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

autoload/asyncrun/locator.vim

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,34 @@ function! asyncrun#locator#nofile_buffer_path() abort
105105
catch
106106
endtry
107107
endtry
108+
elseif &ft == 'NvimTree'
109+
try
110+
let t = luaeval('require("nvim-tree.api").tree.get_nodes().absolute_path')
111+
return t
112+
catch
113+
endtry
114+
elseif &ft == 'defx'
115+
if exists('b:defx')
116+
try
117+
let t = b:defx.paths[0]
118+
return t
119+
catch
120+
endtry
121+
endif
108122
endif
109123
if exists('b:git_dir')
110124
return b:git_dir
111125
endif
112-
endif
113-
if &ft == 'oil' && &bt != ''
114-
let name = bufname('%')
115-
if name =~ '\v^oil\:[\\\/][\\\/]'
116-
let t = strpart(name, s:windows? 7 : 6)
117-
if s:windows && t =~ '\v^\w[\\\/]'
118-
let t = strpart(t, 0, 1) . ':' . strpart(t, 1)
126+
elseif &bt != ''
127+
if &ft == 'oil'
128+
let name = bufname('%')
129+
if name =~ '\v^oil\:[\\\/][\\\/]'
130+
let t = strpart(name, s:windows? 7 : 6)
131+
if s:windows && t =~ '\v^\w[\\\/]'
132+
let t = strpart(t, 0, 1) . ':' . strpart(t, 1)
133+
endif
134+
return t
119135
endif
120-
return t
121136
endif
122137
endif
123138
return ''

0 commit comments

Comments
 (0)