diff options
| author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2024-09-04 19:32:52 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-04 19:32:52 -0500 |
| commit | 51088b67cb1e9363df98cfc8f3bbd6caad03cc5d (patch) | |
| tree | 46394c74748579260f7f0778ea4dd604f32ccc02 /runtime/syntax | |
| parent | b6e350a6b4df40fcc99931c460668c36fadc9989 (diff) | |
| download | rneovim-51088b67cb1e9363df98cfc8f3bbd6caad03cc5d.tar.gz rneovim-51088b67cb1e9363df98cfc8f3bbd6caad03cc5d.tar.bz2 rneovim-51088b67cb1e9363df98cfc8f3bbd6caad03cc5d.zip | |
vim-patch:150b507: runtime(hcl,terraform): Add runtime files for HCL and Terraform (#30266)
closes: vim/vim#15618
https://github.com/vim/vim/commit/150b5078ac886519083576124090489c3a21bd3b
Diffstat (limited to 'runtime/syntax')
| -rw-r--r-- | runtime/syntax/hcl.vim | 66 | ||||
| -rw-r--r-- | runtime/syntax/terraform.vim | 17 |
2 files changed, 83 insertions, 0 deletions
diff --git a/runtime/syntax/hcl.vim b/runtime/syntax/hcl.vim new file mode 100644 index 0000000000..5e9349ab38 --- /dev/null +++ b/runtime/syntax/hcl.vim @@ -0,0 +1,66 @@ +" Vim syntax file +" Language: HCL +" Maintainer: Gregory Anders +" Upstream: https://github.com/hashivim/vim-terraform +" Last Change: 2024-09-03 + +if exists('b:current_syntax') + finish +endif + +syn iskeyword a-z,A-Z,48-57,_,- + +syn case match + +" A block is introduced by a type, some number of labels - which are either +" strings or identifiers - and an opening curly brace. Match the type. +syn match hclBlockType /^\s*\zs\K\k*\ze\s\+\(\("\K\k*"\|\K\k*\)\s\+\)*{/ + +" An attribute name is an identifier followed by an equals sign. +syn match hclAttributeAssignment /\(\K\k*\.\)*\K\k*\s\+=\s/ contains=hclAttributeName +syn match hclAttributeName /\<\K\k*\>/ contained + +syn keyword hclValueBool true false + +syn keyword hclTodo contained TODO FIXME XXX BUG +syn region hclComment start="/\*" end="\*/" contains=hclTodo,@Spell +syn region hclComment start="#" end="$" contains=hclTodo,@Spell +syn region hclComment start="//" end="$" contains=hclTodo,@Spell + +""" misc. +syn match hclValueDec "\<[0-9]\+\([kKmMgG]b\?\)\?\>" +syn match hclValueHexaDec "\<0x[0-9a-f]\+\([kKmMgG]b\?\)\?\>" +syn match hclBraces "[\[\]]" + +""" skip \" and \\ in strings. +syn region hclValueString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=hclStringInterp +syn region hclStringInterp matchgroup=hclBraces start=/\(^\|[^$]\)\$\zs{/ end=/}/ contained contains=ALLBUT,hclAttributeName +syn region hclHereDocText start=/<<-\?\z([a-z0-9A-Z]\+\)/ end=/^\s*\z1/ contains=hclStringInterp + +"" Functions. +syn match hclFunction "[a-z0-9]\+(\@=" + +""" HCL2 +syn keyword hclRepeat for in +syn keyword hclConditional if +syn keyword hclValueNull null + +" enable block folding +syn region hclBlockBody matchgroup=hclBraces start="{" end="}" fold transparent + +hi def link hclComment Comment +hi def link hclTodo Todo +hi def link hclBraces Delimiter +hi def link hclAttributeName Identifier +hi def link hclBlockType Type +hi def link hclValueBool Boolean +hi def link hclValueDec Number +hi def link hclValueHexaDec Number +hi def link hclValueString String +hi def link hclHereDocText String +hi def link hclFunction Function +hi def link hclRepeat Repeat +hi def link hclConditional Conditional +hi def link hclValueNull Constant + +let b:current_syntax = 'hcl' diff --git a/runtime/syntax/terraform.vim b/runtime/syntax/terraform.vim new file mode 100644 index 0000000000..559dc79568 --- /dev/null +++ b/runtime/syntax/terraform.vim @@ -0,0 +1,17 @@ +" Vim syntax file +" Language: Terraform +" Maintainer: Gregory Anders +" Upstream: https://github.com/hashivim/vim-terraform +" Last Change: 2024-09-03 + +if exists('b:current_syntax') + finish +endif + +runtime! syntax/hcl.vim + +syn keyword terraType string bool number object tuple list map set any + +hi def link terraType Type + +let b:current_syntax = 'terraform' |