Update syntax checking

* Line continuation characters should be on the same lines.
* .vim file line indentation should be a multiple of 4.
This commit is contained in:
w0rp 2019-02-06 18:05:13 +00:00
parent 4d426bf287
commit 3e11cbd18d
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
44 changed files with 221 additions and 191 deletions

View File

@ -57,6 +57,7 @@ function! ale_linters#bib#bibclean#Handle(buffer, lines) abort
\ 'text': l:msg, \ 'text': l:msg,
\ 'type': l:type \ 'type': l:type
\}) \})
let l:msg = '' let l:msg = ''
endif endif
endif endif

View File

@ -222,10 +222,10 @@ function! ale_linters#elm#make#GetExecutable(buffer) abort
if l:is_test && l:is_v19 if l:is_test && l:is_v19
return ale#node#FindExecutable( return ale#node#FindExecutable(
\ a:buffer, \ a:buffer,
\ 'elm_make', \ 'elm_make',
\ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] \ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm']
\ ) \)
else else
return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm'])
endif endif

View File

@ -10,7 +10,7 @@ function! ale_linters#go#langserver#GetCommand(buffer) abort
let l:options = substitute(l:options, '-gocodecompletion', '', 'g') let l:options = substitute(l:options, '-gocodecompletion', '', 'g')
let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1') let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1')
if(ale#Var(a:buffer, 'completion_enabled') == 1) if ale#Var(a:buffer, 'completion_enabled')
call add(l:options, '-gocodecompletion') call add(l:options, '-gocodecompletion')
endif endif

View File

@ -35,7 +35,7 @@ function! ale_linters#haskell#hie#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'haskell_hie_executable') let l:executable = ale#Var(a:buffer, 'haskell_hie_executable')
return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hie') return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hie')
\ . ' --lsp' \ . ' --lsp'
endfunction endfunction
call ale#linter#Define('haskell', { call ale#linter#Define('haskell', {

View File

@ -2,10 +2,10 @@
" Description: Adds support for markdownlint " Description: Adds support for markdownlint
call ale#linter#Define('markdown', { call ale#linter#Define('markdown', {
\ 'name': 'markdownlint', \ 'name': 'markdownlint',
\ 'executable': 'markdownlint', \ 'executable': 'markdownlint',
\ 'lint_file': 1, \ 'lint_file': 1,
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'command': 'markdownlint %s', \ 'command': 'markdownlint %s',
\ 'callback': 'ale#handlers#markdownlint#Handle' \ 'callback': 'ale#handlers#markdownlint#Handle'
\ }) \})

View File

@ -86,8 +86,8 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
let l:next_option_index = l:option_index + 1 let l:next_option_index = l:option_index + 1
" Join space-separated option " Join space-separated option
while l:next_option_index < len(l:split_lines) && while l:next_option_index < len(l:split_lines)
\ stridx(l:split_lines[l:next_option_index], '-') != 0 \&& stridx(l:split_lines[l:next_option_index], '-') != 0
let l:next_option_index += 1 let l:next_option_index += 1
endwhile endwhile
@ -96,9 +96,9 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
call insert(l:split_lines, l:option, l:option_index) call insert(l:split_lines, l:option, l:option_index)
" Ignore invalid or conflicting options " Ignore invalid or conflicting options
if stridx(l:option, '-') != 0 || if stridx(l:option, '-') != 0
\ stridx(l:option, '-o') == 0 || \|| stridx(l:option, '-o') == 0
\ stridx(l:option, '-c') == 0 \|| stridx(l:option, '-c') == 0
call remove(l:split_lines, l:option_index) call remove(l:split_lines, l:option_index)
let l:option_index = l:option_index - 1 let l:option_index = l:option_index - 1
" Fix relative path " Fix relative path

View File

@ -11,7 +11,6 @@ function! ale#fixers#stylelint#GetExecutable(buffer) abort
\]) \])
endfunction endfunction
function! ale#fixers#stylelint#Fix(buffer) abort function! ale#fixers#stylelint#Fix(buffer) abort
let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer) let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer)

View File

@ -1,3 +1,4 @@
scriptencoding utf-8
" Author: Christian Gibbons <cgibbons@gmu.edu> " Author: Christian Gibbons <cgibbons@gmu.edu>
" Description: This file defines a handler function that should work for the " Description: This file defines a handler function that should work for the
" flawfinder format with the -CDQS flags. " flawfinder format with the -CDQS flags.

View File

@ -10,7 +10,7 @@ function! ale#handlers#markdownlint#Handle(buffer, lines) abort
\ 'lnum': l:match[1] + 0, \ 'lnum': l:match[1] + 0,
\ 'text': '(' . l:match[2] . l:match[3] . l:match[4] . ')' . l:match[5], \ 'text': '(' . l:match[2] . l:match[3] . l:match[4] . ')' . l:match[5],
\ 'type': 'W', \ 'type': 'W',
\ }) \})
endfor endfor
return l:output return l:output

View File

@ -71,6 +71,7 @@ function! ale#handlers#sml#Handle(buffer, lines) abort
\ 'text': l:match2[3], \ 'text': l:match2[3],
\ 'type': l:match2[3] =~# '^Warning' ? 'W' : 'E', \ 'type': l:match2[3] =~# '^Warning' ? 'W' : 'E',
\}) \})
continue continue
endif endif

View File

@ -62,12 +62,16 @@ function! ale#lsp#response#ReadDiagnostics(response) abort
\ ':' . (val.location.range.start.line + 1) . \ ':' . (val.location.range.start.line + 1) .
\ ':' . (val.location.range.start.character + 1) . \ ':' . (val.location.range.start.character + 1) .
\ ":\n\t" . val.message \ ":\n\t" . val.message
\ }) \})
let l:loclist_item.detail = l:diagnostic.message . "\n" . join(l:related, "\n") let l:loclist_item.detail = l:diagnostic.message . "\n" . join(l:related, "\n")
endif endif
if has_key(l:diagnostic, 'source') if has_key(l:diagnostic, 'source')
let l:loclist_item.detail = printf('[%s] %s', l:diagnostic.source, l:diagnostic.message) let l:loclist_item.detail = printf(
\ '[%s] %s',
\ l:diagnostic.source,
\ l:diagnostic.message
\)
endif endif
call add(l:loclist, l:loclist_item) call add(l:loclist, l:loclist_item)

View File

@ -52,7 +52,8 @@ function! ale#preview#ShowSelection(item_list, ...) abort
let l:filename = l:item.filename let l:filename = l:item.filename
if get(l:options, 'use_relative_paths') if get(l:options, 'use_relative_paths')
let l:filename = substitute(l:item.filename, '^' . getcwd() . l:sep, '', '') " no-custom-checks let l:cwd = getcwd() " no-custom-checks
let l:filename = substitute(l:filename, '^' . l:cwd . l:sep, '', '')
endif endif
call add( call add(

View File

@ -78,8 +78,10 @@ endfunction
function! s:UpdateCacheIfNecessary(buffer) abort function! s:UpdateCacheIfNecessary(buffer) abort
" Cache is cold, so manually ask for an update. " Cache is cold, so manually ask for an update.
if !has_key(g:ale_buffer_info[a:buffer], 'count') if !has_key(g:ale_buffer_info[a:buffer], 'count')
call ale#statusline#Update(a:buffer, call ale#statusline#Update(
\ g:ale_buffer_info[a:buffer].loclist) \ a:buffer,
\ g:ale_buffer_info[a:buffer].loclist
\)
endif endif
endfunction endfunction

View File

@ -10,7 +10,7 @@ import re
INDENTATION_RE = re.compile(r'^ *') INDENTATION_RE = re.compile(r'^ *')
COMMENT_LINE_RE = re.compile(r'^ *"') COMMENT_LINE_RE = re.compile(r'^ *"')
COMMAND_RE = re.compile(r'^ *([a-zA-Z]+)') COMMAND_RE = re.compile(r'^ *([a-zA-Z\\]+)')
START_BLOCKS = set(['if', 'for', 'while', 'try', 'function']) START_BLOCKS = set(['if', 'for', 'while', 'try', 'function'])
END_BLOCKS = set(['endif', 'endfor', 'endwhile', 'endtry', 'endfunction']) END_BLOCKS = set(['endif', 'endfor', 'endwhile', 'endtry', 'endfunction'])
@ -21,6 +21,7 @@ WHITESPACE_BEFORE_SET = START_BLOCKS | TERMINATORS
WHITESPACE_FORBIDDEN_BEFORE_SET = END_BLOCKS | MIDDLE_BLOCKS WHITESPACE_FORBIDDEN_BEFORE_SET = END_BLOCKS | MIDDLE_BLOCKS
WHITESPACE_AFTER_SET = END_BLOCKS WHITESPACE_AFTER_SET = END_BLOCKS
WHITESPACE_FORBIDDEN_AFTER_SET = START_BLOCKS | MIDDLE_BLOCKS WHITESPACE_FORBIDDEN_AFTER_SET = START_BLOCKS | MIDDLE_BLOCKS
SAME_INDENTATION_SET = set(['\\'])
def remove_comment_lines(line_iter): def remove_comment_lines(line_iter):
@ -44,7 +45,7 @@ def check_lines(line_iter):
): ):
yield ( yield (
line_number, line_number,
'Blank line forbidden after `%s`' % (command,) 'Blank line forbidden after `%s`' % (previous_command,)
) )
previous_line_blank = True previous_line_blank = True
@ -56,6 +57,26 @@ def check_lines(line_iter):
if command_match: if command_match:
command = command_match.group(1) command = command_match.group(1)
if (
command in SAME_INDENTATION_SET
and previous_indentation_level is not None
and indentation_level != previous_indentation_level
):
yield (
line_number,
'Line continuation should match previous indentation'
)
if (
previous_indentation_level is not None
and indentation_level != previous_indentation_level
and abs(indentation_level - previous_indentation_level) != 4
):
yield (
line_number,
'Indentation should be 4 spaces'
)
# Check for commands requiring blank lines before them, if they # Check for commands requiring blank lines before them, if they
# aren't at the start of a block. # aren't at the start of a block.
if ( if (