From af870100716f20ee4daef9cc527a9ecf41b54114 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 17 May 2017 11:07:28 +0200 Subject: Update --- after/ftplugin/terraform.vim | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'after/ftplugin') diff --git a/after/ftplugin/terraform.vim b/after/ftplugin/terraform.vim index 17115b1b..add09445 100644 --- a/after/ftplugin/terraform.vim +++ b/after/ftplugin/terraform.vim @@ -18,6 +18,38 @@ if g:terraform_align && exists(':Tabularize') endfunction endif + +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" + 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() + +"inoremap za +nnoremap za +onoremap za +vnoremap zf + " Match the identation put in place by Hashicorp and :TerraformFmt, https://github.com/hashivim/vim-terraform/issues/21 if get(g:, "terraform_align", 1) setlocal tabstop=2 @@ -25,4 +57,5 @@ if get(g:, "terraform_align", 1) setlocal shiftwidth=2 endif + endif -- cgit v1.2.3