2018-05-04 19:44:32 +00:00
|
|
|
" Author: Oyvind Ingvaldsen <oyvind.ingvaldsen@gmail.com>
|
|
|
|
" Description: NASM linter for asmsyntax nasm.
|
|
|
|
|
|
|
|
call ale#Set('nasm_nasm_executable', 'nasm')
|
|
|
|
call ale#Set('nasm_nasm_options', '')
|
|
|
|
|
|
|
|
function! ale_linters#nasm#nasm#GetCommand(buffer) abort
|
2018-08-02 22:44:12 +00:00
|
|
|
" Note that NASM requires a trailing slash for the -I option.
|
2018-05-04 19:44:32 +00:00
|
|
|
let l:separator = has('win32') ? '\' : '/'
|
2018-08-02 22:44:12 +00:00
|
|
|
let l:path = fnamemodify(bufname(a:buffer), ':p:h') . l:separator
|
2018-09-09 22:17:44 +00:00
|
|
|
let l:output_null = has('win32') ? 'NUL' : '/dev/null'
|
2018-05-04 19:44:32 +00:00
|
|
|
|
2018-08-02 22:44:12 +00:00
|
|
|
return '%e -X gnu -I ' . ale#Escape(l:path)
|
|
|
|
\ . ale#Pad(ale#Var(a:buffer, 'nasm_nasm_options'))
|
2018-05-04 19:44:32 +00:00
|
|
|
\ . ' %s'
|
2018-09-09 22:17:44 +00:00
|
|
|
\ . ' -o ' . l:output_null
|
2018-05-04 19:44:32 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#nasm#nasm#Handle(buffer, lines) abort
|
|
|
|
" Note that we treat 'fatal' as errors.
|
|
|
|
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
|
|
|
|
let l:output = []
|
2018-08-02 22:44:12 +00:00
|
|
|
|
2018-05-04 19:44:32 +00:00
|
|
|
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\|fatal' ? 'E' : 'W',
|
|
|
|
\ 'text': l:match[3],
|
|
|
|
\})
|
|
|
|
endfor
|
2018-08-02 22:44:12 +00:00
|
|
|
|
2018-05-04 19:44:32 +00:00
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('nasm', {
|
|
|
|
\ 'name': 'nasm',
|
|
|
|
\ 'output_stream': 'stderr',
|
|
|
|
\ 'lint_file': 1,
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'nasm_nasm_executable')},
|
|
|
|
\ 'command': function('ale_linters#nasm#nasm#GetCommand'),
|
2018-05-04 19:44:32 +00:00
|
|
|
\ 'callback': 'ale_linters#nasm#nasm#Handle',
|
|
|
|
\})
|