Merge pull request #86 from neersighted/vint-s
Explicit scope (aka vint -s)
This commit is contained in:
commit
0fa730aecf
@ -5,4 +5,4 @@ cache: pip
|
|||||||
install:
|
install:
|
||||||
- "pip install vim-vint==0.3.9"
|
- "pip install vim-vint==0.3.9"
|
||||||
script:
|
script:
|
||||||
- "vint ."
|
- "vint -s ."
|
||||||
|
@ -14,34 +14,34 @@ function! ale_linters#coffee#coffeelint#Handle(buffer, lines)
|
|||||||
" stdin,14,,error,Throwing strings is forbidden
|
" stdin,14,,error,Throwing strings is forbidden
|
||||||
"
|
"
|
||||||
" Note that we currently ignore lineNumberEnd for multiline errors
|
" Note that we currently ignore lineNumberEnd for multiline errors
|
||||||
let pattern = 'stdin,\(\d\+\),\(\d*\),\(.\+\),\(.\+\)'
|
let l:pattern = 'stdin,\(\d\+\),\(\d*\),\(.\+\),\(.\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let column = 1
|
let l:column = 1
|
||||||
let type = l:match[3] ==# 'error' ? 'E' : 'W'
|
let l:type = l:match[3] ==# 'error' ? 'E' : 'W'
|
||||||
let text = l:match[4]
|
let l:text = l:match[4]
|
||||||
|
|
||||||
" vcol is needed to indicate that the column is a character
|
" vcol is needed to indicate that the column is a character
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': column,
|
\ 'col': l:column,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('coffee', {
|
call ale#linter#Define('coffee', {
|
||||||
|
@ -9,56 +9,56 @@ let g:loaded_ale_linters_d_dmd = 1
|
|||||||
|
|
||||||
" A function for finding the dmd-wrapper script in the Vim runtime paths
|
" A function for finding the dmd-wrapper script in the Vim runtime paths
|
||||||
function! s:FindWrapperScript()
|
function! s:FindWrapperScript()
|
||||||
for parent in split(&runtimepath, ',')
|
for l:parent in split(&runtimepath, ',')
|
||||||
" Expand the path to deal with ~ issues.
|
" Expand the path to deal with ~ issues.
|
||||||
let path = expand(parent . '/' . 'dmd-wrapper')
|
let l:path = expand(l:parent . '/' . 'dmd-wrapper')
|
||||||
|
|
||||||
if filereadable(path)
|
if filereadable(l:path)
|
||||||
return path
|
return l:path
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#d#dmd#GetCommand(buffer)
|
function! ale_linters#d#dmd#GetCommand(buffer)
|
||||||
let wrapper_script = s:FindWrapperScript()
|
let l:wrapper_script = s:FindWrapperScript()
|
||||||
|
|
||||||
let command = wrapper_script . ' -o- -vcolumns -c'
|
let l:command = l:wrapper_script . ' -o- -vcolumns -c'
|
||||||
|
|
||||||
return command
|
return l:command
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#d#dmd#Handle(buffer, lines)
|
function! ale_linters#d#dmd#Handle(buffer, lines)
|
||||||
" Matches patterns lines like the following:
|
" Matches patterns lines like the following:
|
||||||
"
|
"
|
||||||
" /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read
|
" /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read
|
||||||
let pattern = '^[^(]\+(\([0-9]\+\),\([0-9]\+\)): \([^:]\+\): \(.\+\)'
|
let l:pattern = '^[^(]\+(\([0-9]\+\),\([0-9]\+\)): \([^:]\+\): \(.\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let column = l:match[2] + 0
|
let l:column = l:match[2] + 0
|
||||||
let type = l:match[3]
|
let l:type = l:match[3]
|
||||||
let text = l:match[4]
|
let l:text = l:match[4]
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': bufnr('%'),
|
\ 'bufnr': bufnr('%'),
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': column,
|
\ 'col': l:column,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type ==# 'Warning' ? 'W' : 'E',
|
\ 'type': l:type ==# 'Warning' ? 'W' : 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('d', {
|
call ale#linter#Define('d', {
|
||||||
|
@ -18,33 +18,33 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines)
|
|||||||
"
|
"
|
||||||
" :21.34:
|
" :21.34:
|
||||||
" Error: Expected comma in I/O list at (1)
|
" Error: Expected comma in I/O list at (1)
|
||||||
let line_marker_pattern = '^:\(\d\+\)\.\(\d\+\):$'
|
let l:line_marker_pattern = '^:\(\d\+\)\.\(\d\+\):$'
|
||||||
let message_pattern = '^\(Error\|Warning\): \(.\+\)$'
|
let l:message_pattern = '^\(Error\|Warning\): \(.\+\)$'
|
||||||
let looking_for_message = 0
|
let l:looking_for_message = 0
|
||||||
let last_loclist_obj = {}
|
let l:last_loclist_obj = {}
|
||||||
|
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
if looking_for_message
|
if l:looking_for_message
|
||||||
let l:match = matchlist(line, message_pattern)
|
let l:match = matchlist(l:line, l:message_pattern)
|
||||||
else
|
else
|
||||||
let l:match = matchlist(line, line_marker_pattern)
|
let l:match = matchlist(l:line, l:line_marker_pattern)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if looking_for_message
|
if l:looking_for_message
|
||||||
let looking_for_message = 0
|
let l:looking_for_message = 0
|
||||||
|
|
||||||
" Now we have the text, we can set it and add the error.
|
" Now we have the text, we can set it and add the error.
|
||||||
let last_loclist_obj.text = l:match[2]
|
let l:last_loclist_obj.text = l:match[2]
|
||||||
let last_loclist_obj.type = l:match[1] ==# 'Warning' ? 'W' : 'E'
|
let l:last_loclist_obj.type = l:match[1] ==# 'Warning' ? 'W' : 'E'
|
||||||
call add(output, last_loclist_obj)
|
call add(l:output, l:last_loclist_obj)
|
||||||
else
|
else
|
||||||
let last_loclist_obj = {
|
let l:last_loclist_obj = {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
@ -53,11 +53,11 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines)
|
|||||||
\}
|
\}
|
||||||
|
|
||||||
" Start looking for the message and error type.
|
" Start looking for the message and error type.
|
||||||
let looking_for_message = 1
|
let l:looking_for_message = 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('fortran', {
|
call ale#linter#Define('fortran', {
|
||||||
|
@ -11,40 +11,40 @@ function! ale_linters#haskell#ghc#Handle(buffer, lines)
|
|||||||
" Look for lines like the following.
|
" Look for lines like the following.
|
||||||
"
|
"
|
||||||
" /dev/stdin:28:26: Not in scope: `>>>>>'
|
" /dev/stdin:28:26: Not in scope: `>>>>>'
|
||||||
let pattern = '^[^:]\+:\(\d\+\):\(\d\+\): \(.\+\)$'
|
let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\): \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
" For some reason the output coming out of the GHC through the wrapper
|
" For some reason the output coming out of the GHC through the wrapper
|
||||||
" script breaks the lines up in strange ways. So we have to join some
|
" script breaks the lines up in strange ways. So we have to join some
|
||||||
" lines back together again.
|
" lines back together again.
|
||||||
let corrected_lines = []
|
let l:corrected_lines = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
if len(matchlist(line, pattern)) > 0
|
if len(matchlist(l:line, l:pattern)) > 0
|
||||||
call add(corrected_lines, line)
|
call add(l:corrected_lines, l:line)
|
||||||
if line !~# ': error:$'
|
if l:line !~# ': error:$'
|
||||||
call add(corrected_lines, '')
|
call add(l:corrected_lines, '')
|
||||||
endif
|
endif
|
||||||
elseif line ==# ''
|
elseif l:line ==# ''
|
||||||
call add(corrected_lines, line)
|
call add(l:corrected_lines, l:line)
|
||||||
else
|
else
|
||||||
if len(corrected_lines) > 0
|
if len(l:corrected_lines) > 0
|
||||||
if corrected_lines[-1] =~# ': error:$'
|
if l:corrected_lines[-1] =~# ': error:$'
|
||||||
let line = substitute(line, '\v^\s+', ' ', '')
|
let l:line = substitute(l:line, '\v^\s+', ' ', '')
|
||||||
endif
|
endif
|
||||||
let corrected_lines[-1] .= line
|
let l:corrected_lines[-1] .= l:line
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
for line in corrected_lines
|
for l:line in l:corrected_lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
@ -55,7 +55,7 @@ function! ale_linters#haskell#ghc#Handle(buffer, lines)
|
|||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('haskell', {
|
call ale#linter#Define('haskell', {
|
||||||
|
@ -11,33 +11,33 @@ function! ale_linters#html#htmlhint#Handle(buffer, lines) abort
|
|||||||
" Matches patterns lines like the following:
|
" Matches patterns lines like the following:
|
||||||
"stdin:7:10: <title></title> must not be empty. [error/title-require]
|
"stdin:7:10: <title></title> must not be empty. [error/title-require]
|
||||||
|
|
||||||
let pattern = '^stdin:\(\d\+\):\(\d\+\): \(.\+\)$'
|
let l:pattern = '^stdin:\(\d\+\):\(\d\+\): \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let col = match[2] + 0
|
let l:col = l:match[2] + 0
|
||||||
let text = match[3]
|
let l:text = l:match[3]
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': col,
|
\ 'col': l:col,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('html', {
|
call ale#linter#Define('html', {
|
||||||
|
@ -12,10 +12,9 @@ let g:ale_html_tidy_executable = get(g:, 'ale_html_tidy_executable', 'tidy')
|
|||||||
let g:ale_html_tidy_args = get(g:, 'ale_html_tidy_args', '-q -e -language en')
|
let g:ale_html_tidy_args = get(g:, 'ale_html_tidy_args', '-q -e -language en')
|
||||||
|
|
||||||
function! ale_linters#html#tidy#GetCommand(buffer) abort
|
function! ale_linters#html#tidy#GetCommand(buffer) abort
|
||||||
|
|
||||||
" Specify file encoding in options
|
" Specify file encoding in options
|
||||||
" (Idea taken from https://github.com/scrooloose/syntastic/blob/master/syntax_checkers/html/tidy.vim)
|
" (Idea taken from https://github.com/scrooloose/syntastic/blob/master/syntax_checkers/html/tidy.vim)
|
||||||
let file_encoding = get({
|
let l:file_encoding = get({
|
||||||
\ 'ascii': '-ascii',
|
\ 'ascii': '-ascii',
|
||||||
\ 'big5': '-big5',
|
\ 'big5': '-big5',
|
||||||
\ 'cp1252': '-win1252',
|
\ 'cp1252': '-win1252',
|
||||||
@ -33,7 +32,7 @@ function! ale_linters#html#tidy#GetCommand(buffer) abort
|
|||||||
return printf('%s %s %s -',
|
return printf('%s %s %s -',
|
||||||
\ g:ale_html_tidy_executable,
|
\ g:ale_html_tidy_executable,
|
||||||
\ g:ale_html_tidy_args,
|
\ g:ale_html_tidy_args,
|
||||||
\ file_encoding
|
\ l:file_encoding
|
||||||
\ )
|
\ )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -41,34 +40,34 @@ function! ale_linters#html#tidy#Handle(buffer, lines) abort
|
|||||||
" Matches patterns lines like the following:
|
" Matches patterns lines like the following:
|
||||||
" line 7 column 5 - Warning: missing </title> before </head>
|
" line 7 column 5 - Warning: missing </title> before </head>
|
||||||
|
|
||||||
let pattern = '^line \(\d\+\) column \(\d\+\) - \(Warning\|Error\): \(.\+\)$'
|
let l:pattern = '^line \(\d\+\) column \(\d\+\) - \(Warning\|Error\): \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let col = match[2] + 0
|
let l:col = l:match[2] + 0
|
||||||
let type = match[3] ==# 'Error' ? 'E' : 'W'
|
let l:type = l:match[3] ==# 'Error' ? 'E' : 'W'
|
||||||
let text = match[4]
|
let l:text = l:match[4]
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': col,
|
\ 'col': l:col,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('html', {
|
call ale#linter#Define('html', {
|
||||||
|
@ -15,38 +15,38 @@ function! ale_linters#javascript#eslint#Handle(buffer, lines)
|
|||||||
"
|
"
|
||||||
" /path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]
|
" /path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]
|
||||||
" /path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]
|
" /path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]
|
||||||
let pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) \[\(.\+\)\]$'
|
let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) \[\(.\+\)\]$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let text = l:match[3]
|
let l:text = l:match[3]
|
||||||
let marker = l:match[4]
|
let l:marker = l:match[4]
|
||||||
let marker_parts = split(marker, '/')
|
let l:marker_parts = split(l:marker, '/')
|
||||||
let type = marker_parts[0]
|
let l:type = l:marker_parts[0]
|
||||||
|
|
||||||
if len(marker_parts) == 2
|
if len(l:marker_parts) == 2
|
||||||
let text = text . ' (' . marker_parts[1] . ')'
|
let l:text = l:text . ' (' . l:marker_parts[1] . ')'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type ==# 'Warning' ? 'W' : 'E',
|
\ 'type': l:type ==# 'Warning' ? 'W' : 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('javascript', {
|
call ale#linter#Define('javascript', {
|
||||||
|
@ -11,36 +11,36 @@ function! ale_linters#javascript#jscs#Handle(buffer, lines)
|
|||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
"
|
"
|
||||||
" input:57:8: Unexpected token (57:8)
|
" input:57:8: Unexpected token (57:8)
|
||||||
let pattern = '^.\+:\(\d\+\):\(\d\+\): \(.\+\)'
|
let l:pattern = '^.\+:\(\d\+\):\(\d\+\): \(.\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let text = l:match[3]
|
let l:text = l:match[3]
|
||||||
let marker_parts = l:match[4]
|
let l:marker_parts = l:match[4]
|
||||||
|
|
||||||
if len(marker_parts) == 2
|
if len(l:marker_parts) == 2
|
||||||
let text = text . ' (' . marker_parts[1] . ')'
|
let l:text = l:text . ' (' . l:marker_parts[1] . ')'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('javascript', {
|
call ale#linter#Define('javascript', {
|
||||||
|
@ -14,21 +14,21 @@ function! ale_linters#javascript#jshint#GetCommand(buffer)
|
|||||||
" Set this to the location of the jshint configuration file to
|
" Set this to the location of the jshint configuration file to
|
||||||
" use a fixed location for .jshintrc
|
" use a fixed location for .jshintrc
|
||||||
if exists('g:ale_jshint_config_loc')
|
if exists('g:ale_jshint_config_loc')
|
||||||
let jshint_config = g:ale_jshint_config_loc
|
let l:jshint_config = g:ale_jshint_config_loc
|
||||||
else
|
else
|
||||||
" Look for the JSHint config in parent directories.
|
" Look for the JSHint config in parent directories.
|
||||||
let jshint_config = ale#util#FindNearestFile(a:buffer, '.jshintrc')
|
let l:jshint_config = ale#util#FindNearestFile(a:buffer, '.jshintrc')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let command = g:ale_javascript_jshint_executable . ' --reporter unix'
|
let l:command = g:ale_javascript_jshint_executable . ' --reporter unix'
|
||||||
|
|
||||||
if !empty(jshint_config)
|
if !empty(l:jshint_config)
|
||||||
let command .= ' --config ' . fnameescape(jshint_config)
|
let l:command .= ' --config ' . fnameescape(l:jshint_config)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let command .= ' -'
|
let l:command .= ' -'
|
||||||
|
|
||||||
return command
|
return l:command
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#javascript#jshint#Handle(buffer, lines)
|
function! ale_linters#javascript#jshint#Handle(buffer, lines)
|
||||||
@ -38,36 +38,36 @@ function! ale_linters#javascript#jshint#Handle(buffer, lines)
|
|||||||
" stdin:60:5: Attempting to override 'test2' which is a constant.
|
" stdin:60:5: Attempting to override 'test2' which is a constant.
|
||||||
" stdin:57:10: 'test' is defined but never used.
|
" stdin:57:10: 'test' is defined but never used.
|
||||||
" stdin:57:1: 'function' is defined but never used.
|
" stdin:57:1: 'function' is defined but never used.
|
||||||
let pattern = '^.\+:\(\d\+\):\(\d\+\): \(.\+\)'
|
let l:pattern = '^.\+:\(\d\+\):\(\d\+\): \(.\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let text = l:match[3]
|
let l:text = l:match[3]
|
||||||
let marker_parts = l:match[4]
|
let l:marker_parts = l:match[4]
|
||||||
|
|
||||||
if len(marker_parts) == 2
|
if len(l:marker_parts) == 2
|
||||||
let text = text . ' (' . marker_parts[1] . ')'
|
let l:text = l:text . ' (' . l:marker_parts[1] . ')'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('javascript', {
|
call ale#linter#Define('javascript', {
|
||||||
|
@ -10,29 +10,29 @@ function! ale_linters#json#jsonlint#Handle(buffer, lines)
|
|||||||
" Matches patterns like the following:
|
" Matches patterns like the following:
|
||||||
" line 2, col 15, found: 'STRING' - expected: 'EOF', '}', ',', ']'.
|
" line 2, col 15, found: 'STRING' - expected: 'EOF', '}', ',', ']'.
|
||||||
|
|
||||||
let pattern = '^line \(\d\+\), col \(\d*\), \(.\+\)$'
|
let l:pattern = '^line \(\d\+\), col \(\d*\), \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" vcol is needed to indicate that the column is a character
|
" vcol is needed to indicate that the column is a character
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': match[3],
|
\ 'text': l:match[3],
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('json', {
|
call ale#linter#Define('json', {
|
||||||
|
@ -7,34 +7,34 @@ endif
|
|||||||
|
|
||||||
let g:loaded_ale_linters_perl_perl = 1
|
let g:loaded_ale_linters_perl_perl = 1
|
||||||
function! ale_linters#perl#perl#Handle(buffer, lines)
|
function! ale_linters#perl#perl#Handle(buffer, lines)
|
||||||
let pattern = '\(.\+\) at \(.\+\) line \(\d\+\)'
|
let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[3]
|
let l:line = l:match[3]
|
||||||
let column = 1
|
let l:column = 1
|
||||||
let text = l:match[1]
|
let l:text = l:match[1]
|
||||||
let type = 'E'
|
let l:type = 'E'
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': column,
|
\ 'col': l:column,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('perl', {
|
call ale#linter#Define('perl', {
|
||||||
|
@ -7,34 +7,34 @@ endif
|
|||||||
|
|
||||||
let g:loaded_ale_linters_perl_perlcritic = 1
|
let g:loaded_ale_linters_perl_perlcritic = 1
|
||||||
function! ale_linters#perl#perlcritic#Handle(buffer, lines)
|
function! ale_linters#perl#perlcritic#Handle(buffer, lines)
|
||||||
let pattern = '\(.\+\) at \(.\+\) line \(\d\+\)'
|
let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[3]
|
let l:line = l:match[3]
|
||||||
let column = 1
|
let l:column = 1
|
||||||
let text = l:match[1]
|
let l:text = l:match[1]
|
||||||
let type = 'E'
|
let l:type = 'E'
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': column,
|
\ 'col': l:column,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('perl', {
|
call ale#linter#Define('perl', {
|
||||||
|
@ -11,18 +11,18 @@ function! ale_linters#php#php#Handle(buffer, lines)
|
|||||||
" Matches patterns like the following:
|
" Matches patterns like the following:
|
||||||
"
|
"
|
||||||
" Parse error: parse error in - on line 7
|
" Parse error: parse error in - on line 7
|
||||||
let pattern = 'Parse error:\s\+\(.\+\) on line \(\d\+\)'
|
let l:pattern = 'Parse error:\s\+\(.\+\) on line \(\d\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" vcol is needed to indicate that the column is a character.
|
" vcol is needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[2] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
@ -33,7 +33,7 @@ function! ale_linters#php#php#Handle(buffer, lines)
|
|||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('php', {
|
call ale#linter#Define('php', {
|
||||||
|
@ -8,46 +8,46 @@ endif
|
|||||||
let g:loaded_ale_linters_php_phpcs = 1
|
let g:loaded_ale_linters_php_phpcs = 1
|
||||||
|
|
||||||
function! ale_linters#php#phpcs#GetCommand(buffer)
|
function! ale_linters#php#phpcs#GetCommand(buffer)
|
||||||
let command = 'phpcs -s --report=emacs --stdin-path=%s'
|
let l:command = 'phpcs -s --report=emacs --stdin-path=%s'
|
||||||
|
|
||||||
" This option can be set to change the standard used by phpcs
|
" This option can be set to change the standard used by phpcs
|
||||||
if exists('g:ale_php_phpcs_standard')
|
if exists('g:ale_php_phpcs_standard')
|
||||||
let command .= ' --standard=' . g:ale_php_phpcs_standard
|
let l:command .= ' --standard=' . g:ale_php_phpcs_standard
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return command
|
return l:command
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#php#phpcs#Handle(buffer, lines)
|
function! ale_linters#php#phpcs#Handle(buffer, lines)
|
||||||
" Matches against lines like the following:
|
" 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)
|
" /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
|
||||||
let pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) \(\(.\+\)\)$'
|
let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) \(\(.\+\)\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let text = l:match[4]
|
let l:text = l:match[4]
|
||||||
let type = l:match[3]
|
let l:type = l:match[3]
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type ==# 'warning' ? 'W' : 'E',
|
\ 'type': l:type ==# 'warning' ? 'W' : 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('php', {
|
call ale#linter#Define('php', {
|
||||||
|
@ -11,17 +11,17 @@ function! ale_linters#pug#puglint#Handle(buffer, lines)
|
|||||||
" Matches patterns like the following:
|
" Matches patterns like the following:
|
||||||
"
|
"
|
||||||
" temp.jade:6:1 The end of the string reached with no closing bracket ) found.
|
" temp.jade:6:1 The end of the string reached with no closing bracket ) found.
|
||||||
let pattern = '^.\+:\(\d\+\):\(\d\+\) \(.\+\)$'
|
let l:pattern = '^.\+:\(\d\+\):\(\d\+\) \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
@ -32,7 +32,7 @@ function! ale_linters#pug#puglint#Handle(buffer, lines)
|
|||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('pug', {
|
call ale#linter#Define('pug', {
|
||||||
|
@ -5,11 +5,11 @@ function! ale_linters#pyrex#cython#Handle(buffer, lines)
|
|||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
"
|
"
|
||||||
" test.pyx:13:25: Expected ':', found 'NEWLINE'
|
" test.pyx:13:25: Expected ':', found 'NEWLINE'
|
||||||
let pattern = '^.\+:\(\d\+\):\(\d\+\): \(.\+\)$'
|
let l:pattern = '^.\+:\(\d\+\):\(\d\+\): \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
@ -20,7 +20,7 @@ function! ale_linters#pyrex#cython#Handle(buffer, lines)
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
@ -31,7 +31,7 @@ function! ale_linters#pyrex#cython#Handle(buffer, lines)
|
|||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('pyrex', {
|
call ale#linter#Define('pyrex', {
|
||||||
|
@ -11,40 +11,40 @@ function! ale_linters#python#flake8#Handle(buffer, lines)
|
|||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
"
|
"
|
||||||
" stdin:6:6: E111 indentation is not a multiple of four
|
" stdin:6:6: E111 indentation is not a multiple of four
|
||||||
let pattern = '^stdin:\(\d\+\):\(\d\+\): \([^ ]\+\) \(.\+\)$'
|
let l:pattern = '^stdin:\(\d\+\):\(\d\+\): \([^ ]\+\) \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let column = l:match[2] + 0
|
let l:column = l:match[2] + 0
|
||||||
let code = l:match[3]
|
let l:code = l:match[3]
|
||||||
let text = code . ': ' . l:match[4]
|
let l:text = l:code . ': ' . l:match[4]
|
||||||
let type = code[0] ==# 'E' ? 'E' : 'W'
|
let l:type = l:code[0] ==# 'E' ? 'E' : 'W'
|
||||||
|
|
||||||
if code ==# 'W291' && !g:ale_warn_about_trailing_whitespace
|
if l:code ==# 'W291' && !g:ale_warn_about_trailing_whitespace
|
||||||
" Skip warnings for trailing whitespace if the option is off.
|
" Skip warnings for trailing whitespace if the option is off.
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': column,
|
\ 'col': l:column,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('python', {
|
call ale#linter#Define('python', {
|
||||||
|
@ -12,32 +12,32 @@ function! ale_linters#ruby#rubocop#Handle(buffer, lines)
|
|||||||
"
|
"
|
||||||
" <path>/_:47:14: 83:29: C: Prefer single-quoted strings when you don't
|
" <path>/_:47:14: 83:29: C: Prefer single-quoted strings when you don't
|
||||||
" need string interpolation or special symbols.
|
" need string interpolation or special symbols.
|
||||||
let pattern = '\v_:(\d+):(\d+): (.): (.+)'
|
let l:pattern = '\v_:(\d+):(\d+): (.): (.+)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let text = l:match[4]
|
let l:text = l:match[4]
|
||||||
let type = l:match[3]
|
let l:type = l:match[3]
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type ==# 'C' ? 'E' : 'W',
|
\ 'type': l:type ==# 'C' ? 'E' : 'W',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('ruby', {
|
call ale#linter#Define('ruby', {
|
||||||
|
@ -12,41 +12,41 @@ function! ale_linters#scala#scalac#Handle(buffer, lines)
|
|||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
"
|
"
|
||||||
" /var/folders/5q/20rgxx3x1s34g3m14n5bq0x80000gn/T/vv6pSsy/0:26: error: expected class or object definition
|
" /var/folders/5q/20rgxx3x1s34g3m14n5bq0x80000gn/T/vv6pSsy/0:26: error: expected class or object definition
|
||||||
let pattern = '^.\+:\(\d\+\): \(\w\+\): \(.\+\)'
|
let l:pattern = '^.\+:\(\d\+\): \(\w\+\): \(.\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
let ln = 0
|
let l:ln = 0
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let ln = ln + 1
|
let l:ln = l:ln + 1
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let text = l:match[3]
|
let l:text = l:match[3]
|
||||||
let type = l:match[2] ==# 'error' ? 'E' : 'W'
|
let l:type = l:match[2] ==# 'error' ? 'E' : 'W'
|
||||||
let col = 0
|
let l:col = 0
|
||||||
if ln + 1 < len(a:lines)
|
if l:ln + 1 < len(a:lines)
|
||||||
let col = stridx(a:lines[ln + 1], '^')
|
let l:col = stridx(a:lines[l:ln + 1], '^')
|
||||||
if col == -1
|
if l:col == -1
|
||||||
let col = 0
|
let l:col = 0
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': col + 1,
|
\ 'col': l:col + 1,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('scala', {
|
call ale#linter#Define('scala', {
|
||||||
|
@ -11,11 +11,11 @@ function! ale_linters#scss#scsslint#Handle(buffer, lines)
|
|||||||
" Matches patterns like the following:
|
" Matches patterns like the following:
|
||||||
"
|
"
|
||||||
" test.scss:2:1 [W] Indentation: Line should be indented 2 spaces, but was indented 4 spaces
|
" test.scss:2:1 [W] Indentation: Line should be indented 2 spaces, but was indented 4 spaces
|
||||||
let pattern = '^.*:\(\d\+\):\(\d*\) \[\([^\]]\+\)\] \(.\+\)$'
|
let l:pattern = '^.*:\(\d\+\):\(\d*\) \[\([^\]]\+\)\] \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
@ -27,7 +27,7 @@ function! ale_linters#scss#scsslint#Handle(buffer, lines)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" vcol is needed to indicate that the column is a character
|
" vcol is needed to indicate that the column is a character
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
@ -38,7 +38,7 @@ function! ale_linters#scss#scsslint#Handle(buffer, lines)
|
|||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('scss', {
|
call ale#linter#Define('scss', {
|
||||||
|
@ -18,16 +18,16 @@ if !exists('g:ale_linters_sh_shell_default_shell')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
function! ale_linters#sh#shell#GetExecutable(buffer)
|
function! ale_linters#sh#shell#GetExecutable(buffer)
|
||||||
let banglines = getbufline(a:buffer, 1)
|
let l:banglines = getbufline(a:buffer, 1)
|
||||||
|
|
||||||
" Take the shell executable from the hashbang, if we can.
|
" Take the shell executable from the hashbang, if we can.
|
||||||
if len(banglines) == 1 && banglines[0] =~# '^#!'
|
if len(l:banglines) == 1 && l:banglines[0] =~# '^#!'
|
||||||
" Remove options like -e, etc.
|
" Remove options like -e, etc.
|
||||||
let line = substitute(banglines[0], '--\?[a-zA-Z0-9]\+', '', 'g')
|
let l:line = substitute(l:banglines[0], '--\?[a-zA-Z0-9]\+', '', 'g')
|
||||||
|
|
||||||
for possible_shell in ['bash', 'tcsh', 'csh', 'zsh', 'sh']
|
for l:possible_shell in ['bash', 'tcsh', 'csh', 'zsh', 'sh']
|
||||||
if line =~# possible_shell . '\s*$'
|
if l:line =~# l:possible_shell . '\s*$'
|
||||||
return possible_shell
|
return l:possible_shell
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
@ -44,34 +44,34 @@ function! ale_linters#sh#shell#Handle(buffer, lines)
|
|||||||
"
|
"
|
||||||
" bash: line 13: syntax error near unexpected token `d'
|
" bash: line 13: syntax error near unexpected token `d'
|
||||||
" sh: 11: Syntax error: "(" unexpected
|
" sh: 11: Syntax error: "(" unexpected
|
||||||
let pattern = '^[^:]\+: \%(\w\+ \|\)\(\d\+\): \(.\+\)'
|
let l:pattern = '^[^:]\+: \%(\w\+ \|\)\(\d\+\): \(.\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let column = 1
|
let l:column = 1
|
||||||
let text = l:match[2]
|
let l:text = l:match[2]
|
||||||
let type = 'E'
|
let l:type = 'E'
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': column,
|
\ 'col': l:column,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('sh', {
|
call ale#linter#Define('sh', {
|
||||||
|
@ -13,34 +13,34 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines)
|
|||||||
" hello.ts[7, 41]: trailing whitespace
|
" hello.ts[7, 41]: trailing whitespace
|
||||||
" hello.ts[5, 1]: Forbidden 'var' keyword, use 'let' or 'const' instead
|
" hello.ts[5, 1]: Forbidden 'var' keyword, use 'let' or 'const' instead
|
||||||
"
|
"
|
||||||
let pattern = '.\+.ts\[\(\d\+\), \(\d\+\)\]: \(.\+\)'
|
let l:pattern = '.\+.ts\[\(\d\+\), \(\d\+\)\]: \(.\+\)'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let column = l:match[2] + 0
|
let l:column = l:match[2] + 0
|
||||||
let type = 'E'
|
let l:type = 'E'
|
||||||
let text = l:match[3]
|
let l:text = l:match[3]
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': column,
|
\ 'col': l:column,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('typescript', {
|
call ale#linter#Define('typescript', {
|
||||||
|
@ -14,32 +14,32 @@ function! ale_linters#verilog#iverilog#Handle(buffer, lines)
|
|||||||
" tb_me_top.v:17: syntax error
|
" tb_me_top.v:17: syntax error
|
||||||
" memory_single_port.v:2: syntax error
|
" memory_single_port.v:2: syntax error
|
||||||
" tb_me_top.v:17: error: Invalid module instantiation
|
" tb_me_top.v:17: error: Invalid module instantiation
|
||||||
let pattern = '^[^:]\+:\(\d\+\): \(warning\|error\|syntax error\)\(: \(.\+\)\)\?'
|
let l:pattern = '^[^:]\+:\(\d\+\): \(warning\|error\|syntax error\)\(: \(.\+\)\)\?'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let type = l:match[2] ==# 'warning' ? 'W' : 'E'
|
let l:type = l:match[2] ==# 'warning' ? 'W' : 'E'
|
||||||
let text = l:match[2] ==# 'syntax error' ? 'syntax error' : l:match[4]
|
let l:text = l:match[2] ==# 'syntax error' ? 'syntax error' : l:match[4]
|
||||||
|
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': 1,
|
\ 'col': 1,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('verilog', {
|
call ale#linter#Define('verilog', {
|
||||||
|
@ -16,32 +16,32 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines)
|
|||||||
" %Warning-UNDRIVEN: test.v:3: Signal is not driven: clk
|
" %Warning-UNDRIVEN: test.v:3: Signal is not driven: clk
|
||||||
" %Warning-UNUSED: test.v:4: Signal is not used: dout
|
" %Warning-UNUSED: test.v:4: Signal is not used: dout
|
||||||
" %Warning-BLKSEQ: test.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=).
|
" %Warning-BLKSEQ: test.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=).
|
||||||
let pattern = '^%\(Warning\|Error\)[^:]*:[^:]\+:\(\d\+\): \(.\+\)$'
|
let l:pattern = '^%\(Warning\|Error\)[^:]*:[^:]\+:\(\d\+\): \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = l:match[2] + 0
|
let l:line = l:match[2] + 0
|
||||||
let type = l:match[1] ==# 'Error' ? 'E' : 'W'
|
let l:type = l:match[1] ==# 'Error' ? 'E' : 'W'
|
||||||
let text = l:match[3]
|
let l:text = l:match[3]
|
||||||
|
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': 1,
|
\ 'col': 1,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type,
|
\ 'type': l:type,
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('verilog', {
|
call ale#linter#Define('verilog', {
|
||||||
|
@ -10,34 +10,34 @@ function! ale_linters#yaml#yamllint#Handle(buffer, lines)
|
|||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
" something.yaml:1:1: [warning] missing document start "---" (document-start)
|
" something.yaml:1:1: [warning] missing document start "---" (document-start)
|
||||||
" something.yml:2:1: [error] syntax error: expected the node content, but found '<stream end>'
|
" something.yml:2:1: [error] syntax error: expected the node content, but found '<stream end>'
|
||||||
let pattern = '^.*:\(\d\+\):\(\d\+\): \[\(error\|warning\)\] \(.\+\)$'
|
let l:pattern = '^.*:\(\d\+\):\(\d\+\): \[\(error\|warning\)\] \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line = match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let col = match[2] + 0
|
let l:col = l:match[2] + 0
|
||||||
let type = match[3]
|
let l:type = l:match[3]
|
||||||
let text = match[4]
|
let l:text = l:match[4]
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': line,
|
\ 'lnum': l:line,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': col,
|
\ 'col': l:col,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type ==# 'warning' ? 'W' : 'E',
|
\ 'type': l:type ==# 'warning' ? 'W' : 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('yaml', {
|
call ale#linter#Define('yaml', {
|
||||||
|
@ -10,8 +10,8 @@ function! ale#Queue(delay) abort
|
|||||||
let s:lint_timer = -1
|
let s:lint_timer = -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let linters = ale#linter#Get(&filetype)
|
let l:linters = ale#linter#Get(&filetype)
|
||||||
if len(linters) == 0
|
if len(l:linters) == 0
|
||||||
" There are no linters to lint with, so stop here.
|
" There are no linters to lint with, so stop here.
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -24,18 +24,18 @@ function! ale#Queue(delay) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#Lint(...) abort
|
function! ale#Lint(...) abort
|
||||||
let buffer = bufnr('%')
|
let l:buffer = bufnr('%')
|
||||||
let linters = ale#linter#Get(&filetype)
|
let l:linters = ale#linter#Get(&filetype)
|
||||||
|
|
||||||
" Set a variable telling us to clear the loclist later.
|
" Set a variable telling us to clear the loclist later.
|
||||||
let g:ale_buffer_should_reset_map[buffer] = 1
|
let g:ale_buffer_should_reset_map[l:buffer] = 1
|
||||||
|
|
||||||
for linter in linters
|
for l:linter in l:linters
|
||||||
" Check if a given linter has a program which can be executed.
|
" Check if a given linter has a program which can be executed.
|
||||||
if has_key(linter, 'executable_callback')
|
if has_key(l:linter, 'executable_callback')
|
||||||
let l:executable = ale#util#GetFunction(linter.executable_callback)(buffer)
|
let l:executable = ale#util#GetFunction(l:linter.executable_callback)(l:buffer)
|
||||||
else
|
else
|
||||||
let l:executable = linter.executable
|
let l:executable = l:linter.executable
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !executable(l:executable)
|
if !executable(l:executable)
|
||||||
@ -43,6 +43,6 @@ function! ale#Lint(...) abort
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call ale#engine#Invoke(buffer, linter)
|
call ale#engine#Invoke(l:buffer, l:linter)
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -3,73 +3,73 @@
|
|||||||
|
|
||||||
" Return a formatted message according to g:ale_echo_msg_format variable
|
" Return a formatted message according to g:ale_echo_msg_format variable
|
||||||
function! s:GetMessage(linter, type, text) abort
|
function! s:GetMessage(linter, type, text) abort
|
||||||
let msg = g:ale_echo_msg_format
|
let l:msg = g:ale_echo_msg_format
|
||||||
let type = a:type ==# 'E'
|
let l:type = a:type ==# 'E'
|
||||||
\ ? g:ale_echo_msg_error_str
|
\ ? g:ale_echo_msg_error_str
|
||||||
\ : g:ale_echo_msg_warning_str
|
\ : g:ale_echo_msg_warning_str
|
||||||
" Capitalize the 1st character
|
" Capitalize the 1st character
|
||||||
let text = toupper(a:text[0]) . a:text[1:-1]
|
let l:text = toupper(a:text[0]) . a:text[1:-1]
|
||||||
|
|
||||||
" Replace handlers if they exist
|
" Replace handlers if they exist
|
||||||
for [k, v] in items({'linter': a:linter, 'severity': type})
|
for [l:k, l:v] in items({'linter': a:linter, 'severity': l:type})
|
||||||
let msg = substitute(msg, '\V%' . k . '%', v, '')
|
let l:msg = substitute(l:msg, '\V%' . l:k . '%', l:v, '')
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return printf(msg, text)
|
return printf(l:msg, l:text)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" This function will perform a binary search to find a message from the
|
" This function will perform a binary search to find a message from the
|
||||||
" loclist to echo when the cursor moves.
|
" loclist to echo when the cursor moves.
|
||||||
function! s:BinarySearch(loclist, line, column) abort
|
function! s:BinarySearch(loclist, line, column) abort
|
||||||
let min = 0
|
let l:min = 0
|
||||||
let max = len(a:loclist) - 1
|
let l:max = len(a:loclist) - 1
|
||||||
let last_column_match = -1
|
let l:last_column_match = -1
|
||||||
|
|
||||||
while 1
|
while 1
|
||||||
if max < min
|
if l:max < l:min
|
||||||
return last_column_match
|
return l:last_column_match
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let mid = (min + max) / 2
|
let l:mid = (l:min + l:max) / 2
|
||||||
let obj = a:loclist[mid]
|
let l:obj = a:loclist[l:mid]
|
||||||
|
|
||||||
" Binary search to get on the same line
|
" Binary search to get on the same line
|
||||||
if a:loclist[mid]['lnum'] < a:line
|
if a:loclist[l:mid]['lnum'] < a:line
|
||||||
let min = mid + 1
|
let l:min = l:mid + 1
|
||||||
elseif a:loclist[mid]['lnum'] > a:line
|
elseif a:loclist[l:mid]['lnum'] > a:line
|
||||||
let max = mid - 1
|
let l:max = l:mid - 1
|
||||||
else
|
else
|
||||||
let last_column_match = mid
|
let l:last_column_match = l:mid
|
||||||
|
|
||||||
" Binary search to get the same column, or near it
|
" Binary search to get the same column, or near it
|
||||||
if a:loclist[mid]['col'] < a:column
|
if a:loclist[l:mid]['col'] < a:column
|
||||||
let min = mid + 1
|
let l:min = l:mid + 1
|
||||||
elseif a:loclist[mid]['col'] > a:column
|
elseif a:loclist[l:mid]['col'] > a:column
|
||||||
let max = mid - 1
|
let l:max = l:mid - 1
|
||||||
else
|
else
|
||||||
return mid
|
return l:mid
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#cursor#TruncatedEcho(message) abort
|
function! ale#cursor#TruncatedEcho(message) abort
|
||||||
let message = a:message
|
let l:message = a:message
|
||||||
" Change tabs to spaces.
|
" Change tabs to spaces.
|
||||||
let message = substitute(message, "\t", ' ', 'g')
|
let l:message = substitute(l:message, "\t", ' ', 'g')
|
||||||
" Remove any newlines in the message.
|
" Remove any newlines in the message.
|
||||||
let message = substitute(message, "\n", '', 'g')
|
let l:message = substitute(l:message, "\n", '', 'g')
|
||||||
|
|
||||||
" We need to turn T for truncated messages on for shortmess,
|
" We need to turn T for truncated messages on for shortmess,
|
||||||
" and then then we need to reset the option back to what it was.
|
" and then then we need to reset the option back to what it was.
|
||||||
let shortmess_options = getbufvar('%', '&shortmess')
|
let l:shortmess_options = getbufvar('%', '&shortmess')
|
||||||
|
|
||||||
try
|
try
|
||||||
" Echo the message truncated to fit without creating a prompt.
|
" Echo the message truncated to fit without creating a prompt.
|
||||||
setlocal shortmess+=T
|
setlocal shortmess+=T
|
||||||
exec "norm :echomsg message\n"
|
exec "norm :echomsg message\n"
|
||||||
finally
|
finally
|
||||||
call setbufvar('%', '&shortmess', shortmess_options)
|
call setbufvar('%', '&shortmess', l:shortmess_options)
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -79,22 +79,20 @@ function! ale#cursor#EchoCursorWarning(...) abort
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let buffer = bufnr('%')
|
let l:buffer = bufnr('%')
|
||||||
|
|
||||||
if !has_key(g:ale_buffer_loclist_map, buffer)
|
if !has_key(g:ale_buffer_loclist_map, l:buffer)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let loclist = g:ale_buffer_loclist_map[buffer]
|
let l:pos = getcurpos()
|
||||||
|
let l:loclist = g:ale_buffer_loclist_map[l:buffer]
|
||||||
|
let l:index = s:BinarySearch(l:loclist, l:pos[1], l:pos[2])
|
||||||
|
|
||||||
let pos = getcurpos()
|
if l:index >= 0
|
||||||
|
let l:loc = l:loclist[l:index]
|
||||||
let index = s:BinarySearch(loclist, pos[1], pos[2])
|
let l:msg = s:GetMessage(l:loc.linter_name, l:loc.type, l:loc.text)
|
||||||
|
call ale#cursor#TruncatedEcho(l:msg)
|
||||||
if index >= 0
|
|
||||||
let l = loclist[index]
|
|
||||||
let msg = s:GetMessage(l.linter_name, l.type, l.text)
|
|
||||||
call ale#cursor#TruncatedEcho(msg)
|
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
endif
|
endif
|
||||||
|
@ -21,8 +21,8 @@ function! s:GetJobID(job) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:ClearJob(job) abort
|
function! s:ClearJob(job) abort
|
||||||
let job_id = s:GetJobID(a:job)
|
let l:job_id = s:GetJobID(a:job)
|
||||||
let linter = s:job_info_map[job_id].linter
|
let l:linter = s:job_info_map[l:job_id].linter
|
||||||
|
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
call jobstop(a:job)
|
call jobstop(a:job)
|
||||||
@ -36,18 +36,18 @@ function! s:ClearJob(job) abort
|
|||||||
call job_stop(a:job)
|
call job_stop(a:job)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call remove(s:job_info_map, job_id)
|
call remove(s:job_info_map, l:job_id)
|
||||||
call remove(linter, 'job')
|
call remove(l:linter, 'job')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:GatherOutput(job, data) abort
|
function! s:GatherOutput(job, data) abort
|
||||||
let job_id = s:GetJobID(a:job)
|
let l:job_id = s:GetJobID(a:job)
|
||||||
|
|
||||||
if !has_key(s:job_info_map, job_id)
|
if !has_key(s:job_info_map, l:job_id)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call extend(s:job_info_map[job_id].output, a:data)
|
call extend(s:job_info_map[l:job_id].output, a:data)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:GatherOutputVim(channel, data) abort
|
function! s:GatherOutputVim(channel, data) abort
|
||||||
@ -64,48 +64,48 @@ function! s:HandleExit(job) abort
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let job_id = s:GetJobID(a:job)
|
let l:job_id = s:GetJobID(a:job)
|
||||||
|
|
||||||
if !has_key(s:job_info_map, job_id)
|
if !has_key(s:job_info_map, l:job_id)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let job_info = s:job_info_map[job_id]
|
let l:job_info = s:job_info_map[l:job_id]
|
||||||
|
|
||||||
call s:ClearJob(a:job)
|
call s:ClearJob(a:job)
|
||||||
|
|
||||||
let linter = job_info.linter
|
let l:linter = l:job_info.linter
|
||||||
let output = job_info.output
|
let l:output = l:job_info.output
|
||||||
let buffer = job_info.buffer
|
let l:buffer = l:job_info.buffer
|
||||||
|
|
||||||
let linter_loclist = ale#util#GetFunction(linter.callback)(buffer, output)
|
let l:linter_loclist = ale#util#GetFunction(l:linter.callback)(l:buffer, l:output)
|
||||||
|
|
||||||
" Make some adjustments to the loclists to fix common problems.
|
" Make some adjustments to the loclists to fix common problems.
|
||||||
call s:FixLocList(buffer, linter_loclist)
|
call s:FixLocList(l:buffer, l:linter_loclist)
|
||||||
|
|
||||||
for item in linter_loclist
|
for l:item in l:linter_loclist
|
||||||
let item.linter_name = linter.name
|
let l:item.linter_name = l:linter.name
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
if g:ale_buffer_should_reset_map[buffer]
|
if g:ale_buffer_should_reset_map[l:buffer]
|
||||||
let g:ale_buffer_should_reset_map[buffer] = 0
|
let g:ale_buffer_should_reset_map[l:buffer] = 0
|
||||||
let g:ale_buffer_loclist_map[buffer] = []
|
let g:ale_buffer_loclist_map[l:buffer] = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Add the loclist items from the linter.
|
" Add the loclist items from the linter.
|
||||||
call extend(g:ale_buffer_loclist_map[buffer], linter_loclist)
|
call extend(g:ale_buffer_loclist_map[l:buffer], l:linter_loclist)
|
||||||
|
|
||||||
" Sort the loclist again.
|
" Sort the loclist again.
|
||||||
" We need a sorted list so we can run a binary search against it
|
" We need a sorted list so we can run a binary search against it
|
||||||
" for efficient lookup of the messages in the cursor handler.
|
" for efficient lookup of the messages in the cursor handler.
|
||||||
call sort(g:ale_buffer_loclist_map[buffer], 'ale#util#LocItemCompare')
|
call sort(g:ale_buffer_loclist_map[l:buffer], 'ale#util#LocItemCompare')
|
||||||
|
|
||||||
if g:ale_set_loclist
|
if g:ale_set_loclist
|
||||||
call setloclist(0, g:ale_buffer_loclist_map[buffer])
|
call setloclist(0, g:ale_buffer_loclist_map[l:buffer])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:ale_set_signs
|
if g:ale_set_signs
|
||||||
call ale#sign#SetSigns(buffer, g:ale_buffer_loclist_map[buffer])
|
call ale#sign#SetSigns(l:buffer, g:ale_buffer_loclist_map[l:buffer])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Mark line 200, column 17 with a squiggly line or something
|
" Mark line 200, column 17 with a squiggly line or something
|
||||||
@ -124,14 +124,14 @@ function! s:FixLocList(buffer, loclist) abort
|
|||||||
" Some errors have line numbers beyond the end of the file,
|
" Some errors have line numbers beyond the end of the file,
|
||||||
" so we need to adjust them so they set the error at the last line
|
" so we need to adjust them so they set the error at the last line
|
||||||
" of the file instead.
|
" of the file instead.
|
||||||
let last_line_number = ale#util#GetLineCount(a:buffer)
|
let l:last_line_number = ale#util#GetLineCount(a:buffer)
|
||||||
|
|
||||||
for item in a:loclist
|
for l:item in a:loclist
|
||||||
if item.lnum == 0
|
if l:item.lnum == 0
|
||||||
" When errors appear at line 0, put them at line 1 instead.
|
" When errors appear at line 0, put them at line 1 instead.
|
||||||
let item.lnum = 1
|
let l:item.lnum = 1
|
||||||
elseif item.lnum > last_line_number
|
elseif l:item.lnum > l:last_line_number
|
||||||
let item.lnum = last_line_number
|
let l:item.lnum = l:last_line_number
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
@ -144,38 +144,38 @@ function! ale#engine#Invoke(buffer, linter) abort
|
|||||||
|
|
||||||
if has_key(a:linter, 'command_callback')
|
if has_key(a:linter, 'command_callback')
|
||||||
" If there is a callback for generating a command, call that instead.
|
" If there is a callback for generating a command, call that instead.
|
||||||
let command = ale#util#GetFunction(a:linter.command_callback)(a:buffer)
|
let l:command = ale#util#GetFunction(a:linter.command_callback)(a:buffer)
|
||||||
else
|
else
|
||||||
let command = a:linter.command
|
let l:command = a:linter.command
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if command =~# '%s'
|
if l:command =~# '%s'
|
||||||
" If there is a '%s' in the command string, replace it with the name
|
" If there is a '%s' in the command string, replace it with the name
|
||||||
" of the file.
|
" of the file.
|
||||||
let command = printf(command, shellescape(fnamemodify(bufname(a:buffer), ':p')))
|
let l:command = printf(l:command, shellescape(fnamemodify(bufname(a:buffer), ':p')))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
if a:linter.output_stream ==# 'stderr'
|
if a:linter.output_stream ==# 'stderr'
|
||||||
" Read from stderr instead of stdout.
|
" Read from stderr instead of stdout.
|
||||||
let job = jobstart(command, {
|
let l:job = jobstart(l:command, {
|
||||||
\ 'on_stderr': 's:GatherOutputNeoVim',
|
\ 'on_stderr': 's:GatherOutputNeoVim',
|
||||||
\ 'on_exit': 's:HandleExitNeoVim',
|
\ 'on_exit': 's:HandleExitNeoVim',
|
||||||
\})
|
\})
|
||||||
elseif a:linter.output_stream ==# 'both'
|
elseif a:linter.output_stream ==# 'both'
|
||||||
let job = jobstart(command, {
|
let l:job = jobstart(l:command, {
|
||||||
\ 'on_stdout': 's:GatherOutputNeoVim',
|
\ 'on_stdout': 's:GatherOutputNeoVim',
|
||||||
\ 'on_stderr': 's:GatherOutputNeoVim',
|
\ 'on_stderr': 's:GatherOutputNeoVim',
|
||||||
\ 'on_exit': 's:HandleExitNeoVim',
|
\ 'on_exit': 's:HandleExitNeoVim',
|
||||||
\})
|
\})
|
||||||
else
|
else
|
||||||
let job = jobstart(command, {
|
let l:job = jobstart(l:command, {
|
||||||
\ 'on_stdout': 's:GatherOutputNeoVim',
|
\ 'on_stdout': 's:GatherOutputNeoVim',
|
||||||
\ 'on_exit': 's:HandleExitNeoVim',
|
\ 'on_exit': 's:HandleExitNeoVim',
|
||||||
\})
|
\})
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let job_options = {
|
let l:job_options = {
|
||||||
\ 'in_mode': 'nl',
|
\ 'in_mode': 'nl',
|
||||||
\ 'out_mode': 'nl',
|
\ 'out_mode': 'nl',
|
||||||
\ 'err_mode': 'nl',
|
\ 'err_mode': 'nl',
|
||||||
@ -184,13 +184,13 @@ function! ale#engine#Invoke(buffer, linter) abort
|
|||||||
|
|
||||||
if a:linter.output_stream ==# 'stderr'
|
if a:linter.output_stream ==# 'stderr'
|
||||||
" Read from stderr instead of stdout.
|
" Read from stderr instead of stdout.
|
||||||
let job_options.err_cb = function('s:GatherOutputVim')
|
let l:job_options.err_cb = function('s:GatherOutputVim')
|
||||||
elseif a:linter.output_stream ==# 'both'
|
elseif a:linter.output_stream ==# 'both'
|
||||||
" Read from both streams.
|
" Read from both streams.
|
||||||
let job_options.out_cb = function('s:GatherOutputVim')
|
let l:job_options.out_cb = function('s:GatherOutputVim')
|
||||||
let job_options.err_cb = function('s:GatherOutputVim')
|
let l:job_options.err_cb = function('s:GatherOutputVim')
|
||||||
else
|
else
|
||||||
let job_options.out_cb = function('s:GatherOutputVim')
|
let l:job_options.out_cb = function('s:GatherOutputVim')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has('win32')
|
if has('win32')
|
||||||
@ -204,20 +204,20 @@ function! ale#engine#Invoke(buffer, linter) abort
|
|||||||
|
|
||||||
" On Unix machines, we can send the Vim buffer directly.
|
" On Unix machines, we can send the Vim buffer directly.
|
||||||
" This is faster than reading the lines ourselves.
|
" This is faster than reading the lines ourselves.
|
||||||
let job_options.in_io = 'buffer'
|
let l:job_options.in_io = 'buffer'
|
||||||
let job_options.in_buf = a:buffer
|
let l:job_options.in_buf = a:buffer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Vim 8 will read the stdin from the file's buffer.
|
" Vim 8 will read the stdin from the file's buffer.
|
||||||
let job = job_start(l:command, l:job_options)
|
let l:job = job_start(l:command, l:job_options)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Only proceed if the job is being run.
|
" Only proceed if the job is being run.
|
||||||
if has('nvim') || (job !=# 'no process' && job_status(job) ==# 'run')
|
if has('nvim') || (l:job !=# 'no process' && job_status(l:job) ==# 'run')
|
||||||
let a:linter.job = job
|
let a:linter.job = l:job
|
||||||
|
|
||||||
" Store the ID for the job in the map to read back again.
|
" Store the ID for the job in the map to read back again.
|
||||||
let s:job_info_map[s:GetJobID(job)] = {
|
let s:job_info_map[s:GetJobID(l:job)] = {
|
||||||
\ 'linter': a:linter,
|
\ 'linter': a:linter,
|
||||||
\ 'buffer': a:buffer,
|
\ 'buffer': a:buffer,
|
||||||
\ 'output': [],
|
\ 'output': [],
|
||||||
@ -225,18 +225,18 @@ function! ale#engine#Invoke(buffer, linter) abort
|
|||||||
|
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
" In NeoVim, we have to send the buffer lines ourselves.
|
" In NeoVim, we have to send the buffer lines ourselves.
|
||||||
let input = join(getbufline(a:buffer, 1, '$'), "\n") . "\n"
|
let l:input = join(getbufline(a:buffer, 1, '$'), "\n") . "\n"
|
||||||
|
|
||||||
call jobsend(job, input)
|
call jobsend(l:job, l:input)
|
||||||
call jobclose(job, 'stdin')
|
call jobclose(l:job, 'stdin')
|
||||||
elseif has('win32')
|
elseif has('win32')
|
||||||
" On some Vim versions, we have to send the buffer data ourselves.
|
" On some Vim versions, we have to send the buffer data ourselves.
|
||||||
let input = join(getbufline(a:buffer, 1, '$'), "\n") . "\n"
|
let l:input = join(getbufline(a:buffer, 1, '$'), "\n") . "\n"
|
||||||
let channel = job_getchannel(job)
|
let l:channel = job_getchannel(l:job)
|
||||||
|
|
||||||
if ch_status(channel) ==# 'open'
|
if ch_status(l:channel) ==# 'open'
|
||||||
call ch_sendraw(channel, input)
|
call ch_sendraw(l:channel, l:input)
|
||||||
call ch_close_in(channel)
|
call ch_close_in(l:channel)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -10,17 +10,17 @@ function! ale#handlers#HandleGCCFormat(buffer, lines) abort
|
|||||||
" <stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]
|
" <stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]
|
||||||
" <stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)
|
" <stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)
|
||||||
" -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004]
|
" -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004]
|
||||||
let pattern = '^.\+:\(\d\+\):\(\d\+\): \([^:]\+\): \(.\+\)$'
|
let l:pattern = '^.\+:\(\d\+\):\(\d\+\): \([^:]\+\): \(.\+\)$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
@ -31,7 +31,7 @@ function! ale#handlers#HandleGCCFormat(buffer, lines) abort
|
|||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#handlers#HandleCSSLintFormat(buffer, lines) abort
|
function! ale#handlers#HandleCSSLintFormat(buffer, lines) abort
|
||||||
@ -42,35 +42,35 @@ function! ale#handlers#HandleCSSLintFormat(buffer, lines) abort
|
|||||||
"
|
"
|
||||||
" These errors can be very massive, so the type will be moved to the front
|
" These errors can be very massive, so the type will be moved to the front
|
||||||
" so you can actually read the error type.
|
" so you can actually read the error type.
|
||||||
let pattern = '^.*: line \(\d\+\), col \(\d\+\), \(Error\|Warning\) - \(.\+\) (\([^)]\+\))$'
|
let l:pattern = '^.*: line \(\d\+\), col \(\d\+\), \(Error\|Warning\) - \(.\+\) (\([^)]\+\))$'
|
||||||
let output = []
|
let l:output = []
|
||||||
|
|
||||||
for line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(l:match) == 0
|
if len(l:match) == 0
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let text = l:match[4]
|
let l:text = l:match[4]
|
||||||
let type = l:match[3]
|
let l:type = l:match[3]
|
||||||
let errorGroup = l:match[5]
|
let l:errorGroup = l:match[5]
|
||||||
|
|
||||||
" Put the error group at the front, so we can see what kind of error
|
" Put the error group at the front, so we can see what kind of error
|
||||||
" it is on small echo lines.
|
" it is on small echo lines.
|
||||||
let text = '(' . errorGroup . ') ' . text
|
let l:text = '(' . l:errorGroup . ') ' . l:text
|
||||||
|
|
||||||
" vcol is Needed to indicate that the column is a character.
|
" vcol is Needed to indicate that the column is a character.
|
||||||
call add(output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'vcol': 0,
|
\ 'vcol': 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': text,
|
\ 'text': l:text,
|
||||||
\ 'type': type ==# 'Warning' ? 'W' : 'E',
|
\ 'type': l:type ==# 'Warning' ? 'W' : 'E',
|
||||||
\ 'nr': -1,
|
\ 'nr': -1,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -9,32 +9,32 @@ function! ale#linter#Define(filetype, linter) abort
|
|||||||
let s:linters[a:filetype] = []
|
let s:linters[a:filetype] = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let new_linter = {
|
let l:new_linter = {
|
||||||
\ 'name': a:linter.name,
|
\ 'name': a:linter.name,
|
||||||
\ 'callback': a:linter.callback,
|
\ 'callback': a:linter.callback,
|
||||||
\}
|
\}
|
||||||
|
|
||||||
if has_key(a:linter, 'executable_callback')
|
if has_key(a:linter, 'executable_callback')
|
||||||
let new_linter.executable_callback = a:linter.executable_callback
|
let l:new_linter.executable_callback = a:linter.executable_callback
|
||||||
else
|
else
|
||||||
let new_linter.executable = a:linter.executable
|
let l:new_linter.executable = a:linter.executable
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_key(a:linter, 'command_callback')
|
if has_key(a:linter, 'command_callback')
|
||||||
let new_linter.command_callback = a:linter.command_callback
|
let l:new_linter.command_callback = a:linter.command_callback
|
||||||
else
|
else
|
||||||
let new_linter.command = a:linter.command
|
let l:new_linter.command = a:linter.command
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_key(a:linter, 'output_stream')
|
if has_key(a:linter, 'output_stream')
|
||||||
let new_linter.output_stream = a:linter.output_stream
|
let l:new_linter.output_stream = a:linter.output_stream
|
||||||
else
|
else
|
||||||
let new_linter.output_stream = 'stdout'
|
let l:new_linter.output_stream = 'stdout'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" TODO: Assert the value of the output_stream to be something sensible.
|
" TODO: Assert the value of the output_stream to be something sensible.
|
||||||
|
|
||||||
call add(s:linters[a:filetype], new_linter)
|
call add(s:linters[a:filetype], l:new_linter)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#linter#Get(filetype) abort
|
function! ale#linter#Get(filetype) abort
|
||||||
@ -50,8 +50,8 @@ function! ale#linter#Get(filetype) abort
|
|||||||
|
|
||||||
if has_key(g:ale_linters, a:filetype)
|
if has_key(g:ale_linters, a:filetype)
|
||||||
" Filter loaded linters according to list of linters specified in option.
|
" Filter loaded linters according to list of linters specified in option.
|
||||||
for linter in g:ale_linters[a:filetype]
|
for l:linter in g:ale_linters[a:filetype]
|
||||||
execute 'runtime! ale_linters/' . a:filetype . '/' . linter . '.vim'
|
execute 'runtime! ale_linters/' . a:filetype . '/' . l:linter . '.vim'
|
||||||
endfor
|
endfor
|
||||||
else
|
else
|
||||||
execute 'runtime! ale_linters/' . a:filetype . '/*.vim'
|
execute 'runtime! ale_linters/' . a:filetype . '/*.vim'
|
||||||
|
@ -39,64 +39,64 @@ function! ale#sign#FindCurrentSigns(buffer) abort
|
|||||||
" Matches output like :
|
" Matches output like :
|
||||||
" line=4 id=1 name=ALEErrorSign
|
" line=4 id=1 name=ALEErrorSign
|
||||||
" строка=1 id=1000001 имя=ALEErrorSign
|
" строка=1 id=1000001 имя=ALEErrorSign
|
||||||
let pattern = 'id=\(\d\+\).*=ALE\(Warning\|Error\)Sign'
|
let l:pattern = 'id=\(\d\+\).*=ALE\(Warning\|Error\)Sign'
|
||||||
|
|
||||||
redir => output
|
redir => l:output
|
||||||
silent exec 'sign place buffer=' . a:buffer
|
silent exec 'sign place buffer=' . a:buffer
|
||||||
redir END
|
redir END
|
||||||
|
|
||||||
let id_list = []
|
let l:id_list = []
|
||||||
|
|
||||||
for line in split(output, "\n")
|
for l:line in split(l:output, "\n")
|
||||||
let match = matchlist(line, pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
if len(match) > 0
|
if len(l:match) > 0
|
||||||
call add(id_list, match[1] + 0)
|
call add(l:id_list, l:match[1] + 0)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return id_list
|
return l:id_list
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Given a loclist, combine the loclist into a list of signs such that only
|
" Given a loclist, combine the loclist into a list of signs such that only
|
||||||
" one sign appears per line. Error lines will take precedence.
|
" one sign appears per line. Error lines will take precedence.
|
||||||
" The loclist will have been previously sorted.
|
" The loclist will have been previously sorted.
|
||||||
function! ale#sign#CombineSigns(loclist) abort
|
function! ale#sign#CombineSigns(loclist) abort
|
||||||
let signlist = []
|
let l:signlist = []
|
||||||
|
|
||||||
for obj in a:loclist
|
for l:obj in a:loclist
|
||||||
let should_append = 1
|
let l:should_append = 1
|
||||||
|
|
||||||
if obj.lnum < 1
|
if l:obj.lnum < 1
|
||||||
" Skip warnings and errors at line 0, etc.
|
" Skip warnings and errors at line 0, etc.
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if len(signlist) > 0 && signlist[-1].lnum == obj.lnum
|
if len(l:signlist) > 0 && l:signlist[-1].lnum == l:obj.lnum
|
||||||
" We can't add the same line twice, because signs must be
|
" We can't add the same line twice, because signs must be
|
||||||
" unique per line.
|
" unique per line.
|
||||||
let should_append = 0
|
let l:should_append = 0
|
||||||
|
|
||||||
if signlist[-1].type ==# 'W' && obj.type ==# 'E'
|
if l:signlist[-1].type ==# 'W' && l:obj.type ==# 'E'
|
||||||
" If we had a warning previously, but now have an error,
|
" If we had a warning previously, but now have an error,
|
||||||
" we replace the object to set an error instead.
|
" we replace the object to set an error instead.
|
||||||
let signlist[-1] = obj
|
let l:signlist[-1] = l:obj
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if should_append
|
if l:should_append
|
||||||
call add(signlist, obj)
|
call add(l:signlist, l:obj)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return signlist
|
return l:signlist
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" This function will set the signs which show up on the left.
|
" This function will set the signs which show up on the left.
|
||||||
function! ale#sign#SetSigns(buffer, loclist) abort
|
function! ale#sign#SetSigns(buffer, loclist) abort
|
||||||
let signlist = ale#sign#CombineSigns(a:loclist)
|
let l:signlist = ale#sign#CombineSigns(a:loclist)
|
||||||
|
|
||||||
if len(signlist) > 0 || g:ale_sign_column_always
|
if len(l:signlist) > 0 || g:ale_sign_column_always
|
||||||
if !get(g:ale_buffer_sign_dummy_map, a:buffer, 0)
|
if !get(g:ale_buffer_sign_dummy_map, a:buffer, 0)
|
||||||
" Insert a dummy sign if one is missing.
|
" Insert a dummy sign if one is missing.
|
||||||
execute 'sign place ' . g:ale_sign_offset
|
execute 'sign place ' . g:ale_sign_offset
|
||||||
@ -108,27 +108,27 @@ function! ale#sign#SetSigns(buffer, loclist) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Find the current signs with the markers we use.
|
" Find the current signs with the markers we use.
|
||||||
let current_id_list = ale#sign#FindCurrentSigns(a:buffer)
|
let l:current_id_list = ale#sign#FindCurrentSigns(a:buffer)
|
||||||
|
|
||||||
" Remove those markers.
|
" Remove those markers.
|
||||||
for current_id in current_id_list
|
for l:current_id in l:current_id_list
|
||||||
exec 'sign unplace ' . current_id . ' buffer=' . a:buffer
|
exec 'sign unplace ' . l:current_id . ' buffer=' . a:buffer
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Now set all of the signs.
|
" Now set all of the signs.
|
||||||
for i in range(0, len(signlist) - 1)
|
for l:index in range(0, len(l:signlist) - 1)
|
||||||
let obj = signlist[i]
|
let l:sign = l:signlist[l:index]
|
||||||
let name = obj['type'] ==# 'W' ? 'ALEWarningSign' : 'ALEErrorSign'
|
let l:type = l:sign['type'] ==# 'W' ? 'ALEWarningSign' : 'ALEErrorSign'
|
||||||
|
|
||||||
let sign_line = 'sign place ' . (i + g:ale_sign_offset + 1)
|
let l:sign_line = 'sign place ' . (l:index + g:ale_sign_offset + 1)
|
||||||
\. ' line=' . obj['lnum']
|
\. ' line=' . l:sign['lnum']
|
||||||
\. ' name=' . name
|
\. ' name=' . l:type
|
||||||
\. ' buffer=' . a:buffer
|
\. ' buffer=' . a:buffer
|
||||||
|
|
||||||
exec sign_line
|
exec l:sign_line
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
if !g:ale_sign_column_always && len(signlist) > 0
|
if !g:ale_sign_column_always && len(l:signlist) > 0
|
||||||
if get(g:ale_buffer_sign_dummy_map, a:buffer, 0)
|
if get(g:ale_buffer_sign_dummy_map, a:buffer, 0)
|
||||||
execute 'sign unplace ' . g:ale_sign_offset . ' buffer=' . a:buffer
|
execute 'sign unplace ' . g:ale_sign_offset . ' buffer=' . a:buffer
|
||||||
|
|
||||||
|
@ -5,35 +5,35 @@ function! ale#statusline#Status() abort
|
|||||||
" Returns a formatted string that can be integrated in the
|
" Returns a formatted string that can be integrated in the
|
||||||
" statusline
|
" statusline
|
||||||
|
|
||||||
let buf = bufnr('%')
|
let l:buffer = bufnr('%')
|
||||||
let bufLoclist = g:ale_buffer_loclist_map
|
let l:loclist = g:ale_buffer_loclist_map
|
||||||
|
|
||||||
if !has_key(bufLoclist, buf)
|
if !has_key(l:loclist, l:buffer)
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let errors = 0
|
let l:errors = 0
|
||||||
let warnings = 0
|
let l:warnings = 0
|
||||||
for e in bufLoclist[buf]
|
for l:entry in l:loclist[l:buffer]
|
||||||
if e.type ==# 'E'
|
if l:entry.type ==# 'E'
|
||||||
let errors += 1
|
let l:errors += 1
|
||||||
else
|
else
|
||||||
let warnings += 1
|
let l:warnings += 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
let errors = errors ? printf(g:ale_statusline_format[0], errors) : ''
|
let l:errors = l:errors ? printf(g:ale_statusline_format[0], l:errors) : ''
|
||||||
let warnings = warnings ? printf(g:ale_statusline_format[1], warnings) : ''
|
let l:warnings = l:warnings ? printf(g:ale_statusline_format[1], l:warnings) : ''
|
||||||
let no_errors = g:ale_statusline_format[2]
|
let l:no_errors = g:ale_statusline_format[2]
|
||||||
|
|
||||||
" Different formats if no errors or no warnings
|
" Different formats if no errors or no warnings
|
||||||
if empty(errors) && empty(warnings)
|
if empty(l:errors) && empty(l:warnings)
|
||||||
let res = no_errors
|
let l:res = l:no_errors
|
||||||
elseif !empty(errors) && !empty(warnings)
|
elseif !empty(l:errors) && !empty(l:warnings)
|
||||||
let res = printf('%s %s', errors, warnings)
|
let l:res = printf('%s %s', l:errors, l:warnings)
|
||||||
else
|
else
|
||||||
let res = empty(errors) ? warnings : errors
|
let l:res = empty(l:errors) ? l:warnings : l:errors
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return res
|
return l:res
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
" Description: Contains miscellaneous functions
|
" Description: Contains miscellaneous functions
|
||||||
|
|
||||||
function! s:FindWrapperScript() abort
|
function! s:FindWrapperScript() abort
|
||||||
for parent in split(&runtimepath, ',')
|
for l:parent in split(&runtimepath, ',')
|
||||||
" Expand the path to deal with ~ issues.
|
" Expand the path to deal with ~ issues.
|
||||||
let path = expand(parent . '/' . 'stdin-wrapper')
|
let l:path = expand(l:parent . '/' . 'stdin-wrapper')
|
||||||
|
|
||||||
if filereadable(path)
|
if filereadable(l:path)
|
||||||
if has('win32')
|
if has('win32')
|
||||||
return path . '.exe'
|
return l:path . '.exe'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return path
|
return l:path
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user