1
0
Fork 0
mirror of synced 2024-11-17 22:45:34 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/nasm/nasm.vim

51 lines
1.7 KiB
VimL
Raw Normal View History

2018-06-14 06:31:12 -04: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#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',
\ 'output_stream': 'stderr',
\ 'lint_file': 1,
2018-07-19 08:52:53 -04:00
\ 'executable_callback': 'ale_linters#nasm#nasm#GetExecutable',
2018-06-14 06:31:12 -04:00
\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand',
\ 'callback': 'ale_linters#nasm#nasm#Handle',
\})