2017-03-25 23:02:59 +00:00
|
|
|
" Author: Lucas Kolstad <lkolstad@uw.edu>
|
|
|
|
" Description: gcc linter for asm files
|
|
|
|
|
2017-04-15 11:52:08 +00:00
|
|
|
let g:ale_asm_gcc_options = get(g:, 'ale_asm_gcc_options', '-Wall')
|
2017-03-25 23:02:59 +00:00
|
|
|
|
|
|
|
function! ale_linters#asm#gcc#GetCommand(buffer) abort
|
2017-04-15 11:52:08 +00:00
|
|
|
return 'gcc -x assembler -fsyntax-only '
|
2017-05-08 21:59:25 +00:00
|
|
|
\ . '-iquote ' . shellescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
2017-04-16 00:24:08 +00:00
|
|
|
\ . ' ' . 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 = []
|
|
|
|
|
2017-04-17 23:35:53 +00:00
|
|
|
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',
|
2017-04-17 23:35:53 +00:00
|
|
|
\ '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': 'gcc',
|
|
|
|
\ 'command_callback': 'ale_linters#asm#gcc#GetCommand',
|
|
|
|
\ 'callback': 'ale_linters#asm#gcc#Handle',
|
|
|
|
\})
|