From 09e431130891e5b5415389fe8da11b02d3f20252 Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Fri, 12 Jul 2024 17:23:54 +0200 Subject: add ftl syntax --- ftdetect/ftl.vim | 1 + syntax/ftl.vim | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 ftdetect/ftl.vim create mode 100644 syntax/ftl.vim diff --git a/ftdetect/ftl.vim b/ftdetect/ftl.vim new file mode 100644 index 0000000..17fc41e --- /dev/null +++ b/ftdetect/ftl.vim @@ -0,0 +1 @@ +autocmd BufRead,BufNewFile *.ftl set filetype=ftl diff --git a/syntax/ftl.vim b/syntax/ftl.vim new file mode 100644 index 0000000..342886a --- /dev/null +++ b/syntax/ftl.vim @@ -0,0 +1,97 @@ +" Vim syntax file +" Language: FreeMarker Template Language (FTL) +" Maintainer: Stephan Müller +" Last Change: 2008 Oct 22 +" +" Changelog: +" 1.0 Stephan Müller: Original version +" 1.1 tyru: +" Added Feature: +" * Highlight html tags. +" * The user can disable the feature by adding its setting to .vimrc: +" let g:ftl_no_html = 1 +" The feature enabled by default. +" Fixed Issues: +" * Missing boilerplates of vim syntax plugin +" * b:current_syntax is not defined. vim syntax plugin must define it. +" * if b:current_syntax is defined, do not load syntax plugin +" 1.2 tyru: +" * Sorry, remove HTML highlight feature. +" because ":setfiletype html.ftl" is enough. +" +" Licensed under the MIT License (MIT): +" +" Copyright (c) 2008 Stephan Müller +" +" Permission is hereby granted, free of charge, to any person obtaining a copy +" of this software and associated documentation files (the "Software"), to deal +" in the Software without restriction, including without limitation the rights +" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +" copies of the Software, and to permit persons to whom the Software is +" furnished to do so, subject to the following conditions: +" +" The above copyright notice and this permission notice shall be included in +" all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +" SOFTWARE. + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists('b:current_syntax') + finish +endif + +syn case match + +" directives and interpolations +syn region ftlStartDirective start=+<#+ end=+>+ contains=ftlKeyword, ftlDirective, ftlString, ftlComment +syn region ftlEndDirective start=++ contains=ftlDirective +syn region ftlStartDirectiveAlt start=+\[#+ end=+\]+ contains=ftlKeyword, ftlDirective, ftlString, ftlComment +syn region ftlEndDirectiveAlt start=+\[/#+ end=+\]+ contains=ftlDirective +syn region ftlStartUserDirective start=+<@+ end=+>+ contains=ftlString, ftlComment +syn region ftlEndUserDirective start=++ +syn region ftlStartUserDirectiveAlt start=+\[@+ end=+\]+ contains=ftlString, ftlComment +syn region ftlEndUserDirectiveAlt start=+\[/@+ end=+\]+ +syn region ftlInterpolation start=+${+ end=+}+ +syn region ftlInterpolation2 start=+#{+ end=+}+ +syn region ftlString contained start=+"+ end=+"+ +syn region ftlComment start=+<#--+ end=+-->+ +syn region ftlCommentAlt start=+\[#--+ end=+--\]+ + +" keywords +syn keyword ftlDirective contained list if else macro import include switch case break +syn keyword ftlDirective contained assign local global nested recurse fallback visit +syn keyword ftlDirective contained function return t rt lt nt ftl +syn keyword ftlKeyword contained as in using + +" highlighting + +" don't use standard HiLink, it will not work with included syntax files +if version < 508 + command! -nargs=+ FtlHiLink hi link +else + command! -nargs=+ FtlHiLink hi def link +endif + +FtlHiLink ftlKeyword Statement +FtlHiLink ftlDirective Statement +FtlHiLink ftlStartDirective Function +FtlHiLink ftlEndDirective Function +FtlHiLink ftlStartUserDirective Function +FtlHiLink ftlEndUserDirective Function +FtlHiLink ftlInterpolation Constant +FtlHiLink ftlInterpolation2 Constant +FtlHiLink ftlString Constant +FtlHiLink ftlComment Comment + +delcommand FtlHiLink + +let b:current_syntax = "ftl" -- cgit v1.2.3