Introduction ¶
As more and more people like to lint their files, it’s obvious that we also should lint our TypoScript files in TYPO3 projects. Therefore, Martin Helmich has created a TypoScript parser and TypoScript linter.
In this blog post you will learn how to integrate this linter into vim and neovim by using syntastic or ale as a plugin.
Install dependencies ¶
First of all you need syntastic or ale to be installed properly, refer to their docs for installation guideline.
Also you need to have the linter installed. We prefer composer:
composer require --dev helmich/typo3-typoscript-lintThat will install the linter package with all dependencies into your project. By default the binary will be installed into vendor/bin/typoscript-lint. But the concrete path depends on your composer settings. Also it’s possible to install the package globally.
Configure vim plugin syntastic ¶
After all dependencies are installed, we need to add the syntax checker for TypoScript. The file has to be located at syntax_checkers/typoscript/lint.vim inside your runtimepath, e.g. ~/.vim/syntax_checkers/typoscript/lint.vim.
The file has the following content:
if exists('g:loaded_syntastic_typoscript_lint_checker')
finish
endif
let g:loaded_syntastic_typoscript_lint_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_typoscript_lint_GetLocList() dict
let makeprg = self.makeprgBuild({
\ "exe": self.getExec(),
\ "args": '--format=checkstyle',
\ })
let errorformat = '%f:%t:%l:%c:%m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'preprocess': 'checkstyle',
\ 'postprocess': ['guards'] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'typoscript',
\ 'name': 'lint'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 etAlso add the path to your installed executable, e.g. inside of ~/.vimrc like so:
let g:syntastic_typoscript_lint_exec='./vendor/bin/typoscript-lint'If you have installed the binary on a per project base with default paths. Otherwise adjust accordingly. If your path is different on a project level, take a look at Folder specific settings in Vim.
Use ale instead ¶
ale is another plugin for vim/neovim that integrates linters. You can find my pull request to integrate the linter at https://github.com/dense-analysis/ale/pull/4673.

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.