diff --git a/rc/filetype/terraform.kak b/rc/filetype/terraform.kak new file mode 100644 index 00000000..3ad975a7 --- /dev/null +++ b/rc/filetype/terraform.kak @@ -0,0 +1,120 @@ +# Terraform configuration language +# https://www.terraform.io/docs/configuration/ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*[.](tf|tfvars) %{ + set-option buffer filetype terraform +} + + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=terraform %{ + require-module terraform + + set-option window static_words %opt{terraform_static_words} + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window terraform-.+ } +} + + +hook -group terraform-highlight global WinSetOption filetype=terraform %{ + add-highlighter window/terraform ref terraform + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/terraform } +} + + +provide-module terraform %§ + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +add-highlighter shared/terraform regions +add-highlighter shared/terraform/code default-region group + +add-highlighter shared/terraform/comment1 region '#' '$' fill comment +add-highlighter shared/terraform/comment2 region '\\' '$' fill comment +add-highlighter shared/terraform/comment3 region /\* \*/ fill comment + +# Strings can contain interpolated terraform expressions, which can contain +# strings. Currently, we cannot support nesting of the same type of delimiter, +# so instead we render the full interpolation as a value (otherwise, it +# looks bad). +# See https://github.com/mawww/kakoune/issues/1670 +add-highlighter shared/terraform/string region '"' '(?