Use location of composer.json
for PHP project path too (#2391)
* move php-langserver "test for .git dir" test-project to its own directory * search for composer.json file in php-langserver first then .git dir * add test for php-langserver composer.json
This commit is contained in:
parent
80ef7ea2d0
commit
ad998211f8
5 changed files with 14 additions and 7 deletions
|
@ -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') : ''
|
||||
|
|
0
test/command_callback/php-langserver-project/with-composer/vendor/bin/php-language-server.php
vendored
Executable file
0
test/command_callback/php-langserver-project/with-composer/vendor/bin/php-language-server.php
vendored
Executable file
0
test/command_callback/php-langserver-project/with-git/vendor/bin/php-language-server.php
vendored
Executable file
0
test/command_callback/php-langserver-project/with-git/vendor/bin/php-language-server.php
vendored
Executable file
|
@ -2,10 +2,6 @@ Before:
|
|||
call ale#assert#SetUpLinterTest('php', 'langserver')
|
||||
|
||||
After:
|
||||
if isdirectory(g:dir . '/.git')
|
||||
call delete(g:dir . '/.git', 'd')
|
||||
endif
|
||||
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
|
@ -23,7 +19,12 @@ Execute(Vendor executables should be detected):
|
|||
\ ))
|
||||
|
||||
Execute(The project path should be correct for .git directories):
|
||||
call ale#test#SetFilename('php-langserver-project/test.php')
|
||||
call mkdir(g:dir . '/.git')
|
||||
call ale#test#SetFilename('php-langserver-project/with-git/test.php')
|
||||
silent! call mkdir('php-langserver-project/with-git/.git')
|
||||
|
||||
AssertLSPProject g:dir
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/php-langserver-project/with-git')
|
||||
|
||||
Execute(The project path should be correct for composer.json file):
|
||||
call ale#test#SetFilename('php-langserver-project/with-composer/test.php')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/php-langserver-project/with-composer')
|
||||
|
|
Reference in a new issue