From a4f98d2a9e9dfeb110d4a910ea177432fec88b81 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sat, 12 Mar 2022 15:46:18 +0100 Subject: Update --- autoload/julia_blocks.vim | 94 +++++++++++++++++++++++++++++++++++------------ ftplugin/julia.vim | 2 +- indent/julia.vim | 6 +-- indent/svelte.vim | 16 +++++++- syntax/julia.vim | 5 ++- syntax/smt2.vim | 2 - syntax/solidity.vim | 2 +- syntax/svelte-html.vim | 41 +++++++++++---------- syntax/swayconfig.vim | 9 ++++- syntax/swift.vim | 20 +++++++++- syntax/tmux.vim | 16 ++++---- syntax/zig.vim | 2 + 12 files changed, 150 insertions(+), 65 deletions(-) diff --git a/autoload/julia_blocks.vim b/autoload/julia_blocks.vim index 11bbb435..0f50eb76 100644 --- a/autoload/julia_blocks.vim +++ b/autoload/julia_blocks.vim @@ -117,8 +117,8 @@ function! s:unmap(function) return endif let mapids = a:function =~# "^move" ? ["n", "x", "o"] : - \ a:function =~# "^select" ? ["x", "o"] : - \ ["n"] + \ a:function =~# "^select" ? ["x", "o"] : + \ ["n"] let fn = "julia_blocks#" . a:function let cmd = " " . chars for m in mapids @@ -355,10 +355,10 @@ function! s:move_before_begin() endfunction function! s:cycle_until_end() - let pos = getpos('.') + let c = 0 while !s:on_end() + let pos = getpos('.') call s:matchit() - let c = 0 if getpos('.') == pos || c > 1000 " shouldn't happen, but let's avoid infinite loops anyway return 0 @@ -384,12 +384,12 @@ function! s:moveto_block_delim(toend, backwards, ...) while 1 let searchret = search('\C' . pattern, flags) if !searchret - return ret + return ret endif exe "let skip = " . b:match_skip if !skip - let ret = 1 - break + let ret = 1 + break endif endwhile endfor @@ -495,15 +495,15 @@ function! julia_blocks#moveblock_N() let start1_pos = ret_start ? getpos('.') : [0,0,0,0] call setpos('.', save_pos) if s:on_end() - normal! h + normal! h endif let ret_end = s:moveto_block_delim(1, 0, 1) let end1_pos = ret_end ? getpos('.') : [0,0,0,0] if ret_start && (!ret_end || s:compare_pos(start1_pos, end1_pos) < 0) - call setpos('.', start1_pos) + call setpos('.', start1_pos) else - call setpos('.', save_pos) + call setpos('.', save_pos) endif endif @@ -564,7 +564,7 @@ function! julia_blocks#moveblock_p() if s:on_begin() call s:move_before_begin() if s:on_end() - normal! l + normal! l endif let save_pos = getpos('.') let ret_start = s:moveto_block_delim(0, 1, 1) @@ -574,9 +574,9 @@ function! julia_blocks#moveblock_p() let end1_pos = ret_end ? getpos('.') : [0,0,0,0] if ret_end && (!ret_start || s:compare_pos(start1_pos, end1_pos) < 0) - call setpos('.', end1_pos) + call setpos('.', end1_pos) else - call setpos('.', save_pos) + call setpos('.', save_pos) endif endif @@ -700,7 +700,7 @@ function! s:find_block(current_mode) endfunction function! s:repeated_find(ai_mode) - let repeat = b:jlblk_count + (a:ai_mode == 'i' && v:count1 > 1 ? 1 : 0) + let repeat = b:jlblk_count + (a:ai_mode == 'i' && b:jlblk_count > 1 ? 1 : 0) for c in range(repeat) let current_mode = (c < repeat - 1 ? 'a' : a:ai_mode) let ret_find_block = s:find_block(current_mode) @@ -734,8 +734,8 @@ function! julia_blocks#select_a(...) let b:jlblk_doing_select = 1 - " CursorMove is only triggered if end_pos - " end_pos is different than the staring position; + " CursorMoved is only triggered if end_pos + " is different than the staring position; " so when starting from the 'd' in 'end' we need to " force it if current_pos == end_pos @@ -746,6 +746,39 @@ function! julia_blocks#select_a(...) return [start_pos, end_pos] endfunction +let s:bracketBlocks = '\' +let s:codeBlocks = '\' + +function s:is_in_brackets(lnum, c) + let stack = map(synstack(a:lnum, a:c), 'synIDattr(v:val, "name")') + for i in range(len(stack)-1, 0, -1) + if stack[i] =~# s:bracketBlocks + return 1 + elseif stack[i] =~# s:codeBlocks + return 0 + endif + endfor + return 0 +endfunction + +function! s:seek_bracket_end() + let [lnum, c] = [line('.'), col('.')] + if !s:is_in_brackets(lnum, c) + return + endif + while c > 0 && s:is_in_brackets(lnum, c) + let c -= 1 + endwhile + let c += 1 + if !s:is_in_brackets(lnum, c) + echoerr "this is a bug, please report it" + return + end + call cursor(lnum, c) + call s:matchit() + return +endfunction + function! julia_blocks#select_i() call s:get_save_pos(!b:jlblk_did_select) let current_pos = getpos('.') @@ -759,19 +792,32 @@ function! julia_blocks#select_i() return s:abort() endif - call setpos('.', end_pos) - let b:jlblk_doing_select = 1 - let start_pos[1] += 1 call setpos('.', start_pos) - normal! ^ + normal! $ + call s:seek_bracket_end() + let l = getline('.') + while col('.') < len(l) && l[col('.'):] =~# '^\s*;' + normal! l + endwhile + if col('.') == len(l) || l[col('.')] =~# '\s' + normal! W + else + normal! l + endif let start_pos = getpos('.') - let end_pos[1] -= 1 - let end_pos[2] = len(getline(end_pos[1])) - " CursorMove is only triggered if end_pos - " end_pos is different than the staring position; + call setpos('.', end_pos) + if end_pos[2] > 1 && getline('.')[end_pos[2]-2] =~# '\S' + normal! h + else + normal! gE + endif + let end_pos = getpos('.') + + " CursorMoved is only triggered if end_pos + " is different than the staring position; " so when starting from the 'd' in 'end' we need to " force it if current_pos == end_pos diff --git a/ftplugin/julia.vim b/ftplugin/julia.vim index 1213c6b7..e33b1a42 100644 --- a/ftplugin/julia.vim +++ b/ftplugin/julia.vim @@ -72,7 +72,7 @@ if exists("loaded_matchit") elseif attr == 'juliaBlKeyword' return b:julia_begin_keywordsm . ':' . b:julia_end_keywords elseif attr == 'juliaException' - return b:julia_begin_keywordsm . ':\<\%(catch\|finally\)\>:' . b:julia_end_keywords + return b:julia_begin_keywordsm . ':\<\%(catch\|else\|finally\)\>:' . b:julia_end_keywords endif return '\<\>:\<\>' endfunction diff --git a/indent/julia.vim b/indent/julia.vim index 9f7c4dd0..fabef022 100644 --- a/indent/julia.vim +++ b/indent/julia.vim @@ -92,7 +92,7 @@ function GetJuliaNestingStruct(lnum, ...) let i = JuliaMatch(a:lnum, line, '\', s) if i >= 0 && i == fb let s = i+1 - if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(else\)\=if\>' + if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(\%(else\)\=if\|catch\)\>' let blocks_stack[-1] = 'else' else call add(blocks_stack, 'else') @@ -110,7 +110,7 @@ function GetJuliaNestingStruct(lnum, ...) let i = JuliaMatch(a:lnum, line, '\', s) if i >= 0 && i == fb let s = i+1 - if len(blocks_stack) > 0 && blocks_stack[-1] == 'try' + if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(try\|finally\)\>' let blocks_stack[-1] = 'catch' else call add(blocks_stack, 'catch') @@ -121,7 +121,7 @@ function GetJuliaNestingStruct(lnum, ...) let i = JuliaMatch(a:lnum, line, '\', s) if i >= 0 && i == fb let s = i+1 - if len(blocks_stack) > 0 && (blocks_stack[-1] == 'try' || blocks_stack[-1] == 'catch') + if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(try\|catch\|else\)\>' let blocks_stack[-1] = 'finally' else call add(blocks_stack, 'finally') diff --git a/indent/svelte.vim b/indent/svelte.vim index 147df65b..bae715df 100644 --- a/indent/svelte.vim +++ b/indent/svelte.vim @@ -119,7 +119,7 @@ function! GetSvelteIndent() let cursyns = s:SynsSOL(v:lnum) let cursyn = get(cursyns, 0, '') - if s:SynHTML(cursyn) + if s:SynHTML(cursyn) && !s:IsMultipleLineSvelteExpression(curline, cursyns) call s:Log('syntax: html') let ind = XmlIndentGet(v:lnum, 0) if prevline =~? s:empty_tag @@ -233,6 +233,20 @@ function! s:SynHTML(syn) return a:syn ==? 'htmlSvelteTemplate' endfunction +function! s:IsMultipleLineSvelteExpression(curline, syns) + if a:curline =~ '^\s*{.*}\s*$' + return 0 + endif + + for syn in a:syns + if syn ==? 'svelteExpression' + return 1 + endif + endfor + + return 0 +endfunction + function! s:SynBlockBody(syn) return a:syn ==? 'svelteBlockBody' endfunction diff --git a/syntax/julia.vim b/syntax/julia.vim index 3d02d5ed..0dcb1382 100644 --- a/syntax/julia.vim +++ b/syntax/julia.vim @@ -183,8 +183,9 @@ syntax region juliaLetBlock matchgroup=juliaBlKeyword start="\" end="\[:blank:]]+' containedin=htmlTag +syntax match htmlAttr '\v(\S|\<)@[:blank:]]+' + \ containedin=htmlTag \ contains=htmlString,svelteValue,htmlArg syntax match htmlAttrEqual '\v\=' containedin=htmlAttr -syntax match svelteAttr - \ '\v(\S)@[:blank:]]+(\=\"[^"]*\"|\=\{[^}]*\})?' +syntax match svelteAttr + \ '\(\S\)\@[:blank:]]\+\(="[^"]*"\|={[^}]*}\)\?' \ containedin=htmlTag \ contains=svelteKey,svelteValue - -syntax match svelteKey contained '\v(on|bind|use|in|out|transition|animate|class):[^\=\>[:blank:]]+' -syntax match svelteValue contained '\v\{[^}]*\}' +syntax match svelteValue contained '{[^}]*}' +syntax match svelteKey contained '\w\+:[^=>[:blank:]]\+' syntax region svelteExpression \ containedin=htmlH.*,htmlItalic \ matchgroup=svelteBrace - \ transparent \ start="{" - \ end="}\(}\)\@!" + \ end="}\(}\|;\)\@!" +" Multiple lines expressions are supposed to end with '}}' syntax region svelteExpression - \ containedin=htmlSvelteTemplate,svelteValue,htmlString,htmlValue,htmlArg,htmlTag - \ contains=@simpleJavascriptExpression,svelteAtTags + \ containedin=svelteValue,htmlValue,htmlAttr + \ contains=@simpleJavascriptExpression \ matchgroup=svelteBrace - \ transparent \ start="{" - \ end="}\(}\)\@!" + \ end="\(}\)\@<=}" syntax region svelteExpression - \ containedin=htmlTag - \ contains=@simpleJavascriptExpression,svelteAtTags,svelteShortProp + \ containedin=htmlSvelteTemplate,svelteValue,htmlString,htmlArg,htmlTag,htmlAttr,htmlValue,htmlAttr + \ contains=@simpleJavascriptExpression,svelteAtTags \ matchgroup=svelteBrace - \ transparent \ start="{" - \ end="}\(}\)\@!" + \ end="}\(}\|;\)\@!" + \ oneline -syntax match svelteAtTags '\v\@(html|debug)' -syntax match svelteShortProp '\v<\w+>' +syntax match svelteAtTags '@\(html\|debug\)' syntax region svelteBlockBody \ containedin=htmlSvelteTemplate,htmlLink @@ -101,7 +99,9 @@ syntax region javaScriptTemplateExpression syntax match javaScriptNumber '\v<-?\d+L?>|0[xX][0-9a-fA-F]+>' contained syntax match javaScriptOperator '[-!|&+<>=%*~^]' contained syntax match javaScriptOperator '\v(*)@:p'), 'tmux', 'syntax/tmux.vim') endif " Language: tmux(1) configuration file -" Version: 3.3-rc (git-85ef7359) +" Version: 3.3-rc (git-ee3f1d25) " URL: https://github.com/ericpruitt/tmux.vim/ " Maintainer: Eric Pruitt " License: 2-Clause BSD (http://opensource.org/licenses/BSD-2-Clause) @@ -88,13 +88,13 @@ syn keyword tmuxOptions \ pane-border-indicators pane-border-lines pane-border-status \ pane-border-style pane-colours popup-border-lines popup-border-style \ popup-style prefix prefix2 prompt-history-limit remain-on-exit -\ renumber-windows repeat-time set-clipboard set-titles set-titles-string -\ silence-action status status-bg status-fg status-format status-interval -\ status-justify status-keys status-left status-left-length -\ status-left-style status-position status-right status-right-length -\ status-right-style status-style synchronize-panes terminal-features -\ terminal-overrides update-environment user-keys visual-activity -\ visual-bell visual-silence window-active-style window-size +\ remain-on-exit-format renumber-windows repeat-time set-clipboard +\ set-titles set-titles-string silence-action status status-bg status-fg +\ status-format status-interval status-justify status-keys status-left +\ status-left-length status-left-style status-position status-right +\ status-right-length status-right-style status-style synchronize-panes +\ terminal-features terminal-overrides update-environment user-keys +\ visual-activity visual-bell visual-silence window-active-style window-size \ window-status-activity-style window-status-bell-style \ window-status-current-format window-status-current-style \ window-status-format window-status-last-style window-status-separator diff --git a/syntax/zig.vim b/syntax/zig.vim index 287ce0ba..9441b37f 100644 --- a/syntax/zig.vim +++ b/syntax/zig.vim @@ -203,6 +203,8 @@ let s:zig_syntax_keywords = { \ , "@floor" \ , "@ceil" \ , "@trunc" + \ , "@wasmMemorySize" + \ , "@wasmMemoryGrow" \ , "@round"] \ } -- cgit v1.2.3