diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2017-12-06 12:56:27 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2017-12-06 12:56:27 +0100 |
commit | dce9e8dec5ef51730291c7bbff3e3997433eabbd (patch) | |
tree | 1ca7140cd4244dfdff3d8d58f936d9dc159c9d4e /after/ftplugin | |
parent | 30c87b73deff05c7dd9590228c0615a3299f39ff (diff) | |
download | vim-polyglot-dce9e8dec5ef51730291c7bbff3e3997433eabbd.tar.gz vim-polyglot-dce9e8dec5ef51730291c7bbff3e3997433eabbd.zip |
Update
Diffstat (limited to 'after/ftplugin')
-rw-r--r-- | after/ftplugin/terraform.vim | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/after/ftplugin/terraform.vim b/after/ftplugin/terraform.vim index a1750984..1328931a 100644 --- a/after/ftplugin/terraform.vim +++ b/after/ftplugin/terraform.vim @@ -8,6 +8,10 @@ if !exists('g:terraform_remap_spacebar') let g:terraform_remap_spacebar = 0 endif +if !exists('g:terraform_fold_sections') + let g:terraform_fold_sections = 0 +endif + if g:terraform_align && exists(':Tabularize') inoremap <buffer> <silent> = =<Esc>:call <SID>terraformalign()<CR>a function! s:terraformalign() @@ -22,38 +26,39 @@ if g:terraform_align && exists(':Tabularize') endfunction endif +if g:terraform_fold_sections + function! TerraformFolds() + 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 + setlocal foldmethod=expr + setlocal foldexpr=TerraformFolds() + setlocal foldlevel=1 -function! TerraformFolds() - 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 -setlocal foldmethod=expr -setlocal foldexpr=TerraformFolds() -setlocal foldlevel=1 - -function! TerraformFoldText() - let foldsize = (v:foldend-v:foldstart) - return getline(v:foldstart).' ('.foldsize.' lines)' -endfunction -setlocal foldtext=TerraformFoldText() + function! TerraformFoldText() + let foldsize = (v:foldend-v:foldstart) + return getline(v:foldstart).' ('.foldsize.' lines)' + endfunction + setlocal foldtext=TerraformFoldText() +endif " Re-map the space bar to fold and unfold if get(g:, "terraform_remap_spacebar", 1) @@ -70,5 +75,4 @@ if get(g:, "terraform_align", 1) setlocal shiftwidth=2 endif - endif |