From 4b77fc3240db7fb18bbad7dc187a2860ef46ec3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna=20=E2=80=9CCyberTailor=E2=80=9D?= Date: Tue, 9 Jan 2024 08:41:08 +0000 Subject: [PATCH] contrib/vim: add ALE linter ALE is faster and otherwise better alternative to Syntastic. --- .gitignore | 1 + contrib/vim/ale_linters/gmid/gmid.vim | 36 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 contrib/vim/ale_linters/gmid/gmid.vim diff --git a/.gitignore b/.gitignore index 9e51b12..2a74d3a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ config.log.old config.mk configure.local !contrib/gmid +!contrib/vim/ale_linters/gmid !contrib/vim/syntax_checkers/gmid regress/testdata regress/*.pem diff --git a/contrib/vim/ale_linters/gmid/gmid.vim b/contrib/vim/ale_linters/gmid/gmid.vim new file mode 100644 index 0000000..cf7bed4 --- /dev/null +++ b/contrib/vim/ale_linters/gmid/gmid.vim @@ -0,0 +1,36 @@ +" Linter for ALE +" Language: gmid(1) configuration file +" Licence: ISC + +call ale#Set('gmid_executable', 'gmid') + +function! ale_linters#gmid#gmid#Handle(buffer, lines) abort + let l:output = [] + let l:gmid_type_to_ale_type = { + \ 'error': 'E', + \ 'warning': 'W', + \} + + let l:pattern = '\v^(.*):(\d*) ([a-z]+): (.*)$' + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'filename': l:match[1], + \ 'lnum': l:match[2], + \ 'type': get(l:gmid_type_to_ale_type, l:match[3], 'E'), + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('gmid', { +\ 'name': 'gmid', +\ 'executable': {buffer -> ale#Var(buffer, 'gmid_executable')}, +\ 'command': '%e -nc %s', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\ 'callback': 'ale_linters#gmid#gmid#Handle', +\}) + +" vim: set sw=4 sts=4 et fdm=marker: