ale/ale_linters/asm/gcc.vim

44 lines
1.2 KiB
VimL
Raw Normal View History

2017-03-25 19:02:59 -04:00
" Author: Lucas Kolstad <lkolstad@uw.edu>
" Description: gcc linter for asm files
2017-04-15 07:52:08 -04:00
let g:ale_asm_gcc_options = get(g:, 'ale_asm_gcc_options', '-Wall')
2017-03-25 19:02:59 -04:00
function! ale_linters#asm#gcc#GetCommand(buffer) abort
2017-04-15 07:52:08 -04:00
return 'gcc -x assembler -fsyntax-only '
\ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ' ' . g:ale_asm_gcc_options . ' -'
2017-03-25 19:02:59 -04:00
endfunction
function! ale_linters#asm#gcc#Handle(buffer, lines) abort
2017-04-15 07:52:08 -04:00
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
continue
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:match[3],
\ 'type': l:match[2] =~? 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor
return l:output
2017-03-25 19:02:59 -04: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',
\})