diff --git a/home/programs/neovim/configuration/ale_linters/typoscript/typoscript_lint.vim b/home/programs/neovim/configuration/ale_linters/typoscript/typoscript_lint.vim new file mode 100644 index 0000000..7dfe337 --- /dev/null +++ b/home/programs/neovim/configuration/ale_linters/typoscript/typoscript_lint.vim @@ -0,0 +1,39 @@ +" Author: Daniel Siepmann +" 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, '"', '"', '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', +\})