mirror of https://github.com/dense-analysis/ale
Merge pull request #3357 from creativenull/feat-php-intelephense
feat: add intelephense support for php
This commit is contained in:
commit
e4bfcb44b3
|
@ -0,0 +1,32 @@
|
|||
" Author: Eric Stern <eric@ericstern.com>,
|
||||
" Arnold Chand <creativenull@outlook.com>
|
||||
" Description: Intelephense language server integration for ALE
|
||||
|
||||
call ale#Set('php_intelephense_executable', 'intelephense')
|
||||
call ale#Set('php_intelephense_use_global', 1)
|
||||
call ale#Set('php_intelephense_config', {})
|
||||
|
||||
function! ale_linters#php#intelephense#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
|
||||
|
||||
function! ale_linters#php#intelephense#GetInitializationOptions() abort
|
||||
return ale#Get('php_intelephense_config')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'intelephense',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'initialization_options': function('ale_linters#php#intelephense#GetInitializationOptions'),
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'php_intelephense', [])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'project_root': function('ale_linters#php#intelephense#GetProjectRoot'),
|
||||
\})
|
|
@ -243,5 +243,40 @@ g:ale_php_php_executable *g:ale_php_php_executable*
|
|||
|
||||
This variable sets the executable used for php.
|
||||
|
||||
===============================================================================
|
||||
intelephense *ale-php-intelephense*
|
||||
|
||||
g:ale_php_intelephense_executable *g:ale_php_intelephense_executable*
|
||||
*b:ale_php_intelephense_executable*
|
||||
Type: |String|
|
||||
Default: `'intelephense'`
|
||||
|
||||
The variable can be set to configure the executable that will be used for
|
||||
running the intelephense language server. `node_modules` directory
|
||||
executable will be preferred instead of this setting if
|
||||
|g:ale_php_intelephense_use_global| is `0`.
|
||||
|
||||
See: |ale-integrations-local-executables|
|
||||
|
||||
|
||||
g:ale_php_intelephense_use_global *g:ale_php_intelephense_use_global*
|
||||
*b:ale_php_intelephense_use_global*
|
||||
Type: |Number|
|
||||
Default: `get(g:, 'ale_use_global_executables', 0)`
|
||||
|
||||
This variable can be set to `1` to force the language server to be run with
|
||||
the executable set for |g:ale_php_intelephense_executable|.
|
||||
|
||||
See: |ale-integrations-local-executables|
|
||||
|
||||
g:ale_php_intelephense_config *g:ale_php_intelephense_config*
|
||||
*b:ale_php_intelephense_config*
|
||||
Type: |Dictionary|
|
||||
Default: `{}`
|
||||
|
||||
The initialization options config specified by Intelephense. Refer to the
|
||||
installation docs provided by intelephense (github.com/bmewburn/intelephense
|
||||
-docs).
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
|
|
@ -326,6 +326,7 @@ Notes:
|
|||
* Perl6
|
||||
* `perl6 -c`
|
||||
* PHP
|
||||
* `intelephense`
|
||||
* `langserver`
|
||||
* `phan`
|
||||
* `phpcbf`
|
||||
|
|
|
@ -2796,6 +2796,7 @@ documented in additional help files.
|
|||
psalm.................................|ale-php-psalm|
|
||||
php-cs-fixer..........................|ale-php-php-cs-fixer|
|
||||
php...................................|ale-php-php|
|
||||
intelephense..........................|ale-php-intelephense|
|
||||
po......................................|ale-po-options|
|
||||
write-good............................|ale-po-write-good|
|
||||
pod.....................................|ale-pod-options|
|
||||
|
|
|
@ -335,6 +335,7 @@ formatting.
|
|||
* Perl6
|
||||
* [perl6 -c](https://perl6.org) :warning:
|
||||
* PHP
|
||||
* [intelephense](https://github.com/bmewburn/intelephense-docs)
|
||||
* [langserver](https://github.com/felixfbecker/php-language-server)
|
||||
* [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions
|
||||
* [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer)
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('php', 'intelephense')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'intelephense',
|
||||
\ ale#Escape('intelephense') . ' --stdio'
|
||||
|
||||
Execute(The project path should be correct for .git directories):
|
||||
call ale#test#SetFilename('php-intelephense-project/with-git/test.php')
|
||||
silent! call mkdir('php-intelephense-project/with-git/.git', 'p')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/php-intelephense-project/with-git')
|
||||
|
||||
Execute(The project path should be correct for composer.json file):
|
||||
call ale#test#SetFilename('php-intelephense-project/with-composer/test.php')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/php-intelephense-project/with-composer')
|
||||
|
||||
Execute(The project cache should be saved in a temp dir):
|
||||
call ale#test#SetFilename('php-intelephense-project/with-composer/test.php')
|
||||
let g:ale_php_intelephense_config = { 'storagePath': '/tmp/intelephense' }
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/php-intelephense-project/with-composer')
|
Loading…
Reference in New Issue