diff options
Diffstat (limited to '')
| -rw-r--r-- | after/ftplugin/terraform.vim | 68 | ||||
| -rw-r--r-- | after/syntax/yaml.vim | 2 | 
2 files changed, 37 insertions, 33 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 diff --git a/after/syntax/yaml.vim b/after/syntax/yaml.vim index 89914cbe..b68c4b80 100644 --- a/after/syntax/yaml.vim +++ b/after/syntax/yaml.vim @@ -26,7 +26,7 @@ syn match yamlBlock "[\[\]\{\}\|\>]"  syn region yamlComment	start="\#" end="$"  syn match yamlIndicator	"#YAML:\S\+" -syn region yamlString	start="'" end="'" skip="\\'" +syn region yamlString	start="\%(^\| \)\zs'" end="'\ze\%( \|$\)" skip="\\'"  syn region yamlString	start='"' end='"' skip='\\"' contains=yamlEscape  syn match  yamlEscape	+\\[abfnrtv'"\\]+ contained  syn match  yamlEscape	"\\\o\o\=\o\=" contained | 
