summaryrefslogtreecommitdiffstats
path: root/after
diff options
context:
space:
mode:
Diffstat (limited to 'after')
-rw-r--r--after/ftplugin/terraform.vim33
-rw-r--r--after/syntax/yaml.vim4
2 files changed, 35 insertions, 2 deletions
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 <space> <C-O>za
+nnoremap <space> za
+onoremap <space> <C-C>za
+vnoremap <space> 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
diff --git a/after/syntax/yaml.vim b/after/syntax/yaml.vim
index 78983cc2..d429da68 100644
--- a/after/syntax/yaml.vim
+++ b/after/syntax/yaml.vim
@@ -38,8 +38,8 @@ syn keyword yamlConstant NULL Null null NONE None none NIL Nil nil
syn keyword yamlConstant TRUE True true YES Yes yes ON On on
syn keyword yamlConstant FALSE False false NO No no OFF Off off
-syn match yamlKey "^\s*\zs\S\+\ze\s*:"
-syn match yamlKey "^\s*-\s*\zs\S\+\ze\s*:"
+syn match yamlKey "^\s*\zs[^ \t\"]\+\ze\s*:"
+syn match yamlKey "^\s*-\s*\zs[^ \t\"]\+\ze\s*:"
syn match yamlAnchor "&\S\+"
syn match yamlAlias "*\S\+"