diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2021-07-08 11:54:15 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2021-07-08 11:54:15 +0200 |
commit | c794f186c0a618d2d4cdd5445d9ff20e6f640762 (patch) | |
tree | 11e6b01bac01b0ec694c8fa5c574870f5e268182 /ftplugin | |
parent | 4f5388350be1052f610b830c8fce8fbc17370ec6 (diff) | |
download | vim-polyglot-c794f186c0a618d2d4cdd5445d9ff20e6f640762.tar.gz vim-polyglot-c794f186c0a618d2d4cdd5445d9ff20e6f640762.zip |
Update
Diffstat (limited to 'ftplugin')
-rw-r--r-- | ftplugin/hcl.vim | 56 | ||||
-rw-r--r-- | ftplugin/terraform.vim | 47 |
2 files changed, 48 insertions, 55 deletions
diff --git a/ftplugin/hcl.vim b/ftplugin/hcl.vim index 58dc67e4..10102b08 100644 --- a/ftplugin/hcl.vim +++ b/ftplugin/hcl.vim @@ -1,41 +1,43 @@ -if polyglot#init#is_disabled(expand('<sfile>:p'), 'hcl', 'ftplugin/hcl.vim') +if polyglot#init#is_disabled(expand('<sfile>:p'), 'terraform', 'ftplugin/hcl.vim') finish endif -" File: ftplugin/hcl.vim -" Author: BABAROT <b4b4r07@gmail.com> -" Description: FileType Plugin for HCL -" Last Change: Nob 05, 2015 +" hcl.vim - basic vim/hcl integration +" Maintainer: HashiVim <https://github.com/hashivim> -if exists('b:did_ftplugin') - finish +if exists('b:did_ftplugin') || v:version < 700 || &compatible + finish endif let b:did_ftplugin = 1 -let s:save_cpo = &cpo -set cpo&vim +let s:cpo_save = &cpoptions +set cpoptions&vim -setlocal commentstring=#\ %s +" j is a relatively recent addition; silence warnings when setting it. +setlocal formatoptions-=t formatoptions+=croql +silent! setlocal formatoptions+=j +let b:undo_ftplugin = 'setlocal formatoptions<' -" Add NERDCommenter delimiters +if !has('patch-7.4.1142') + " Include hyphens as keyword characters so that a keyword appearing as + " part of a longer name doesn't get partially highlighted. + setlocal iskeyword+=- + let b:undo_ftplugin .= ' iskeyword<' +endif -let s:delims = { 'left': '#' } -if exists('g:NERDDelimiterMap') - if !has_key(g:NERDDelimiterMap, 'hcl') - let g:NERDDelimiterMap.hcl = s:delims - endif -elseif exists('g:NERDCustomDelimiters') - if !has_key(g:NERDCustomDelimiters, 'hcl') - let g:NERDCustomDelimiters.hcl = s:delims - endif -else - let g:NERDCustomDelimiters = { 'hcl': s:delims } +if get(g:, 'hcl_fold_sections', 0) + setlocal foldmethod=syntax + let b:undo_ftplugin .= ' foldmethod<' endif -unlet s:delims -let b:undo_ftplugin = "" +" Set the commentstring +setlocal commentstring=#%s +let b:undo_ftplugin .= ' commentstring<' -let &cpo = s:save_cpo -unlet s:save_cpo +if get(g:, 'hcl_align', 0) && exists(':Tabularize') + inoremap <buffer> <silent> = =<Esc>:call hcl#align()<CR>a + let b:undo_ftplugin .= '|iunmap <buffer> =' +endif -" vim: set et sw=4 ts=4: +let &cpoptions = s:cpo_save +unlet s:cpo_save diff --git a/ftplugin/terraform.vim b/ftplugin/terraform.vim index 36b42dbc..1f4ef2cc 100644 --- a/ftplugin/terraform.vim +++ b/ftplugin/terraform.vim @@ -8,39 +8,30 @@ endif if exists('b:did_ftplugin') || v:version < 700 || &compatible finish endif -let b:did_ftplugin = 1 - -let s:cpo_save = &cpoptions -set cpoptions&vim - -" j is a relatively recent addition; silence warnings when setting it. -setlocal formatoptions-=t formatoptions+=croql -silent! setlocal formatoptions+=j -let b:undo_ftplugin = 'setlocal formatoptions<' - -if !has('patch-7.4.1142') - " Include hyphens as keyword characters so that a keyword appearing as - " part of a longer name doesn't get partially highlighted. - setlocal iskeyword+=- - let b:undo_ftplugin .= ' iskeyword<' -endif +" Have only kept the terraform versions of these options for backwards +" compatibility. if get(g:, 'terraform_fold_sections', 0) - setlocal foldmethod=syntax - let b:undo_ftplugin .= ' foldmethod<' -endif + let s:hcl_fold_sections_save = get(g:, 'hcl_fold_sections', 0) + let g:hcl_fold_sections=1 +end -" Set the commentstring -setlocal commentstring=#%s -let b:undo_ftplugin .= ' commentstring<' +if get(g:, 'terraform_align', 0) + let s:hcl_align_save = get(g:, 'hcl_align', 0) + let g:hcl_align=1 +end -if get(g:, 'terraform_align', 0) && exists(':Tabularize') - inoremap <buffer> <silent> = =<Esc>:call terraform#align()<CR>a - let b:undo_ftplugin .= '|iunmap <buffer> =' -endif +runtime! ftplugin/hcl.vim -let &cpoptions = s:cpo_save -unlet s:cpo_save +if exists('s:hcl_align_save') + let g:hcl_align = s:hcl_align_save +end +if exists('s:hcl_fold_sections_save') + let g:hcl_fold_sections = s:hcl_fold_sections_save +end + +let s:cpo_save = &cpoptions +set cpoptions&vim if !exists('g:terraform_binary_path') let g:terraform_binary_path='terraform' |