Integrate TypoScript linter into vim ale

This commit is contained in:
Daniel Siepmann 2023-12-07 09:08:14 +01:00
parent 4bd2bc8332
commit bd59e551bd
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -0,0 +1,39 @@
" Author: Daniel Siepmann <https://daniel-siepmann.de>
" Description: This file adds support for checking TypoScript with helmich/typo3-typoscript-lint
" PR is open at: https://github.com/dense-analysis/ale/pull/4673
call ale#Set('typoscript_typoscript_lint_executable', 'typoscript-lint')
call ale#Set('typoscript_typoscript_lint_executable_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#typoscript#typoscript_lint#Handle(buffer, lines) abort
let l:output = []
let l:lines = []
for l:line in a:lines
call add(l:lines, substitute(l:line, '&quot;', '"', 'g'))
endfor
let l:pattern = '\vline\="(\d+)" severity\="(warning|info)" message\="(.+)" source\='
for l:match in ale#util#GetMatches(l:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'type': l:match[2] is? 'warning' ? 'E' : 'W',
\ 'text': l:match[3],
\ 'sub_type': 'style',
\})
endfor
return l:output
endfunction
call ale#linter#Define('typoscript', {
\ 'name': 'typoscript_lint',
\ 'executable': {b -> ale#path#FindExecutable(b, 'typoscript_typoscript_lint_executable', [
\ 'vendor/bin/typoscript-lint',
\ 'typoscript-lint'
\ ])},
\ 'output_stream': 'stdout',
\ 'command': '%e --format=checkstyle -- %s',
\ 'callback': 'ale_linters#typoscript#typoscript_lint#Handle',
\})