Skip to content

Commit 061bf87

Browse files
author
skywind3000
committed
Refactor asyncrun#locator#buffer_path() function to asyncrun#locator#nofile_buffer_path()
and add condition to handle NeogitStatus filetype in nvim
1 parent 08b871b commit 061bf87

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

autoload/asyncrun/locator.vim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"----------------------------------------------------------------------
1212
" guess current buffer's directory
1313
"----------------------------------------------------------------------
14-
function! asyncrun#locator#buffer_path()
14+
function! asyncrun#locator#nofile_buffer_path()
1515
if &bt == ''
1616
return ''
1717
elseif &bt == 'nofile'
@@ -29,6 +29,12 @@ function! asyncrun#locator#buffer_path()
2929
if exists('b:magit_top_dir')
3030
return b:magit_top_dir
3131
endif
32+
elseif &ft == 'NeogitStatus' && has('nvim')
33+
try
34+
let t = luaeval('require("neogit.lib.git").repo.git_root')
35+
return t
36+
catch
37+
endtry
3238
endif
3339
if exists('b:git_dir')
3440
return b:git_dir
@@ -45,7 +51,7 @@ function! asyncrun#locator#detect()
4551
if &bt == ''
4652
return ''
4753
endif
48-
let path = asyncrun#locator#buffer_path()
54+
let path = asyncrun#locator#nofile_buffer_path()
4955
if path != '' && (isdirectory(path) || filereadable(path))
5056
return asyncrun#get_root(path)
5157
endif

0 commit comments

Comments
 (0)