Skip to content

Commit a4f98d2

Browse files
committed
Update
1 parent 83422e0 commit a4f98d2

File tree

12 files changed

+150
-65
lines changed

12 files changed

+150
-65
lines changed

autoload/julia_blocks.vim

Lines changed: 70 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ function! s:unmap(function)
117117
return
118118
endif
119119
let mapids = a:function =~# "^move" ? ["n", "x", "o"] :
120-
\ a:function =~# "^select" ? ["x", "o"] :
121-
\ ["n"]
120+
\ a:function =~# "^select" ? ["x", "o"] :
121+
\ ["n"]
122122
let fn = "julia_blocks#" . a:function
123123
let cmd = "<buffer> " . chars
124124
for m in mapids
@@ -355,10 +355,10 @@ function! s:move_before_begin()
355355
endfunction
356356

357357
function! s:cycle_until_end()
358-
let pos = getpos('.')
358+
let c = 0
359359
while !s:on_end()
360+
let pos = getpos('.')
360361
call s:matchit()
361-
let c = 0
362362
if getpos('.') == pos || c > 1000
363363
" shouldn't happen, but let's avoid infinite loops anyway
364364
return 0
@@ -384,12 +384,12 @@ function! s:moveto_block_delim(toend, backwards, ...)
384384
while 1
385385
let searchret = search('\C' . pattern, flags)
386386
if !searchret
387-
return ret
387+
return ret
388388
endif
389389
exe "let skip = " . b:match_skip
390390
if !skip
391-
let ret = 1
392-
break
391+
let ret = 1
392+
break
393393
endif
394394
endwhile
395395
endfor
@@ -495,15 +495,15 @@ function! julia_blocks#moveblock_N()
495495
let start1_pos = ret_start ? getpos('.') : [0,0,0,0]
496496
call setpos('.', save_pos)
497497
if s:on_end()
498-
normal! h
498+
normal! h
499499
endif
500500
let ret_end = s:moveto_block_delim(1, 0, 1)
501501
let end1_pos = ret_end ? getpos('.') : [0,0,0,0]
502502

503503
if ret_start && (!ret_end || s:compare_pos(start1_pos, end1_pos) < 0)
504-
call setpos('.', start1_pos)
504+
call setpos('.', start1_pos)
505505
else
506-
call setpos('.', save_pos)
506+
call setpos('.', save_pos)
507507
endif
508508
endif
509509

@@ -564,7 +564,7 @@ function! julia_blocks#moveblock_p()
564564
if s:on_begin()
565565
call s:move_before_begin()
566566
if s:on_end()
567-
normal! l
567+
normal! l
568568
endif
569569
let save_pos = getpos('.')
570570
let ret_start = s:moveto_block_delim(0, 1, 1)
@@ -574,9 +574,9 @@ function! julia_blocks#moveblock_p()
574574
let end1_pos = ret_end ? getpos('.') : [0,0,0,0]
575575

576576
if ret_end && (!ret_start || s:compare_pos(start1_pos, end1_pos) < 0)
577-
call setpos('.', end1_pos)
577+
call setpos('.', end1_pos)
578578
else
579-
call setpos('.', save_pos)
579+
call setpos('.', save_pos)
580580
endif
581581
endif
582582

@@ -700,7 +700,7 @@ function! s:find_block(current_mode)
700700
endfunction
701701

702702
function! s:repeated_find(ai_mode)
703-
let repeat = b:jlblk_count + (a:ai_mode == 'i' && v:count1 > 1 ? 1 : 0)
703+
let repeat = b:jlblk_count + (a:ai_mode == 'i' && b:jlblk_count > 1 ? 1 : 0)
704704
for c in range(repeat)
705705
let current_mode = (c < repeat - 1 ? 'a' : a:ai_mode)
706706
let ret_find_block = s:find_block(current_mode)
@@ -734,8 +734,8 @@ function! julia_blocks#select_a(...)
734734

735735
let b:jlblk_doing_select = 1
736736

737-
" CursorMove is only triggered if end_pos
738-
" end_pos is different than the staring position;
737+
" CursorMoved is only triggered if end_pos
738+
" is different than the staring position;
739739
" so when starting from the 'd' in 'end' we need to
740740
" force it
741741
if current_pos == end_pos
@@ -746,6 +746,39 @@ function! julia_blocks#select_a(...)
746746
return [start_pos, end_pos]
747747
endfunction
748748

749+
let s:bracketBlocks = '\<julia\%(\%(\%(Printf\)\?Par\|SqBra\%(Idx\)\?\|CurBra\)Block\|ParBlockInRange\|StringVars\%(Par\|SqBra\|CurBra\)\|Dollar\%(Par\|SqBra\)\|QuotedParBlockS\?\)\>'
750+
let s:codeBlocks = '\<julia\%(Conditional\|While\|For\|Begin\|Function\|Macro\|Quote\|\%(Mutable\)\?Struct\|Let\|Do\|Exception\|Abstract\|Primitive\)Block\>'
751+
752+
function s:is_in_brackets(lnum, c)
753+
let stack = map(synstack(a:lnum, a:c), 'synIDattr(v:val, "name")')
754+
for i in range(len(stack)-1, 0, -1)
755+
if stack[i] =~# s:bracketBlocks
756+
return 1
757+
elseif stack[i] =~# s:codeBlocks
758+
return 0
759+
endif
760+
endfor
761+
return 0
762+
endfunction
763+
764+
function! s:seek_bracket_end()
765+
let [lnum, c] = [line('.'), col('.')]
766+
if !s:is_in_brackets(lnum, c)
767+
return
768+
endif
769+
while c > 0 && s:is_in_brackets(lnum, c)
770+
let c -= 1
771+
endwhile
772+
let c += 1
773+
if !s:is_in_brackets(lnum, c)
774+
echoerr "this is a bug, please report it"
775+
return
776+
end
777+
call cursor(lnum, c)
778+
call s:matchit()
779+
return
780+
endfunction
781+
749782
function! julia_blocks#select_i()
750783
call s:get_save_pos(!b:jlblk_did_select)
751784
let current_pos = getpos('.')
@@ -759,19 +792,32 @@ function! julia_blocks#select_i()
759792
return s:abort()
760793
endif
761794

762-
call setpos('.', end_pos)
763-
764795
let b:jlblk_doing_select = 1
765796

766-
let start_pos[1] += 1
767797
call setpos('.', start_pos)
768-
normal! ^
798+
normal! $
799+
call s:seek_bracket_end()
800+
let l = getline('.')
801+
while col('.') < len(l) && l[col('.'):] =~# '^\s*;'
802+
normal! l
803+
endwhile
804+
if col('.') == len(l) || l[col('.')] =~# '\s'
805+
normal! W
806+
else
807+
normal! l
808+
endif
769809
let start_pos = getpos('.')
770-
let end_pos[1] -= 1
771-
let end_pos[2] = len(getline(end_pos[1]))
772810

773-
" CursorMove is only triggered if end_pos
774-
" end_pos is different than the staring position;
811+
call setpos('.', end_pos)
812+
if end_pos[2] > 1 && getline('.')[end_pos[2]-2] =~# '\S'
813+
normal! h
814+
else
815+
normal! gE
816+
endif
817+
let end_pos = getpos('.')
818+
819+
" CursorMoved is only triggered if end_pos
820+
" is different than the staring position;
775821
" so when starting from the 'd' in 'end' we need to
776822
" force it
777823
if current_pos == end_pos

ftplugin/julia.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if exists("loaded_matchit")
7272
elseif attr == 'juliaBlKeyword'
7373
return b:julia_begin_keywordsm . ':' . b:julia_end_keywords
7474
elseif attr == 'juliaException'
75-
return b:julia_begin_keywordsm . ':\<\%(catch\|finally\)\>:' . b:julia_end_keywords
75+
return b:julia_begin_keywordsm . ':\<\%(catch\|else\|finally\)\>:' . b:julia_end_keywords
7676
endif
7777
return '\<\>:\<\>'
7878
endfunction

indent/julia.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function GetJuliaNestingStruct(lnum, ...)
9292
let i = JuliaMatch(a:lnum, line, '\<else\>', s)
9393
if i >= 0 && i == fb
9494
let s = i+1
95-
if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(else\)\=if\>'
95+
if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(\%(else\)\=if\|catch\)\>'
9696
let blocks_stack[-1] = 'else'
9797
else
9898
call add(blocks_stack, 'else')
@@ -110,7 +110,7 @@ function GetJuliaNestingStruct(lnum, ...)
110110
let i = JuliaMatch(a:lnum, line, '\<catch\>', s)
111111
if i >= 0 && i == fb
112112
let s = i+1
113-
if len(blocks_stack) > 0 && blocks_stack[-1] == 'try'
113+
if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(try\|finally\)\>'
114114
let blocks_stack[-1] = 'catch'
115115
else
116116
call add(blocks_stack, 'catch')
@@ -121,7 +121,7 @@ function GetJuliaNestingStruct(lnum, ...)
121121
let i = JuliaMatch(a:lnum, line, '\<finally\>', s)
122122
if i >= 0 && i == fb
123123
let s = i+1
124-
if len(blocks_stack) > 0 && (blocks_stack[-1] == 'try' || blocks_stack[-1] == 'catch')
124+
if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(try\|catch\|else\)\>'
125125
let blocks_stack[-1] = 'finally'
126126
else
127127
call add(blocks_stack, 'finally')

indent/svelte.vim

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function! GetSvelteIndent()
119119
let cursyns = s:SynsSOL(v:lnum)
120120
let cursyn = get(cursyns, 0, '')
121121

122-
if s:SynHTML(cursyn)
122+
if s:SynHTML(cursyn) && !s:IsMultipleLineSvelteExpression(curline, cursyns)
123123
call s:Log('syntax: html')
124124
let ind = XmlIndentGet(v:lnum, 0)
125125
if prevline =~? s:empty_tag
@@ -233,6 +233,20 @@ function! s:SynHTML(syn)
233233
return a:syn ==? 'htmlSvelteTemplate'
234234
endfunction
235235

236+
function! s:IsMultipleLineSvelteExpression(curline, syns)
237+
if a:curline =~ '^\s*{.*}\s*$'
238+
return 0
239+
endif
240+
241+
for syn in a:syns
242+
if syn ==? 'svelteExpression'
243+
return 1
244+
endif
245+
endfor
246+
247+
return 0
248+
endfunction
249+
236250
function! s:SynBlockBody(syn)
237251
return a:syn ==? 'svelteBlockBody'
238252
endfunction

syntax/julia.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ syntax region juliaLetBlock matchgroup=juliaBlKeyword start="\<let\>" end="\<e
183183
syntax region juliaDoBlock matchgroup=juliaBlKeyword start="\<do\>" end="\<end\>" contains=@juliaExpressions fold
184184
syntax region juliaModuleBlock matchgroup=juliaBlKeyword start="\<\%(bare\)\?module\>" end="\<end\>" contains=@juliaExpressions fold
185185
syntax region juliaExceptionBlock matchgroup=juliaException start="\<try\>" end="\<end\>" contains=@juliaExpressions,juliaCatchBlock,juliaFinallyBlock fold
186-
syntax region juliaCatchBlock matchgroup=juliaException transparent contained start="\<catch\>" end="\<end\>"me=s-1 contains=@juliaExpressions,juliaFinallyBlock
187-
syntax region juliaFinallyBlock matchgroup=juliaException transparent contained start="\<finally\>" end="\<end\>"me=s-1 contains=@juliaExpressions
186+
syntax region juliaCatchBlock matchgroup=juliaException transparent contained start="\<catch\>" end="\<end\>"me=s-1 contains=@juliaExpressions,juliaTryElseBlock,juliaFinallyBlock
187+
syntax region juliaTryElseBlock matchgroup=juliaException transparent contained start="\<else\>" end="\<end\>"me=s-1 contains=@juliaExpressions,juliaFinallyBlock
188+
syntax region juliaFinallyBlock matchgroup=juliaException transparent contained start="\<finally\>" end="\<end\>"me=s-1 contains=@juliaExpressions,juliaCatchBlock
188189
syntax region juliaAbstractBlock matchgroup=juliaBlKeyword start="\<abstract\s\+type\>" end="\<end\>" fold contains=@juliaExpressions,juliaStructR
189190
syntax region juliaPrimitiveBlock matchgroup=juliaBlKeyword start="\<primitive\s\+type\>" end="\<end\>" fold contains=@juliaExpressions,juliaStructR
190191

syntax/smt2.vim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,13 @@ syntax keyword smt2Builtin
129129
\ rotate_left
130130
\ rotate_right
131131
\ sat
132-
\ sat
133132
\ select
134133
\ sign_extend
135134
\ store
136135
\ to_int
137136
\ to_real
138137
\ true
139138
\ unsat
140-
\ unsat
141139
\ xor
142140
\ zero_extend
143141
syntax match smt2Builtin "\m\C[\^\~]"

syntax/solidity.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ syn keyword solMethod delete new var return import
247247
syn region solMethodParens start='(' end=')' contains=solString,solConstant,solNumber,solFuncCall,solTypeCast,solMethod,solComma,solOperator contained transparent
248248
syn keyword solMethod nextgroup=solMethodParens skipwhite skipempty
249249
\ blockhash require revert assert keccak256 sha256
250-
\ ripemd160 ecrecover addmod mullmod selfdestruct
250+
\ ripemd160 ecrecover addmod mulmod selfdestruct
251251

252252
hi def link solMethod Special
253253

syntax/svelte-html.vim

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,41 @@ syntax match svelteComponentName containedin=htmlTagN '\v\C<[a-z0-9]+(-[a-z0-9]+
2222
syntax match svelteComponentName containedin=htmlTagN '\vsvelte:\w*'
2323

2424
" Syntax for vim-svelte-theme
25-
syntax match htmlAttr '\v(\S|\<)@<![^\/\<\>[:blank:]]+' containedin=htmlTag
25+
syntax match htmlAttr '\v(\S|\<)@<![^\/\<\>[:blank:]]+'
26+
\ containedin=htmlTag
2627
\ contains=htmlString,svelteValue,htmlArg
2728
syntax match htmlAttrEqual '\v\=' containedin=htmlAttr
2829

29-
syntax match svelteAttr
30-
\ '\v(\S)@<!(on|bind|use|in|out|transition|animate|class):[^\=\>[:blank:]]+(\=\"[^"]*\"|\=\{[^}]*\})?'
30+
syntax match svelteAttr
31+
\ '\(\S\)\@<!\w\+:[^=>[:blank:]]\+\(="[^"]*"\|={[^}]*}\)\?'
3132
\ containedin=htmlTag
3233
\ contains=svelteKey,svelteValue
33-
34-
syntax match svelteKey contained '\v(on|bind|use|in|out|transition|animate|class):[^\=\>[:blank:]]+'
35-
syntax match svelteValue contained '\v\{[^}]*\}'
34+
syntax match svelteValue contained '{[^}]*}'
35+
syntax match svelteKey contained '\w\+:[^=>[:blank:]]\+'
3636

3737
syntax region svelteExpression
3838
\ containedin=htmlH.*,htmlItalic
3939
\ matchgroup=svelteBrace
40-
\ transparent
4140
\ start="{"
42-
\ end="}\(}\)\@!"
41+
\ end="}\(}\|;\)\@!"
4342

43+
" Multiple lines expressions are supposed to end with '}}'
4444
syntax region svelteExpression
45-
\ containedin=htmlSvelteTemplate,svelteValue,htmlString,htmlValue,htmlArg,htmlTag
46-
\ contains=@simpleJavascriptExpression,svelteAtTags
45+
\ containedin=svelteValue,htmlValue,htmlAttr
46+
\ contains=@simpleJavascriptExpression
4747
\ matchgroup=svelteBrace
48-
\ transparent
4948
\ start="{"
50-
\ end="}\(}\)\@!"
49+
\ end="\(}\)\@<=}"
5150

5251
syntax region svelteExpression
53-
\ containedin=htmlTag
54-
\ contains=@simpleJavascriptExpression,svelteAtTags,svelteShortProp
52+
\ containedin=htmlSvelteTemplate,svelteValue,htmlString,htmlArg,htmlTag,htmlAttr,htmlValue,htmlAttr
53+
\ contains=@simpleJavascriptExpression,svelteAtTags
5554
\ matchgroup=svelteBrace
56-
\ transparent
5755
\ start="{"
58-
\ end="}\(}\)\@!"
56+
\ end="}\(}\|;\)\@!"
57+
\ oneline
5958

60-
syntax match svelteAtTags '\v\@(html|debug)'
61-
syntax match svelteShortProp '\v<\w+>'
59+
syntax match svelteAtTags '@\(html\|debug\)'
6260

6361
syntax region svelteBlockBody
6462
\ containedin=htmlSvelteTemplate,htmlLink
@@ -101,7 +99,9 @@ syntax region javaScriptTemplateExpression
10199
syntax match javaScriptNumber '\v<-?\d+L?>|0[xX][0-9a-fA-F]+>' contained
102100
syntax match javaScriptOperator '[-!|&+<>=%*~^]' contained
103101
syntax match javaScriptOperator '\v(*)@<!/(/|*)@!' contained
104-
syntax keyword javaScriptOperator delete instanceof typeof void new in of contained
102+
syntax keyword javaScriptOperator contained
103+
\ delete instanceof typeof void new in of const let var
104+
\ return function
105105

106106
highlight default link svelteAttr htmlTag
107107
if s:highlight_svelte_attr
@@ -112,7 +112,9 @@ else
112112
highlight default link svelteValue String
113113
endif
114114

115+
highlight default link svelteExpression None
115116
highlight default link svelteBrace Type
117+
highlight default link svelteAtTags Type
116118
highlight default link svelteBlockKeyword Statement
117119
highlight default link svelteComponentName htmlTagName
118120
highlight default link javaScriptTemplateString String
@@ -122,6 +124,5 @@ highlight default link javaScriptNumber Constant
122124
highlight default link javaScriptOperator Operator
123125
highlight default link svelteAttr htmlTag
124126
highlight default link svelteAttrEqual htmlTag
125-
highlight default link svelteShortProp htmlValue
126127
"}}}
127128
" vim: fdm=marker

syntax/swayconfig.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ syn keyword swayConfigDrawingMarksKeyword show_marks contained
192192
syn match swayConfigDrawingMarks /^\s*show_marks\s\+\(yes\|no\)\s\?$/ contains=swayConfigFocusWrappingType,swayConfigDrawingMarksKeyword
193193

194194
" Group mode/bar
195-
syn keyword swayConfigBlockKeyword mode bar colors i3bar_command status_command position exec mode hidden_state modifier id position output background statusline tray_output tray_padding separator separator_symbol workspace_buttons strip_workspace_numbers binding_mode_indicator focused_workspace active_workspace inactive_workspace urgent_workspace binding_mode contained
195+
syn keyword swayConfigBlockKeyword set input mode bar colors i3bar_command status_command position exec mode hidden_state modifier id position output background statusline tray_output tray_padding separator separator_symbol workspace_buttons strip_workspace_numbers binding_mode_indicator focused_workspace active_workspace inactive_workspace urgent_workspace binding_mode contained
196196
syn region swayConfigBlock start=+.*s\?{$+ end=+^}$+ contains=swayConfigBlockKeyword,swayConfigString,swayConfigBind,swayConfigComment,swayConfigFont,swayConfigFocusWrappingType,swayConfigColor,swayConfigVariable transparent keepend extend
197197

198198
" Line continuation
@@ -202,6 +202,10 @@ syn region swayConfigLineCont start=/^.*\\$/ end=/^.*$/ contains=swayConfigBlock
202202
syn keyword swayConfigInclude include contained
203203
syn match swayConfigFile /^include\s\(\~\?\/.*$\|\.\{0,2}\/.*$\)/ contains=swayConfigInclude
204204

205+
" xwayland
206+
syn keyword swayConfigXwaylandKeyword xwayland contained
207+
syn match swayConfigXwaylandModifier /^\s*xwayland\s\+\(enable\|disable\|force\)\s\?$/ contains=swayConfigXwaylandKeyword
208+
205209
" Define the highlighting.
206210
let b:current_syntax = "swayconfig"
207211
hi! def link swayConfigError Error
@@ -281,5 +285,6 @@ hi! def link swayConfigFloatingModifier Identifier
281285
hi! def link swayConfigFloatingMouseAction Type
282286
hi! def link swayConfigFocusKeyword Type
283287
hi! def link swayConfigFocusType Identifier
284-
288+
hi! def link swayConfigXwaylandKeyword Identifier
289+
hi! def link swayConfigXwaylandModifier Type
285290

0 commit comments

Comments
 (0)