summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-10-25 15:22:34 +0100
committerGitHub <noreply@github.com>2018-10-25 15:22:34 +0100
commit9bdd5771ef85ca24aeadab80bb1d0976920e9305 (patch)
tree7780e78a361b0ae2d88ee2a7573317484137208e /ale_linters
parentb3829d043dec7c35870197eec4b50ab7a14ea1bf (diff)
parent7fa0d3dcc47a03c54c4450377ef8053b32e0139a (diff)
downloadale-9bdd5771ef85ca24aeadab80bb1d0976920e9305.zip
Merge pull request #2018 from muglug/patch-1
Update Psalm to use LSP
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/php/psalm.vim31
1 files changed, 12 insertions, 19 deletions
diff --git a/ale_linters/php/psalm.vim b/ale_linters/php/psalm.vim
index cd20ab81..dce59178 100644
--- a/ale_linters/php/psalm.vim
+++ b/ale_linters/php/psalm.vim
@@ -1,28 +1,21 @@
-" Author: richard marmorstein <https://github.com/twitchard>
+" Author: Matt Brown <https://github.com/muglug>
" Description: plugin for Psalm, static analyzer for PHP
-call ale#Set('php_psalm_executable', 'psalm')
+call ale#Set('psalm_langserver_executable', 'psalm-language-server')
+call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#php#psalm#Handle(buffer, lines) abort
- " Matches patterns like the following:
- let l:pattern = '^.*:\(\d\+\):\(\d\+\):\(\w\+\) - \(.*\)$'
- let l:output = []
+function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
+ let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
- for l:match in ale#util#GetMatches(a:lines, l:pattern)
- call add(l:output, {
- \ 'lnum': l:match[1] + 0,
- \ 'text': l:match[4],
- \ 'type': l:match[3][:0] is# 'e' ? 'E' : 'W',
- \})
- endfor
-
- return l:output
+ return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
call ale#linter#Define('php', {
\ 'name': 'psalm',
-\ 'command': '%e --diff --output-format=emacs %s',
-\ 'executable_callback': ale#VarFunc('php_psalm_executable'),
-\ 'callback': 'ale_linters#php#psalm#Handle',
-\ 'lint_file': 1,
+\ 'lsp': 'stdio',
+\ 'executable_callback': ale#node#FindExecutableFunc('psalm_langserver', [
+\ 'vendor/bin/psalm-language-server',
+\ ]),
+\ 'command': '%e',
+\ 'project_root_callback': 'ale_linters#php#psalm#GetProjectRoot',
\})