diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-05-08 19:02:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-08 19:02:17 +0100 |
commit | f7ecf3f47a22de588c241cd17d75331875097110 (patch) | |
tree | d75173623b49f821f5581c1a298eb848a1f10625 /ale_linters | |
parent | 7541a40859040d4cd2a5d504cc41ccb1237013b4 (diff) | |
parent | 3bc07b482bfae9211f96b3a737650fc4987536cb (diff) | |
download | ale-f7ecf3f47a22de588c241cd17d75331875097110.zip |
Merge pull request #1555 from BobuSumisu/nasm-linter
Added NASM assembly linter
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/nasm/nasm.vim | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ale_linters/nasm/nasm.vim b/ale_linters/nasm/nasm.vim new file mode 100644 index 00000000..f4b2ca4b --- /dev/null +++ b/ale_linters/nasm/nasm.vim @@ -0,0 +1,50 @@ +" 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#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'nasm_nasm_executable') +endfunction + +function! ale_linters#nasm#nasm#GetOptions(buffer) abort + return ale#Var(a:buffer, 'nasm_nasm_options') +endfunction + +function! ale_linters#nasm#nasm#GetCommand(buffer) abort + " Note that NASM require a trailing slash to the -I option. + let l:executable = ale#Escape(ale_linters#nasm#nasm#GetExecutable(a:buffer)) + let l:separator = has('win32') ? '\' : '/' + let l:path = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h') . l:separator) + let l:options = ale_linters#nasm#nasm#GetOptions(a:buffer) + + return l:executable + \ . ' -X gnu' + \ . ' -I ' . l:path + \ . ' ' . l:options + \ . ' %s' +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', +\ 'executable': 'nasm', +\ 'output_stream': 'stderr', +\ 'lint_file': 1, +\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand', +\ 'callback': 'ale_linters#nasm#nasm#Handle', +\}) |