X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..5a4872f466ebd76ddd532bdf2798554421c53df4:/.vim/bundle/ale/ale_linters/nasm/nasm.vim?ds=sidebyside diff --git a/.vim/bundle/ale/ale_linters/nasm/nasm.vim b/.vim/bundle/ale/ale_linters/nasm/nasm.vim new file mode 100644 index 00000000..c4f53629 --- /dev/null +++ b/.vim/bundle/ale/ale_linters/nasm/nasm.vim @@ -0,0 +1,41 @@ +" Author: Oyvind Ingvaldsen +" 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 + " Note that NASM requires a trailing slash for the -I option. + let l:separator = has('win32') ? '\' : '/' + let l:output_null = has('win32') ? 'NUL' : '/dev/null' + + return '%e -X gnu -I %s:h' . l:separator + \ . ale#Pad(ale#Var(a:buffer, 'nasm_nasm_options')) + \ . ' %s' + \ . ' -o ' . l:output_null +endfunction + +function! ale_linters#nasm#nasm#Handle(buffer, lines) abort + " Note that we treat 'fatal' as errors. + 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\|fatal' ? 'E' : 'W', + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('nasm', { +\ 'name': 'nasm', +\ 'output_stream': 'stderr', +\ 'lint_file': 1, +\ 'executable': {b -> ale#Var(b, 'nasm_nasm_executable')}, +\ 'command': function('ale_linters#nasm#nasm#GetCommand'), +\ 'callback': 'ale_linters#nasm#nasm#Handle', +\})