diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2019-06-08 12:44:15 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2019-06-08 12:44:15 +0200 |
commit | 671078ef6c851b688b63165761cec82f9f6e03f7 (patch) | |
tree | efde30baaf2ca21a09a35e1ccf1d2ff744482d2b /indent/terraform.vim | |
parent | aebef2c2e76b88384b1121c237c965e8cf8b3bcb (diff) | |
download | vim-polyglot-671078ef6c851b688b63165761cec82f9f6e03f7.tar.gz vim-polyglot-671078ef6c851b688b63165761cec82f9f6e03f7.zip |
Update
Diffstat (limited to 'indent/terraform.vim')
-rw-r--r-- | indent/terraform.vim | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/indent/terraform.vim b/indent/terraform.vim index 888e5149..2a0e5799 100644 --- a/indent/terraform.vim +++ b/indent/terraform.vim @@ -3,20 +3,31 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'terraform') != - endif " Only load this file if no other indent file was loaded -if exists("b:did_indent") +if exists('b:did_indent') finish endif let b:did_indent = 1 +let s:cpo_save = &cpoptions +set cpoptions&vim + setlocal nolisp -setlocal autoindent sw=2 ts=2 +setlocal autoindent shiftwidth=2 tabstop=2 softtabstop=2 setlocal indentexpr=TerraformIndent(v:lnum) setlocal indentkeys+=<:>,0=},0=) +let b:undo_indent = 'setlocal lisp< autoindent< shiftwidth< tabstop< softtabstop<' + \ . ' indentexpr< indentkeys<' + +let &cpoptions = s:cpo_save +unlet s:cpo_save -if exists("*TerraformIndent") +if exists('*TerraformIndent') finish endif +let s:cpo_save = &cpoptions +set cpoptions&vim + function! TerraformIndent(lnum) " Beginning of the file should have no indent if a:lnum == 0 @@ -32,8 +43,8 @@ function! TerraformIndent(lnum) let thisindent = previndent " Config block starting with [ { ( should increase the indent level - if prevline =~ '[\[{\(]\s*$' - let thisindent += &sw + if prevline =~# '[\[{\(]\s*$' + let thisindent += &shiftwidth endif " Current line without comments should continue the indent level @@ -41,9 +52,12 @@ function! TerraformIndent(lnum) " Config block ending with ) } ] should get the indentation " level from the initial config block - if thisline =~ '^\s*[\)}\]]' - let thisindent -= &sw + if thisline =~# '^\s*[\)}\]]' + let thisindent -= &shiftwidth endif return thisindent endfunction + +let &cpoptions = s:cpo_save +unlet s:cpo_save |