diff options
Diffstat (limited to 'autoload/terraform.vim')
-rw-r--r-- | autoload/terraform.vim | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/autoload/terraform.vim b/autoload/terraform.vim index 210ee59f..db1e3934 100644 --- a/autoload/terraform.vim +++ b/autoload/terraform.vim @@ -23,3 +23,71 @@ function! terraform#fmt() 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) + 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 + +function! terraform#commands(A, L, P) + return [ + \ 'apply', + \ 'console', + \ 'destroy', + \ 'env', + \ 'fmt', + \ 'get', + \ 'graph', + \ 'import', + \ 'init', + \ 'output', + \ 'plan', + \ 'providers', + \ 'push', + \ 'refresh', + \ 'show', + \ 'taint', + \ 'untaint', + \ 'validate', + \ 'version', + \ 'workspace', + \ '0.12checklist', + \ 'debug', + \ 'force-unlock', + \ 'state' + \ ] +endfunction |