Skip to content

Commit b9d7f56

Browse files
authored
Use FindNearestFileOrDirectory, perl languageserver (#5038)
Update to use mentioned function to find both .git/ directories and .git worktree files. Co-authored-by: cos <cos>
1 parent 6d8e4a6 commit b9d7f56

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ale_linters/perl/languageserver.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function! ale_linters#perl#languageserver#GetProjectRoot(buffer) abort
99
" Makefile.PL, https://perldoc.perl.org/ExtUtils::MakeMaker
1010
" Build.PL, https://metacpan.org/pod/Module::Build
1111
" dist.ini, https://metacpan.org/pod/Dist::Zilla
12-
let l:potential_roots = [ 'Makefile.PL', 'Build.PL', 'dist.ini', '.git' ]
12+
let l:potential_roots = [ 'Makefile.PL', 'Build.PL', 'dist.ini' ]
1313

1414
for l:root in l:potential_roots
1515
let l:project_root = ale#path#FindNearestFile(a:buffer, l:root)
@@ -19,6 +19,12 @@ function! ale_linters#perl#languageserver#GetProjectRoot(buffer) abort
1919
endif
2020
endfor
2121

22+
let l:project_root = ale#path#FindNearestFileOrDirectory(a:buffer, '.git')
23+
24+
if !empty(l:project_root)
25+
return fnamemodify(l:project_root . '/', ':p:h:h')
26+
endif
27+
2228
return fnamemodify(expand('#' . a:buffer . ':p:h'), ':p:h')
2329
endfunction
2430

0 commit comments

Comments
 (0)