diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2019-09-04 15:44:43 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2019-09-04 15:44:43 +0200 |
commit | 664aa988f6d9cdb7b75218666fbe348c85ef8b29 (patch) | |
tree | 306173199576430e6133a1ed137bd80bbc2fb01b /autoload/terraform.vim | |
parent | 3ddca5da461ebfaa82104f82e3cbf19d1c326ade (diff) | |
download | vim-polyglot-664aa988f6d9cdb7b75218666fbe348c85ef8b29.tar.gz vim-polyglot-664aa988f6d9cdb7b75218666fbe348c85ef8b29.zip |
Update
Diffstat (limited to 'autoload/terraform.vim')
-rw-r--r-- | autoload/terraform.vim | 53 |
1 files changed, 10 insertions, 43 deletions
diff --git a/autoload/terraform.vim b/autoload/terraform.vim index db1e3934..8554022e 100644 --- a/autoload/terraform.vim +++ b/autoload/terraform.vim @@ -2,56 +2,23 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'terraform') != - finish endif -" Adapted from vim-hclfmt: -" https://github.com/fatih/vim-hclfmt/blob/master/autoload/fmt.vim function! terraform#fmt() if !filereadable(expand('%:p')) return endif let l:curw = winsaveview() - let l:tmpfile = tempname() . '.tf' - call writefile(getline(1, '$'), l:tmpfile) - let output = system('terraform fmt -write ' . l:tmpfile) - if v:shell_error == 0 - try | silent undojoin | catch | endtry - call rename(l:tmpfile, resolve(expand('%'))) - silent edit! - let &syntax = &syntax - else - echo output - call delete(l:tmpfile) + " Make a fake change so that the undo point is right. + normal! ix + normal! "_x + silent execute '%!terraform fmt -no-color -' + if v:shell_error != 0 + let output = getline(1, '$') + silent undo + echo join(output, "\n") endif call winrestview(l:curw) endfunction -function! terraform#folds() - let thisline = getline(v:lnum) - if match(thisline, '^resource') >= 0 - return '>1' - elseif match(thisline, '^provider') >= 0 - return '>1' - elseif match(thisline, '^module') >= 0 - return '>1' - elseif match(thisline, '^variable') >= 0 - return '>1' - elseif match(thisline, '^output') >= 0 - return '>1' - elseif match(thisline, '^data') >= 0 - return '>1' - elseif match(thisline, '^terraform') >= 0 - return '>1' - elseif match(thisline, '^locals') >= 0 - return '>1' - else - return '=' - endif -endfunction - -function! terraform#foldText() - let foldsize = (v:foldend-v:foldstart) - return getline(v:foldstart).' ('.foldsize.' lines)' -endfunction - function! terraform#align() let p = '^.*=[^>]*$' if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) @@ -77,7 +44,6 @@ function! terraform#commands(A, L, P) \ 'output', \ 'plan', \ 'providers', - \ 'push', \ 'refresh', \ 'show', \ 'taint', @@ -85,9 +51,10 @@ function! terraform#commands(A, L, P) \ 'validate', \ 'version', \ 'workspace', - \ '0.12checklist', + \ '0.12upgrade', \ 'debug', \ 'force-unlock', + \ 'push', \ 'state' \ ] endfunction |