summaryrefslogtreecommitdiff
path: root/ale_linters/asm
diff options
context:
space:
mode:
authorLucas Kolstad <lkolstad@uw.edu>2017-03-25 16:02:59 -0700
committerLucas Kolstad <lkolstad@uw.edu>2017-03-25 16:36:17 -0700
commitd84d91ff35cf2852556c10a6bed6c3979348c507 (patch)
tree70aa97b50fb08ac4084fbd3c9bd7dac9de54f2e9 /ale_linters/asm
parent822b19ac8376677d73c4df5ce80ed708a1cabd8b (diff)
downloadale-d84d91ff35cf2852556c10a6bed6c3979348c507.zip
Add support for ASM files using GCC
Diffstat (limited to 'ale_linters/asm')
-rw-r--r--ale_linters/asm/gcc.vim44
1 files changed, 44 insertions, 0 deletions
diff --git a/ale_linters/asm/gcc.vim b/ale_linters/asm/gcc.vim
new file mode 100644
index 00000000..cbc61ed7
--- /dev/null
+++ b/ale_linters/asm/gcc.vim
@@ -0,0 +1,44 @@
+" Author: Lucas Kolstad <lkolstad@uw.edu>
+" Description: gcc linter for asm files
+
+let g:ale_asm_gcc_options =
+\ get(g:, 'ale_asm_gcc_options', '-Wall')
+
+function! ale_linters#asm#gcc#GetCommand(buffer) abort
+ return 'gcc -x assembler -fsyntax-only '
+ \ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
+ \ . ' ' . g:ale_asm_gcc_options . ' -'
+endfunction
+
+function! ale_linters#asm#gcc#Handle(buffer, lines) abort
+ 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
+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',
+\})