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/autoload | |
| 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/autoload')
| -rw-r--r-- | runtime/autoload/hcl.vim | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/runtime/autoload/hcl.vim b/runtime/autoload/hcl.vim new file mode 100644 index 0000000000..2215fc8f27 --- /dev/null +++ b/runtime/autoload/hcl.vim @@ -0,0 +1,40 @@ +" Language: HCL +" Maintainer: Gregory Anders +" Last Change: 2024-09-03 +" Based on: https://github.com/hashivim/vim-terraform + +function! hcl#indentexpr(lnum) + " Beginning of the file should have no indent + if a:lnum == 0 + return 0 + endif + + " Usual case is to continue at the same indent as the previous non-blank line. + let prevlnum = prevnonblank(a:lnum-1) + let thisindent = indent(prevlnum) + + " If that previous line is a non-comment ending in [ { (, increase the + " indent level. + let prevline = getline(prevlnum) + if prevline !~# '^\s*\(#\|//\)' && prevline =~# '[\[{\(]\s*$' + let thisindent += &shiftwidth + endif + + " If the current line ends a block, decrease the indent level. + let thisline = getline(a:lnum) + if thisline =~# '^\s*[\)}\]]' + let thisindent -= &shiftwidth + endif + + " If the previous line starts a block comment /*, increase by one + if prevline =~# '/\*' + let thisindent += 1 + endif + + " If the previous line ends a block comment */, decrease by one + if prevline =~# '\*/' + let thisindent -= 1 + endif + + return thisindent +endfunction |