-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: QOL and ft snippets and manage freemarkers
- Loading branch information
Kevin Manca
authored and
Kevin Manca
committed
Jan 3, 2025
1 parent
36de0d0
commit de423c0
Showing
13 changed files
with
518 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
" Only load this indent file when no other was loaded. | ||
if exists("b:did_indent") | ||
finish | ||
endif | ||
runtime! indent/html.vim | ||
let s:htmlindent = &indentexpr | ||
setlocal indentexpr=FreemarkerIndent() | ||
|
||
let s:tags = [] | ||
let s:closetags = [] | ||
let s:special= [] | ||
|
||
" Conditional and block tags. | ||
call add(s:tags, 'if') | ||
call add(s:tags, 'elseif') | ||
call add(s:tags, 'else') | ||
call add(s:tags, 'attempt') | ||
call add(s:tags, 'recover') | ||
call add(s:tags, 'list') | ||
call add(s:tags, 'break') | ||
call add(s:tags, 'macro') | ||
call add(s:tags, 'nested') | ||
call add(s:tags, 'switch') | ||
call add(s:tags, 'case') | ||
call add(s:tags, 'default') | ||
call add(s:tags, 'items') | ||
|
||
" Conditional and block ending tags. | ||
call add(s:closetags, 'if') | ||
call add(s:closetags, 'attempt') | ||
call add(s:closetags, 'list') | ||
call add(s:closetags, 'macro') | ||
call add(s:closetags, 'switch') | ||
call add(s:closetags, 'items') | ||
|
||
" Special tags that indent back. | ||
call add(s:special, 'elseif') | ||
call add(s:special, 'else') | ||
call add(s:special, 'recover') | ||
|
||
let s:tag_expr = join(s:tags, '\|') | ||
let s:tag_close_expr = join(s:closetags, '\|') | ||
let s:special_expr = join(s:special, '\|') | ||
|
||
function! FreemarkerIndent() | ||
let line = getline(v:lnum) | ||
let previousNum = prevnonblank(v:lnum - 1) | ||
|
||
" Hit the start of the file, use zero indent. | ||
if previousNum == 0 | ||
return 0 | ||
endif | ||
|
||
let previous = getline(previousNum) | ||
|
||
if previous =~'<#\('.s:tag_expr.'\)' | ||
return indent(previousNum) + &tabstop | ||
endif | ||
|
||
if line =~'</#\('.s:tag_close_expr.'\)' || line =~'<#\('.s:special_expr.'\)' | ||
return indent(previousNum) - &tabstop | ||
endif | ||
|
||
" Special handling for html | ||
if s:htmlindent == '' | ||
return cindent(previousNum) | ||
else | ||
execute 'let ind = ' . s:htmlindent | ||
return ind | ||
endif | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
if exists("b:current_syntax") | ||
finish | ||
endif | ||
|
||
"Basic html syntax{{{ | ||
syntax keyword freemarkerKeyword div p html body head title a href br b i form | ||
syntax keyword freemarkerKeyword pre hr h1 h2 h3 tr td table thead th tbody type | ||
syntax keyword freemarkerKeyword class caption style button input label script | ||
syntax keyword freemarkerBoolean true false | ||
"}}} | ||
|
||
"Functions, assignments{{{ | ||
syntax match freemarkerFunction "\v\#function|\#return" | ||
syntax match freemarkerFunction "\v\#return" | ||
syntax match freemarkerFunction "\v\#assign" | ||
syntax match freemarkerFunction "\v\#include" | ||
syntax match freemarkerFunction "\v\#local" | ||
"}}} | ||
|
||
"open and close tags {{{ | ||
syntax match freemarkerFunction "<" | ||
syntax match freemarkerFunction ">" | ||
syntax match freemarkerFunction "(" | ||
syntax match freemarkerFunction ")" | ||
syntax match freemarkerFunction "\[" | ||
syntax match freemarkerFunction "\]" | ||
syntax match freemarkerFunction "\v/" | ||
"}}} | ||
|
||
"variables {{{ | ||
"variable type @s.example | ||
syntax match freemarkerFunction "\v\@\S*" | ||
|
||
"External variables ${example.test} | ||
syntax region freemarkerSpecialChar start=+${+ end=+}+ | ||
"}}} | ||
|
||
"Conditionals and blocs {{{ | ||
syntax match freemarkerConditional "\v\v\#if|\#else" | ||
syntax match freemarkerConditional "\v\#elseif" | ||
syntax match freemarkerConditional "\v\#attemp" | ||
syntax match freemarkerConditional "\v\#recover" | ||
syntax match freemarkerConditional "\v\#list" | ||
syntax match freemarkerConditional "\v\#break" | ||
syntax match freemarkerConditional "\v\#macro" | ||
syntax match freemarkerConditional "\v\#nested" | ||
syntax match freemarkerConditional "\v\#switch" | ||
syntax match freemarkerConditional "\v\#case" | ||
syntax match freemarkerConditional "\v\#default" | ||
syntax match freemarkerConditional "\v\#items" | ||
"}}} | ||
|
||
"Basic operators {{{ | ||
syntax match freemarkerOperator "\v\*" | ||
syntax match freemarkerOperator "\v/" | ||
syntax match freemarkerOperator "\v\+" | ||
syntax match freemarkerOperator "\v-" | ||
syntax match freemarkerOperator "\v\?" | ||
syntax match freemarkerOperator "\v\*\=" | ||
syntax match freemarkerOperator "\v/\=" | ||
syntax match freemarkerOperator "\v\+\=" | ||
syntax match freemarkerOperator "\v-\=" | ||
syntax match freemarkerOperator "\v\=" | ||
"}}} | ||
|
||
"Strings and comments {{{ | ||
syntax match freemarkerString '\v".*"' | ||
syntax match freemarkerComment "\v\<#--.*--\>" | ||
"}}} | ||
|
||
"highlighting groups {{{ | ||
highlight link freemarkerConditional Conditional | ||
highlight link freemarkerOperator Operator | ||
highlight link freemarkerFunction Function | ||
highlight link freemarkerSpecialChar SpecialChar | ||
highlight link freemarkerString String | ||
highlight link freemarkerComment Comment | ||
highlight link freemarkerKeyword Keyword | ||
highlight link freemarkerBoolean Boolean | ||
"}}} | ||
|
||
let b:current_syntax = "freemarker" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.