ale/ale_linters/asm/gcc.vim

38 lines
1.1 KiB
VimL
Raw Normal View History

2017-03-25 23:02:59 +00:00
" Author: Lucas Kolstad <lkolstad@uw.edu>
" Description: gcc linter for asm files
call ale#Set('asm_gcc_executable', 'gcc')
call ale#Set('asm_gcc_options', '-Wall')
2017-03-25 23:02:59 +00:00
function! ale_linters#asm#gcc#GetCommand(buffer) abort
" `-o /dev/null` or `-o null` is needed to catch all errors,
" -fsyntax-only doesn't catch everything.
return '%e -x assembler'
\ . ' -o ' . g:ale#util#nul_file
\ . '-iquote %s:h'
\ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
2017-03-25 23:02:59 +00:00
endfunction
function! ale_linters#asm#gcc#Handle(buffer, lines) abort
2017-04-15 11:52:08 +00:00
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
2017-04-15 11:52:08 +00:00
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'type': l:match[2] =~? 'error' ? 'E' : 'W',
\ 'text': l:match[3],
2017-04-15 11:52:08 +00:00
\})
endfor
return l:output
2017-03-25 23:02:59 +00:00
endfunction
call ale#linter#Define('asm', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'asm_gcc_executable')},
\ 'command': function('ale_linters#asm#gcc#GetCommand'),
2017-03-25 23:02:59 +00:00
\ 'callback': 'ale_linters#asm#gcc#Handle',
\})