diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2021-07-08 11:54:15 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2021-07-08 11:54:15 +0200 |
commit | c794f186c0a618d2d4cdd5445d9ff20e6f640762 (patch) | |
tree | 11e6b01bac01b0ec694c8fa5c574870f5e268182 /autoload/hcl.vim | |
parent | 4f5388350be1052f610b830c8fce8fbc17370ec6 (diff) | |
download | vim-polyglot-c794f186c0a618d2d4cdd5445d9ff20e6f640762.tar.gz vim-polyglot-c794f186c0a618d2d4cdd5445d9ff20e6f640762.zip |
Update
Diffstat (limited to 'autoload/hcl.vim')
-rw-r--r-- | autoload/hcl.vim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/autoload/hcl.vim b/autoload/hcl.vim new file mode 100644 index 00000000..b76def6a --- /dev/null +++ b/autoload/hcl.vim @@ -0,0 +1,20 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'terraform', 'autoload/hcl.vim') + finish +endif + +let s:cpo_save = &cpoptions +set cpoptions&vim + +function! hcl#align() abort + let p = '^.*=[^>]*$' + if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) + let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g')) + let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*')) + Tabularize/=.*/l1 + normal! 0 + call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) + endif +endfunction + +let &cpoptions = s:cpo_save +unlet s:cpo_save |