2018-03-31 10:55:20 -04: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')
|
|
|
|
|
|
|
|
function! ale_linters#asm#gcc#GetCommand(buffer) abort
|
2018-08-25 12:13:42 -04:00
|
|
|
return '%e -x assembler -fsyntax-only '
|
|
|
|
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
|
|
|
\ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
|
2018-03-31 10:55:20 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#asm#gcc#Handle(buffer, lines) abort
|
|
|
|
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
|
|
|
|
let l:output = []
|
|
|
|
|
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
|
|
|
call add(l:output, {
|
|
|
|
\ 'lnum': l:match[1] + 0,
|
|
|
|
\ 'type': l:match[2] =~? 'error' ? 'E' : 'W',
|
|
|
|
\ 'text': l:match[3],
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('asm', {
|
|
|
|
\ 'name': 'gcc',
|
|
|
|
\ 'output_stream': 'stderr',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'asm_gcc_executable')},
|
|
|
|
\ 'command': function('ale_linters#asm#gcc#GetCommand'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale_linters#asm#gcc#Handle',
|
|
|
|
\})
|