From 199846c6d87c9ea60eb5f9f8f68e2d9ea4f02b2a Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 16 Oct 2019 14:56:00 +0200 Subject: Update --- after/syntax/jsx_pretty.vim | 2 +- autoload/rust.vim | 13 +++++++++-- autoload/rust/tags.vim | 3 ++- autoload/rustfmt.vim | 16 ++++++++------ autoload/terraform.vim | 53 +++++++++++++++++++++++---------------------- ftplugin/meson.vim | 3 +++ ftplugin/plantuml.vim | 8 +++---- ftplugin/terraform.vim | 2 +- ftplugin/typescript.vim | 2 +- indent/plantuml.vim | 2 +- syntax/crystal.vim | 2 +- syntax/plantuml.vim | 23 +++++++++++++------- syntax/rust.vim | 18 +++++---------- syntax/svelte.vim | 9 ++++---- 14 files changed, 86 insertions(+), 70 deletions(-) diff --git a/after/syntax/jsx_pretty.vim b/after/syntax/jsx_pretty.vim index fd5c9bde..b4d0e0f0 100644 --- a/after/syntax/jsx_pretty.vim +++ b/after/syntax/jsx_pretty.vim @@ -38,7 +38,7 @@ syntax region jsxElement " detect jsx region syntax region jsxRegion - \ start=+\(\(\_[([,?:=+\-*/<>{}]\|&&\|||\|=>\|\\|\z(\(script\)\@!\<[_\$A-Za-z][-:_\.\$0-9A-Za-z]*\>\)\(\_s*\([-+*)\]}&|?]\|/\([/*]\|\_s*>\)\@!\)\)\@!\)+ + \ start=+\(\(\_[([,?:=+\-*/<>{}]\|&&\|||\|=>\|\\|\z(\(script\)\@!\<[_\$A-Za-z][-:_\.\$0-9A-Za-z]*\>\)\(\_s*\([-+*)\]}&|?,]\|/\([/*]\|\_s*>\)\@!\)\)\@!\)+ \ end=++ \ contains=jsxElement diff --git a/autoload/rust.vim b/autoload/rust.vim index e8a675f3..b6ab1c68 100644 --- a/autoload/rust.vim +++ b/autoload/rust.vim @@ -398,10 +398,19 @@ function! s:RmDir(path) echoerr 'Attempted to delete empty path' return 0 elseif a:path ==# '/' || a:path ==# $HOME - echoerr 'Attempted to delete protected path: ' . a:path + let l:path = expand(a:path) + if l:path ==# '/' || l:path ==# $HOME + echoerr 'Attempted to delete protected path: ' . a:path + return 0 + endif + endif + + if !isdirectory(a:path) return 0 endif - return system("rm -rf " . shellescape(a:path)) + + " delete() returns 0 when removing file successfully + return delete(a:path, 'rf') == 0 endfunction " Executes {cmd} with the cwd set to {pwd}, without changing Vim's cwd. diff --git a/autoload/rust/tags.vim b/autoload/rust/tags.vim index 21faaabb..e75fb208 100644 --- a/autoload/rust/tags.vim +++ b/autoload/rust/tags.vim @@ -8,7 +8,8 @@ let s:checked_ctags = 0 function! rust#tags#IsUCtags() abort if s:checked_ctags == 0 - if system('ctags --version') =~? 'universal ctags' + let l:ctags_bin = get(g:, 'tagbar_ctags_bin', 'ctags') + if system(l:ctags_bin.' --version') =~? 'universal ctags' let s:ctags_is_uctags = 1 endif let s:checked_ctags = 1 diff --git a/autoload/rustfmt.vim b/autoload/rustfmt.vim index 151ac82d..53ea9b28 100644 --- a/autoload/rustfmt.vim +++ b/autoload/rustfmt.vim @@ -112,7 +112,7 @@ function! s:DeleteLines(start, end) abort silent! execute a:start . ',' . a:end . 'delete _' endfunction -function! s:RunRustfmt(command, tmpname, fail_silently) +function! s:RunRustfmt(command, tmpname, from_writepre) mkview! let l:stderr_tmpname = tempname() @@ -149,8 +149,10 @@ function! s:RunRustfmt(command, tmpname, fail_silently) let l:open_lwindow = 0 if v:shell_error == 0 - " remove undo point caused via BufWritePre - try | silent undojoin | catch | endtry + if a:from_writepre + " remove undo point caused via BufWritePre + try | silent undojoin | catch | endtry + endif if a:tmpname ==# '' let l:content = l:out @@ -170,7 +172,7 @@ function! s:RunRustfmt(command, tmpname, fail_silently) call setloclist(0, []) let l:open_lwindow = 1 endif - elseif g:rustfmt_fail_silently == 0 && a:fail_silently == 0 + elseif g:rustfmt_fail_silently == 0 && !a:from_writepre " otherwise get the errors and put them in the location list let l:errors = [] @@ -224,12 +226,12 @@ function! rustfmt#FormatRange(line1, line2) let l:tmpname = tempname() call writefile(getline(1, '$'), l:tmpname) let command = s:RustfmtCommandRange(l:tmpname, a:line1, a:line2) - call s:RunRustfmt(command, l:tmpname, 0) + call s:RunRustfmt(command, l:tmpname, v:false) call delete(l:tmpname) endfunction function! rustfmt#Format() - call s:RunRustfmt(s:RustfmtCommand(), '', 0) + call s:RunRustfmt(s:RustfmtCommand(), '', v:false) endfunction function! rustfmt#Cmd() @@ -257,7 +259,7 @@ function! rustfmt#PreWrite() return endif - call s:RunRustfmt(s:RustfmtCommand(), '', 1) + call s:RunRustfmt(s:RustfmtCommand(), '', v:true) endfunction diff --git a/autoload/terraform.vim b/autoload/terraform.vim index da36751e..b156b6b9 100644 --- a/autoload/terraform.vim +++ b/autoload/terraform.vim @@ -31,33 +31,34 @@ function! terraform#align() endif endfunction -function! terraform#commands(A, L, P) - return [ - \ 'apply', - \ 'console', - \ 'destroy', - \ 'env', - \ 'fmt', - \ 'get', - \ 'graph', - \ 'import', - \ 'init', - \ 'output', - \ 'plan', - \ 'providers', - \ 'refresh', - \ 'show', - \ 'taint', - \ 'untaint', - \ 'validate', - \ 'version', - \ 'workspace', - \ '0.12upgrade', - \ 'debug', - \ 'force-unlock', - \ 'push', - \ 'state' +function! terraform#commands(ArgLead, CmdLine, CursorPos) + let l:commands = [ + \ 'apply', + \ 'console', + \ 'destroy', + \ 'env', + \ 'fmt', + \ 'get', + \ 'graph', + \ 'import', + \ 'init', + \ 'output', + \ 'plan', + \ 'providers', + \ 'refresh', + \ 'show', + \ 'taint', + \ 'untaint', + \ 'validate', + \ 'version', + \ 'workspace', + \ '0.12upgrade', + \ 'debug', + \ 'force-unlock', + \ 'push', + \ 'state' \ ] + return join(l:commands, "\n") endfunction endif diff --git a/ftplugin/meson.vim b/ftplugin/meson.vim index 2f4abd9b..e401158d 100644 --- a/ftplugin/meson.vim +++ b/ftplugin/meson.vim @@ -10,6 +10,9 @@ let b:did_ftplugin = 1 let s:keepcpo= &cpo set cpo&vim +setlocal commentstring=#\ %s +setlocal comments=:# + setlocal shiftwidth=2 setlocal softtabstop=2 diff --git a/ftplugin/plantuml.vim b/ftplugin/plantuml.vim index b17f88ba..9db919de 100644 --- a/ftplugin/plantuml.vim +++ b/ftplugin/plantuml.vim @@ -37,10 +37,10 @@ endif setlocal comments=s1:/',mb:',ex:'/,:' commentstring=/'%s'/ formatoptions-=t formatoptions+=croql -let b:endwise_addition = '\=index(["note","legend"], submatch(0))!=-1 ? "end " . submatch(0) : "end"' -let b:endwise_words = 'loop,group,alt,note,legend' -let b:endwise_pattern = '^\s*\zs\<\(loop\|group\|alt\|note\ze[^:]*$\|legend\)\>.*$' -let b:endwise_syngroups = 'plantumlKeyword' +let b:endwise_addition = '\=index(["dot","mindmap","uml","salt","wbs"], submatch(0))!=-1 ? "@end" . submatch(0) : index(["note","legend"], submatch(0))!=-1 ? "end " . submatch(0) : "end"' +let b:endwise_words = 'loop,group,alt,note,legend,startdot,startmindmap,startuml,startsalt,startwbs' +let b:endwise_pattern = '^\s*\zs\(loop\|group\|alt\|note\ze[^:]*$\|legend\|@start\zs\(dot\|mindmap\|uml\|salt\|wbs\)\)\>.*$' +let b:endwise_syngroups = 'plantumlKeyword,plantumlPreProc' let &cpoptions = s:cpo_save unlet s:cpo_save diff --git a/ftplugin/terraform.vim b/ftplugin/terraform.vim index 4426a890..3786648f 100644 --- a/ftplugin/terraform.vim +++ b/ftplugin/terraform.vim @@ -47,7 +47,7 @@ endif let s:cpo_save = &cpoptions set cpoptions&vim -command! -nargs=+ -complete=customlist,terraform#commands -buffer Terraform execute '!terraform '.. ' -no-color' +command! -nargs=+ -complete=custom,terraform#commands -buffer Terraform execute '!terraform '.. ' -no-color' command! -nargs=0 -buffer TerraformFmt call terraform#fmt() let b:undo_ftplugin .= '|delcommand Terraform|delcommand TerraformFmt' diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim index 60992bee..148eff9e 100644 --- a/ftplugin/typescript.vim +++ b/ftplugin/typescript.vim @@ -34,7 +34,7 @@ endfunction set path+=./node_modules/**,node_modules/** set include=import\_s.\\zs[^'\"]*\\ze set includeexpr=TsIncludeExpr(v:fname) -set suffixesadd=.ts +set suffixesadd+=.ts " " TagBar diff --git a/indent/plantuml.vim b/indent/plantuml.vim index 53a42f3e..d2d0aa99 100644 --- a/indent/plantuml.vim +++ b/indent/plantuml.vim @@ -77,7 +77,7 @@ endfunction function! s:getIncIndent() abort " Function to determine the s:incIndent pattern return - \ '^\s*\%(class\|object\|interface\|partition\|rectangle\|enum\|namespace\)\>.*{\s*$\|' . + \ '^\s*\%(class\|object\|interface\|partition\|rectangle\|enum\|namespace\|package\)\>.*{\s*$\|' . \ '^\s*\%(loop\|alt\|opt\|group\|critical\|else\|legend\|box\|if\|while\|fork\|split\)\>\|' . \ '^\s*ref\>[^:]*$\|' . \ '^\s*[hr]\?note\>\%(\%("[^"]*" \\)\@![^:]\)*$\|' . diff --git a/syntax/crystal.vim b/syntax/crystal.vim index edfd327e..8fdd2a6b 100644 --- a/syntax/crystal.vim +++ b/syntax/crystal.vim @@ -290,7 +290,7 @@ if !exists('g:crystal_no_special_methods') syn match crystalInclude "\[?!]\@!" display syn keyword crystalInclude extend require syn keyword crystalKeyword caller typeof pointerof sizeof instance_sizeof - syn match crystalRecord "\[?!]\@!" display + syn match crystalRecord "\/ @@ -136,6 +140,7 @@ syntax region plantumlText oneline matchgroup=plantumlSequenceDelay start=/^\.\{ " Usecase diagram syntax match plantumlUsecaseActor /:.\{-1,}:/ contains=plantumlSpecialString + " Mindmap diagram let s:mindmapHilightLinks = [ \ 'WarningMsg', 'Directory', 'Special', 'MoreMsg', 'Statement', 'Title', @@ -143,18 +148,20 @@ let s:mindmapHilightLinks = [ \ 'Function', 'Todo' \ ] -syntax match plantumlMindmap1 /^[-+*][_<>]\?/ contained - let i = 1 let contained = [] while i < len(s:mindmapHilightLinks) - execute "syntax match plantumlMindmap" . i . " /^\\%(\\s\\|[-+*]\\)\\{" . (i - 1) . "}[-+*][_<>]\\?/ contained" - execute "highlight default link plantumlMindmap" . i . " " . s:mindmapHilightLinks[i - 1] - call add(contained, "plantumlMindmap" . i) + execute 'syntax match plantumlMindmap' . i . ' /^\([-+*]\)\1\{' . (i - 1) . '}_\?\s\+/ contained' + execute 'syntax match plantumlMindmap' . i . ' /^\s\{' . (i - 1) . '}\*_\?\s\+/ contained' + execute 'highlight default link plantumlMindmap' . i . ' ' . s:mindmapHilightLinks[i - 1] + call add(contained, 'plantumlMindmap' . i) let i = i + 1 endwhile -execute "syntax region plantumlMindmap oneline start=/^\\s*[-+*]_\\?/ end=/$/ contains=" . join(contained, ',') +execute 'syntax region plantumlMindmap oneline start=/^\([-+*]\)\1*_\?\s/ end=/$/ contains=' . join(contained, ',') +" Markdown syntax +execute 'syntax region plantumlMindmap oneline start=/^\s*\*_\?\s/ end=/$/ contains=' . join(contained, ',') + " Skinparam keywords syntax case ignore diff --git a/syntax/rust.vim b/syntax/rust.vim index e9f41d19..b61caa5f 100644 --- a/syntax/rust.vim +++ b/syntax/rust.vim @@ -36,7 +36,7 @@ syn match rustAssert "\" " "bind:something", etc. syntax match svelteKeyword "\<[a-z]\+:[a-zA-Z|]\+=" contained containedin=htmlTag +" Mixed-case attributes are likely props. +syntax match svelteKeyword "\<[a-z]\+:[a-zA-Z|]\+=" contained containedin=htmlTag + " The "slot" attribute has special meaning. syntax keyword svelteKeyword slot contained containedin=htmlTag " According to vim-jsx, you can let jsBlock take care of ending the region. " https://github.com/mxw/vim-jsx/blob/master/after/syntax/jsx.vim -" -" ALLBUT,htmlSpecialTagName keeps Vim from marking CSS regions as jsBlock. syntax region svelteExpression start="{" end="" contains=jsBlock,javascriptBlock containedin=htmlString,htmlTag,htmlArg,htmlValue,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlHead,htmlTitle,htmlBoldItalicUnderline,htmlUnderlineBold,htmlUnderlineItalicBold,htmlUnderlineBoldItalic,htmlItalicUnderline,htmlItalicBold,htmlItalicBoldUnderline,htmlItalicUnderlineBold,htmlLink,htmlLeadingSpace,htmlBold,htmlBoldUnderline,htmlBoldItalic,htmlBoldUnderlineItalic,htmlUnderline,htmlUnderlineItalic,htmlItalic,htmlStrike,javaScript " Block conditionals. -- cgit v1.2.3