diff options
author | cos <cos> | 2024-09-10 16:55:39 +0200 |
---|---|---|
committer | cos <cos> | 2024-09-10 16:55:41 +0200 |
commit | 013308a68f20ee742dc709086d1db4ba7065df05 (patch) | |
tree | 92a3b3dc732a943c2eaa2ef6d2e83b97c03c8d45 | |
parent | a7ef1817b7aa06d0f80952ad530be87ad3c8f6e2 (diff) | |
download | ale-013308a68f20ee742dc709086d1db4ba7065df05.zip |
wip: Hackish support for twig-cs-fixer, as a linterwip/twig
The regex does't make sense, but it kind of does the trick. What's the
thing with needing a dot before the initial quotes, and where does it
go?
-rw-r--r-- | ale_linters/twig/cs.vim | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/ale_linters/twig/cs.vim b/ale_linters/twig/cs.vim new file mode 100644 index 00000000..da4ec1ae --- /dev/null +++ b/ale_linters/twig/cs.vim @@ -0,0 +1,42 @@ +" Author: cos http://www.netizen.se/ +" Description: Support for Twig CS Check + +" See also autoload/ale/fixers/php_cs_fixer.vim for inspiration. + +call ale#Set('twig_cs_executable', 'twig_cs_fixer') + +function! ale_linters#twig#cs#GetCommand(buffer) abort + let l:tmp_dir = fnamemodify(ale#command#CreateDirectory(a:buffer), ':p') + let l:out_file = l:tmp_dir . fnamemodify(bufname(a:buffer), ':t:r') . '.o' + +" ~/.vim/tools/twig-cs-fixer/vendor/bin/twig-cs-fixer --report=junit check +" + " -gnatc: Check syntax and semantics only (no code generation attempted) + return '%e --report=checkstyle check %t' +endfunction + +function! ale_linters#twig#cs#Handle(buffer, lines) abort + " <error line="15" column="60" severity="error" message="Expecting 0 whitespace before "|"; found 1." source="TwigCsFixer\Rules\Punctuation\PunctuationSpacingRule"/> + let l:re = '\v.*line=."([0-9]*)" column=."([0-9]*)" severity=."([^"]*)" message=."([^"]*)"' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:re) + echom 'Linenum: ' . l:match[1] + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1], + \ 'col': l:match[2], + \ 'type': l:match[3] is# 'warning:' ? 'W' : 'E', + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('twig', { +\ 'name': 'cs', +\ 'callback': 'ale_linters#twig#cs#Handle', +\ 'executable': {b -> ale#Var(b, 'twig_cs_executable')}, +\ 'command': function('ale_linters#twig#cs#GetCommand'), +\}) |