diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | ale_linters/haskell/hlint.vim | 15 | ||||
-rw-r--r-- | ale_linters/php/psalm.vim | 28 | ||||
-rw-r--r-- | ale_linters/scss/stylelint.vim | 8 | ||||
-rw-r--r-- | doc/ale-haskell.txt | 9 | ||||
-rw-r--r-- | doc/ale-php.txt | 10 | ||||
-rw-r--r-- | doc/ale-scss.txt | 6 | ||||
-rw-r--r-- | doc/ale.txt | 3 | ||||
-rw-r--r-- | test/command_callback/test_haskell_hlint_command_callbacks.vader | 16 | ||||
-rw-r--r-- | test/command_callback/test_psalm_command_callbacks.vader | 12 | ||||
-rw-r--r-- | test/command_callback/test_scss_stylelint_command_callback.vader | 31 | ||||
-rw-r--r-- | test/handler/test_php_psalm_handler.vader | 24 |
12 files changed, 159 insertions, 5 deletions
@@ -155,7 +155,7 @@ formatting. | OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server), [ocamlformat](https://github.com/ocaml-ppx/ocamlformat) | | Pawn | [uncrustify](https://github.com/uncrustify/uncrustify) | | Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic), [perltidy](https://metacpan.org/pod/distribution/Perl-Tidy/bin/perltidy) | -| PHP | [langserver](https://github.com/felixfbecker/php-language-server), [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions, [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer), [php-cs-fixer](http://cs.sensiolabs.org/) | +| PHP | [langserver](https://github.com/felixfbecker/php-language-server), [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions, [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer), [php-cs-fixer](http://cs.sensiolabs.org/), [psalm](https://getpsalm.org) !! | | PO | [alex](https://github.com/wooorm/alex) !!, [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html), [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) | | Pod | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) | | Pony | [ponyc](https://github.com/ponylang/ponyc) | diff --git a/ale_linters/haskell/hlint.vim b/ale_linters/haskell/hlint.vim index be40d92c..3ee864bf 100644 --- a/ale_linters/haskell/hlint.vim +++ b/ale_linters/haskell/hlint.vim @@ -1,6 +1,9 @@ " Author: jparoz <jesse.paroz@gmail.com> " Description: hlint for Haskell files +call ale#Set('haskell_hlint_executable', 'hlint') +call ale#Set('haskell_hlint_options', get(g:, 'hlint_options', '')) + function! ale_linters#haskell#hlint#Handle(buffer, lines) abort let l:output = [] @@ -26,9 +29,17 @@ function! ale_linters#haskell#hlint#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#haskell#hlint#GetCommand(buffer) abort + let l:hlintopts = '--color=never --json' + + return '%e' + \ . ' ' . ale#Var(a:buffer, 'haskell_hlint_options') + \ . ' ' . l:hlintopts . ' -' +endfunction + call ale#linter#Define('haskell', { \ 'name': 'hlint', -\ 'executable': 'hlint', -\ 'command': 'hlint --color=never --json -', +\ 'executable_callback': ale#VarFunc('haskell_hlint_executable'), +\ 'command_callback': 'ale_linters#haskell#hlint#GetCommand', \ 'callback': 'ale_linters#haskell#hlint#Handle', \}) diff --git a/ale_linters/php/psalm.vim b/ale_linters/php/psalm.vim new file mode 100644 index 00000000..cd20ab81 --- /dev/null +++ b/ale_linters/php/psalm.vim @@ -0,0 +1,28 @@ +" Author: richard marmorstein <https://github.com/twitchard> +" Description: plugin for Psalm, static analyzer for PHP + +call ale#Set('php_psalm_executable', 'psalm') + +function! ale_linters#php#psalm#Handle(buffer, lines) abort + " Matches patterns like the following: + let l:pattern = '^.*:\(\d\+\):\(\d\+\):\(\w\+\) - \(.*\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'text': l:match[4], + \ 'type': l:match[3][:0] is# 'e' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'psalm', +\ 'command': '%e --diff --output-format=emacs %s', +\ 'executable_callback': ale#VarFunc('php_psalm_executable'), +\ 'callback': 'ale_linters#php#psalm#Handle', +\ 'lint_file': 1, +\}) diff --git a/ale_linters/scss/stylelint.vim b/ale_linters/scss/stylelint.vim index 6d183b4a..2bffa8e1 100644 --- a/ale_linters/scss/stylelint.vim +++ b/ale_linters/scss/stylelint.vim @@ -1,13 +1,19 @@ " Author: diartyz <diartyz@gmail.com> call ale#Set('scss_stylelint_executable', 'stylelint') +call ale#Set('scss_stylelint_options', '') call ale#Set('scss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) +function! ale_linters#scss#stylelint#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'scss_stylelint_options')) + \ . ' --stdin-filename %s' +endfunction + call ale#linter#Define('scss', { \ 'name': 'stylelint', \ 'executable_callback': ale#node#FindExecutableFunc('scss_stylelint', [ \ 'node_modules/.bin/stylelint', \ ]), -\ 'command': '%e --stdin-filename %s', +\ 'command_callback': 'ale_linters#scss#stylelint#GetCommand', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/doc/ale-haskell.txt b/doc/ale-haskell.txt index c1f1e889..a59fa4e2 100644 --- a/doc/ale-haskell.txt +++ b/doc/ale-haskell.txt @@ -77,6 +77,15 @@ g:ale_haskell_hlint_executable *g:ale_haskell_hlint_executable* This variable can be changed to use a different executable for hlint. + +g:ale_haskell_hlint_options g:ale_haskell_hlint_options + b:ale_haskell_hlint_options + Type: String + Default: '' + + This variable can be used to pass extra options to the underlying hlint + executable. + =============================================================================== stack-build *ale-haskell-stack-build* diff --git a/doc/ale-php.txt b/doc/ale-php.txt index f38c3f88..2eed838e 100644 --- a/doc/ale-php.txt +++ b/doc/ale-php.txt @@ -170,6 +170,16 @@ g:ale_php_phpstan_configuration *g:ale_php_phpstan_configuration* =============================================================================== +psalm *ale-php-psalm* + +g:ale_php_psalm_executable *g:ale_php_psalm_executable* + *b:ale_php_psalm_executable* + Type: |String| + Default: `'psalm'` + + This variable sets the executable used for psalm. + +=============================================================================== php-cs-fixer *ale-php-php-cs-fixer* g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable* diff --git a/doc/ale-scss.txt b/doc/ale-scss.txt index 14e6feb7..3ad84fc1 100644 --- a/doc/ale-scss.txt +++ b/doc/ale-scss.txt @@ -18,6 +18,12 @@ g:ale_scss_stylelint_executable *g:ale_scss_stylelint_executable* See |ale-integrations-local-executables| +g:ale_scss_stylelint_options *g:ale_scss_stylelint_options* + *b:ale_scss_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. g:ale_scss_stylelint_use_global *g:ale_scss_stylelint_use_global* *b:ale_scss_stylelint_use_global* diff --git a/doc/ale.txt b/doc/ale.txt index e8e3b477..ec44f3b8 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -209,6 +209,7 @@ CONTENTS *ale-contents* phpcs...............................|ale-php-phpcs| phpmd...............................|ale-php-phpmd| phpstan.............................|ale-php-phpstan| + psalm...............................|ale-php-psalm| php-cs-fixer........................|ale-php-php-cs-fixer| po....................................|ale-po-options| write-good..........................|ale-po-write-good| @@ -436,7 +437,7 @@ Notes: * OCaml: `merlin` (see |ale-ocaml-merlin|), `ols`, `ocamlformat` * Pawn: `uncrustify` * Perl: `perl -c`, `perl-critic`, `perltidy` -* PHP: `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer` +* PHP: `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer`, `psalm`!! * PO: `alex`!!, `msgfmt`, `proselint`, `write-good` * Pod: `alex`!!, `proselint`, `write-good` * Pony: `ponyc` diff --git a/test/command_callback/test_haskell_hlint_command_callbacks.vader b/test/command_callback/test_haskell_hlint_command_callbacks.vader new file mode 100644 index 00000000..fb354ed4 --- /dev/null +++ b/test/command_callback/test_haskell_hlint_command_callbacks.vader @@ -0,0 +1,16 @@ +Before: + call ale#assert#SetUpLinterTest('haskell', 'hlint') + let b:base_opts = '--color=never --json -' + +After: + unlet! b:base_opts + call ale#assert#TearDownLinterTest() + +Execute(executable should be configurable): + AssertLinter 'hlint', ale#Escape('hlint') . ' ' . b:base_opts + let b:ale_haskell_hlint_executable = 'myHlint' + AssertLinter 'myHlint', ale#Escape('myHlint') . ' ' . b:base_opts + +Execute(should accept options): + let b:ale_haskell_hlint_options= '-h myhlintfile.yaml' + AssertLinter 'hlint', ale#Escape('hlint') . ' -h myhlintfile.yaml ' . b:base_opts diff --git a/test/command_callback/test_psalm_command_callbacks.vader b/test/command_callback/test_psalm_command_callbacks.vader new file mode 100644 index 00000000..4c31b7b4 --- /dev/null +++ b/test/command_callback/test_psalm_command_callbacks.vader @@ -0,0 +1,12 @@ +Before: + call ale#assert#SetUpLinterTest('php', 'psalm') + +After: + call ale#assert#TearDownLinterTest() + +Execute(Custom executables should be used for the executable and command): + let g:ale_php_psalm_executable = 'psalm_test' + + AssertLinter 'psalm_test', + \ ale#Escape('psalm_test') . ' --diff --output-format=emacs %s' + diff --git a/test/command_callback/test_scss_stylelint_command_callback.vader b/test/command_callback/test_scss_stylelint_command_callback.vader new file mode 100644 index 00000000..9c3a02d8 --- /dev/null +++ b/test/command_callback/test_scss_stylelint_command_callback.vader @@ -0,0 +1,31 @@ +Before: + call ale#assert#SetUpLinterTest('scss', 'stylelint') + unlet! b:executable + +After: + unlet! b:executable + call ale#assert#TearDownLinterTest() + +Execute(node_modules directories should be discovered): + call ale#test#SetFilename('stylelint_paths/nested/testfile.scss') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/stylelint_paths/node_modules/.bin/stylelint' + \) + + AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin-filename %s' + +Execute(The global override should work): + let b:ale_scss_stylelint_executable = 'foobar' + let b:ale_scss_stylelint_use_global = 1 + + call ale#test#SetFilename('stylelint_paths/nested/testfile.scss') + + AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin-filename %s' + +Execute(Extra options should be configurable): + let b:ale_scss_stylelint_options = '--configFile ''/absolute/path/to/file''' + + AssertLinter 'stylelint', + \ ale#Escape('stylelint') . ' --configFile ''/absolute/path/to/file'' --stdin-filename %s' diff --git a/test/handler/test_php_psalm_handler.vader b/test/handler/test_php_psalm_handler.vader new file mode 100644 index 00000000..fd62a467 --- /dev/null +++ b/test/handler/test_php_psalm_handler.vader @@ -0,0 +1,24 @@ +Before: + runtime ale_linters/php/psalm.vim + +After: + call ale#linter#Reset() + +Execute(The php static analyzer handler should parse errors from psalm): + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'type': 'W', + \ 'text': 'somewarning', + \ }, + \ { + \ 'lnum': 11, + \ 'type': 'E', + \ 'text': 'someerror', + \ }, + \ ], + \ ale_linters#php#psalm#Handle(347, [ + \ "/file:1:3:warning - somewarning", + \ "/file:11:33:error - someerror", + \ ]) |