summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/perl/plls.vim45
-rw-r--r--doc/ale-perl.txt6
2 files changed, 51 insertions, 0 deletions
diff --git a/ale_linters/perl/plls.vim b/ale_linters/perl/plls.vim
new file mode 100644
index 00000000..3dd642cc
--- /dev/null
+++ b/ale_linters/perl/plls.vim
@@ -0,0 +1,45 @@
+function! ale_linters#perl#plls#GetProjectRoot(buffer) abort
+ let l:potential_roots = [
+ \ 'Makefile.PL',
+ \ 'Build.PL',
+ \ 'dist.ini',
+ \ 'MYMETA.yml',
+ \ 'META.yml',
+ \ '.git',
+ \ bufname(a:buffer),
+ \ ]
+
+ for l:root in l:potential_roots
+ let l:project_root = ale#path#FindNearestFile(
+ \ a:buffer,
+ \ l:root,
+ \ )
+
+ if empty(l:project_root)
+ let l:project_root = ale#path#FindNearestDirectory(
+ \ a:buffer,
+ \ l:root,
+ \ )
+ endif
+
+ if !empty(l:project_root)
+ " dir:p expands to /full/path/to/dir/ whereas
+ " file:p expands to /full/path/to/file (no trailing slash)
+ " Appending '/' ensures that :h:h removes the path's last segment
+ " regardless of whether it is a directory or not.
+ return fnamemodify(l:project_root . '/', ':p:h:h')
+ endif
+ endfor
+
+ return ''
+endfunction
+
+call ale#Set('perl_plls_config', {})
+call ale#linter#Define('perl', {
+\ 'name': 'plls',
+\ 'lsp': 'stdio',
+\ 'executable': {b -> ale#Var(b, 'perl_perl_executable')},
+\ 'command': '%e -MPerl::LanguageServer -ePerl::LanguageServer::run',
+\ 'lsp_config': {b -> ale#Var(b, 'perl_plls_config')},
+\ 'project_root': function('ale_linters#perl#plls#GetProjectRoot'),
+\ })
diff --git a/doc/ale-perl.txt b/doc/ale-perl.txt
index 5eebc0e3..19751e98 100644
--- a/doc/ale-perl.txt
+++ b/doc/ale-perl.txt
@@ -77,6 +77,12 @@ g:ale_perl_perlcritic_showrules *g:ale_perl_perlcritic_showrules*
Controls whether perlcritic rule names are shown after the error message.
Defaults to off to reduce length of message.
===============================================================================
+perl language server *ale-perl-plls*
+
+g:ale_perl_plls_config *g:ale_perl_plls_config*
+ *b:ale_perl_plls_config*
+
+===============================================================================
perltidy *ale-perl-perltidy*
g:ale_perl_perltidy_options *g:ale_perl_perltidy_options*