summaryrefslogtreecommitdiff
path: root/ale_linters/php/langserver.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/php/langserver.vim')
-rw-r--r--ale_linters/php/langserver.vim12
1 files changed, 9 insertions, 3 deletions
diff --git a/ale_linters/php/langserver.vim b/ale_linters/php/langserver.vim
index ca91db4c..fdd1bf2b 100644
--- a/ale_linters/php/langserver.vim
+++ b/ale_linters/php/langserver.vim
@@ -5,6 +5,12 @@ call ale#Set('php_langserver_executable', 'php-language-server.php')
call ale#Set('php_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#php#langserver#GetProjectRoot(buffer) abort
+ let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json')
+
+ if (!empty(l:composer_path))
+ return fnamemodify(l:composer_path, ':h')
+ endif
+
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
@@ -13,9 +19,9 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'langserver',
\ 'lsp': 'stdio',
-\ 'executable_callback': ale#node#FindExecutableFunc('php_langserver', [
+\ 'executable': {b -> ale#node#FindExecutable(b, 'php_langserver', [
\ 'vendor/bin/php-language-server.php',
-\ ]),
+\ ])},
\ 'command': 'php %e',
-\ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot',
+\ 'project_root': function('ale_linters#php#langserver#GetProjectRoot'),
\})