mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-13 10:08:32 +08:00
Add support for PerlNavigator (#5028)
* Add support for PerlNavigator * fixup! Add support for PerlNavigator * fixup! fixup! Add support for PerlNavigator * fixup! fixup! fixup! Add support for PerlNavigator --------- Co-authored-by: cos <cos>
This commit is contained in:
@@ -5,29 +5,6 @@
|
||||
call ale#Set('perl_perl_executable', 'perl')
|
||||
" Please note that perl_perl_options does not exist here.
|
||||
|
||||
function! ale_linters#perl#languageserver#GetProjectRoot(buffer) abort
|
||||
" Makefile.PL, https://perldoc.perl.org/ExtUtils::MakeMaker
|
||||
" Build.PL, https://metacpan.org/pod/Module::Build
|
||||
" dist.ini, https://metacpan.org/pod/Dist::Zilla
|
||||
let l:potential_roots = [ 'Makefile.PL', 'Build.PL', 'dist.ini' ]
|
||||
|
||||
for l:root in l:potential_roots
|
||||
let l:project_root = ale#path#FindNearestFile(a:buffer, l:root)
|
||||
|
||||
if !empty(l:project_root)
|
||||
return fnamemodify(l:project_root . '/', ':p:h:h')
|
||||
endif
|
||||
endfor
|
||||
|
||||
let l:project_root = ale#path#FindNearestFileOrDirectory(a:buffer, '.git')
|
||||
|
||||
if !empty(l:project_root)
|
||||
return fnamemodify(l:project_root . '/', ':p:h:h')
|
||||
endif
|
||||
|
||||
return fnamemodify(expand('#' . a:buffer . ':p:h'), ':p:h')
|
||||
endfunction
|
||||
|
||||
call ale#Set('perl_languageserver_config', {})
|
||||
|
||||
function! s:get_lsp_config(buffer) abort
|
||||
@@ -45,5 +22,5 @@ call ale#linter#Define('perl', {
|
||||
\ 'executable': {b -> ale#Var(b, 'perl_perl_executable')},
|
||||
\ 'command': '%e -MPerl::LanguageServer -ePerl::LanguageServer::run',
|
||||
\ 'lsp_config': {b -> s:get_lsp_config(b)},
|
||||
\ 'project_root': function('ale_linters#perl#languageserver#GetProjectRoot'),
|
||||
\ 'project_root': function('ale#handlers#perl#GetProjectRoot'),
|
||||
\ })
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
" Author: rymdbar <https://rymdbar.x20.se/>
|
||||
" Description: Perl Navigator Language Server
|
||||
" See: https://github.com/bscan/PerlNavigator
|
||||
|
||||
call ale#Set('perl_perlnavigator_config', {})
|
||||
call ale#Set('perl_perlnavigator_executable', 'perlnavigator')
|
||||
|
||||
call ale#linter#Define('perl', {
|
||||
\ 'name': 'perlnavigator',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'perl_perlnavigator_executable')},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'perl_perlnavigator_config')},
|
||||
\ 'project_root': function('ale#handlers#perl#GetProjectRoot'),
|
||||
\ })
|
||||
Reference in New Issue
Block a user