From 140430ffb73d5e0851ba2df2abd29106b1677687 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 1 Jul 2019 16:25:37 +0200 Subject: [PATCH] Update --- after/syntax/cpp.vim | 11 ++- autoload/go/config.vim | 8 -- autoload/jsx_pretty/indent.vim | 31 ++++---- autoload/terraform.vim | 68 ++++++++++++++++ ftdetect/polyglot.vim | 14 ++-- ftplugin/scala.vim | 4 +- ftplugin/terraform.vim | 140 +++++++-------------------------- indent/dune.vim | 14 ++++ indent/rust.vim | 66 +++++++++++++++- indent/scala.vim | 9 ++- indent/terraform.vim | 21 ++--- syntax/erlang.vim | 4 +- syntax/gitconfig.vim | 2 +- syntax/javascript.vim | 2 +- syntax/rst.vim | 11 ++- syntax/rust.vim | 11 ++- syntax/scss.vim | 2 + syntax/svelte.vim | 3 + syntax/terraform.vim | 11 ++- 19 files changed, 262 insertions(+), 170 deletions(-) create mode 100644 indent/dune.vim diff --git a/after/syntax/cpp.vim b/after/syntax/cpp.vim index 01108d5..ae11705 100644 --- a/after/syntax/cpp.vim +++ b/after/syntax/cpp.vim @@ -6,7 +6,7 @@ endif " Language: C++ Additions " Maintainer: Jon Haggblad " URL: http://www.haeggblad.com -" Last Change: 1 Feb 2018 +" Last Change: 29 Jun 2019 " Version: 0.6 " Changelog: " 0.1 - initial version. @@ -964,6 +964,12 @@ if !exists("cpp_no_cpp11") syntax keyword cppSTLtype atomic_uintmax_t syntax keyword cppSTLconstant ATOMIC_FLAG_INIT syntax keyword cppSTLenum memory_order + syntax keyword cppSTLtype memory_order_relaxed + syntax keyword cppSTLtype memory_order_consume + syntax keyword cppSTLtype memory_order_acquire + syntax keyword cppSTLtype memory_order_release + syntax keyword cppSTLtype memory_order_acq_rel + syntax keyword cppSTLtype memory_order_seq_cst syntax keyword cppSTLfunction is_lock_free syntax keyword cppSTLfunction compare_exchange_weak syntax keyword cppSTLfunction compare_exchange_strong @@ -1983,6 +1989,9 @@ endif " C++17 if !exists("cpp_no_cpp20") " type_traits syntax keyword cppSTLtype remove_cvref remove_cvref_t + syntax keyword cppType char8_t + syntax keyword cppStatement co_yield co_return co_await + syntax keyword cppStorageClass consteval endif diff --git a/autoload/go/config.vim b/autoload/go/config.vim index 4eff6f6..787c4e2 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -18,10 +18,6 @@ function! go#config#VersionWarning() abort return get(g:, 'go_version_warning', 1) endfunction -function! go#config#NullModuleWarning() abort - return get(g:, 'go_null_module_warning', 1) -endfunction - function! go#config#BuildTags() abort return get(g:, 'go_build_tags', '') endfunction @@ -279,10 +275,6 @@ function! go#config#MetalinterEnabled() abort return get(g:, "go_metalinter_enabled", default_enabled) endfunction -function! go#config#MetalinterDisabled() abort - return get(g:, "go_metalinter_disabled", []) -endfunction - function! go#config#GolintBin() abort return get(g:, "go_golint_bin", "golint") endfunction diff --git a/autoload/jsx_pretty/indent.vim b/autoload/jsx_pretty/indent.vim index d37d399..428c366 100644 --- a/autoload/jsx_pretty/indent.vim +++ b/autoload/jsx_pretty/indent.vim @@ -73,17 +73,27 @@ function! jsx_pretty#indent#get(js_indent) let line = substitute(getline(lnum), '^\s*\|\s*$', '', 'g') let current_syn = s:syn_sol(lnum) let current_syn_eol = s:syn_eol(lnum) - let prev_syn_sol = s:syn_sol(lnum - 1) - let prev_syn_eol = s:syn_eol(lnum - 1) + let prev_line_num = prevnonblank(lnum - 1) + let prev_syn_sol = s:syn_sol(prev_line_num) + let prev_syn_eol = s:syn_eol(prev_line_num) let prev_line = s:prev_line(lnum) let prev_ind = s:prev_indent(lnum) if s:syn_xmlish(current_syn) + if !s:syn_xmlish(prev_syn_sol) + \ && !s:syn_jsx_escapejs(prev_syn_sol) + \ && !s:syn_jsx_escapejs(prev_syn_eol) + \ && !s:syn_js_comment(prev_syn_sol) + if line =~ '^/\s*>' || line =~ '^<\s*' . s:end_tag + return prev_ind + else + return prev_ind + s:sw() + endif " { "
" ##} <-- - if s:syn_jsx_element(current_syn) && line =~ '}$' + elseif s:syn_jsx_element(current_syn) && line =~ '}$' let pair_line = searchpair('{', '', '}', 'b') return indent(pair_line) elseif line =~ '^-->$' @@ -143,16 +153,6 @@ function! jsx_pretty#indent#get(js_indent) else return prev_ind endif - elseif !s:syn_xmlish(prev_syn_sol) - if prev_line =~ '^\<\(return\|default\|await\|yield\)' - if line !~ '^/\s*>' || line !~ '^<\s*' . s:end_tag - return prev_ind + s:sw() - else - return prev_ind - endif - else - return prev_ind - endif else return prev_ind endif @@ -193,9 +193,10 @@ function! jsx_pretty#indent#get(js_indent) " Issue #68 " return (
" |
) - if prev_line =~ '^\' || line =~ '^<\s*' . s:end_tag) + \ && !s:syn_xmlish(prev_syn_sol) return prev_ind - endif + endif " If current syntax is not a jsx syntax group if s:syn_xmlish(prev_syn_eol) && line !~ '^[)\]}]' diff --git a/autoload/terraform.vim b/autoload/terraform.vim index 210ee59..db1e393 100644 --- a/autoload/terraform.vim +++ b/autoload/terraform.vim @@ -23,3 +23,71 @@ function! terraform#fmt() endif call winrestview(l:curw) endfunction + +function! terraform#folds() + 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 + +function! terraform#foldText() + let foldsize = (v:foldend-v:foldstart) + return getline(v:foldstart).' ('.foldsize.' lines)' +endfunction + +function! terraform#align() + 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(A, L, P) + return [ + \ 'apply', + \ 'console', + \ 'destroy', + \ 'env', + \ 'fmt', + \ 'get', + \ 'graph', + \ 'import', + \ 'init', + \ 'output', + \ 'plan', + \ 'providers', + \ 'push', + \ 'refresh', + \ 'show', + \ 'taint', + \ 'untaint', + \ 'validate', + \ 'version', + \ 'workspace', + \ '0.12checklist', + \ 'debug', + \ 'force-unlock', + \ 'state' + \ ] +endfunction diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index b080cfd..073ef3a 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -631,11 +631,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jenkins') == -1 augroup filetypedetect " jenkins, from Jenkinsfile.vim in martinda/Jenkinsfile-vim-syntax " Jenkinsfile -autocmd BufRead,BufNewFile Jenkinsfile set ft=Jenkinsfile -autocmd BufRead,BufNewFile Jenkinsfile* setf Jenkinsfile -autocmd BufRead,BufNewFile *.jenkinsfile set ft=Jenkinsfile -autocmd BufRead,BufNewFile *.jenkinsfile setf Jenkinsfile -autocmd BufRead,BufNewFile *.Jenkinsfile setf Jenkinsfile + +augroup JenkinsAUGroup + autocmd BufRead,BufNewFile *Jenkins* set ft=Jenkinsfile + autocmd BufRead,BufNewFile *jenkins* set ft=Jenkinsfile +augroup END augroup end endif @@ -1085,7 +1085,7 @@ endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'racket') == -1 augroup filetypedetect " racket, from racket.vim in wlangstroth/vim-racket -au BufRead,BufNewFile *.rkt,*.rktl setf racket +au BufRead,BufNewFile *.rkt,*.rktl set filetype=racket augroup end endif @@ -1348,6 +1348,8 @@ endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1 augroup filetypedetect " terraform, from terraform.vim in hashivim/vim-terraform +" By default, Vim associates .tf files with TinyFugue - tell it not to. +autocmd! filetypedetect BufRead,BufNewFile *.tf autocmd BufRead,BufNewFile *.tf set filetype=terraform autocmd BufRead,BufNewFile *.tfvars set filetype=terraform autocmd BufRead,BufNewFile *.tfstate set filetype=json diff --git a/ftplugin/scala.vim b/ftplugin/scala.vim index 817b6f9..d843daa 100644 --- a/ftplugin/scala.vim +++ b/ftplugin/scala.vim @@ -29,8 +29,8 @@ setlocal commentstring=//\ %s setlocal shiftwidth=2 softtabstop=2 expandtab -setlocal include='^\s*import' -setlocal includeexpr='substitute(v:fname,"\\.","/","g")' +setlocal include=^\\s*import +setlocal includeexpr=substitute(v:fname,'\\.','/','g') setlocal path+=src/main/scala,src/test/scala setlocal suffixesadd=.scala diff --git a/ftplugin/terraform.vim b/ftplugin/terraform.vim index fd4c2be..e8ed9fb 100644 --- a/ftplugin/terraform.vim +++ b/ftplugin/terraform.vim @@ -11,127 +11,44 @@ endif let b:did_ftplugin = 1 let s:cpo_save = &cpoptions - -setlocal formatoptions-=t -let b:undo_ftplugin = 'setlocal formatoptions<' - -" 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<' - set cpoptions&vim -if !exists('g:terraform_align') - let g:terraform_align = 0 +" 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 -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 = =:call terraformalign()a - function! s:terraformalign() - 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 -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 +if get(g:, 'terraform_fold_sections', 0) setlocal foldmethod=expr - setlocal foldexpr=TerraformFolds() + setlocal foldexpr=terraform#folds() setlocal foldlevel=1 - let b:undo_ftplugin .= ' foldmethod< foldexpr< foldlevel<' - - function! TerraformFoldText() - let foldsize = (v:foldend-v:foldstart) - return getline(v:foldstart).' ('.foldsize.' lines)' - endfunction - setlocal foldtext=TerraformFoldText() - let b:undo_ftplugin .= ' foldtext<' -endif - -" Re-map the space bar to fold and unfold -if get(g:, 'terraform_remap_spacebar', 1) - "inoremap za - nnoremap za - onoremap za - vnoremap zf + setlocal foldtext=terraform#foldText() + let b:undo_ftplugin .= ' foldmethod< foldexpr< foldlevel< foldtext<' endif " Set the commentstring -if exists('g:terraform_commentstring') - let &l:commentstring=g:terraform_commentstring -else - setlocal commentstring=#%s -endif +let &l:commentstring = get(g:, 'terraform_commentstring', '#%s') let b:undo_ftplugin .= ' commentstring<' -if !exists('g:terraform_fmt_on_save') - let g:terraform_fmt_on_save = 0 +" Re-map the space bar to fold and unfold +if get(g:, 'terraform_remap_spacebar', 0) + nnoremap za + onoremap za + vnoremap zf + let b:undo_ftplugin .= '|unmap ' endif -function! s:commands(A, L, P) - return [ - \ 'apply', - \ 'console', - \ 'destroy', - \ 'env', - \ 'fmt', - \ 'get', - \ 'graph', - \ 'import', - \ 'init', - \ 'output', - \ 'plan', - \ 'providers', - \ 'push', - \ 'refresh', - \ 'show', - \ 'taint', - \ 'untaint', - \ 'validate', - \ 'version', - \ 'workspace', - \ '0.12checklist', - \ 'debug', - \ 'force-unlock', - \ 'state' - \ ] -endfunction +if get(g:, 'terraform_align', 0) && exists(':Tabularize') + inoremap = =:call terraform#align()a + let b:undo_ftplugin .= '|iunmap =' +endif let &cpoptions = s:cpo_save unlet s:cpo_save @@ -141,13 +58,14 @@ if !executable('terraform') endif let s:cpo_save = &cpoptions +set cpoptions&vim -command! -nargs=+ -complete=customlist,s:commands -buffer Terraform execute '!terraform '.. ' -no-color' +command! -nargs=+ -complete=customlist,terraform#commands -buffer Terraform execute '!terraform '.. ' -no-color' command! -nargs=0 -buffer TerraformFmt call terraform#fmt() let b:undo_ftplugin .= '|delcommand Terraform|delcommand TerraformFmt' -if get(g:, 'terraform_fmt_on_save', 1) - augroup terraform +if get(g:, 'terraform_fmt_on_save', 0) + augroup vim.terraform.fmt autocmd! autocmd BufWritePre *.tf call terraform#fmt() autocmd BufWritePre *.tfvars call terraform#fmt() diff --git a/indent/dune.vim b/indent/dune.vim new file mode 100644 index 0000000..3f8e7e8 --- /dev/null +++ b/indent/dune.vim @@ -0,0 +1,14 @@ +if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'ocaml') != -1 + finish +endif + +" Vim indent file +" Language: dune + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +" dune format-dune-file uses 1 space to indent +set softtabstop=1 shiftwidth=1 expandtab diff --git a/indent/rust.vim b/indent/rust.vim index 5c43d2e..ee7f6cf 100644 --- a/indent/rust.vim +++ b/indent/rust.vim @@ -85,8 +85,17 @@ function! s:is_string_comment(lnum, col) endif endfunction -function GetRustIndent(lnum) +if exists('*shiftwidth') + function! s:shiftwidth() + return shiftwidth() + endfunc +else + function! s:shiftwidth() + return &shiftwidth + endfunc +endif +function GetRustIndent(lnum) " Starting assumption: cindent (called at the end) will do it right " normally. We just want to fix up a few cases. @@ -132,14 +141,65 @@ function GetRustIndent(lnum) let prevline = s:get_line_trimmed(prevlinenum) endwhile + " A standalone '{', '}', or 'where' + let l:standalone_open = line =~# '\V\^\s\*{\s\*\$' + let l:standalone_close = line =~# '\V\^\s\*}\s\*\$' + let l:standalone_where = line =~# '\V\^\s\*where\s\*\$' + if l:standalone_open || l:standalone_close || l:standalone_where + " ToDo: we can search for more items than 'fn' and 'if'. + let [l:found_line, l:col, l:submatch] = + \ searchpos('\<\(fn\)\|\(if\)\>', 'bnWp') + if l:found_line !=# 0 + " Now we count the number of '{' and '}' in between the match + " locations and the current line (there is probably a better + " way to compute this). + let l:i = l:found_line + let l:search_line = strpart(getline(l:i), l:col - 1) + let l:opens = 0 + let l:closes = 0 + while l:i < a:lnum + let l:search_line2 = substitute(l:search_line, '\V{', '', 'g') + let l:opens += strlen(l:search_line) - strlen(l:search_line2) + let l:search_line3 = substitute(l:search_line2, '\V}', '', 'g') + let l:closes += strlen(l:search_line2) - strlen(l:search_line3) + let l:i += 1 + let l:search_line = getline(l:i) + endwhile + if l:standalone_open || l:standalone_where + if l:opens ==# l:closes + return indent(l:found_line) + endif + else + " Expect to find just one more close than an open + if l:opens ==# l:closes + 1 + return indent(l:found_line) + endif + endif + endif + endif + + " A standalone 'where' adds a shift. + let l:standalone_prevline_where = prevline =~# '\V\^\s\*where\s\*\$' + if l:standalone_prevline_where + return indent(prevlinenum) + 4 + endif + " Handle where clauses nicely: subsequent values should line up nicely. if prevline[len(prevline) - 1] ==# "," \ && prevline =~# '^\s*where\s' return indent(prevlinenum) + 6 endif - if prevline[len(prevline) - 1] ==# "," - \ && s:get_line_trimmed(a:lnum) !~# '^\s*[\[\]{}]' + let l:last_prevline_character = prevline[len(prevline) - 1] + + " A line that ends with '.;' is probably an end of a long list + " of method operations. + if prevline =~# '\V\^\s\*.' && l:last_prevline_character ==# ';' + return indent(prevlinenum) - s:shiftwidth() + endif + + if l:last_prevline_character ==# "," + \ && s:get_line_trimmed(a:lnum) !~# '^\s*[\[\]{})]' \ && prevline !~# '^\s*fn\s' \ && prevline !~# '([^()]\+,$' \ && s:get_line_trimmed(a:lnum) !~# '^\s*\S\+\s*=>' diff --git a/indent/scala.vim b/indent/scala.vim index db52cf9..2fcb337 100644 --- a/indent/scala.vim +++ b/indent/scala.vim @@ -21,7 +21,10 @@ if exists("*GetScalaIndent") finish endif -let s:defMatcher = '\%(\%(private\|protected\)\%(\[[^\]]*\]\)\?\s\+\|abstract\s\+\|override\s\+\)*\' +let s:annotationMatcher = '@[A-Za-z._]\+\s\+' +let s:modifierMatcher = s:annotationMatcher . '\|\%(private\|protected\)\%(\[[^\]]*\]\)\?\s\+\|abstract\s\+\|override\s\+\|final\s\+' +let s:defMatcher = '\%(' . s:modifierMatcher . '\)*\' +let s:valMatcher = '\%(' . s:modifierMatcher . '\|lazy\s\+\)*\' let s:funcNameMatcher = '\w\+' let s:typeSpecMatcher = '\%(\s*\[\_[^\]]*\]\)' let s:defArgMatcher = '\%((\_.\{-})\)' @@ -185,7 +188,7 @@ function! scala#NumberOfBraceGroups(line) endfunction function! scala#MatchesIncompleteDefValr(line) - if a:line =~ '^\s*\%(' . s:defMatcher . '\|\\).*[=({]\s*$' + if a:line =~ '^\s*\%(' . s:defMatcher . '\|' . s:valMatcher . '\).*[=({]\s*$' return 1 else return 0 @@ -435,7 +438,7 @@ function! GetScalaIndent() " If 'val', 'var', 'def' end with =, this is a one-line block if (prevline =~ '^\s*\<\%(\%(}\?\s*else\s\+\)\?if\|for\|while\)\>.*[)=]\s*$' && scala#NumberOfBraceGroups(prevline) <= 1) \ || prevline =~ '^\s*' . s:defMatcher . '.*=\s*$' - \ || prevline =~ '^\s*\.*[=]\s*$' + \ || prevline =~ '^\s*' . s:valMatcher . '.*[=]\s*$' \ || prevline =~ '^\s*\%(}\s*\)\?\\s*$' \ || prevline =~ '=\s*$' call scala#ConditionalConfirm("4") diff --git a/indent/terraform.vim b/indent/terraform.vim index 2a0e579..74b7808 100644 --- a/indent/terraform.vim +++ b/indent/terraform.vim @@ -34,24 +34,19 @@ function! TerraformIndent(lnum) return 0 endif - " Previous non-blank line should continue the indent level + " 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) - " Previous line without comments should continue the indent level - let prevline = substitute(getline(prevlnum), '//.*$', '', '') - let previndent = indent(prevlnum) - let thisindent = previndent - - " Config block starting with [ { ( should increase the indent level - if prevline =~# '[\[{\(]\s*$' + " 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 - " Current line without comments should continue the indent level - let thisline = substitute(getline(a:lnum), '//.*$', '', '') - - " Config block ending with ) } ] should get the indentation - " level from the initial config block + " If the current line ends a block, decrease the indent level. + let thisline = getline(a:lnum) if thisline =~# '^\s*[\)}\]]' let thisindent -= &shiftwidth endif diff --git a/syntax/erlang.vim b/syntax/erlang.vim index 1c54996..391ad1b 100644 --- a/syntax/erlang.vim +++ b/syntax/erlang.vim @@ -6,7 +6,7 @@ endif " Language: Erlang (http://www.erlang.org) " Maintainer: Csaba Hoch " Contributor: Adam Rutkowski -" Last Update: 2017-Mar-05 +" Last Update: 2019-Jun-18 " License: Vim license " URL: https://github.com/vim-erlang/vim-erlang-runtime @@ -121,7 +121,7 @@ syn keyword erlangBIF garbage_collect get get_keys group_leader contained syn keyword erlangBIF halt hd integer_to_binary integer_to_list contained syn keyword erlangBIF iolist_to_binary iolist_size is_alive contained syn keyword erlangBIF is_atom is_binary is_bitstring is_boolean contained -syn keyword erlangBIF is_float is_function is_integer is_list is_map contained +syn keyword erlangBIF is_float is_function is_integer is_list is_map is_map_key contained syn keyword erlangBIF is_number is_pid is_port is_process_alive contained syn keyword erlangBIF is_record is_reference is_tuple length link contained syn keyword erlangBIF list_to_atom list_to_binary contained diff --git a/syntax/gitconfig.vim b/syntax/gitconfig.vim index 438ccea..80ee797 100644 --- a/syntax/gitconfig.vim +++ b/syntax/gitconfig.vim @@ -34,7 +34,7 @@ hi def link gitconfigBoolean Boolean hi def link gitconfigNumber Number hi def link gitconfigString String hi def link gitconfigDelim Delimiter -hi def link gitconfigEscape Delimiter +hi def link gitconfigEscape Special hi def link gitconfigError Error let b:current_syntax = "gitconfig" diff --git a/syntax/javascript.vim b/syntax/javascript.vim index a48c58e..0c917b6 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -65,7 +65,7 @@ syntax match jsFloat /\c\<\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%(e[+-]\= " Regular Expressions syntax match jsSpecial contained "\v\\%(x\x\x|u%(\x{4}|\{\x{4,5}})|c\u|.)" syntax region jsTemplateExpression contained matchgroup=jsTemplateBraces start=+${+ end=+}+ contains=@jsExpression keepend -syntax region jsRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+ contains=jsSpecial +syntax region jsRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+ contains=jsSpecial extend syntax match jsRegexpBoundary contained "\v\c[$^]|\\b" syntax match jsRegexpBackRef contained "\v\\[1-9]\d*" syntax match jsRegexpQuantifier contained "\v[^\\]%([?*+]|\{\d+%(,\d*)?})\??"lc=1 diff --git a/syntax/rst.vim b/syntax/rst.vim index a875a44..43b17aa 100644 --- a/syntax/rst.vim +++ b/syntax/rst.vim @@ -94,7 +94,14 @@ execute 'syn match rstSubstitutionDefinition contained' . \ ' /|.*|\_s\+/ nextgroup=@rstDirectives' function! s:DefineOneInlineMarkup(name, start, middle, end, char_left, char_right) - execute 'syn match rstEscape'.a:name.' +\\\\\|\\'.a:start.'+'.' contained' + " Only escape the first char of a multichar delimiter (e.g. \* inside **) + if a:start[0] == '\' + let first = a:start[0:1] + else + let first = a:start[0] + endif + + execute 'syn match rstEscape'.a:name.' +\\\\\|\\'.first.'+'.' contained' execute 'syn region rst' . a:name . \ ' start=+' . a:char_left . '\zs' . a:start . @@ -170,7 +177,7 @@ syn match rstStandaloneHyperlink contains=@NoSpell \ "\<\%(\%(\%(https\=\|file\|ftp\|gopher\)://\|\%(mailto\|news\):\)[^[:space:]'\"<>]\+\|www[[:alnum:]_-]*\.[[:alnum:]_-]\+\.[^[:space:]'\"<>]\+\)[[:alnum:]/]" syn region rstCodeBlock contained matchgroup=rstDirective - \ start=+\%(sourcecode\|code\%(-block\)\=\)::\s\+.*\_s*\n\ze\z(\s\+\)+ + \ start=+\%(sourcecode\|code\%(-block\)\=\)::\s*\n\%(\s*:.*:\s*.*\s*\n\)*\n\ze\z(\s\+\)+ \ skip=+^$+ \ end=+^\z1\@!+ \ contains=@NoSpell diff --git a/syntax/rust.vim b/syntax/rust.vim index 6f65301..a4fff5c 100644 --- a/syntax/rust.vim +++ b/syntax/rust.vim @@ -153,7 +153,16 @@ syn region rustString start=+b"+ skip=+\\\\\|\\"+ end=+"+ contains=rustE syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustStringContinuation,@Spell syn region rustString start='b\?r\z(#*\)"' end='"\z1' contains=@Spell -syn region rustAttribute start="#!\?\[" end="\]" contains=rustString,rustDerive,rustCommentLine,rustCommentBlock,rustCommentLineDocError,rustCommentBlockDocError +" Match attributes with either arbitrary syntax or special highlighting for +" derives. We still highlight strings and comments inside of the attribute. +syn region rustAttribute start="#!\?\[" end="\]" contains=@rustAttributeContents,rustAttributeParenthesizedParens,rustAttributeParenthesizedCurly,rustAttributeParenthesizedBrackets,rustDerive +syn region rustAttributeParenthesizedParens matchgroup=rustAttribute start="\w\%(\w\)*("rs=e end=")"re=s transparent contained contains=rustAttributeBalancedParens,@rustAttributeContents +syn region rustAttributeParenthesizedCurly matchgroup=rustAttribute start="\w\%(\w\)*{"rs=e end="}"re=s transparent contained contains=rustAttributeBalancedCurly,@rustAttributeContents +syn region rustAttributeParenthesizedBrackets matchgroup=rustAttribute start="\w\%(\w\)*\["rs=e end="\]"re=s transparent contained contains=rustAttributeBalancedBrackets,@rustAttributeContents +syn region rustAttributeBalancedParens matchgroup=rustAttribute start="("rs=e end=")"re=s transparent contained contains=rustAttributeBalancedParens,@rustAttributeContents +syn region rustAttributeBalancedCurly matchgroup=rustAttribute start="{"rs=e end="}"re=s transparent contained contains=rustAttributeBalancedCurly,@rustAttributeContents +syn region rustAttributeBalancedBrackets matchgroup=rustAttribute start="\["rs=e end="\]"re=s transparent contained contains=rustAttributeBalancedBrackets,@rustAttributeContents +syn cluster rustAttributeContents contains=rustString,rustCommentLine,rustCommentBlock,rustCommentLineDocError,rustCommentBlockDocError syn region rustDerive start="derive(" end=")" contained contains=rustDeriveTrait " This list comes from src/libsyntax/ext/deriving/mod.rs " Some are deprecated (Encodable, Decodable) or to be removed after a new snapshot (Show). diff --git a/syntax/scss.vim b/syntax/scss.vim index 84f75fe..6957473 100644 --- a/syntax/scss.vim +++ b/syntax/scss.vim @@ -50,6 +50,7 @@ syn cluster scssSelectors contains=@comment,cssSelectorOp,cssTagName,cssPseudoCl syn match scssProperty "\([[:alnum:]-]\)\+\s*\(:\)\@=" contained contains=css.*Prop,cssVendor containedin=cssMediaBlock nextgroup=scssAttribute,scssAttributeWithNestedDefinition syn match scssAttribute ":[^;]*\ze\(;\|}\)" contained contains=css.*Attr,cssValue.*,cssColor,cssFunction,cssString.*,cssURL,scssFunction,scssInterpolation,scssVariable +syn match scssSemicolon ";" containedin=scssDefinition,scssNestedDefinition syn match scssAttributeWithNestedDefinition ": [^#"]*{\@=" nextgroup=scssNestedDefinition contained contains=css.*Attr,cssValue.*,scssVariable syn region scssNestedDefinition matchgroup=cssBraces start="{" end="}" contained contains=@comment,scssProperty,scssNestedProperty @@ -218,6 +219,7 @@ hi def link scssImport Include hi def link scssTodo Todo hi def link scssAtRoot Keyword hi def link scssMapParens Delimiter +hi def link scssSemicolon Delimiter let b:current_syntax = "scss" if main_syntax == 'scss' diff --git a/syntax/svelte.vim b/syntax/svelte.vim index e119d60..2149e71 100644 --- a/syntax/svelte.vim +++ b/syntax/svelte.vim @@ -48,7 +48,10 @@ syntax match svelteKeyword "#await" contained containedin=jsBlock,javascriptBloc syntax match svelteKeyword "/await" contained containedin=jsBlock,javascriptBlock syntax match svelteKeyword ":catch" contained containedin=jsBlock,javascriptBlock syntax match svelteKeyword ":then" contained containedin=jsBlock,javascriptBlock + +" Inline keywords. syntax match svelteKeyword "@html" contained containedin=jsBlock,javascriptBlock +syntax match svelteKeyword "@debug" contained containedin=jsBlock,javascriptBlock " Repeat functions. syntax match svelteRepeat "#each" contained containedin=jsBlock,javascriptBlock diff --git a/syntax/terraform.vim b/syntax/terraform.vim index eb7745e..58c6020 100644 --- a/syntax/terraform.vim +++ b/syntax/terraform.vim @@ -9,6 +9,12 @@ if exists('b:current_syntax') finish endif +" 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 syn keyword terraSection connection output provider variable data terraform locals @@ -3732,7 +3738,7 @@ syn region terraDynamicName start=/"/ end=/"/ nextgroup=terraDynamicBlock skipwh """ misc. syn match terraValueDec "\<[0-9]\+\([kKmMgG]b\?\)\?\>" syn match terraValueHexaDec "\<0x[0-9a-f]\+\([kKmMgG]b\?\)\?\>" -syn match terraBraces "[{}\[\]]" +syn match terraBraces "[\[\]]" """ skip \" in strings. """ we may also want to pass \\" into a function to escape quotes. @@ -3757,6 +3763,9 @@ syn keyword terraValueNull null """ Terraform v0.12 syn keyword terraTodo contained TF-UPGRADE-TODO +" enable block folding +syn region terraBlock matchgroup=terraBraces start="{" end="}" fold transparent + hi def link terraComment Comment hi def link terraTodo Todo hi def link terraBrackets Operator