mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 05:04:28 +08:00
Adds PHPActor Linter (LSP) (#3975)
* Adds phpactor lsp linter * Fixes missing comma * Adds tests for phpactor lsp linter * Adds note that this part is not my own work * Removes unused variable * Adds phpactor to supported tools list * Fixes doc sorting * Wraps phpactor in code tags
This commit is contained in:
23
ale_linters/php/phpactor.vim
Normal file
23
ale_linters/php/phpactor.vim
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
" Author: Arizard <https://github.com/Arizard>
|
||||||
|
" Description: PHPactor integration for ALE
|
||||||
|
|
||||||
|
" Copied from langserver.vim
|
||||||
|
function! ale_linters#php#phpactor#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') : ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('php', {
|
||||||
|
\ 'name': 'phpactor',
|
||||||
|
\ 'lsp': 'stdio',
|
||||||
|
\ 'executable': 'phpactor',
|
||||||
|
\ 'command': '%e language-server',
|
||||||
|
\ 'project_root': function('ale_linters#php#phpactor#GetProjectRoot'),
|
||||||
|
\})
|
||||||
@@ -382,6 +382,7 @@ Notes:
|
|||||||
* `phan`
|
* `phan`
|
||||||
* `php -l`
|
* `php -l`
|
||||||
* `php-cs-fixer`
|
* `php-cs-fixer`
|
||||||
|
* `phpactor`
|
||||||
* `phpcbf`
|
* `phpcbf`
|
||||||
* `phpcs`
|
* `phpcs`
|
||||||
* `phpmd`
|
* `phpmd`
|
||||||
|
|||||||
@@ -391,6 +391,7 @@ formatting.
|
|||||||
* [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions
|
* [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions
|
||||||
* [php -l](https://secure.php.net/)
|
* [php -l](https://secure.php.net/)
|
||||||
* [php-cs-fixer](http://cs.sensiolabs.org/)
|
* [php-cs-fixer](http://cs.sensiolabs.org/)
|
||||||
|
* [phpactor](https://github.com/phpactor/phpactor)
|
||||||
* [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer)
|
* [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer)
|
||||||
* [phpcs](https://github.com/squizlabs/PHP_CodeSniffer)
|
* [phpcs](https://github.com/squizlabs/PHP_CodeSniffer)
|
||||||
* [phpmd](https://phpmd.org)
|
* [phpmd](https://phpmd.org)
|
||||||
|
|||||||
20
test/linter/test_phpactor.vader
Normal file
20
test/linter/test_phpactor.vader
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
Before:
|
||||||
|
call ale#assert#SetUpLinterTest('php', 'phpactor')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(The default executable path should be correct):
|
||||||
|
AssertLinter 'phpactor',
|
||||||
|
\ ale#Escape('phpactor') . ' language-server'
|
||||||
|
|
||||||
|
Execute(The project path should be correct for .git directories):
|
||||||
|
call ale#test#SetFilename('../test-files/php/with-git/test.php')
|
||||||
|
silent! call mkdir('../test-files/php/with-git/.git')
|
||||||
|
|
||||||
|
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/php/with-git')
|
||||||
|
|
||||||
|
Execute(The project path should be correct for composer.json file):
|
||||||
|
call ale#test#SetFilename('../test-files/php/with-composer/test.php')
|
||||||
|
|
||||||
|
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/php/with-composer')
|
||||||
Reference in New Issue
Block a user