summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2023-03-07 20:29:10 +0100
committercos <cos>2023-11-12 13:55:08 +0100
commitaa410cd95be4b4368b5c9bc1d594937333a93a8d (patch)
tree175551f69907c209dbe4d1eeb7371c1dcd4c1a76
parent50e237facda4b9c3761c3f3e9df185cfdf3d91e8 (diff)
downloadale-aa410cd95be4b4368b5c9bc1d594937333a93a8d.zip
Add support for perl language servertopic/plls
-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*