From 013308a68f20ee742dc709086d1db4ba7065df05 Mon Sep 17 00:00:00 2001 From: cos Date: Tue, 10 Sep 2024 16:55:39 +0200 Subject: wip: Hackish support for twig-cs-fixer, as a linter 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? --- ale_linters/twig/cs.vim | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ale_linters/twig/cs.vim (limited to 'ale_linters/twig') 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 + " + 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'), +\}) -- cgit v1.2.3