This commit is contained in:
Adam Stankiewicz
2020-04-25 21:03:34 +02:00
parent 14dc82fc4e
commit 68b2748af1
15 changed files with 292 additions and 300 deletions

View File

@@ -31,6 +31,11 @@ lockvar g:crystal#indent#sol
let g:crystal#indent#eol = '\s*\%(%}\)\=\ze\s*\%(#.*\)\=$' let g:crystal#indent#eol = '\s*\%(%}\)\=\ze\s*\%(#.*\)\=$'
lockvar g:crystal#indent#eol lockvar g:crystal#indent#eol
" Regex that defines blocks.
let g:crystal#indent#block_regex =
\ '\%(\<do\>\|%\@1<!{\)\s*\%(|[^|]*|\)\='.g:crystal#indent#eol
lockvar g:crystal#indent#block_regex
" Regex that defines the start-match for the 'end' keyword. " Regex that defines the start-match for the 'end' keyword.
" NOTE: This *should* properly match the 'do' only at the end of the " NOTE: This *should* properly match the 'do' only at the end of the
" line " line
@@ -43,7 +48,7 @@ let g:crystal#indent#end_start_regex =
\ '\<\%(if\|unless\|while\|until\|case\|begin\|for\|union\)\>' . \ '\<\%(if\|unless\|while\|until\|case\|begin\|for\|union\)\>' .
\ '\)' . \ '\)' .
\ '\|' . \ '\|' .
\ '.\{-}\zs\<do\s*\%(|.*|\)\='.g:crystal#indent#eol \ g:crystal#indent#block_regex
lockvar g:crystal#indent#end_start_regex lockvar g:crystal#indent#end_start_regex
" Regex that defines the middle-match for the 'end' keyword. " Regex that defines the middle-match for the 'end' keyword.
@@ -80,13 +85,15 @@ lockvar g:crystal#indent#crystal_type_declaration
" Regex that defines continuation lines, not including (, {, or [. " Regex that defines continuation lines, not including (, {, or [.
let g:crystal#indent#non_bracket_continuation_regex = let g:crystal#indent#non_bracket_continuation_regex =
\ '\%(' . \ '\%(' .
\ '[\\.,:/%+\-=~<>|&^]' . \ '[\\.,:/%+\-=~<>&^]' .
\ '\|' .
\ '\%(\%(\<do\>\|%\@1<!{\)\s*|[^|]*\)\@<!|' .
\ '\|' . \ '\|' .
\ '\W?' . \ '\W?' .
\ '\|' . \ '\|' .
\ '\<\%(if\|unless\)\>' . \ '\<\%(if\|unless\)\>' .
\ '\|' . \ '\|' .
\ '\%('.g:crystal#indent#sol.g:crystal#indent#crystal_type_declaration.'\h\k*\)\@<!\*' . \ '\%('.g:crystal#indent#crystal_type_declaration.'\h\k*\)\@<!\*' .
\ '\)' . \ '\)' .
\ g:crystal#indent#eol \ g:crystal#indent#eol
lockvar g:crystal#indent#non_bracket_continuation_regex lockvar g:crystal#indent#non_bracket_continuation_regex
@@ -117,19 +124,6 @@ lockvar g:crystal#indent#continuable_regex
let g:crystal#indent#splat_regex = '[[,(]\s*\*\s*\%(#.*\)\=$' let g:crystal#indent#splat_regex = '[[,(]\s*\*\s*\%(#.*\)\=$'
lockvar g:crystal#indent#splat_regex lockvar g:crystal#indent#splat_regex
" Regex that defines blocks.
"
" Note that there's a slight problem with this regex and crystal#indent#continuation_regex.
" Code like this will be matched by both:
"
" method_call do |(a, b)|
"
" The reason is that the pipe matches a hanging "|" operator.
"
let g:crystal#indent#block_regex =
\ '\%(\<do:\@!\>\|%\@1<!{\)\s*\%(|\s*(*\s*\%([*@&]\=\h\w*,\=\s*\)\%(,\s*(*\s*[*@&]\=\h\w*\s*)*\s*\)*|\)\=\s*\%(%}\)\=\s*\%(#.*\)\=$'
lockvar g:crystal#indent#block_regex
let g:crystal#indent#block_continuation_regex = '^\s*[^])}\t ].*'.g:crystal#indent#block_regex let g:crystal#indent#block_continuation_regex = '^\s*[^])}\t ].*'.g:crystal#indent#block_regex
lockvar g:crystal#indent#block_continuation_regex lockvar g:crystal#indent#block_continuation_regex
@@ -368,4 +362,6 @@ function! crystal#indent#FindContainingClass() abort
return 0 return 0
endfunction endfunction
" vim: sw=2 sts=2 et:
endif endif

View File

@@ -368,4 +368,6 @@ endfunction
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo
" vim: sw=2 sts=2 et:
endif endif

View File

@@ -31,4 +31,6 @@ function! ecrystal#SetSubtype() abort
endif endif
endfunction endfunction
" vim: sw=2 sts=2 et:
endif endif

View File

@@ -310,7 +310,7 @@ function! go#config#FmtAutosave() abort
endfunction endfunction
function! go#config#ImportsAutosave() abort function! go#config#ImportsAutosave() abort
return get(g:, 'go_imports_autosave', 1) return get(g:, 'go_imports_autosave', 0)
endfunction endfunction
function! go#config#SetFmtAutosave(value) abort function! go#config#SetFmtAutosave(value) abort

View File

@@ -502,13 +502,13 @@ function! s:SearchTestFunctionNameUnderCursor() abort
" Search the end of test function (closing brace) to ensure that the " Search the end of test function (closing brace) to ensure that the
" cursor position is within function definition " cursor position is within function definition
if maparg('<Plug>(MatchitNormalForward)') ==# '' if maparg('<Plug>(MatchitNormalForward)') ==# ''
normal! % keepjumps normal! %
else else
" Prefer matchit.vim official plugin to native % since the plugin " Prefer matchit.vim official plugin to native % since the plugin
" provides better behavior than original % (#391) " provides better behavior than original % (#391)
" To load the plugin, run: " To load the plugin, run:
" :packadd matchit " :packadd matchit
execute 'normal' "\<Plug>(MatchitNormalForward)" execute 'keepjumps' 'normal' "\<Plug>(MatchitNormalForward)"
endif endif
if line('.') < cursor_line if line('.') < cursor_line
return '' return ''

View File

@@ -89,6 +89,6 @@ endif
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo
" vim: nowrap sw=2 sts=2 ts=8: " vim: sw=2 sts=2 et:
endif endif

View File

@@ -33,7 +33,7 @@ if exists("loaded_matchit")
" note: begin_keywords must contain all blocks, in order " note: begin_keywords must contain all blocks, in order
" for nested-structures-skipping to work properly " for nested-structures-skipping to work properly
" note: 'mutable struct' and 'strcut' are defined separately because " note: 'mutable struct' and 'struct' are defined separately because
" using \? puts the cursor on 'struct' instead of 'mutable' for some reason " using \? puts the cursor on 'struct' instead of 'mutable' for some reason
let b:julia_begin_keywords = '\%(\%(\.\s*\)\@<!\|\%(@\s*.\s*\)\@<=\)\<\%(function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|do\|\%(bare\)\?module\|quote\|if\|for\|while\|try\)\>' let b:julia_begin_keywords = '\%(\%(\.\s*\)\@<!\|\%(@\s*.\s*\)\@<=\)\<\%(function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|do\|\%(bare\)\?module\|quote\|if\|for\|while\|try\)\>'
" note: the following regex not only recognizes macros, but also local/global keywords. " note: the following regex not only recognizes macros, but also local/global keywords.

View File

@@ -42,7 +42,7 @@ function GetCrystalIndent(...)
let clnum = a:0 ? a:1 : v:lnum let clnum = a:0 ? a:1 : v:lnum
" Set up variables for restoring position in file " Set up variables for restoring position in file
let vcol = col(clnum) let vcol = col('.')
" Work on the current line {{{2 " Work on the current line {{{2
" ------------------------ " ------------------------
@@ -170,7 +170,7 @@ function GetCrystalIndent(...)
" "
" If it contained hanging closing brackets, find the rightmost one, find its " If it contained hanging closing brackets, find the rightmost one, find its
" match and indent according to that. " match and indent according to that.
if line =~# '[[({]' || line =~# '[])}]\s*\%(#.*\)\=$' if line =~# '[[({]' || line =~# '[])]\s*\%(#.*\)\=$'
let [opening, closing] = crystal#indent#ExtraBrackets(lnum) let [opening, closing] = crystal#indent#ExtraBrackets(lnum)
if opening.pos != -1 if opening.pos != -1
@@ -186,7 +186,7 @@ function GetCrystalIndent(...)
endif endif
elseif closing.pos != -1 elseif closing.pos != -1
call cursor(lnum, closing.pos + 1) call cursor(lnum, closing.pos + 1)
normal! % keepjumps normal! %
if crystal#indent#Match(line('.'), g:crystal#indent#crystal_indent_keywords) if crystal#indent#Match(line('.'), g:crystal#indent#crystal_indent_keywords)
return indent('.') + s:sw() return indent('.') + s:sw()

View File

@@ -370,23 +370,13 @@ function GetJuliaIndent()
" Analyse the reference line " Analyse the reference line
let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(lnum, st, lim) let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(lnum, st, lim)
" Increase indentation for each newly opened block in the reference line
" Increase indentation for each newly opened block let ind += shiftwidth() * num_open_blocks
" in the reference line
while num_open_blocks > 0
let ind += &sw
let num_open_blocks -= 1
endwhile
" Analyse the current line " Analyse the current line
let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(v:lnum) let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(v:lnum)
" Decrease indentation for each closed block in the current line
" Decrease indentation for each closed block let ind -= shiftwidth() * num_closed_blocks
" in the current line
while num_closed_blocks > 0
let ind -= &sw
let num_closed_blocks -= 1
endwhile
return ind return ind
endfunction endfunction

View File

@@ -7,8 +7,9 @@ syntax match shellbang "^#!.*iojs\>"
"JavaScript comments "JavaScript comments
syntax keyword typescriptCommentTodo TODO FIXME XXX TBD syntax keyword typescriptCommentTodo TODO FIXME XXX TBD
syntax match typescriptMagicComment "@ts-\%(ignore\|expect-error\)\>"
syntax match typescriptLineComment "//.*" syntax match typescriptLineComment "//.*"
\ contains=@Spell,typescriptCommentTodo,typescriptRef \ contains=@Spell,typescriptCommentTodo,typescriptRef,typescriptMagicComment
syntax region typescriptComment syntax region typescriptComment
\ start="/\*" end="\*/" \ start="/\*" end="\*/"
\ contains=@Spell,typescriptCommentTodo extend \ contains=@Spell,typescriptCommentTodo extend

View File

@@ -57,6 +57,7 @@ if exists("did_typescript_hilink")
HiLink typescriptLineComment Comment HiLink typescriptLineComment Comment
HiLink typescriptDocComment Comment HiLink typescriptDocComment Comment
HiLink typescriptCommentTodo Todo HiLink typescriptCommentTodo Todo
HiLink typescriptMagicComment SpecialComment
HiLink typescriptRef Include HiLink typescriptRef Include
HiLink typescriptDocNotation SpecialComment HiLink typescriptDocNotation SpecialComment
HiLink typescriptDocTags SpecialComment HiLink typescriptDocTags SpecialComment

View File

@@ -486,6 +486,6 @@ let b:current_syntax = 'crystal'
delc SynFold delc SynFold
" vim: nowrap sw=2 sts=2: " vim: sw=2 sts=2 et:
endif endif

View File

@@ -197,7 +197,7 @@ syntax match juliaConstGeneric display "\<\%(nothing\|Main\|undef\|missing\)\>
syntax match juliaPossibleMacro transparent "@" contains=juliaMacroCall,juliaMacroCallP,juliaPrintfMacro syntax match juliaPossibleMacro transparent "@" contains=juliaMacroCall,juliaMacroCallP,juliaPrintfMacro
exec 'syntax match juliaMacro contained "@' . s:idregex . '\%(\.' . s:idregex . '\)*"' exec 'syntax match juliaMacro contained "@' . s:idregex . '\%(\.' . s:idregex . '\)*"'
syntax match juliaMacro contained "@\.\ze[^0-9]" syntax match juliaMacro contained "@[!.~$%^*/\\|<>+-]\ze[^0-9]"
exec 'syntax region juliaMacroCall contained transparent start="\(@' . s:idregex . '\%(\.' . s:idregex . '\)*\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\|\<end\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS' exec 'syntax region juliaMacroCall contained transparent start="\(@' . s:idregex . '\%(\.' . s:idregex . '\)*\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\|\<end\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS'
exec 'syntax region juliaMacroCall contained transparent start="\(@.\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\|\<end\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS' exec 'syntax region juliaMacroCall contained transparent start="\(@.\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\|\<end\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS'
exec 'syntax region juliaMacroCallP contained transparent start="@' . s:idregex . '\%(\.' . s:idregex . '\)*(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaParBlock' exec 'syntax region juliaMacroCallP contained transparent start="@' . s:idregex . '\%(\.' . s:idregex . '\)*(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaParBlock'

View File

@@ -58,8 +58,8 @@ endif
if s:Enabled('g:python_highlight_builtins') if s:Enabled('g:python_highlight_builtins')
call s:EnableByDefault('g:python_highlight_builtin_objs') call s:EnableByDefault('g:python_highlight_builtin_objs')
call s:EnableByDefault('g:python_highlight_builtin_funcs')
call s:EnableByDefault('g:python_highlight_builtin_types') call s:EnableByDefault('g:python_highlight_builtin_types')
call s:EnableByDefault('g:python_highlight_builtin_funcs')
endif endif
" "

View File

@@ -463,7 +463,7 @@ endif
syn match rubyDefinedOperator "\%#=1\<defined?" display syn match rubyDefinedOperator "\%#=1\<defined?" display
" 1.9-style Hash Keys and Keyword Parameters {{{1 " 1.9-style Hash Keys and Keyword Parameters {{{1
syn match rubySymbol "\%([{(|,]\_s*\)\@<=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[?!]\=::\@!"he=e-1 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 "[]})\"':]\@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 rubySymbol "[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],;]\@="hs=s+1,he=e-1