Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Add indentation configuration #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ftdetect/typoscript.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
autocmd BufNewFile,BufRead *.ts setlocal filetype=typoscript
autocmd BufNewFile,BufRead *.ts2 setlocal filetype=typoscript
autocmd BufNewFile,BufRead *.typoscript setlocal filetype=typoscript
autocmd BufNewFile,BufRead *.tsconfig setlocal filetype=typoscript

Expand Down
9 changes: 9 additions & 0 deletions ftplugin/typoscript.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
setlocal commentstring=#%s

setlocal cindent
setlocal cinwords=
setlocal cinoptions=
" Do not indent after assignment
setlocal cinoptions+=+0
" Indent multi line value, but not closing brace
setlocal cinoptions+=(s,m1
21 changes: 21 additions & 0 deletions indent/typoscript.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
" Vim indent file
" Language: typoscript
" Maintainer: Daniel Siepmann <[email protected]>
" Last Change: 2018 Oct 14

" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1

" We can use C like indentations with modified options
setlocal cindent
setlocal cinwords=
setlocal cinoptions=
" Do not indent after assignment
setlocal cinoptions+=+0
" Indent multi line value, but not closing brace
setlocal cinoptions+=(s,m1

" let b:undo_indent = "setl cin<"
17 changes: 14 additions & 3 deletions syntax/typoscript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ syntax region tsComment keepend start="^\s*#" end="$"
syntax region tsComment keepend start="\v^\s*\/\/" end="$"
syntax region tsInclude keepend start="\v^\s*\<" end="\v\>\s*$"
syntax region tsCondition keepend start="\v^\s*\[" end="\]\s*$"
syntax match tsSingleline "\v^\s*\i+\s*[=<>{].*$"
syntax match tsSingleline "\v^\s*\i+\s*[=:<>{].*$"
syntax region tsMultiline keepend start="\v^\s*\i+\s*\(\s*$" end="\v^\s*\)\s*$"
syntax match tsDelimiter "\v^\s*\}\s*$"

Expand All @@ -20,9 +20,10 @@ syntax region tsValue keepend matchgroup=tsLineOperator start="\v\=" end="\v$" c
syntax region tsValue keepend matchgroup=tsDelimiter start="\v\(" end="\v^\s*\)\s*$" contained containedin=tsMultiline
syntax match tsIdentifier "\v^\s*\i+" contained containedin=tsSingleline,tsMultiline
syntax match tsLineOperator "\v[=<]" contained containedin=tsSymlink
syntax match tsSymlink "\v(\<|\=\s*\<)\s*\i+\s*$" contained containedin=tsSingleline
syntax match tsSymlink "\v(\<|\=\s*\<|\>\s*)\s*\i+\s*$" contained containedin=tsSingleline
syntax match tsDelimiter "\v\{\s*$" contained containedin=tsSingleline
syntax match tsLineOperator "\v\>\s*$" contained containedin=tsSingleline
syntax match tsLineOperator "\v:\=" contained containedin=tsSingleline
syntax match tsLineOperator "\v\>" contained containedin=tsSingleline
syntax match tsIdentifier "\v\i+\s*$" contained containedin=tsSymlink

" Sub level elements
Expand Down Expand Up @@ -66,6 +67,15 @@ syntax case match | syntax keyword tsObjectType contained containedin=tsValue TE
syntax case match | syntax keyword tsObjectType contained containedin=tsValue USER
syntax case match | syntax keyword tsObjectType contained containedin=tsValue USER_INT

syntax case match | syntax keyword modificationFunction contained containedin=tsValue addToList
syntax case match | syntax keyword modificationFunction contained containedin=tsValue prependString
syntax case match | syntax keyword modificationFunction contained containedin=tsValue removeFromList
syntax case match | syntax keyword modificationFunction contained containedin=tsValue removeString
syntax case match | syntax keyword modificationFunction contained containedin=tsValue replaceString
syntax case match | syntax keyword modificationFunction contained containedin=tsValue reverseList
syntax case match | syntax keyword modificationFunction contained containedin=tsValue sortList
syntax case match | syntax keyword modificationFunction contained containedin=tsValue uniqueList

" Link groups
highlight link tsComment Comment
highlight link tsCondition Conditional
Expand All @@ -81,6 +91,7 @@ highlight link tsTag Identifier
highlight link tsTagOperator Operator
highlight link tsTagAttrValue String
highlight link tsObjectType Type
highlight link modificationFunction Type

let b:current_syntax = "typoscript"