Skip to content

Commit b415ddd

Browse files
authored
Make phpactor configurable and documented (#5027)
Add php_phpactor_executable for phpactor and make it configurable through php_phpactor_config. When phpactor was first added in 3b8ff65, it had no configuration. Thus the documentation for it could be completely blank. That is why it now seems like an initial addition Co-authored-by: cos <cos>
1 parent 55acb65 commit b415ddd

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

ale_linters/php/phpactor.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
" Author: Arizard <https://github.com/Arizard>
22
" Description: PHPactor integration for ALE
33

4+
call ale#Set('php_phpactor_executable', 'phpactor')
5+
call ale#Set('php_phpactor_init_options', {})
6+
47
" Copied from langserver.vim
58
function! ale_linters#php#phpactor#GetProjectRoot(buffer) abort
69
let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json')
@@ -17,7 +20,8 @@ endfunction
1720
call ale#linter#Define('php', {
1821
\ 'name': 'phpactor',
1922
\ 'lsp': 'stdio',
20-
\ 'executable': 'phpactor',
23+
\ 'executable': {b -> ale#Var(b, 'php_phpactor_executable')},
2124
\ 'command': '%e language-server',
25+
\ 'initialization_options': {b -> ale#Var(b, 'php_phpactor_init_options')},
2226
\ 'project_root': function('ale_linters#php#phpactor#GetProjectRoot'),
2327
\})

doc/ale-php.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,36 @@ g:ale_php_phan_use_client
7878
instead of the phan standalone.
7979

8080

81+
===============================================================================
82+
phpactor *ale-php-phpactor*
83+
84+
*ale-options.php_phpactor_executable*
85+
*g:ale_php_phpactor_executable*
86+
*b:ale_php_phpactor_executable*
87+
php_phpactor_executable
88+
g:ale_php_phpactor_executable
89+
Type: |String|
90+
Default: `'phpactor'`
91+
92+
This variable sets executable used for phpactor.
93+
94+
php_phpactor_init_options
95+
g:ale_php_phpactor_init_options
96+
Type: |Dictionary|
97+
Default: `'{}'`
98+
99+
This variable can be changed to customize the LSP initialization_options.
100+
For example: >
101+
102+
let g:ale_php_phpactor_init_options = {
103+
\ 'language_server_phpstan.enabled': v:false,
104+
\ 'language_server_psalm.enabled': v:false,
105+
\ 'worse_reflection.stub_dir': '%application_root%/.php-stubs'
106+
\}
107+
<
108+
For all available options and explanations, visit
109+
https://phpactor.readthedocs.io/en/master/reference/configuration.html
110+
81111
===============================================================================
82112
phpcbf *ale-php-phpcbf*
83113

doc/ale.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3760,6 +3760,7 @@ documented in additional help files.
37603760
cspell................................|ale-php-cspell|
37613761
langserver............................|ale-php-langserver|
37623762
phan..................................|ale-php-phan|
3763+
phpactor..............................|ale-php-phpactor|
37633764
phpcbf................................|ale-php-phpcbf|
37643765
phpcs.................................|ale-php-phpcs|
37653766
phpmd.................................|ale-php-phpmd|

test/linter/test_phpactor.vader

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Execute(The default executable path should be correct):
88
AssertLinter 'phpactor',
99
\ ale#Escape('phpactor') . ' language-server'
1010

11+
Execute(Overriding the executable should work):
12+
let b:ale_php_phpactor_executable = 'my_phpactor'
13+
14+
AssertLinter 'my_phpactor', ale#Escape('my_phpactor') . ' language-server'
15+
unlet b:ale_php_phpactor_executable
16+
1117
Execute(The project path should be correct for .git directories):
1218
call ale#test#SetFilename('../test-files/php/with-git/test.php')
1319
silent! call mkdir('../test-files/php/with-git/.git')
@@ -18,3 +24,20 @@ Execute(The project path should be correct for composer.json file):
1824
call ale#test#SetFilename('../test-files/php/with-composer/test.php')
1925

2026
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/php/with-composer')
27+
28+
Execute(The LSP values should be set correctly):
29+
30+
AssertLSPLanguage 'php'
31+
32+
AssertLSPOptions {}
33+
34+
AssertLSPConfig {}
35+
36+
Execute(Should accept initialization options):
37+
let b:ale_php_phpactor_init_options = {
38+
\ 'language_server_phpstan.enabled': v:false,
39+
\ }
40+
41+
AssertLSPOptions {
42+
\ 'language_server_phpstan.enabled': v:false,
43+
\ }

0 commit comments

Comments
 (0)