redpen: use 'code' key to show validator

instead of embedding it into text
This commit is contained in:
rhysd 2017-11-21 15:41:19 +09:00
parent 7ea3aba5e5
commit d465b71362
2 changed files with 8 additions and 3 deletions

View File

@ -8,8 +8,9 @@ function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
let l:output = [] let l:output = []
for l:err in l:res.errors for l:err in l:res.errors
let l:item = { let l:item = {
\ 'text': l:err.message . ' (' . l:err.validator . ')', \ 'text': l:err.message,
\ 'type': 'W', \ 'type': 'W',
\ 'code': l:err.validator,
\} \}
if has_key(l:err, 'startPosition') if has_key(l:err, 'startPosition')
let l:item.lnum = l:err.startPosition.lineNum let l:item.lnum = l:err.startPosition.lineNum
@ -19,6 +20,8 @@ function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
let l:item.end_col = l:err.endPosition.offset let l:item.end_col = l:err.endPosition.offset
endif endif
else else
" Fallback to a whole sentence region when a region is not
" specified by the error.
let l:item.lnum = l:err.lineNum let l:item.lnum = l:err.lineNum
let l:item.col = l:err.sentenceStartColumnNum + 1 let l:item.col = l:err.sentenceStartColumnNum + 1
endif endif

View File

@ -12,14 +12,16 @@ Execute(redpen handler should handle errors output):
\ 'col': 10, \ 'col': 10,
\ 'end_lnum': 1, \ 'end_lnum': 1,
\ 'end_col': 15, \ 'end_col': 15,
\ 'text': 'Found possibly misspelled word "plugin". (Spelling)', \ 'text': 'Found possibly misspelled word "plugin".',
\ 'type': 'W', \ 'type': 'W',
\ 'code': 'Spelling',
\ }, \ },
\ { \ {
\ 'lnum': 1, \ 'lnum': 1,
\ 'col': 1, \ 'col': 1,
\ 'text': 'Found possibly misspelled word "NeoVim". (Spelling)', \ 'text': 'Found possibly misspelled word "NeoVim".',
\ 'type': 'W', \ 'type': 'W',
\ 'code': 'Spelling',
\ }, \ },
\ ], \ ],
\ ale#handlers#redpen#HandleRedpenOutput(bufnr(''), [ \ ale#handlers#redpen#HandleRedpenOutput(bufnr(''), [