From 2666d69e6d4bd6d45d905377f472ecd058e098bd Mon Sep 17 00:00:00 2001 From: Daniel Gorin Date: Mon, 18 Nov 2019 20:41:42 +0000 Subject: [PATCH 1/2] Add filetype for terraform files with syntax hl --- rc/filetype/terraform.kak | 120 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 rc/filetype/terraform.kak diff --git a/rc/filetype/terraform.kak b/rc/filetype/terraform.kak new file mode 100644 index 000000000..3ad975a7b --- /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 '"' '(? Date: Mon, 18 Nov 2019 20:48:03 +0000 Subject: [PATCH 2/2] Daniel Gorin Copyright Waiver I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.