summaryrefslogtreecommitdiffstats
path: root/after
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2017-02-02 21:44:42 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2017-02-02 21:44:42 +0100
commit39036a553f353ffb70ec4ad25c0789567fb3518d (patch)
tree9993c4d2ce0fddc3b014e39f18014d6af54a93bb /after
parente685e4b431ab017d1aec9f9668fbeeeb6e7113e6 (diff)
downloadvim-polyglot-39036a553f353ffb70ec4ad25c0789567fb3518d.tar.gz
vim-polyglot-39036a553f353ffb70ec4ad25c0789567fb3518d.zip
Add terraform, closes #163
Diffstat (limited to 'after')
-rw-r--r--after/ftplugin/terraform.vim21
1 files changed, 21 insertions, 0 deletions
diff --git a/after/ftplugin/terraform.vim b/after/ftplugin/terraform.vim
new file mode 100644
index 00000000..f495e583
--- /dev/null
+++ b/after/ftplugin/terraform.vim
@@ -0,0 +1,21 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1
+
+if !exists('g:terraform_align')
+ let g:terraform_align = 0
+endif
+
+if g:terraform_align && exists(':Tabularize')
+ inoremap <buffer> <silent> = =<Esc>:call <SID>terraformalign()<CR>a
+ function! s:terraformalign()
+ 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
+endif
+
+endif