diff options
author | javad <uidopsu@gmail.com> | 2023-02-09 05:19:24 +0330 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-09 10:49:24 +0900 |
commit | f78e9d634f9c1177031d4bdeda93f98d63b6bc12 (patch) | |
tree | 6e3eaab73797ff565994d6ef6435454d31e02565 /ale_linters/asm/llvm_mc.vim | |
parent | ae2d47ba831043e34fcd9547c41a76a4800992b8 (diff) | |
download | ale-f78e9d634f9c1177031d4bdeda93f98d63b6bc12.zip |
Add support for llvm-mc as an assembly linter (#4446)
Diffstat (limited to 'ale_linters/asm/llvm_mc.vim')
-rw-r--r-- | ale_linters/asm/llvm_mc.vim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ale_linters/asm/llvm_mc.vim b/ale_linters/asm/llvm_mc.vim new file mode 100644 index 00000000..ebfd0064 --- /dev/null +++ b/ale_linters/asm/llvm_mc.vim @@ -0,0 +1,37 @@ +" Author: uidops <uidops@protonmail.com> +" Description: llvm-mc linter for asm files + +call ale#Set('asm_llvm_mc_executable', 'llvm-mc') +call ale#Set('asm_llvm_mc_options', '') + +function! ale_linters#asm#llvm_mc#GetCommand(buffer) abort + return '%e --assemble' + \ . ' --filetype=asm' + \ . ' -o ' . g:ale#util#nul_file + \ . ' ' . ale#Var(a:buffer, 'asm_llvm_mc_options') +endfunction + +function! ale_linters#asm#llvm_mc#Handle(buffer, lines) abort + let l:pattern = '^.\+:\(\d\+\):\(\d\+\): \([^:]\+\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] =~? 'error' ? 'E' : 'W', + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('asm', { +\ 'name': 'llvm_mc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'asm_llvm_mc_executable')}, +\ 'command': function('ale_linters#asm#llvm_mc#GetCommand'), +\ 'callback': 'ale_linters#asm#llvm_mc#Handle', +\}) + |