summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--ale_linters/php/phpstan.vim36
-rw-r--r--autoload/ale/virtualtext.vim8
-rw-r--r--test/command_callback/test_phpstan_command_callbacks.vader10
4 files changed, 50 insertions, 8 deletions
diff --git a/README.md b/README.md
index 4136ae81..ad55e255 100644
--- a/README.md
+++ b/README.md
@@ -182,7 +182,7 @@ formatting.
| Re:VIEW | [redpen](http://redpen.cc/) |
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org), [rufo](https://github.com/ruby-formatter/rufo), [solargraph](https://solargraph.org) |
-| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/), [rustfmt](https://github.com/rust-lang-nursery/rustfmt) |
+| Rust | [cargo](https://github.com/rust-lang/cargo) !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/), [rustfmt](https://github.com/rust-lang-nursery/rustfmt) |
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
| SCSS | [prettier](https://github.com/prettier/prettier), [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) |
| Scala | [fsc](https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html), [sbtserver](https://www.scala-sbt.org/1.x/docs/sbt-server.html), [scalac](http://scala-lang.org), [scalafmt](https://scalameta.org/scalafmt/), [scalastyle](http://www.scalastyle.org)|
@@ -197,7 +197,7 @@ formatting.
| Texinfo | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good)|
| Text^ | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [textlint](https://textlint.github.io/), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
| Thrift | [thrift](http://thrift.apache.org/) |
-| TypeScript | [eslint](http://eslint.org/), [prettier](https://github.com/prettier/prettier), [tslint](https://github.com/palantir/tslint), tsserver, typecheck |
+| TypeScript | [eslint](http://eslint.org/), [prettier](https://github.com/prettier/prettier), [tslint](https://github.com/palantir/tslint), [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29), typecheck |
| VALA | [uncrustify](https://github.com/uncrustify/uncrustify) |
| Verilog | [iverilog](https://github.com/steveicarus/iverilog), [verilator](http://www.veripool.org/projects/verilator/wiki/Intro) |
| Vim | [vint](https://github.com/Kuniwak/vint) |
diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim
index b3875216..1c831e1b 100644
--- a/ale_linters/php/phpstan.vim
+++ b/ale_linters/php/phpstan.vim
@@ -6,15 +6,40 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
-function! ale_linters#php#phpstan#GetCommand(buffer) abort
+function! ale_linters#php#phpstan#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'php_phpstan_executable')
+endfunction
+
+function! ale_linters#php#phpstan#VersionCheck(buffer) abort
+ let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
+
+ " If we have previously stored the version number in a cache, then
+ " don't look it up again.
+ if ale#semver#HasVersion(l:executable)
+ " Returning an empty string skips this command.
+ return ''
+ endif
+
+ let l:executable = ale#Escape(l:executable)
+
+ return l:executable . ' --version'
+endfunction
+
+function! ale_linters#php#phpstan#GetCommand(buffer, version_output) abort
let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration')
let l:configuration_option = !empty(l:configuration)
\ ? ' -c ' . l:configuration
\ : ''
+ let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
+ let l:version = ale#semver#GetVersion(l:executable, a:version_output)
+ let l:error_format = ale#semver#GTE(l:version, [0, 10, 3])
+ \ ? ' --error-format raw'
+ \ : ' --errorFormat raw'
+
return '%e analyze -l'
\ . ale#Var(a:buffer, 'php_phpstan_level')
- \ . ' --errorFormat raw'
+ \ . l:error_format
\ . l:configuration_option
\ . ' %s'
endfunction
@@ -40,7 +65,10 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpstan',
-\ 'executable_callback': ale#VarFunc('php_phpstan_executable'),
-\ 'command_callback': 'ale_linters#php#phpstan#GetCommand',
+\ 'executable_callback': 'ale_linters#php#phpstan#GetExecutable',
+\ 'command_chain': [
+\ {'callback': 'ale_linters#php#phpstan#VersionCheck'},
+\ {'callback': 'ale_linters#php#phpstan#GetCommand'},
+\ ],
\ 'callback': 'ale_linters#php#phpstan#Handle',
\})
diff --git a/autoload/ale/virtualtext.vim b/autoload/ale/virtualtext.vim
index a2f88a3a..c4ce37dd 100644
--- a/autoload/ale/virtualtext.vim
+++ b/autoload/ale/virtualtext.vim
@@ -8,6 +8,10 @@ let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10)
let s:cursor_timer = -1
let s:last_pos = [0, 0, 0]
+if has('nvim-0.3.2')
+ let s:ns_id = nvim_create_namespace('ale')
+endif
+
if !hlexists('ALEVirtualTextError')
highlight link ALEVirtualTextError ALEError
endif
@@ -35,7 +39,7 @@ function! ale#virtualtext#Clear() abort
let l:buffer = bufnr('')
- call nvim_buf_clear_highlight(l:buffer, 1000, 0, -1)
+ call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1)
endfunction
function! ale#virtualtext#ShowMessage(message, hl_group) abort
@@ -48,7 +52,7 @@ function! ale#virtualtext#ShowMessage(message, hl_group) abort
let l:buffer = bufnr('')
let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ')
- call nvim_buf_set_virtual_text(l:buffer, 1000, l:line-1, [[l:prefix.a:message, a:hl_group]], {})
+ call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, a:hl_group]], {})
endfunction
function! s:StopCursorTimer() abort
diff --git a/test/command_callback/test_phpstan_command_callbacks.vader b/test/command_callback/test_phpstan_command_callbacks.vader
index c7db587a..665661a3 100644
--- a/test/command_callback/test_phpstan_command_callbacks.vader
+++ b/test/command_callback/test_phpstan_command_callbacks.vader
@@ -1,6 +1,8 @@
Before:
call ale#assert#SetUpLinterTest('php', 'phpstan')
+ WithChainResults ['0.10.2']
+
After:
call ale#assert#TearDownLinterTest()
@@ -22,3 +24,11 @@ Execute(Custom phpstan configuration file):
AssertLinter 'phpstan',
\ ale#Escape('phpstan') . ' analyze -l4 --errorFormat raw -c phpstan_config %s'
+
+Execute(Choose the right format for error format param):
+ WithChainResults ['0.10.3']
+
+ AssertLinter 'phpstan', [
+ \ ale#Escape('phpstan') . ' --version',
+ \ ale#Escape('phpstan') . ' analyze -l4 --error-format raw %s'
+ \ ]