summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/dafny/dafny.vim2
-rw-r--r--ale_linters/elixir/credo.vim11
-rw-r--r--ale_linters/erlang/elvis.vim39
-rw-r--r--ale_linters/erlang/erlc.vim16
-rw-r--r--ale_linters/inko/inko.vim33
-rw-r--r--ale_linters/java/checkstyle.vim2
-rw-r--r--ale_linters/julia/languageserver.vim4
-rwxr-xr-xale_linters/php/intelephense.vim32
-rw-r--r--ale_linters/php/phpcs.vim2
-rw-r--r--ale_linters/php/tlint.vim80
-rw-r--r--ale_linters/r/languageserver.vim26
-rw-r--r--ale_linters/ruby/sorbet.vim5
-rw-r--r--ale_linters/salt/salt_lint.vim33
-rw-r--r--ale_linters/typescript/tsserver.vim1
14 files changed, 276 insertions, 10 deletions
diff --git a/ale_linters/dafny/dafny.vim b/ale_linters/dafny/dafny.vim
index b5b90675..e6021d99 100644
--- a/ale_linters/dafny/dafny.vim
+++ b/ale_linters/dafny/dafny.vim
@@ -6,7 +6,7 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
+ \ 'filename': l:match[1],
\ 'col': l:match[3] + 0,
\ 'lnum': l:match[2] + 0,
\ 'text': l:match[5],
diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim
index 7c298502..892d47b9 100644
--- a/ale_linters/elixir/credo.vim
+++ b/ale_linters/elixir/credo.vim
@@ -45,6 +45,16 @@ function! ale_linters#elixir#credo#GetMode() abort
endif
endfunction
+function! ale_linters#elixir#credo#GetConfigFile() abort
+ let l:config_file = get(g:, 'ale_elixir_credo_config_file', '')
+
+ if empty(l:config_file)
+ return ''
+ endif
+
+ return ' --config-file ' . l:config_file
+endfunction
+
function! ale_linters#elixir#credo#GetCommand(buffer) abort
let l:project_root = ale#handlers#elixir#FindMixUmbrellaRoot(a:buffer)
let l:mode = ale_linters#elixir#credo#GetMode()
@@ -52,6 +62,7 @@ function! ale_linters#elixir#credo#GetCommand(buffer) abort
return ale#path#CdString(l:project_root)
\ . 'mix help credo && '
\ . 'mix credo ' . ale_linters#elixir#credo#GetMode()
+ \ . ale_linters#elixir#credo#GetConfigFile()
\ . ' --format=flycheck --read-from-stdin %s'
endfunction
diff --git a/ale_linters/erlang/elvis.vim b/ale_linters/erlang/elvis.vim
new file mode 100644
index 00000000..31dea3dd
--- /dev/null
+++ b/ale_linters/erlang/elvis.vim
@@ -0,0 +1,39 @@
+" Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
+" Description: Elvis linter for Erlang files
+
+call ale#Set('erlang_elvis_executable', 'elvis')
+
+function! ale_linters#erlang#elvis#Handle(buffer, lines) abort
+ let l:pattern = '\v:(\d+):[^:]+:(.+)'
+ let l:loclist = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:loclist, {
+ \ 'lnum': str2nr(l:match[1]),
+ \ 'text': s:AbbreviateMessage(l:match[2]),
+ \ 'type': 'W',
+ \})
+ endfor
+
+ return l:loclist
+endfunction
+
+function! s:AbbreviateMessage(text) abort
+ let l:pattern = '\v\c^(line \d+ is too long):.*$'
+
+ return substitute(a:text, l:pattern, '\1.', '')
+endfunction
+
+function! s:GetCommand(buffer) abort
+ let l:file = ale#Escape(expand('#' . a:buffer . ':.'))
+
+ return '%e rock --output-format=parsable ' . l:file
+endfunction
+
+call ale#linter#Define('erlang', {
+\ 'name': 'elvis',
+\ 'callback': 'ale_linters#erlang#elvis#Handle',
+\ 'executable': {b -> ale#Var(b, 'erlang_elvis_executable')},
+\ 'command': function('s:GetCommand'),
+\ 'lint_file': 1,
+\})
diff --git a/ale_linters/erlang/erlc.vim b/ale_linters/erlang/erlc.vim
index a83bacc3..e78dc341 100644
--- a/ale_linters/erlang/erlc.vim
+++ b/ale_linters/erlang/erlc.vim
@@ -1,14 +1,22 @@
" Author: Magnus Ottenklinger - https://github.com/evnu
+let g:ale_erlang_erlc_executable = get(g:, 'ale_erlang_erlc_executable', 'erlc')
let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '')
+function! ale_linters#erlang#erlc#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'erlang_erlc_executable')
+endfunction
+
function! ale_linters#erlang#erlc#GetCommand(buffer) abort
let l:output_file = ale#util#Tempname()
call ale#command#ManageFile(a:buffer, l:output_file)
- return 'erlc -o ' . ale#Escape(l:output_file)
- \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options')
- \ . ' %t'
+ let l:command = ale#Escape(ale_linters#erlang#erlc#GetExecutable(a:buffer))
+ \ . ' -o ' . ale#Escape(l:output_file)
+ \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options')
+ \ . ' %t'
+
+ return l:command
endfunction
function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
@@ -90,7 +98,7 @@ endfunction
call ale#linter#Define('erlang', {
\ 'name': 'erlc',
-\ 'executable': 'erlc',
+\ 'executable': function('ale_linters#erlang#erlc#GetExecutable'),
\ 'command': function('ale_linters#erlang#erlc#GetCommand'),
\ 'callback': 'ale_linters#erlang#erlc#Handle',
\})
diff --git a/ale_linters/inko/inko.vim b/ale_linters/inko/inko.vim
new file mode 100644
index 00000000..11558897
--- /dev/null
+++ b/ale_linters/inko/inko.vim
@@ -0,0 +1,33 @@
+" Author: Yorick Peterse <yorick@yorickpeterse.com>
+" Description: linting of Inko source code using the Inko compiler
+
+call ale#Set('inko_inko_executable', 'inko')
+
+function! ale_linters#inko#inko#GetCommand(buffer) abort
+ let l:include = ''
+
+ " Include the tests source directory, but only for test files.
+ if expand('#' . a:buffer . ':p') =~? '\vtests[/\\]test[/\\]'
+ let l:test_dir = ale#path#FindNearestDirectory(a:buffer, 'tests')
+
+ if isdirectory(l:test_dir)
+ let l:include = '--include ' . ale#Escape(l:test_dir)
+ endif
+ endif
+
+ " We use %s instead of %t so the compiler determines the correct module
+ " names for the file being edited. Not doing so may lead to errors in
+ " certain cases.
+ return '%e build --check --format=json'
+ \ . ale#Pad(l:include)
+ \ . ' %s'
+endfunction
+
+call ale#linter#Define('inko', {
+\ 'name': 'inko',
+\ 'executable': {b -> ale#Var(b, 'inko_inko_executable')},
+\ 'command': function('ale_linters#inko#inko#GetCommand'),
+\ 'callback': 'ale#handlers#inko#Handle',
+\ 'output_stream': 'stderr',
+\ 'lint_file': 1
+\})
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim
index ec7339d1..f00734e0 100644
--- a/ale_linters/java/checkstyle.vim
+++ b/ale_linters/java/checkstyle.vim
@@ -9,7 +9,7 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
let l:output = []
" modern checkstyle versions
- let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
+ let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
diff --git a/ale_linters/julia/languageserver.vim b/ale_linters/julia/languageserver.vim
index 564bec39..999ad815 100644
--- a/ale_linters/julia/languageserver.vim
+++ b/ale_linters/julia/languageserver.vim
@@ -6,9 +6,9 @@ call ale#Set('julia_executable', 'julia')
function! ale_linters#julia#languageserver#GetCommand(buffer) abort
let l:julia_executable = ale#Var(a:buffer, 'julia_executable')
- let l:cmd_string = 'using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);'
+ let l:cmd_string = 'using LanguageServer; using Pkg; import StaticLint; import SymbolServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, dirname(Pkg.Types.Context().env.project_file)); server.runlinter = true; run(server);'
- return ale#Escape(l:julia_executable) . ' --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string)
+ return ale#Escape(l:julia_executable) . ' --project=@. --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string)
endfunction
call ale#linter#Define('julia', {
diff --git a/ale_linters/php/intelephense.vim b/ale_linters/php/intelephense.vim
new file mode 100755
index 00000000..aca619e3
--- /dev/null
+++ b/ale_linters/php/intelephense.vim
@@ -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(buffer) abort
+ return ale#Var(a:buffer, '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'),
+\})
diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim
index 11b81e84..c5a3faa9 100644
--- a/ale_linters/php/phpcs.vim
+++ b/ale_linters/php/phpcs.vim
@@ -23,7 +23,7 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort
" Matches against lines like the following:
"
" /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
- let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\))$'
+ let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\)).*$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
diff --git a/ale_linters/php/tlint.vim b/ale_linters/php/tlint.vim
new file mode 100644
index 00000000..6bba8def
--- /dev/null
+++ b/ale_linters/php/tlint.vim
@@ -0,0 +1,80 @@
+" Author: Jose Soto <jose@tighten.co>
+"
+" Description: Tighten Opinionated PHP Linting
+" Website: https://github.com/tightenco/tlint
+
+call ale#Set('php_tlint_executable', 'tlint')
+call ale#Set('php_tlint_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('php_tlint_options', '')
+
+function! ale_linters#php#tlint#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#tlint#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'php_tlint', [
+ \ 'vendor/bin/tlint',
+ \ 'tlint',
+ \])
+endfunction
+
+function! ale_linters#php#tlint#GetCommand(buffer) abort
+ let l:executable = ale_linters#php#tlint#GetExecutable(a:buffer)
+ let l:options = ale#Var(a:buffer, 'php_tlint_options')
+
+ return ale#node#Executable(a:buffer, l:executable)
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' lint %s'
+endfunction
+
+function! ale_linters#php#tlint#Handle(buffer, lines) abort
+ " Matches against lines like the following:
+ "
+ " ! There should be 1 space around `.` concatenations, and additional lines should always start with a `.`
+ " 22 : ` $something = 'a'.'name';`
+ "
+ let l:loop_count = 0
+ let l:messages_pattern = '^\! \(.*\)'
+ let l:output = []
+ let l:pattern = '^\(\d\+\) \:'
+ let l:temp_messages = []
+
+ for l:message in ale#util#GetMatches(a:lines, l:messages_pattern)
+ call add(l:temp_messages, l:message)
+ endfor
+
+ let l:loop_count = 0
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ let l:num = l:match[1]
+ let l:text = l:temp_messages[l:loop_count]
+
+ call add(l:output, {
+ \ 'lnum': l:num,
+ \ 'col': 0,
+ \ 'text': l:text,
+ \ 'type': 'W',
+ \ 'sub_type': 'style',
+ \})
+
+ let l:loop_count += 1
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('php', {
+\ 'name': 'tlint',
+\ 'executable': function('ale_linters#php#tlint#GetExecutable'),
+\ 'command': function('ale_linters#php#tlint#GetCommand'),
+\ 'callback': 'ale_linters#php#tlint#Handle',
+\ 'project_root': function('ale_linters#php#tlint#GetProjectRoot'),
+\})
diff --git a/ale_linters/r/languageserver.vim b/ale_linters/r/languageserver.vim
new file mode 100644
index 00000000..febe66bd
--- /dev/null
+++ b/ale_linters/r/languageserver.vim
@@ -0,0 +1,26 @@
+" Author: Eric Zhao <21zhaoe@protonmail.com>
+" Description: Implementation of the Language Server Protocol for R.
+
+call ale#Set('r_languageserver_cmd', 'languageserver::run()')
+call ale#Set('r_languageserver_config', {})
+
+function! ale_linters#r#languageserver#GetCommand(buffer) abort
+ let l:cmd_string = ale#Var(a:buffer, 'r_languageserver_cmd')
+
+ return 'Rscript --vanilla -e ' . ale#Escape(l:cmd_string)
+endfunction
+
+function! ale_linters#r#languageserver#GetProjectRoot(buffer) abort
+ let l:project_root = ale#path#FindNearestFile(a:buffer, '.Rprofile')
+
+ return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : fnamemodify(a:buffer, ':h')
+endfunction
+
+call ale#linter#Define('r', {
+\ 'name': 'languageserver',
+\ 'lsp': 'stdio',
+\ 'lsp_config': {b -> ale#Var(b, 'r_languageserver_config')},
+\ 'executable': 'Rscript',
+\ 'command': function('ale_linters#r#languageserver#GetCommand'),
+\ 'project_root': function('ale_linters#r#languageserver#GetProjectRoot')
+\})
diff --git a/ale_linters/ruby/sorbet.vim b/ale_linters/ruby/sorbet.vim
index cae0683c..c67e20cc 100644
--- a/ale_linters/ruby/sorbet.vim
+++ b/ale_linters/ruby/sorbet.vim
@@ -1,14 +1,17 @@
call ale#Set('ruby_sorbet_executable', 'srb')
call ale#Set('ruby_sorbet_options', '')
+call ale#Set('ruby_sorbet_enable_watchman', 0)
function! ale_linters#ruby#sorbet#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable')
let l:options = ale#Var(a:buffer, 'ruby_sorbet_options')
+ let l:enable_watchman = ale#Var(a:buffer, 'ruby_sorbet_enable_watchman')
return ale#ruby#EscapeExecutable(l:executable, 'srb')
\ . ' tc'
\ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' --lsp --disable-watchman'
+ \ . ' --lsp'
+ \ . (l:enable_watchman ? '' : ' --disable-watchman')
endfunction
call ale#linter#Define('ruby', {
diff --git a/ale_linters/salt/salt_lint.vim b/ale_linters/salt/salt_lint.vim
new file mode 100644
index 00000000..47f66d83
--- /dev/null
+++ b/ale_linters/salt/salt_lint.vim
@@ -0,0 +1,33 @@
+" Author: Benjamin BINIER <poulpatine@gmail.com>
+" Description: salt-lint, saltstack linter
+
+call ale#Set('salt_salt_lint_executable', 'salt-lint')
+call ale#Set('salt_salt_lint_options', '')
+
+function! ale_linters#salt#salt_lint#GetCommand(buffer) abort
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'salt_salt_lint_options'))
+ \ . ' --json'
+endfunction
+
+function! ale_linters#salt#salt_lint#Handle(buffer, lines) abort
+ let l:output = []
+
+ for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
+ call add(l:output, {
+ \ 'lnum': l:error.linenumber + 0,
+ \ 'code': l:error.id + 0,
+ \ 'text': l:error.message,
+ \ 'type': l:error.severity is# 'HIGH' ? 'E' : 'W',
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('salt', {
+\ 'name': 'salt_lint',
+\ 'aliases': ['salt-lint'],
+\ 'executable': {b -> ale#Var(b, 'salt_salt_lint_executable')},
+\ 'command': function('ale_linters#salt#salt_lint#GetCommand'),
+\ 'callback': 'ale_linters#salt#salt_lint#Handle'
+\})
diff --git a/ale_linters/typescript/tsserver.vim b/ale_linters/typescript/tsserver.vim
index 840889f3..4726e40d 100644
--- a/ale_linters/typescript/tsserver.vim
+++ b/ale_linters/typescript/tsserver.vim
@@ -9,6 +9,7 @@ call ale#linter#Define('typescript', {
\ 'name': 'tsserver',
\ 'lsp': 'tsserver',
\ 'executable': {b -> ale#node#FindExecutable(b, 'typescript_tsserver', [
+\ '.yarn/sdks/typescript/bin/tsserver',
\ 'node_modules/.bin/tsserver',
\ ])},
\ 'command': '%e',