-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for syntax based folding #7
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ syn match hclNumber /\<0[xX]\x\+\>/ | |
|
||
syn keyword hclConstant true false null | ||
|
||
syn region hclInterpolation start=/\${/ end=/}/ contained contains=hclInterpolation | ||
syn region hclInterpolation start=/\${/ end=/}/ contained contains=hclString,hclInterpolation,hclAttribute,hclAttributeName | ||
|
||
syn region hclComment start=/\/\// end=/$/ contains=hclTodo | ||
syn region hclComment start=/\#/ end=/$/ contains=hclTodo | ||
|
@@ -41,11 +41,13 @@ syn region hclComment start=/\/\*/ end=/\*\// contains=hclTodo | |
syn match hclAttributeName /\w\+/ contained | ||
syn match hclAttribute /^.*=/ contains=hclAttributeName,hclComment,hclString | ||
|
||
syn match hclBlockName /\w\+/ contained | ||
syn match hclBlock /^[^=]\+{/ contains=hclBlockName,hclString | ||
syn match hclBlockName /\<[A-Za-z0-9_.\[\]*]\+\>/ nextgroup=hclString,hclBlock | ||
syn region hclBlock start="{" end="}" fold transparent contains=hclBlock,hclVariable,hclString,hclInterpolation,hclComment | ||
syn region hclBlock start="\[" end="\]" fold transparent contains=hclBlock,hclVariable,hclString,hclInterpolation,hclComment | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the change in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this change also breaks the highlighting of |
||
|
||
syn keyword hclTodo TODO FIXME XXX DEBUG NOTE contained | ||
|
||
hi def link hclBlockName Statement | ||
hi def link hclVariable PreProc | ||
hi def link hclFunction Function | ||
hi def link hclKeyword Keyword | ||
|
@@ -57,4 +59,11 @@ hi def link hclInterpolation PreProc | |
hi def link hclComment Comment | ||
hi def link hclTodo Todo | ||
|
||
syn sync fromstart | ||
|
||
let b:current_syntax = 'hcl' | ||
set tabstop=2 | ||
set softtabstop=2 | ||
set shiftwidth=2 | ||
set expandtab | ||
set smarttab | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't these more of a personal preference than part of Vim runtime files for a language? 🤔 One could argue that HCL has a canonical form at least in Terraform with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an example that has a string inside an interpolation? I admit I work almost exclusively with Terraform, but I have never seen such a construct in the wild. 🙂
In similar vein, is there a use case, which utilizes an
hclAttribute
(/^.*=/
) inside an interpolation? 🤔Finally, I think possibly the addition of
hclAttributeName
here breaks highlighting of variables (i.e. identifiers) inside interpolations, as they now become unadorned (i.e. light gray) instead of being highlighted the same wayhclVariable
(i.e. yellow). I think this is confusing, because it changes how variables are highlighted inside and outside interpolations.