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 | |
parent | 4f5388350be1052f610b830c8fce8fbc17370ec6 (diff) | |
download | vim-polyglot-c794f186c0a618d2d4cdd5445d9ff20e6f640762.tar.gz vim-polyglot-c794f186c0a618d2d4cdd5445d9ff20e6f640762.zip |
Update
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | autoload/csv.vim | 124 | ||||
-rw-r--r-- | autoload/fsharp.vim | 25 | ||||
-rw-r--r-- | autoload/hcl.vim | 20 | ||||
-rw-r--r-- | autoload/polyglot/init.vim | 5 | ||||
-rw-r--r-- | autoload/polyglot/sleuth.vim | 2 | ||||
-rw-r--r-- | autoload/terraform.vim | 11 | ||||
-rw-r--r-- | extras/filetype.vim | 8 | ||||
-rw-r--r-- | ftplugin/hcl.vim | 56 | ||||
-rw-r--r-- | ftplugin/terraform.vim | 47 | ||||
-rw-r--r-- | indent/hcl.vim | 65 | ||||
-rw-r--r-- | indent/pascal.vim | 4 | ||||
-rw-r--r-- | indent/terraform.vim | 61 | ||||
-rw-r--r-- | packages.yaml | 22 | ||||
-rw-r--r-- | syntax/8th.vim | 2 | ||||
-rw-r--r-- | syntax/csv.vim | 14 | ||||
-rw-r--r-- | syntax/git.vim | 2 | ||||
-rw-r--r-- | syntax/gitcommit.vim | 1 | ||||
-rw-r--r-- | syntax/go.vim | 2 | ||||
-rw-r--r-- | syntax/hcl.vim | 112 | ||||
-rw-r--r-- | syntax/julia.vim | 6 | ||||
-rw-r--r-- | syntax/kotlin.vim | 4 | ||||
-rw-r--r-- | syntax/ruby.vim | 8 | ||||
-rw-r--r-- | syntax/terraform.vim | 66 | ||||
-rw-r--r-- | tests/filetypes.vim | 2 |
25 files changed, 344 insertions, 330 deletions
@@ -7,7 +7,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the <!--Package Count-->607<!--/Package Count--> packages it consists of. +- It **installs and updates 120+ times faster** than the <!--Package Count-->606<!--/Package Count--> packages it consists of. - It is also more secure (scripts loaded for every filetype are generated by vim-polyglot) - Best syntax and indentation support (no other features). Hand-selected language packs. - Automatically detects indentation (includes performance-optimized version of [vim-sleuth](https://github.com/tpope/vim-sleuth), can be disabled) @@ -96,7 +96,6 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr - [haproxy](https://github.com/CH-DanReif/haproxy.vim) (HAProxy syntax highlighting) - [haskell](https://github.com/neovimhaskell/haskell-vim) (Haskell syntax highlighting for hs, hs-boot, hsc, bpk and hsig files) - [haxe](https://github.com/jdonaldson/vaxe) (Haxe and HXML syntax highlighting for hx, hxsl, hxml and hss files) -- [hcl](https://github.com/b4b4r07/vim-hcl) (HCL syntax highlighting for hcl, nomad and workflow files) - [helm](https://github.com/towolf/vim-helm) - [help](https://github.com/neovim/neovim/tree/master/runtime) - [hive](https://github.com/zebradil/hive.vim) (HiveQL syntax highlighting for q, hql and ql files) @@ -187,7 +186,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr - [swift](https://github.com/keith/swift.vim) (Swift syntax highlighting for swift files) - [sxhkd](https://github.com/baskerville/vim-sxhkdrc) (Syntax highlighting for sxhkdrc files) - [systemd](https://github.com/wgwoods/vim-systemd-syntax) (Syntax highlighting for automount, dnssd, link, mount, netdev and 9 more files) -- [terraform](https://github.com/hashivim/vim-terraform) (Syntax highlighting for tf and tfvars files) +- [terraform](https://github.com/hashivim/vim-terraform) (HCL syntax highlighting for tf, tfvars, hcl, nomad and workflow files) - [textile](https://github.com/timcharper/textile.vim) (Textile syntax highlighting for textile files) - [thrift](https://github.com/solarnz/thrift.vim) (Thrift syntax highlighting for thrift files) - [tmux](https://github.com/ericpruitt/tmux.vim/tree/master/vim) diff --git a/autoload/csv.vim b/autoload/csv.vim index 98feee75..36a65dd3 100644 --- a/autoload/csv.vim +++ b/autoload/csv.vim @@ -14,7 +14,7 @@ endif " Some ideas are taken from the wiki http://vim.wikia.com/wiki/VimTip667 " though, implementation differs. -let s:csv_numeric_sort = v:version > 704 || v:version == 704 && has("patch341") +let s:csv_numeric_sort = v:version > 704 || v:version == 704 && has("patch951") if !s:csv_numeric_sort "{{{2 fu! csv#CSVSortValues(i1, i2) "{{{3 return (a:i1+0) == (a:i2+0) ? 0 : (a:i1+0) > (a:i2+0) ? 1 : -1 @@ -222,6 +222,15 @@ fu! csv#LocalSettings(type) "{{{3 endif endfu +fu! csv#RemoveAutoHighlight() "{{{3 + exe "aug CSV_HI".bufnr('') + exe "au! CursorMoved <buffer=".bufnr('').">" + aug end + exe "aug! CSV_HI".bufnr('') + " Remove any existing highlighting + HiColumn! +endfu + fu! csv#DoAutoCommands() "{{{3 " Highlight column, on which the cursor is if exists("g:csv_highlight_column") && g:csv_highlight_column =~? 'y' @@ -233,12 +242,7 @@ fu! csv#DoAutoCommands() "{{{3 " Set highlighting for column, on which the cursor is currently HiColumn else - exe "aug CSV_HI".bufnr('') - exe "au! CursorMoved <buffer=".bufnr('').">" - aug end - exe "aug! CSV_HI".bufnr('') - " Remove any existing highlighting - HiColumn! + call csv#RemoveAutoHighlight() endif " undo autocommand: let b:undo_ftplugin .= '| exe "sil! au! CSV_HI'.bufnr('').' CursorMoved <buffer> "' @@ -539,7 +543,7 @@ fu! csv#WColumn(...) "{{{3 let temp=getpos('.')[2] let j=1 let ret = 1 - for i in sort(b:csv_fixed_width_cols, s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues') + for i in sort(b:csv_fixed_width_cols, s:csv_numeric_sort ? 'N' : 'csv#CSVSortValues') if temp >= i let ret = j endif @@ -549,6 +553,9 @@ fu! csv#WColumn(...) "{{{3 call setpos('.',_cur) return ret endfu +fu! csv#ValidComment() "{{{3 + return b:csv_cmt != ['', ''] && !empty(b:csv_cmt[0]) +endfu fu! csv#MaxColumns(...) "{{{3 let this_col = exists("a:1") "return maximum number of columns in first 10 lines @@ -561,8 +568,10 @@ fu! csv#MaxColumns(...) "{{{3 endif " Filter comments out - let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') - call filter(l, 'v:val !~ pat') + if csv#ValidComment() + let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') + call filter(l, 'v:val !~ pat') + endif if !empty(l) || this_col break else @@ -606,8 +615,10 @@ fu! csv#ColWidth(colnr, row, silent) "{{{3 endif endif let b:csv_list=getline(skipfirst+1,last) - let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') - call filter(b:csv_list, 'v:val !~ pat') + if csv#ValidComment() + let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') + call filter(b:csv_list, 'v:val !~ pat') + endif call filter(b:csv_list, '!empty(v:val)') call map(b:csv_list, 'split(v:val, b:col.''\zs'')') endif @@ -898,7 +909,7 @@ fu! csv#Columnize(field) "{{{3 return result else " right align - return printf("%*S", width+1 , a:field) + return printf("%*S", width , a:field) endif endfun fu! csv#GetColPat(colnr, zs_flag) "{{{3 @@ -912,15 +923,15 @@ fu! csv#GetColPat(colnr, zs_flag) "{{{3 let pat='\%' . b:csv_fixed_width_cols[-1] . 'v.*' else let pat='\%' . b:csv_fixed_width_cols[(a:colnr - 1)] . - \ 'c.\{-}\%' . b:csv_fixed_width_cols[a:colnr] . 'v' + \ 'c.*\%<' . (b:csv_fixed_width_cols[a:colnr] + 1) . 'v' endif endif elseif !exists("b:csv_fixed_width_cols") let pat=b:col else - let pat='\%' . b:csv_fixed_width_cols[0] . 'v.\{-}' . + let pat='\%' . b:csv_fixed_width_cols[0] . 'v.*' . \ (len(b:csv_fixed_width_cols) > 1 ? - \ '\%' . b:csv_fixed_width_cols[1] . 'v' : + \ '\%<' . (b:csv_fixed_width_cols[1] + 1) . 'v' : \ '') endif return pat . (a:zs_flag ? '\zs' : '') @@ -1115,7 +1126,12 @@ fu! csv#MoveCol(forward, line, ...) "{{{3 let pat=csv#GetColPat(1, 0) else " Move backwards - let pat=csv#GetColPat(maxcol, 0) + if cpos == 1 && (exists("a:1") && a:1) + " H move to previous line + let pat=csv#GetColPat(maxcol, 0) + else + let pat='\%1v' + endif endif endif else @@ -1149,9 +1165,13 @@ fu! csv#MoveCol(forward, line, ...) "{{{3 " of a field. let epos = getpos('.') if getline('.')[col('.')-1] == ' ' - call search('\S', 'W', line('.')) - if getpos('.')[2] > spos - call setpos('.', epos) + if !exists("b:csv_fixed_width_cols") + call search('\S', 'W', line('.')) + if getpos('.')[2] > spos + call setpos('.', epos) + endif + elseif cpos > b:csv_fixed_width_cols[colnr] + call search('\%'. b:csv_fixed_width_cols[colnr]. 'v', 'W', line('.')) endif endif endif @@ -1246,8 +1266,10 @@ fu! csv#CopyCol(reg, col, cnt) "{{{3 endfor endif " Filter comments out - let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') - call filter(a, 'v:val !~ pat') + if csv#ValidComment() + let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') + call filter(a, 'v:val !~ pat') + endif if !exists("b:csv_fixed_width_cols") call map(a, 'split(v:val, ''^'' . b:col . ''\zs'')[col-1:cnt_cols]') @@ -1288,10 +1310,9 @@ fu! csv#MoveColumn(start, stop, ...) range "{{{3 endif " Swap line by line, instead of reading the whole range into memory - for i in range(a:start, a:stop) let content = getline(i) - if content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') + if b:csv_cmt != ['',''] && content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') " skip comments continue endif @@ -1359,13 +1380,9 @@ fu! csv#DupColumn(start, stop, ...) range "{{{3 " skipping comment lines (we could do it with a single :s statement, " but that would fail for the first and last column. - let commentpat = '\%(\%>'.(a:start-1).'l\V'. - \ escape(b:csv_cmt[0], '\\').'\m\)'. '\&\%(\%<'. - \ (a:stop+1). 'l\V'. escape(b:csv_cmt[0], '\\'). '\m\)' - for i in range(a:start, a:stop) let content = getline(i) - if content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') + if csv#ValidComment() && content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') " skip comments continue endif @@ -1429,10 +1446,12 @@ fu! csv#AddColumn(start, stop, ...) range "{{{3 " skipping comment lines (we could do it with a single :s statement, " but that would fail for the first and last column. - let commentpat = '\%(\%>'.(a:start-1).'l\V'. - \ escape(b:csv_cmt[0], '\\').'\m\)'. '\&\%(\%<'. - \ (a:stop+1). 'l\V'. escape(b:csv_cmt[0], '\\'). '\m\)' - if search(commentpat) + if b:csv_cmt != ['',''] + let commentpat = '\%(\%>'.(a:start-1).'l\V'. + \ escape(b:csv_cmt[0], '\\').'\m\)'. '\&\%(\%<'. + \ (a:stop+1). 'l\V'. escape(b:csv_cmt[0], '\\'). '\m\)' + endif + if !empty(commentpat) && search(commentpat) for i in range(a:start, a:stop) let content = getline(i) if content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') @@ -1611,7 +1630,7 @@ fu! csv#MaxColumn(list) "{{{3 endtry call add(result, str2float(nr)) endfor - let result = sort(result, s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues') + let result = sort(result, s:csv_numeric_sort ? 'N' : 'csv#CSVSortValues') let ind = len(result) > 9 ? 9 : len(result) if has_key(get(s:, 'additional', {}), 'distinct') && s:additional['distinct'] if exists("*uniq") @@ -1672,7 +1691,7 @@ fu! csv#DoForEachColumn(start, stop, bang) range "{{{3 endif let t = g:csv_convert let line = getline(item) - if line =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') + if b:csv_cmt!=['',''] && line =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') " Filter comments out call add(result, line) continue @@ -1736,7 +1755,7 @@ fu! csv#FoldValue(lnum, filter) "{{{3 for item in values(a:filter) " always fold comments away let content = getline(a:lnum) - if content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') + if b:csv_cmt != ['',''] && content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') return 1 elseif eval('content' . (item.match ? '!~' : '=~') . 'item.pat') let result += 1 @@ -1898,7 +1917,7 @@ fu! csv#GetColumn(line, col, strip) "{{{3 " Return Column content at a:line, a:col let a=getline(a:line) " Filter comments out - if a =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') + if csv#ValidComment() && a =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') return '' endif @@ -1979,7 +1998,7 @@ fu! csv#AnalyzeColumn(...) "{{{3 let res[item]+=1 endfor - let max_items = reverse(sort(values(res), s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues')) + let max_items = reverse(sort(values(res), s:csv_numeric_sort ? 'N' : 'csv#CSVSortValues')) " What about the minimum 5 items? let count_items = keys(res) if len(max_items) > topn @@ -2057,6 +2076,7 @@ fu! csv#InitCSVFixedWidth() "{{{3 endif " Turn off syntax highlighting syn clear + call csv#RemoveAutoHighlight() let max_line = line('$') > 10 ? 10 : line('$') let t = getline(1, max_line) let max_len = max(map(t, 'len(split(v:val, ''\zs''))')) @@ -2118,8 +2138,8 @@ fu! csv#InitCSVFixedWidth() "{{{3 endw let b:csv_fixed_width_cols=[] let tcc=0 - let b:csv_fixed_width_cols = sort(keys(Dict), s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues') - let b:csv_fixed_width = join(sort(keys(Dict), s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues'), ',') + let b:csv_fixed_width_cols = sort(keys(Dict), s:csv_numeric_sort ? 'N' : 'csv#CSVSortValues') + let b:csv_fixed_width = join(sort(keys(Dict), s:csv_numeric_sort ? 'N' : 'csv#CSVSortValues'), ',') call csv#Init(1, line('$')) let &l:cc=_cc @@ -2200,7 +2220,7 @@ fu! csv#CSVMappings() "{{{3 call csv#Map('nnoremap', '<C-Right>', ':<C-U>call csv#MoveCol(1, line("."))<CR>') call csv#Map('nnoremap', 'L', ':<C-U>call csv#MoveCol(1, line("."))<CR>') try - if g:csv_bind_B == 1 + if get(g:, 'csv_bind_B', 0) == 1 call csv#Map('nnoremap', 'B', ':<C-U>call csv#MoveCol(-1, line("."))<CR>') else call csv#Map('nnoremap', 'E', ':<C-U>call csv#MoveCol(-1, line("."))<CR>') @@ -2431,7 +2451,7 @@ fu! csv#NewDelimiter(newdelimiter, firstl, lastl) "{{{3 let line=a:firstl while line <= a:lastl " Don't change delimiter for comments - if getline(line) =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') + if csv#ValidComment() && getline(line) =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') let line+=1 continue endif @@ -2476,7 +2496,7 @@ fu! csv#DuplicateRows(columnlist) "{{{3 let i = 1 let content = getline(line) " Skip comments - if content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') + if csv#ValidComment() && content =~ '^\s*\V'. escape(b:csv_cmt[0], '\\') continue endif let cols = split(content, b:col. '\zs') @@ -2532,7 +2552,11 @@ fu! csv#Transpose(line1, line2) "{{{3 let TrailingDelim = getline(1) =~ b:delimiter.'$' endif - let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') + if b:csv_cmt != ['',''] + let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') + else + let pat = '' + endif try let columns = csv#MaxColumns(a:line1) @@ -2544,7 +2568,7 @@ fu! csv#Transpose(line1, line2) "{{{3 let matrix = [] for line in range(a:line1, a:line2) " Filter comments out - if getline(line) =~ pat + if !empty(pat) && getline(line) =~ pat continue endif let r = [] @@ -3033,10 +3057,12 @@ fu! csv#SumCSVRow(line, nr) "{{{3 endif let line=getline(ln) " Filter comments out - let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') - if line =~ pat - call csv#Warn("Invalid count specified") - return + if csv#ValidComment() + let pat = '^\s*\V'. escape(b:csv_cmt[0], '\\') + if line =~ pat + call csv#Warn("Invalid count specified") + return + endif endif let func='csv#SumColumn' let cells=split(line, b:col.'\zs') diff --git a/autoload/fsharp.vim b/autoload/fsharp.vim index 89287042..67f56495 100644 --- a/autoload/fsharp.vim +++ b/autoload/fsharp.vim @@ -122,7 +122,7 @@ function! s:documentationSymbol(xmlSig, assembly, cont) endfunction " FSharpConfigDto from https://github.com/fsharp/FsAutoComplete/blob/master/src/FsAutoComplete/LspHelpers.fs -" +" " * The following options seems not working with workspace/didChangeConfiguration " since the initialization has already completed? " 'AutomaticWorkspaceInit', @@ -153,7 +153,7 @@ let s:config_keys_camel = \ {'key': 'EnableAnalyzers', 'default': 0}, \ {'key': 'AnalyzersPath'}, \ {'key': 'DisableInMemoryProjectReferences', 'default': 0}, - \ {'key': 'LineLens', 'default': {'enabled': 'replaceCodeLens', 'prefix': '//'}}, + \ {'key': 'LineLens', 'default': {'enabled': 'never', 'prefix': ''}}, \ {'key': 'UseSdkScripts', 'default': 1}, \ {'key': 'dotNetRoot'}, \ {'key': 'fsiExtraParameters', 'default': []}, @@ -182,7 +182,7 @@ endfunction function! g:fsharp#getServerConfig() let fsharp = {} - call s:buildConfigKeys() + call s:buildConfigKeys() for key in s:config_keys if exists('g:fsharp#' . key.snake) let fsharp[key.camel] = g:fsharp#{key.snake} @@ -323,11 +323,17 @@ endfunction let s:script_root_dir = expand('<sfile>:p:h') . "/../" let s:fsac = fnamemodify(s:script_root_dir . "fsac/fsautocomplete.dll", ":p") let g:fsharp#languageserver_command = - \ ['dotnet', s:fsac, + \ ['dotnet', s:fsac, \ '--background-service-enabled' \ ] -function! s:download(branch) +function! s:update_win() + echom "[FSAC] Downloading FSAC. This may take a while..." + let script = s:script_root_dir . "install.ps1" + call system('powershell -ExecutionPolicy Unrestricted ' . script . " update") +endfunction + +function! s:update_unix() echom "[FSAC] Downloading FSAC. This may take a while..." let zip = s:script_root_dir . "fsac.zip" call system( @@ -337,19 +343,18 @@ function! s:download(branch) if v:shell_error == 0 call system('unzip -o -d ' . s:script_root_dir . "/fsac " . zip) call system('find ' . s:script_root_dir . '/fsac' . ' -type f -exec chmod 777 \{\} \;') - echom "[FSAC] Updated FsAutoComplete to version " . a:branch . "" + echom "[FSAC] Updated FsAutoComplete" else echom "[FSAC] Failed to update FsAutoComplete" endif endfunction function! fsharp#updateFSAC(...) - if len(a:000) == 0 - let branch = "master" + if has('win32') && !has('win32unix') + call s:update_win() else - let branch = a:000[0] + call s:update_unix() endif - call s:download(branch) endfunction let s:fsi_buffer = -1 diff --git a/autoload/hcl.vim b/autoload/hcl.vim new file mode 100644 index 00000000..b76def6a --- /dev/null +++ b/autoload/hcl.vim @@ -0,0 +1,20 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'terraform', 'autoload/hcl.vim') + finish +endif + +let s:cpo_save = &cpoptions +set cpoptions&vim + +function! hcl#align() abort + let p = '^.*=[^>]*$' + if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) + let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g')) + let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*')) + Tabularize/=.*/l1 + normal! 0 + call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) + endif +endfunction + +let &cpoptions = s:cpo_save +unlet s:cpo_save diff --git a/autoload/polyglot/init.vim b/autoload/polyglot/init.vim index 7aa94939..04353964 100644 --- a/autoload/polyglot/init.vim +++ b/autoload/polyglot/init.vim @@ -1944,6 +1944,7 @@ endif if !has_key(g:polyglot_is_disabled, 'terraform') au BufNewFile,BufRead *.tf,*.tfvars setf terraform + au BufNewFile,BufRead *.hcl,*.nomad,*.workflow,{.,}terraformrc,Appfile,terraform.rc setf hcl endif if !has_key(g:polyglot_is_disabled, 'tf') @@ -2309,10 +2310,6 @@ if !has_key(g:polyglot_is_disabled, 'hive') au BufNewFile,BufRead *.hql,*.q,*.ql setf hive endif -if !has_key(g:polyglot_is_disabled, 'hcl') - au BufNewFile,BufRead *.hcl,*.nomad,*.workflow,Appfile setf hcl -endif - if !has_key(g:polyglot_is_disabled, 'haxe') au BufNewFile,BufRead *.hx,*.hxsl setf haxe au BufNewFile,BufRead *.hxml setf hxml diff --git a/autoload/polyglot/sleuth.vim b/autoload/polyglot/sleuth.vim index d308561c..bf3166a4 100644 --- a/autoload/polyglot/sleuth.vim +++ b/autoload/polyglot/sleuth.vim @@ -217,7 +217,7 @@ let s:globs = { \ 'hastepreproc': '*.htpp', \ 'haxe': '*.hx,*.hxsl', \ 'hb': '*.hb', - \ 'hcl': '*.hcl,*.nomad,*.workflow,Appfile', + \ 'hcl': '*.hcl,*.nomad,*.workflow,Appfile,.terraformrc,terraform.rc', \ 'helm': '', \ 'help': '', \ 'hercules': '*.vc,*.ev,*.sum,*.errsum', diff --git a/autoload/terraform.vim b/autoload/terraform.vim index 324b978d..852b261f 100644 --- a/autoload/terraform.vim +++ b/autoload/terraform.vim @@ -35,17 +35,6 @@ function! terraform#fmt() abort call winrestview(curw) endfunction -function! terraform#align() abort - let p = '^.*=[^>]*$' - if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) - let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g')) - let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*')) - Tabularize/=.*/l1 - normal! 0 - call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) - endif -endfunction - function! terraform#commands(ArgLead, CmdLine, CursorPos) abort let commands = [ \ 'init', diff --git a/extras/filetype.vim b/extras/filetype.vim index 4bee61e2..19f4a4ed 100644 --- a/extras/filetype.vim +++ b/extras/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Jun 13 +" Last Change: 2021 Jul 03 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -650,6 +650,9 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo " Gedcom au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom +" Gemtext +au BufNewFile,BufRead *.gmi,*.gemini setf gemtext + " Gift (Moodle) autocmd BufRead,BufNewFile *.gift setf gift @@ -868,6 +871,9 @@ au BufNewFile,BufRead *.json-patch setf json " Jupyter Notebook is also json au BufNewFile,BufRead *.ipynb setf json +" JSONC +au BufNewFile,BufRead *.jsonc setf jsonc + " Kixtart au BufNewFile,BufRead *.kix setf kix 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' diff --git a/indent/hcl.vim b/indent/hcl.vim index 346e8585..1338fec0 100644 --- a/indent/hcl.vim +++ b/indent/hcl.vim @@ -1,15 +1,68 @@ -if polyglot#init#is_disabled(expand('<sfile>:p'), 'hcl', 'indent/hcl.vim') +if polyglot#init#is_disabled(expand('<sfile>:p'), 'terraform', 'indent/hcl.vim') finish endif +" Only load this file if no other indent file was loaded if exists('b:did_indent') finish endif - let b:did_indent = 1 -" cindent seems to work adequately with HCL's brace-y syntax -setlocal cindent +let s:cpo_save = &cpoptions +set cpoptions&vim + +setlocal nolisp +setlocal autoindent shiftwidth=2 tabstop=2 softtabstop=2 expandtab +setlocal indentexpr=HclIndent(v:lnum) +setlocal indentkeys+=<:>,0=},0=) +let b:undo_indent = 'setlocal lisp< autoindent< shiftwidth< tabstop< softtabstop<' + \ . ' expandtab< indentexpr< indentkeys<' + +let &cpoptions = s:cpo_save +unlet s:cpo_save + +if exists('*HclIndent') + finish +endif + +let s:cpo_save = &cpoptions +set cpoptions&vim + +function! HclIndent(lnum) + " Beginning of the file should have no indent + if a:lnum == 0 + return 0 + endif + + " Usual case is to continue at the same indent as the previous non-blank line. + let prevlnum = prevnonblank(a:lnum-1) + let thisindent = indent(prevlnum) + + " If that previous line is a non-comment ending in [ { (, increase the + " indent level. + let prevline = getline(prevlnum) + if prevline !~# '^\s*\(#\|//\)' && prevline =~# '[\[{\(]\s*$' + let thisindent += &shiftwidth + endif + + " If the current line ends a block, decrease the indent level. + let thisline = getline(a:lnum) + if thisline =~# '^\s*[\)}\]]' + let thisindent -= &shiftwidth + endif + + " If the previous line starts a block comment /*, increase by one + if prevline =~# '/\*' + let thisindent += 1 + endif + + " If the previous line ends a block comment */, decrease by one + if prevline =~# '\*/' + let thisindent -= 1 + endif + + return thisindent +endfunction -" don't de-indent comments (cindent treats them like preprocessor directives) -setlocal cinkeys-=0# +let &cpoptions = s:cpo_save +unlet s:cpo_save diff --git a/indent/pascal.vim b/indent/pascal.vim index 9e1c3e96..d4a6a5a7 100644 --- a/indent/pascal.vim +++ b/indent/pascal.vim @@ -6,7 +6,7 @@ endif " Language: Pascal " Maintainer: Neil Carter <n.carter@swansea.ac.uk> " Created: 2004 Jul 13 -" Last Change: 2017 Jun 13 +" Last Change: 2021 Jul 01 " " This is version 2.0, a complete rewrite. " @@ -24,6 +24,8 @@ setlocal indentkeys+==end;,==const,==type,==var,==begin,==repeat,==until,==for setlocal indentkeys+==program,==function,==procedure,==object,==private setlocal indentkeys+==record,==if,==else,==case +let b:undo_indent = "setl indentkeys< indentexpr<" + if exists("*GetPascalIndent") finish endif diff --git a/indent/terraform.vim b/indent/terraform.vim index 32c194ef..3f7690f8 100644 --- a/indent/terraform.vim +++ b/indent/terraform.vim @@ -6,63 +6,4 @@ endif if exists('b:did_indent') finish endif -let b:did_indent = 1 - -let s:cpo_save = &cpoptions -set cpoptions&vim - -setlocal nolisp -setlocal autoindent shiftwidth=2 tabstop=2 softtabstop=2 expandtab -setlocal indentexpr=TerraformIndent(v:lnum) -setlocal indentkeys+=<:>,0=},0=) -let b:undo_indent = 'setlocal lisp< autoindent< shiftwidth< tabstop< softtabstop<' - \ . ' expandtab< indentexpr< indentkeys<' - -let &cpoptions = s:cpo_save -unlet s:cpo_save - -if exists('*TerraformIndent') - finish -endif - -let s:cpo_save = &cpoptions -set cpoptions&vim - -function! TerraformIndent(lnum) - " Beginning of the file should have no indent - if a:lnum == 0 - return 0 - endif - - " Usual case is to continue at the same indent as the previous non-blank line. - let prevlnum = prevnonblank(a:lnum-1) - let thisindent = indent(prevlnum) - - " If that previous line is a non-comment ending in [ { (, increase the - " indent level. - let prevline = getline(prevlnum) - if prevline !~# '^\s*\(#\|//\)' && prevline =~# '[\[{\(]\s*$' - let thisindent += &shiftwidth - endif - - " If the current line ends a block, decrease the indent level. - let thisline = getline(a:lnum) - if thisline =~# '^\s*[\)}\]]' - let thisindent -= &shiftwidth - endif - - " If the previous line starts a block comment /*, increase by one - if prevline =~# '/\*' - let thisindent += 1 - endif - - " If the previous line ends a block comment */, decrease by one - if prevline =~# '\*/' - let thisindent -= 1 - endif - - return thisindent -endfunction - -let &cpoptions = s:cpo_save -unlet s:cpo_save +runtime! indent/hcl.vim diff --git a/packages.yaml b/packages.yaml index f76f522c..e4295b07 100644 --- a/packages.yaml +++ b/packages.yaml @@ -787,18 +787,6 @@ ignored_dirs: - autoload - compiler --- -name: hcl -remote: b4b4r07/vim-hcl -filetypes: -- name: hcl - linguist: HCL - extra_filenames: - - Appfile - ignored_extensions: - # handled by vim-terraform - - tf - - tfvars ---- name: hive remote: zebradil/hive.vim filetypes: @@ -1632,6 +1620,16 @@ filetypes: extensions: - tf - tfvars +- name: hcl + linguist: HCL + extra_filenames: + - Appfile + - .terraformrc + - terraform.rc + ignored_extensions: + # handled by vim-terraform + - tf + - tfvars --- name: textile remote: timcharper/textile.vim diff --git a/syntax/8th.vim b/syntax/8th.vim index f297dc54..abad0092 100644 --- a/syntax/8th.vim +++ b/syntax/8th.vim @@ -297,7 +297,7 @@ syn region eighthComment start="\zs\\" end="$" contains=eighthTodo " Define the default highlighting. if !exists("did_eighth_syntax_inits") let did_eighth_syntax_inits=1 - " The default methods for highlighting. Can be overriden later. + " The default methods for highlighting. Can be overridden later. hi def link eighthTodo Todo hi def link eighthOperators Operator hi def link eighthMath Number diff --git a/syntax/csv.vim b/syntax/csv.vim index ed045c7f..0e1d3a02 100644 --- a/syntax/csv.vim +++ b/syntax/csv.vim @@ -55,6 +55,12 @@ fu! <sid>CheckSaneSearchPattern() "{{{3 let b:csv_cmt = [g:csv_comment] endif + " Make sure, b:csv_cmt always has 2 items + " can happen with e.g. :set cms="#%s + if b:csv_cmt == [] + let b:csv_cmt = ['', ''] + endif + " Second: Check for sane defaults for the column pattern " Not necessary to check for fixed width columns @@ -131,9 +137,11 @@ fu! <sid>DoHighlight() "{{{3 endfor endif " Comment regions - exe 'syn match CSVComment /'. s:cmts. '.*'. - \ (!empty(s:cmte) ? '\%('. s:cmte. '\)\?' - \: ''). '/' + if !empty(s:cmts) + exe 'syn match CSVComment /'. s:cmts. '.*'. + \ (!empty(s:cmte) ? '\%('. s:cmte. '\)\?' + \: ''). '/' + endif hi def link CSVComment Comment endfun diff --git a/syntax/git.vim b/syntax/git.vim index 5688874a..558d39b5 100644 --- a/syntax/git.vim +++ b/syntax/git.vim @@ -33,7 +33,7 @@ syn match gitDiffAdded "{+[^}]*+}" contained containedin=gitDiff syn match gitDiffRemoved "^ \+-.*" contained containedin=gitDiffMerge syn match gitDiffRemoved "\[-[^]]*-\]" contained containedin=gitDiff -syn match gitKeyword /^\%(object\|type\|tag\|commit\|tree\|parent\|encoding\|summary\|boundary\|filename\|previous\)\>/ contained containedin=gitHead nextgroup=gitHash,gitType skipwhite contains=@NoSpell +syn match gitKeyword /^\%(object\|type\|tag\|commit\|tree\|parent\|encoding\|gpgsig\|summary\|boundary\|filename\|previous\)\>/ contained containedin=gitHead nextgroup=gitHash,gitType skipwhite contains=@NoSpell syn match gitKeyword /^\%(tag\>\|ref:\)/ contained containedin=gitHead nextgroup=gitReference skipwhite contains=@NoSpell syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite contains=@NoSpell syn match gitMode /^\d\{6\}\>/ contained containedin=gitHead nextgroup=gitType,gitHash skipwhite diff --git a/syntax/gitcommit.vim b/syntax/gitcommit.vim index 8e847650..842c453d 100644 --- a/syntax/gitcommit.vim +++ b/syntax/gitcommit.vim @@ -14,6 +14,7 @@ endif syn case match syn sync minlines=50 +syn sync linebreaks=1 if has("spell") syn spell toplevel diff --git a/syntax/go.vim b/syntax/go.vim index ecb94127..1bca27c2 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -171,7 +171,7 @@ syn match goDecimalError "\<-\=\(_\(\d\+_*\)\+\|\([1-9]\d*_*\)\+__\(\ syn match goHexadecimalInt "\<-\=0[xX]_\?\(\x\+_\?\)\+\>" syn match goHexadecimalError "\<-\=0[xX]_\?\(\x\+_\?\)*\(\([^ \t0-9A-Fa-f_)]\|__\)\S*\|_\)\>" syn match goOctalInt "\<-\=0[oO]\?_\?\(\o\+_\?\)\+\>" -syn match goOctalError "\<-\=0[0-7oO_]*\(\([^ \t0-7oOxX_/)\]\}\:]\|[oO]\{2,\}\|__\)\S*\|_\|[oOxX]\)\>" +syn match goOctalError "\<-\=0[0-7oO_]*\(\([^ \t0-7oOxX_/)\]\}\:;]\|[oO]\{2,\}\|__\)\S*\|_\|[oOxX]\)\>" syn match goBinaryInt "\<-\=0[bB]_\?\([01]\+_\?\)\+\>" syn match goBinaryError "\<-\=0[bB]_\?[01_]*\([^ \t01_)]\S*\|__\S*\|_\)\>" diff --git a/syntax/hcl.vim b/syntax/hcl.vim index d11c031b..7b6ab441 100644 --- a/syntax/hcl.vim +++ b/syntax/hcl.vim @@ -1,48 +1,76 @@ -if polyglot#init#is_disabled(expand('<sfile>:p'), 'hcl', 'syntax/hcl.vim') +if polyglot#init#is_disabled(expand('<sfile>:p'), 'terraform', 'syntax/hcl.vim') finish endif - -if exists("b:current_syntax") +" Forked from Larry Gilbert's syntax file +" github.com/L2G/vim-syntax-terraform +if exists('b:current_syntax') finish endif -syn match hclEqual '=' -syn match hclSimpleString '"[^\"]*"' -syn region hclComment display oneline start='\%\(^\|\s\)#' end='$' -syn region hclComment display oneline start='\%\(^\|\s\)//' end='$' -syn region hclInterpolation display oneline start='(' end=')' contains=hclInterpolation,hclSimpleString -syn region hclSmartString display oneline start='"' end='"\s*$' contains=hclInterpolation - -syn keyword hclRootKeywords variable provider resource nextgroup=hclString,hclString skipwhite -syn keyword hclRootKeywords default nextgroup=hclEquals skipwhite - - -syn keyword hclAwsResourcesKeywords availability_zones desired_capacity force_delete health_check_grace_period health_check_type launch_configuration load_balancers max_size min_size name vpc_zone_identifier nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords allocated_storage availability_zone backup_retention_period backup_window db_subnet_group_name engine engine_version final_snapshot_identifier identifier instance_class iops maintenance_window multi_az name password port publicly_accessible security_group_names skip_final_snapshot username vpc_security_group_ids nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords cidr description ingress name security_group_id security_group_name security_group_owner_id source_security_group_id nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords description name subnet_ids nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords instance vpc nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords availability_zones health_check healthy_threshold instance_port instance_protocol instances internal interval lb_port lb_protocol listener name security_groups ssl_certificate_id subnets target timeout unhealthy_threshold nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords ami associate_public_ip_address availability_zone ebs_optimized iam_instance_profile instance_type key_name private_ip security_groups source_dest_check subnet_id tags user_data nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords vpc_id nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords iam_instance_profile image_id instance_type key_name name name_prefix security_groups user_data nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords name records ttl type zone_id nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords name nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords route_table_id subnet_id nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords cidr_block gateway_id instance_id route vpc_id nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords acl bucket nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords cidr_blocks description from_port ingress name owner_id protocol security_groups self tags to_port vpc_id nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords availability_zone- cidr_block map_public_ip_on_launch vpc_id nextgroup=hclEquals,hclString skipwhite -syn keyword hclAwsResourcesKeywords cidr_block enable_dns_hostnames enable_dns_support tags nextgroup=hclEquals,hclString skipwhite - - -hi def link hclComment Comment -hi def link hclEqual Operator -hi def link hclRootKeywords Statement -hi def link hclAwsResourcesKeywords Type -hi def link hclSmartString String -hi def link hclInterpolation String -hi def link hclSimpleString PreProc - -let b:current_syntax = "hcl" +let s:cpo_save = &cpoptions +set cpoptions&vim + +" Identifiers are made up of alphanumeric characters, underscores, and +" hyphens. +if has('patch-7.4.1142') + syn iskeyword a-z,A-Z,48-57,_,- +endif + +syn case match + +" A block is introduced by a type, some number of labels - which are either +" strings or identifiers - and an opening curly brace. Match the type. +syn match hclBlockType /^\s*\zs\K\k*\ze\s\+\(\("\K\k*"\|\K\k*\)\s\+\)*{/ + +" An attribute name is an identifier followed by an equals sign. +syn match hclAttributeAssignment /\(\K\k*\.\)*\K\k*\s\+=\s/ contains=hclAttributeName +syn match hclAttributeName /\<\K\k*\>/ contained + +syn keyword hclValueBool true false + +syn keyword hclTodo contained TODO FIXME XXX BUG +syn region hclComment start="/\*" end="\*/" contains=hclTodo,@Spell +syn region hclComment start="#" end="$" contains=hclTodo,@Spell +syn region hclComment start="//" end="$" contains=hclTodo,@Spell + +""" misc. +syn match hclValueDec "\<[0-9]\+\([kKmMgG]b\?\)\?\>" +syn match hclValueHexaDec "\<0x[0-9a-f]\+\([kKmMgG]b\?\)\?\>" +syn match hclBraces "[\[\]]" + +""" skip \" and \\ in strings. +syn region hclValueString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=hclStringInterp +syn region hclStringInterp matchgroup=hclBraces start=/\(^\|[^$]\)\$\zs{/ end=/}/ contained contains=ALLBUT,hclAttributeName +syn region hclHereDocText start=/<<-\?\z([a-z0-9A-Z]\+\)/ end=/^\s*\z1/ contains=hclStringInterp + +"" Functions. +syn match hclFunction "[a-z0-9]\+(\@=" + +""" HCL2 +syn keyword hclRepeat for in +syn keyword hclConditional if +syn keyword hclValueNull null + +" enable block folding +syn region hclBlockBody matchgroup=hclBraces start="{" end="}" fold transparent + +hi def link hclComment Comment +hi def link hclTodo Todo +hi def link hclBraces Delimiter +hi def link hclAttributeName Identifier +hi def link hclBlockType Type +hi def link hclValueBool Boolean +hi def link hclValueDec Number +hi def link hclValueHexaDec Number +hi def link hclValueString String +hi def link hclHereDocText String +hi def link hclFunction Function +hi def link hclRepeat Repeat +hi def link hclConditional Conditional +hi def link hclValueNull Constant + +let b:current_syntax = 'hcl' + +let &cpoptions = s:cpo_save +unlet s:cpo_save diff --git a/syntax/julia.vim b/syntax/julia.vim index 53dea077..88aa464e 100644 --- a/syntax/julia.vim +++ b/syntax/julia.vim @@ -327,15 +327,15 @@ exec 'syntax match juliaStringVarsPla contained "\$' . s:idregex . '"' " TODO improve RegEx syntax region juliaRegEx matchgroup=juliaStringDelim start=+\<r\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1[imsx]*+ -syntax cluster juliaSpecialChars contains=juliaSpecialChar,juliaOctalEscapeChar,juliaHexEscapeChar,juliaUniCharSmall,juliaUniCharLarge +syntax cluster juliaSpecialChars contains=juliaSpecialChar,juliaDoubleBackslash,juliaEscapedQuote,juliaOctalEscapeChar,juliaHexEscapeChar,juliaUniCharSmall,juliaUniCharLarge syntax match juliaSpecialChar display contained "\\." syntax match juliaOctalEscapeChar display contained "\\\o\{3\}" syntax match juliaHexEscapeChar display contained "\\x\x\{2\}" syntax match juliaUniCharSmall display contained "\\u\x\{1,4\}" syntax match juliaUniCharLarge display contained "\\U\x\{1,8\}" syntax cluster juliaSpecialCharsRaw contains=juliaDoubleBackslash,juliaEscapedQuote -syntax match juliaDoubleBackslash display contained "\\\\" -syntax match juliaEscapedQuote display contained "\\\"" +syntax match juliaDoubleBackslash contained "\\\\" +syntax match juliaEscapedQuote contained "\\\"" syntax cluster juliaPrintfChars contains=juliaErrorPrintfFmt,juliaPrintfFmt syntax match juliaErrorPrintfFmt display contained "\\\?%." diff --git a/syntax/kotlin.vim b/syntax/kotlin.vim index ca7fbef5..b5e75dba 100644 --- a/syntax/kotlin.vim +++ b/syntax/kotlin.vim @@ -5,7 +5,7 @@ endif " Vim syntax file " Language: Kotlin " Maintainer: Alexander Udalov -" Latest Revision: 20 April 2021 +" Latest Revision: 3 July 2021 if exists('b:current_syntax') finish @@ -101,6 +101,8 @@ syn match ktEscapedName "\v`.*`" syn match ktExclExcl "!!" syn match ktArrow "->" +exec "syntax sync ccomment ktComment minlines=10" + hi def link ktStatement Statement hi def link ktConditional Conditional hi def link ktRepeat Repeat diff --git a/syntax/ruby.vim b/syntax/ruby.vim index ce28d380..bbf86e8a 100644 --- a/syntax/ruby.vim +++ b/syntax/ruby.vim @@ -69,7 +69,7 @@ endfunction com! -nargs=* SynFold call s:run_syntax_fold(<q-args>) " Not-Top Cluster {{{1 -syn cluster rubyNotTop contains=@rubyCommentNotTop,@rubyStringNotTop,@rubyRegexpSpecial,@rubyDeclaration,@rubyExceptionHandler,@rubyClassOperator,rubyConditional,rubyModuleName,rubyClassName,rubySymbolDelimiter,rubyParentheses,@Spell +syn cluster rubyNotTop contains=@rubyCommentNotTop,@rubyStringNotTop,@rubyRegexpSpecial,@rubyDeclaration,@rubyExceptionHandler,@rubyClassOperator,rubyConditional,rubyModuleName,rubyClassName,rubySymbolDelimiter,rubyDoubleQuoteSymbolDelimiter,rubySingleQuoteSymbolDelimiter,rubyParentheses,@Spell " Whitespace Errors {{{1 if exists("ruby_space_errors") @@ -468,6 +468,10 @@ syn match rubyDefinedOperator "\%#=1\<defined?" display syn match rubySymbol "\%(\w\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[?!]\=::\@!"he=e-1 contained containedin=rubyBlockParameterList,rubyCurlyBlock syn match rubySymbol "[]})\"':]\@1<!\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],;]\@="he=e-1 syn match rubySymbol "[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],;]\@="hs=s+1,he=e-1 +syn match rubySingleQuoteSymbolDelimiter "'" contained +syn match rubySymbol "'\%(\\.\|[^']\)*'::\@!"he=e-1 contains=rubyQuoteEscape,rubyBackslashEscape,rubySingleQuoteSymbolDelimiter +syn match rubyDoubleQuoteSymbolDelimiter "\"" contained +syn match rubySymbol "\"\%(\\.\|[^\"]\)*\"::\@!"he=e-1 contains=@rubyStringSpecial,rubyDoubleQuoteSymbolDelimiter " __END__ Directive {{{1 SynFold '__END__' syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" @@ -568,6 +572,8 @@ hi def link rubyHeredocDelimiter rubyStringDelimiter hi def link rubyPercentRegexpDelimiter rubyRegexpDelimiter hi def link rubyPercentStringDelimiter rubyStringDelimiter hi def link rubyPercentSymbolDelimiter rubySymbolDelimiter +hi def link rubyDoubleQuoteSymbolDelimiter rubySymbolDelimiter +hi def link rubySingleQuoteSymbolDelimiter rubySymbolDelimiter hi def link rubyRegexpDelimiter rubyStringDelimiter hi def link rubySymbolDelimiter rubySymbol hi def link rubyString String diff --git a/syntax/terraform.vim b/syntax/terraform.vim index c99dbe47..7a330e45 100644 --- a/syntax/terraform.vim +++ b/syntax/terraform.vim @@ -2,74 +2,14 @@ if polyglot#init#is_disabled(expand('<sfile>:p'), 'terraform', 'syntax/terraform finish endif -" Forked from Larry Gilbert's syntax file -" github.com/L2G/vim-syntax-terraform - if exists('b:current_syntax') finish endif +runtime! syntax/hcl.vim +unlet b:current_syntax -let s:cpo_save = &cpoptions -set cpoptions&vim - -" Identifiers are made up of alphanumeric characters, underscores, and -" hyphens. -if has('patch-7.4.1142') - syn iskeyword a-z,A-Z,48-57,_,- -endif - -syn case match - -" A block is introduced by a type, some number of labels - which are either -" strings or identifiers - and an opening curly brace. Match the type. -syn match terraBlockIntroduction /^\s*\zs\K\k*\ze\s\+\(\("\K\k*"\|\K\k*\)\s\+\)*{/ contains=terraBlockType -syn keyword terraBlockType contained data locals module output provider resource terraform variable - -syn keyword terraValueBool true false on off yes no - -syn keyword terraTodo contained TODO FIXME XXX BUG TF-UPGRADE-TODO -syn region terraComment start="/\*" end="\*/" contains=terraTodo,@Spell -syn region terraComment start="#" end="$" contains=terraTodo,@Spell -syn region terraComment start="//" end="$" contains=terraTodo,@Spell - -""" misc. -syn match terraValueDec "\<[0-9]\+\([kKmMgG]b\?\)\?\>" -syn match terraValueHexaDec "\<0x[0-9a-f]\+\([kKmMgG]b\?\)\?\>" -syn match terraBraces "[\[\]]" - -""" skip \" and \\ in strings. -syn region terraValueString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=terraStringInterp -syn region terraStringInterp matchgroup=terraBraces start=/\(^\|[^$]\)\$\zs{/ end=/}/ contained contains=ALL -syn region terraHereDocText start=/<<-\?\z([a-z0-9A-Z]\+\)/ end=/^\s*\z1/ contains=terraStringInterp - -"" Functions. -syn match terraFunction "[a-z0-9]\+(\@=" - -""" HCL2 -syn keyword terraRepeat for in -syn keyword terraConditional if syn keyword terraType string bool number object tuple list map set any -syn keyword terraValueNull null - -" enable block folding -syn region terraBlockBody matchgroup=terraBraces start="{" end="}" fold transparent -hi def link terraComment Comment -hi def link terraTodo Todo -hi def link terraBraces Delimiter -hi def link terraBlockType Structure -hi def link terraValueBool Boolean -hi def link terraValueDec Number -hi def link terraValueHexaDec Number -hi def link terraValueString String -hi def link terraHereDocText String -hi def link terraFunction Function -hi def link terraRepeat Repeat -hi def link terraConditional Conditional -hi def link terraType Type -hi def link terraValueNull Constant +hi def link terraType Type let b:current_syntax = 'terraform' - -let &cpoptions = s:cpo_save -unlet s:cpo_save diff --git a/tests/filetypes.vim b/tests/filetypes.vim index 05582424..15bd60e9 100644 --- a/tests/filetypes.vim +++ b/tests/filetypes.vim @@ -119,7 +119,6 @@ call TestFiletype('haskell') call TestFiletype('haxe') call TestFiletype('hxml') call TestFiletype('hss') -call TestFiletype('hcl') call TestFiletype('hive') call TestFiletype('icalendar') call TestFiletype('idris') @@ -221,6 +220,7 @@ call TestFiletype('sxhkdrc') call TestFiletype('systemd') call TestFiletype('tf') call TestFiletype('terraform') +call TestFiletype('hcl') call TestFiletype('textile') call TestFiletype('thrift') call TestFiletype('tmux') |