From 5f2bdc2bf78f44d58ccc2a8de5394e8441eee657 Mon Sep 17 00:00:00 2001 From: Elmar Hinz Date: Wed, 24 Sep 2014 20:44:41 +0200 Subject: [PATCH] elaborated syntax highlighting for typoscript --- LICENSE | 0 README | 0 ftdetect/typoscript.vim | 1 + syntax/typoscript.vim | 64 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 LICENSE create mode 100644 README create mode 100644 ftdetect/typoscript.vim create mode 100644 syntax/typoscript.vim diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/ftdetect/typoscript.vim b/ftdetect/typoscript.vim new file mode 100644 index 0000000..fbb1d67 --- /dev/null +++ b/ftdetect/typoscript.vim @@ -0,0 +1 @@ +autocmd BufNewFile,BufRead *.ts setlocal filetype=typoscript diff --git a/syntax/typoscript.vim b/syntax/typoscript.vim new file mode 100644 index 0000000..6e513d9 --- /dev/null +++ b/syntax/typoscript.vim @@ -0,0 +1,64 @@ +if exists("b:current_syntax") + finish +endif + +" Setup +setlocal isident=@,48-57,-,.,_,192-255 + +" Top level elements +syntax region tsComment keepend start="\/\*" end="\*\/" +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 region tsMultiline keepend start="\v^\s*\i+\s*\(\s*$" end="\v^\s*\)\s*$" +syntax match tsDelimiter "\v^\s*\}\s*$" + +" Resolving tsSingleline and Multiline +syntax region tsValue keepend matchgroup=tsLineOperator start="\v\=" end="\v$" contained containedin=tsSingleline +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 tsDelimiter "\v\{\s*$" contained containedin=tsSingleline +syntax match tsLineOperator "\v\>\s*$" contained containedin=tsSingleline +syntax match tsIdentifier "\v\i+\s*$" contained containedin=tsSymlink + +" Sub level elements +syntax match tsDelimiter "\v[\[\]]" contained containedin=tsCondition +" This is one sign each hit, to give it a minimum priority. +syntax match tsValueString "\v\S" contained containedin=tsValue +syntax match tsValuePipe "\v\|" contained containedin=tsValue +" Detect numbers, but not those that are part of words. +syntax match tsNumber "\v(\a\d*)@]+\/?\>" contained containedin=tsValue +syntax region tsTag keepend matchgroup=tsDelimiter start="\v\<\/?" end="\v\/?\>" contained containedin=tsTagMatch +syntax match tsTagOperator "\v\=" contained containedin=tsTag +syntax region tsTagAttrValue matchgroup=tsDelimiter start="\v\"" end="\v\"" contained containedin=tsTag + +" Keywords +syntax case ignore | syntax keyword tsTodo contained containedin=tsComment todo xxx +syntax case match | syntax keyword tsObjectType PAGE CONTENT COA COA_INT HTML TEXT USER USER_INT LOAD_REGISTER RESTORE_REGISTER IMAGE CASE contained containedin=tsValue + +" Link groups +highlight link tsComment Comment +highlight link tsCondition Conditional +highlight link tsDelimiter Delimiter +highlight link tsIdentifier Identifier +highlight link tsInclude Include +highlight link tsNumber NONE +highlight link tsLineOperator Operator +highlight link tsTodo Todo +highlight link tsValuePipe Delimiter +highlight link tsValueString String +highlight link tsTag Identifier +highlight link tsTagOperator Operator +highlight link tsTagAttrValue String +highlight link tsObjectType Type + +let b:current_syntax = "typoscript" +