summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/bib/bibclean.vim74
-rw-r--r--ale_linters/java/javalsp.vim6
-rw-r--r--ale_linters/python/pydocstyle.vim74
-rw-r--r--ale_linters/sass/sasslint.vim27
-rw-r--r--ale_linters/scala/scalac.vim2
-rw-r--r--ale_linters/scss/sasslint.vim28
-rw-r--r--ale_linters/swift/swiftlint.vim32
7 files changed, 220 insertions, 23 deletions
diff --git a/ale_linters/bib/bibclean.vim b/ale_linters/bib/bibclean.vim
new file mode 100644
index 00000000..6750f22f
--- /dev/null
+++ b/ale_linters/bib/bibclean.vim
@@ -0,0 +1,74 @@
+" Author: Horacio Sanson - https://github.com/hsanson
+" Description: Support for bibclean linter for BibTeX files.
+
+call ale#Set('bib_bibclean_executable', 'bibclean')
+
+function! ale_linters#bib#bibclean#GetCommand(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'bib_bibclean_executable')
+
+ return ale#Escape(l:executable) . ' -file-position '
+endfunction
+
+function! ale_linters#bib#bibclean#get_type(str) abort
+ if a:str is# '??'
+ return 'E'
+ else
+ return 'W'
+ endif
+endfunction
+
+function! ale_linters#bib#bibclean#match_msg(line) abort
+ return matchlist(a:line, '^\(.*\) "stdin", line \(.*\): \(.*\)$')
+endfunction
+
+function! ale_linters#bib#bibclean#match_entry(line) abort
+ return matchlist(a:line, 'Entry input byte=.* line=\(.*\) column=\(.*\) output .*$')
+endfunction
+
+function! ale_linters#bib#bibclean#match_value(line) abort
+ return matchlist(a:line, 'Value input byte=.* line=\(.*\) column=\(.*\) output .*$')
+endfunction
+
+function! ale_linters#bib#bibclean#Handle(buffer, lines) abort
+ let l:output = []
+
+ let l:type = 'E'
+ let l:msg = ''
+
+ for l:line in a:lines
+ if empty(l:msg)
+ let l:mlist = ale_linters#bib#bibclean#match_msg(l:line)
+
+ if !empty(l:mlist)
+ let l:msg = l:mlist[3]
+ let l:type = ale_linters#bib#bibclean#get_type(l:mlist[1])
+ endif
+ else
+ if l:type is# 'E'
+ let l:mlist = ale_linters#bib#bibclean#match_entry(l:line)
+ else
+ let l:mlist = ale_linters#bib#bibclean#match_value(l:line)
+ endif
+
+ if !empty(l:mlist)
+ call add(l:output, {
+ \ 'lnum': l:mlist[1],
+ \ 'col': l:mlist[2],
+ \ 'text': l:msg,
+ \ 'type': l:type
+ \})
+ let l:msg = ''
+ endif
+ endif
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('bib', {
+\ 'name': 'bibclean',
+\ 'executable_callback': ale#VarFunc('bib_bibclean_executable'),
+\ 'command_callback': 'ale_linters#bib#bibclean#GetCommand',
+\ 'output_stream': 'stderr',
+\ 'callback': 'ale_linters#bib#bibclean#Handle',
+\})
diff --git a/ale_linters/java/javalsp.vim b/ale_linters/java/javalsp.vim
index 5d1a0c63..1436a52c 100644
--- a/ale_linters/java/javalsp.vim
+++ b/ale_linters/java/javalsp.vim
@@ -2,15 +2,17 @@
" Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac
call ale#Set('java_javalsp_jar', 'javacs.jar')
+call ale#Set('java_javalsp_executable', 'java')
function! ale_linters#java#javalsp#Executable(buffer) abort
- return 'java'
+ return ale#Var(a:buffer, 'java_javalsp_executable')
endfunction
function! ale_linters#java#javalsp#Command(buffer) abort
let l:jar = ale#Var(a:buffer, 'java_javalsp_jar')
+ let l:executable = ale_linters#java#javalsp#Executable(a:buffer)
- return ale#Escape('java -cp ' . l:jar . ' -Xverify:none org.javacs.Main')
+ return ale#Escape(l:executable) . ' -cp ' . l:jar . ' -Xverify:none org.javacs.Main'
endfunction
call ale#linter#Define('java', {
diff --git a/ale_linters/python/pydocstyle.vim b/ale_linters/python/pydocstyle.vim
new file mode 100644
index 00000000..ebf92bf1
--- /dev/null
+++ b/ale_linters/python/pydocstyle.vim
@@ -0,0 +1,74 @@
+" Author: Pablo Acosta <pmasdev@gmail.com>
+" Description: pydocstyle for python files
+
+call ale#Set('python_pydocstyle_executable', 'pydocstyle')
+call ale#Set('python_pydocstyle_options', '')
+call ale#Set('python_pydocstyle_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('python_pydocstyle_auto_pipenv', 0)
+
+function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort
+ if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pydocstyle_auto_pipenv'))
+ \ && ale#python#PipenvPresent(a:buffer)
+ return 'pipenv'
+ endif
+
+ return ale#python#FindExecutable(a:buffer, 'python_pydocstyle', ['pydocstyle'])
+endfunction
+
+function! ale_linters#python#pydocstyle#GetCommand(buffer) abort
+ let l:dir = fnamemodify(bufname(a:buffer), ':p:h')
+ let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer)
+
+ let l:exec_args = l:executable =~? 'pipenv$'
+ \ ? ' run pydocstyle'
+ \ : ''
+
+ return ale#path#CdString(l:dir)
+ \ . ale#Escape(l:executable) . l:exec_args
+ \ . ' ' . ale#Var(a:buffer, 'python_pydocstyle_options')
+ \ . ' ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:t'))
+endfunction
+
+function! ale_linters#python#pydocstyle#Handle(buffer, lines) abort
+ " Matches patterns like the following:
+ " mydir/myfile.py:33 in public function `myfunction`:
+ " DXXX: Error description
+ let l:fname = ale#Escape(fnamemodify(bufname(a:buffer), ':p:t'))
+ let l:line1_pattern = '\v^' . l:fname . ':\s*(\d+)\s+.*$'
+ let l:line2_pattern = '\v^.*([a-zA-Z]\d+):\s*(.*)$'
+ let l:output = []
+
+ let l:num_lines = len(a:lines)
+ let l:index = 0
+
+ while l:index < l:num_lines
+ let l:lnum = matchlist(a:lines[l:index], l:line1_pattern)
+
+ if !empty(l:lnum) && (l:index + 1 < l:num_lines)
+ let l:desc = matchlist(a:lines[l:index + 1], l:line2_pattern)
+
+ if !empty(l:desc)
+ call add(l:output, {
+ \ 'lnum': l:lnum[1] + 0,
+ \ 'col': 1,
+ \ 'type': 'W',
+ \ 'text': l:desc[2],
+ \ 'code': l:desc[1],
+ \})
+ endif
+
+ let l:index = l:index + 2
+ else
+ let l:index = l:index + 1
+ endif
+ endwhile
+
+ return l:output
+endfunction
+
+call ale#linter#Define('python', {
+\ 'name': 'pydocstyle',
+\ 'executable_callback': 'ale_linters#python#pydocstyle#GetExecutable',
+\ 'command_callback': 'ale_linters#python#pydocstyle#GetCommand',
+\ 'callback': 'ale_linters#python#pydocstyle#Handle',
+\})
diff --git a/ale_linters/sass/sasslint.vim b/ale_linters/sass/sasslint.vim
index 4df56dfd..8d24185d 100644
--- a/ale_linters/sass/sasslint.vim
+++ b/ale_linters/sass/sasslint.vim
@@ -1,9 +1,28 @@
-" Author: KabbAmine - https://github.com/KabbAmine,
-" Ben Falconer <ben@falconers.me.uk>
+" Author: sQVe - https://github.com/sQVe
+
+call ale#Set('sass_sasslint_executable', 'sass-lint')
+call ale#Set('sass_sasslint_options', '')
+call ale#Set('sass_sasslint_use_global', get(g:, 'ale_use_global_executables', 0))
+
+function! ale_linters#sass#sasslint#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'sass_sasslint', [
+ \ 'node_modules/sass-lint/bin/sass-lint.js',
+ \ 'node_modules/.bin/sass-lint',
+ \])
+endfunction
+
+function! ale_linters#sass#sasslint#GetCommand(buffer) abort
+ let l:executable = ale_linters#sass#sasslint#GetExecutable(a:buffer)
+ let l:options = ale#Var(a:buffer, 'sass_sasslint_options')
+
+ return ale#node#Executable(a:buffer, l:executable)
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' -v -q -f compact %t'
+endfunction
call ale#linter#Define('sass', {
\ 'name': 'sasslint',
-\ 'executable': 'sass-lint',
-\ 'command_callback': 'ale#handlers#sasslint#GetCommand',
+\ 'executable_callback': 'ale_linters#sass#sasslint#GetExecutable',
+\ 'command_callback': 'ale_linters#sass#sasslint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleCSSLintFormat',
\})
diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim
index ba105927..3dbdd925 100644
--- a/ale_linters/scala/scalac.vim
+++ b/ale_linters/scala/scalac.vim
@@ -9,7 +9,7 @@ endfunction
call ale#linter#Define('scala', {
\ 'name': 'scalac',
\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'},
-\ 'command': '%e -Ystop-before:jvm %t',
+\ 'command': '%e -Ystop-after:parser %t',
\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat',
\ 'output_stream': 'stderr',
\})
diff --git a/ale_linters/scss/sasslint.vim b/ale_linters/scss/sasslint.vim
index f6075001..8b725ba6 100644
--- a/ale_linters/scss/sasslint.vim
+++ b/ale_linters/scss/sasslint.vim
@@ -1,18 +1,28 @@
-" Author: KabbAmine - https://github.com/KabbAmine, Ben Falconer
-" <ben@falconers.me.uk>
+" Author: sQVe - https://github.com/sQVe
+
+call ale#Set('scss_sasslint_executable', 'sass-lint')
+call ale#Set('scss_sasslint_options', '')
+call ale#Set('scss_sasslint_use_global', get(g:, 'ale_use_global_executables', 0))
+
+function! ale_linters#scss#sasslint#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'scss_sasslint', [
+ \ 'node_modules/sass-lint/bin/sass-lint.js',
+ \ 'node_modules/.bin/sass-lint',
+ \])
+endfunction
function! ale_linters#scss#sasslint#GetCommand(buffer) abort
- return ale#path#BufferCdString(a:buffer)
- \ . ale#Escape('sass-lint')
- \ . ' -v'
- \ . ' -q'
- \ . ' -f compact'
- \ . ' %t'
+ let l:executable = ale_linters#scss#sasslint#GetExecutable(a:buffer)
+ let l:options = ale#Var(a:buffer, 'scss_sasslint_options')
+
+ return ale#node#Executable(a:buffer, l:executable)
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' -v -q -f compact %t'
endfunction
call ale#linter#Define('scss', {
\ 'name': 'sasslint',
-\ 'executable': 'sass-lint',
+\ 'executable_callback': 'ale_linters#scss#sasslint#GetExecutable',
\ 'command_callback': 'ale_linters#scss#sasslint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleCSSLintFormat',
\})
diff --git a/ale_linters/swift/swiftlint.vim b/ale_linters/swift/swiftlint.vim
index 697d246b..a1150658 100644
--- a/ale_linters/swift/swiftlint.vim
+++ b/ale_linters/swift/swiftlint.vim
@@ -1,6 +1,24 @@
-" Author: David Mohundro <david@mohundro.com>
+" Author: David Mohundro <david@mohundro.com>, Gordon Fontenot <gordon@fonten.io>
" Description: swiftlint for swift files
+call ale#Set('swift_swiftlint_executable', 'swiftlint')
+call ale#Set('swift_swiftlint_use_global', get(g:, 'ale_use_global_executables', 0))
+
+function! ale_linters#swift#swiftlint#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'swift_swiftlint', [
+ \ 'Pods/SwiftLint/swiftlint',
+ \ 'ios/Pods/SwiftLint/swiftlint',
+ \ 'swiftlint',
+ \])
+endfunction
+
+function! ale_linters#swift#swiftlint#GetCommand(buffer) abort
+ let l:executable = ale_linters#swift#swiftlint#GetExecutable(a:buffer)
+ let l:args = 'lint --use-stdin'
+
+ return ale#Escape(l:executable)
+ \ . ' ' .l:args
+endfunction
function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$'
@@ -8,10 +26,10 @@ function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
- \ 'lnum': str2nr(l:match[2]),
- \ 'type': l:match[4] is# 'error' ? 'E' : 'W',
- \ 'text': l:match[5],
- \}
+ \ 'lnum': str2nr(l:match[2]),
+ \ 'type': l:match[4] is# 'error' ? 'E' : 'W',
+ \ 'text': l:match[5],
+ \}
if l:match[4] is# 'error'
let l:item.type = 'E'
@@ -45,7 +63,7 @@ endfunction
call ale#linter#Define('swift', {
\ 'name': 'swiftlint',
-\ 'executable': 'swiftlint',
-\ 'command': 'swiftlint lint --use-stdin',
+\ 'executable_callback': 'ale_linters#swift#swiftlint#GetExecutable',
+\ 'command_callback': 'ale_linters#swift#swiftlint#GetCommand',
\ 'callback': 'ale_linters#swift#swiftlint#Handle',
\})