This commit is contained in:
Adam Stankiewicz
2021-03-10 17:22:05 +01:00
parent cc63193ce8
commit eda351ca89
21 changed files with 490 additions and 101 deletions

View File

@@ -329,7 +329,7 @@ function! s:extract_identifier(word) abort
return '' return ''
endif endif
if a:word[1] == '"' if a:word[1] ==# '"'
let idx = stridx(a:word, '"', 2) let idx = stridx(a:word, '"', 2)
if idx == -1 if idx == -1
return '' return ''
@@ -343,7 +343,7 @@ function! s:extract_identifier(word) abort
endif endif
if prefix ==# '#' if prefix ==# '#'
return matchstr(a:word, '^#\d\+') return matchstr(a:word, '^#\d\+\>')
endif endif
return '' return ''
@@ -478,8 +478,14 @@ function! s:run_lli(...) abort
let tmpfile = tempname() let tmpfile = tempname()
call writefile(getline(1, '$'), tmpfile) call writefile(getline(1, '$'), tmpfile)
let Cleanup = {ch -> filereadable(tmpfile) ? delete(tmpfile) : 0} let Cleanup = {ch -> filereadable(tmpfile) ? delete(tmpfile) : 0}
try
let bufnr = term_start([g:llvm_ext_lli_executable, tmpfile], {'close_cb': Cleanup, 'exit_cb': Cleanup}) let bufnr = term_start([g:llvm_ext_lli_executable, tmpfile], {'close_cb': Cleanup, 'exit_cb': Cleanup})
echo 'Run lli in termnal buffer(' . bufnr . ')' echo 'Run lli in termnal buffer(' . bufnr . ')'
catch
if filereadable(tmpfile)
delete(tmpfile)
endif
endtry
endfunction endfunction
if !exists(':LLI') if !exists(':LLI')

View File

@@ -42,10 +42,6 @@ function! s:L2U_Setup()
let b:l2u_found_completion = 0 let b:l2u_found_completion = 0
" Is the cursor just after a single backslash " Is the cursor just after a single backslash
let b:l2u_singlebslash = 0 let b:l2u_singlebslash = 0
" Backup value of the completeopt settings
" (since we temporarily add the 'longest' setting while
" attempting LaTeX-to-Unicode)
let b:l2u_backup_commpleteopt = &completeopt
" Are we in the middle of a L2U tab completion? " Are we in the middle of a L2U tab completion?
let b:l2u_tab_completing = 0 let b:l2u_tab_completing = 0
" Are we calling the tab fallback? " Are we calling the tab fallback?
@@ -68,7 +64,7 @@ function! s:L2U_SetupGlobal()
call s:L2U_deprecated_options() call s:L2U_deprecated_options()
if v:version < 704 if v:version < 704
let g:latex_to_unicode_tab = 0 let g:latex_to_unicode_tab = "off"
let g:latex_to_unicode_auto = 0 let g:latex_to_unicode_auto = 0
endif endif
@@ -161,6 +157,14 @@ function! s:L2U_deprecated_options()
exec "let g:" . new . " = g:" . old exec "let g:" . new . " = g:" . old
endif endif
endfor endfor
if has_key(g:, "latex_to_unicode_tab")
if g:latex_to_unicode_tab is# 1
let g:latex_to_unicode_tab = "on"
elseif g:latex_to_unicode_tab is# 0
let g:latex_to_unicode_tab = "off"
endif
endif
endfunction endfunction
function! s:L2U_file_type_regex(ft) function! s:L2U_file_type_regex(ft)
@@ -239,22 +243,23 @@ function! s:L2U_longest_common_prefix(partmatches)
return common return common
endfunction endfunction
" Omnicompletion function. Besides the usual two-stage omnifunc behaviour, " Completion function. Besides the usual two-stage completefunc behaviour,
" it has the following peculiar features: " it has the following peculiar features:
" *) keeps track of the previous completion attempt " *) keeps track of the previous completion attempt
" *) sets some info to be used by the fallback function " *) sets some info to be used by the fallback function
" *) either returns a list of completions if a partial match is found, or a " *) either returns a list of completions if a partial match is found, or a
" Unicode char if an exact match is found " Unicode char if an exact match is found
" *) forces its way out of completion mode through a hack in some cases " *) forces its way out of completion mode through a hack in some cases
function! LaTeXtoUnicode#omnifunc(findstart, base) function! LaTeXtoUnicode#completefunc(findstart, base)
if a:findstart if a:findstart
" first stage " first stage
" avoid infinite loop if the fallback happens to call omnicompletion " avoid infinite loop if the fallback happens to call completion
if b:l2u_in_fallback if b:l2u_in_fallback
let b:l2u_in_fallback = 0 let b:l2u_in_fallback = 0
return -3 return -3
endif endif
let b:l2u_in_fallback = 0 call s:L2U_SetCompleteopt()
call s:L2U_InsertCompleteDoneAutocommand()
" set info for the callback " set info for the callback
let b:l2u_found_completion = 1 let b:l2u_found_completion = 1
" analyse current line " analyse current line
@@ -385,27 +390,20 @@ function! LaTeXtoUnicode#Tab()
" reset the in_fallback info " reset the in_fallback info
let b:l2u_in_fallback = 0 let b:l2u_in_fallback = 0
let b:l2u_tab_completing = 1 let b:l2u_tab_completing = 1
" temporary change to completeopt to use the `longest` setting, which is " invoke completion; failure to perform LaTeX-to-Unicode completion is
" probably the only one which makes sense given that the goal of the
" completion is to substitute the final string
let b:l2u_backup_commpleteopt = &completeopt
set completeopt+=longest
set completeopt-=noinsert
" invoke omnicompletion; failure to perform LaTeX-to-Unicode completion is
" handled by the CompleteDone autocommand. " handled by the CompleteDone autocommand.
call feedkeys("\<C-X>\<C-O>", 'n') call feedkeys("\<C-X>\<C-U>", 'n')
return "" return ""
endfunction endfunction
" This function is called at every CompleteDone event, and is meant to handle " This function is called at every CompleteDone event, and is meant to handle
" the failures of LaTeX-to-Unicode completion by calling a fallback " the failures of LaTeX-to-Unicode completion by calling a fallback
function! LaTeXtoUnicode#FallbackCallback() function! LaTeXtoUnicode#FallbackCallback()
call s:L2U_RemoveCompleteDoneAutocommand()
call s:L2U_RestoreCompleteopt()
if !b:l2u_tab_completing if !b:l2u_tab_completing
" completion was not initiated by L2U, nothing to do " completion was not initiated by L2U, nothing to do
return return
else
" completion was initiated by L2U, restore completeopt
let &completeopt = b:l2u_backup_commpleteopt
endif endif
" at this point L2U tab completion is over " at this point L2U tab completion is over
let b:l2u_tab_completing = 0 let b:l2u_tab_completing = 0
@@ -467,9 +465,56 @@ function! LaTeXtoUnicode#CmdTab(trigger)
return '' return ''
endfunction endfunction
function! s:L2U_SetCompleteopt()
" temporary change completeopt to use settings which make sense
" for L2U
let backup_new = 0
if !exists('b:l2u_backup_completeopt')
let b:l2u_backup_completeopt = &completeopt
let backup_new = 1
endif
noautocmd set completeopt+=longest
noautocmd set completeopt-=noinsert
noautocmd set completeopt-=noselect
noautocmd set completeopt-=menuone
if backup_new
let b:l2u_modified_completeopt = &completeopt
endif
endfunction
function! s:L2U_RestoreCompleteopt()
" restore completeopt, but only if nothing else has
" messed with it in the meanwhile
if exists('b:l2u_backup_completeopt')
if exists('b:l2u_modified_completeopt')
if &completeopt ==# b:l2u_modified_completeopt
noautocmd let &completeopt = b:l2u_backup_completeopt
endif
unlet b:l2u_modified_completeopt
endif
unlet b:l2u_backup_completeopt
endif
endfunction
function! s:L2U_InsertCompleteDoneAutocommand()
augroup L2UTab
autocmd! * <buffer>
" Every time a L2U completion finishes, the fallback may be invoked
autocmd CompleteDone <buffer> call LaTeXtoUnicode#FallbackCallback()
augroup END
endfunction
function! s:L2U_RemoveCompleteDoneAutocommand()
augroup L2UTab
autocmd! * <buffer>
augroup END
endfunction
" Setup the L2U tab mapping " Setup the L2U tab mapping
function! s:L2U_SetTab(wait_insert_enter) function! s:L2U_SetTab(wait_insert_enter)
if !b:l2u_cmdtab_set && get(g:, "latex_to_unicode_tab", 1) && b:l2u_enabled let opt_do_cmdtab = index(["on", "command", "cmd"], get(g:, "latex_to_unicode_tab", "on")) != -1
let opt_do_instab = index(["on", "insert", "ins"], get(g:, "latex_to_unicode_tab", "on")) != -1
if !b:l2u_cmdtab_set && opt_do_cmdtab && b:l2u_enabled
let b:l2u_cmdtab_keys = get(g:, "latex_to_unicode_cmd_mapping", ['<Tab>','<S-Tab>']) let b:l2u_cmdtab_keys = get(g:, "latex_to_unicode_cmd_mapping", ['<Tab>','<S-Tab>'])
if type(b:l2u_cmdtab_keys) != type([]) " avoid using v:t_list for backward compatibility if type(b:l2u_cmdtab_keys) != type([]) " avoid using v:t_list for backward compatibility
let b:l2u_cmdtab_keys = [b:l2u_cmdtab_keys] let b:l2u_cmdtab_keys = [b:l2u_cmdtab_keys]
@@ -487,26 +532,20 @@ function! s:L2U_SetTab(wait_insert_enter)
if a:wait_insert_enter && !get(g:, "did_insert_enter", 0) if a:wait_insert_enter && !get(g:, "did_insert_enter", 0)
return return
endif endif
if !get(g:, "latex_to_unicode_tab", 1) || !b:l2u_enabled if !opt_do_instab || !b:l2u_enabled
return return
endif endif
" Backup the previous omnifunc (the check is probably not really needed) " Backup the previous completefunc (the check is probably not really needed)
if get(b:, "prev_omnifunc", "") != "LaTeXtoUnicode#omnifunc" if get(b:, "prev_completefunc", "") != "LaTeXtoUnicode#completefunc"
let b:prev_omnifunc = &omnifunc let b:prev_completefunc = &completefunc
endif endif
setlocal omnifunc=LaTeXtoUnicode#omnifunc setlocal completefunc=LaTeXtoUnicode#completefunc
call s:L2U_SetFallbackMapping('<Tab>', s:l2u_fallback_trigger) call s:L2U_SetFallbackMapping('<Tab>', s:l2u_fallback_trigger)
imap <buffer> <Tab> <Plug>L2UTab imap <buffer> <Tab> <Plug>L2UTab
inoremap <buffer><expr> <Plug>L2UTab LaTeXtoUnicode#Tab() inoremap <buffer><expr> <Plug>L2UTab LaTeXtoUnicode#Tab()
augroup L2UTab
autocmd! * <buffer>
" Every time a completion finishes, the fallback may be invoked
autocmd CompleteDone <buffer> call LaTeXtoUnicode#FallbackCallback()
augroup END
let b:l2u_tab_set = 1 let b:l2u_tab_set = 1
endfunction endfunction
@@ -521,16 +560,13 @@ function! s:L2U_UnsetTab()
if !b:l2u_tab_set if !b:l2u_tab_set
return return
endif endif
exec "setlocal omnifunc=" . get(b:, "prev_omnifunc", "") exec "setlocal completefunc=" . get(b:, "prev_completefunc", "")
iunmap <buffer> <Tab> iunmap <buffer> <Tab>
if empty(maparg("<Tab>", "i")) if empty(maparg("<Tab>", "i"))
call s:L2U_SetFallbackMapping(s:l2u_fallback_trigger, '<Tab>') call s:L2U_SetFallbackMapping(s:l2u_fallback_trigger, '<Tab>')
endif endif
iunmap <buffer> <Plug>L2UTab iunmap <buffer> <Plug>L2UTab
exe 'iunmap <buffer> ' . s:l2u_fallback_trigger exe 'iunmap <buffer> ' . s:l2u_fallback_trigger
augroup L2UTab
autocmd! * <buffer>
augroup END
let b:l2u_tab_set = 0 let b:l2u_tab_set = 0
endfunction endfunction

View File

@@ -97,7 +97,7 @@ function! s:write_to_preview_window(content, ftype, buffername)
else else
" We couldn't make it to the preview window, so as a fallback we dump the " We couldn't make it to the preview window, so as a fallback we dump the
" contents in the status area. " contents in the status area.
execute printf("echo '%s'", join(a:content, "\n")) echo join(a:content, "\n")
endif endif
endfunction endfunction

View File

@@ -79,6 +79,69 @@ function! ledger#transaction_date_set(lnum, type, ...) abort
call setline(trans['head'], trans.format_head()) call setline(trans['head'], trans.format_head())
endf endf
function! ledger#transaction_post_state_get(lnum) abort
" safe view / position
let view = winsaveview()
call cursor(a:lnum, 0)
let line = getline('.')
if line[0] !~# '[ \t]'
" not a post
let state = ''
else
let m = matchlist(line, '^[ \t]\+\([*?!]\)')
if len(m) > 1
let state = m[1]
else
let state = ' '
endif
endif
call winrestview(view)
return state
endf
function! ledger#transaction_post_state_toggle(lnum, ...) abort
if a:0 == 1
let chars = a:1
else
let chars = ' *'
endif
let old = ledger#transaction_post_state_get(a:lnum)
if old ==# ''
" not a post, probably at the first line of transaction
call ledger#transaction_state_toggle(a:lnum, chars)
return
endif
let i = stridx(chars, old) + 1
let new = chars[i >= len(chars) ? 0 : i]
call ledger#transaction_post_state_set(a:lnum, new)
endf
function! ledger#transaction_post_state_set(lnum, char) abort
let state = ledger#transaction_post_state_get(a:lnum)
if state ==# ''
" not a post, probably at the first line of transaction
call ledger#transaction_state_set(a:lnum, a:char)
return
elseif state == a:char || (state ==# ' ' && a:char ==# '')
return
endif
let line = getline('.')
if a:char =~# '^\s*$'
let newline = substitute(line, '\V' . state . '\m[ \t]', '', '')
elseif state ==# ' '
let m = matchlist(line, '^\([ \t]\+\)\(.*\)')
let newline = m[1] . a:char . ' ' . m[2]
else
let newline = substitute(line, '\V' . state, a:char, '')
endif
call setline(a:lnum, newline)
endf
" == get transactions == " == get transactions ==
function! ledger#transaction_from_lnum(lnum) abort function! ledger#transaction_from_lnum(lnum) abort
@@ -178,8 +241,10 @@ function! s:transaction.from_lnum(lnum) abort dict "{{{2
endf "}}} endf "}}}
function! s:transaction.set_state(char) abort dict "{{{2 function! s:transaction.set_state(char) abort dict "{{{2
if has_key(self, 'state') && a:char =~# '^\s*$' if a:char =~# '^\s*$'
if has_key(self, 'state')
call remove(self, 'state') call remove(self, 'state')
endif
else else
let self['state'] = a:char let self['state'] = a:char
endif endif
@@ -426,7 +491,9 @@ function! ledger#align_commodity() abort
" Remove everything after the account name (including spaces): " Remove everything after the account name (including spaces):
call setline('.', substitute(l:line, '\m^\s\+[^[:space:]].\{-}\zs\(\t\| \).*$', '', '')) call setline('.', substitute(l:line, '\m^\s\+[^[:space:]].\{-}\zs\(\t\| \).*$', '', ''))
let pos = -1 let pos = -1
if g:ledger_decimal_sep !=# '' if g:ledger_align_commodity == 1
let pos = 0
elseif g:ledger_decimal_sep !=# ''
" Find the position of the first decimal separator: " Find the position of the first decimal separator:
let pos = s:decimalpos(rhs) let pos = s:decimalpos(rhs)
endif endif
@@ -435,7 +502,7 @@ function! ledger#align_commodity() abort
let pos = matchend(rhs, '\m\d[^[:space:]]*') let pos = matchend(rhs, '\m\d[^[:space:]]*')
endif endif
" Go to the column that allows us to align the decimal separator at g:ledger_align_at: " Go to the column that allows us to align the decimal separator at g:ledger_align_at:
if pos > 0 if pos >= 0
call s:goto_col(g:ledger_align_at - pos - 1, 2) call s:goto_col(g:ledger_align_at - pos - 1, 2)
else else
call s:goto_col(g:ledger_align_at - strdisplaywidth(rhs) - 2, 2) call s:goto_col(g:ledger_align_at - strdisplaywidth(rhs) - 2, 2)

View File

@@ -31,7 +31,11 @@ function! zig#fmt#Format() abort
try | silent undojoin | catch | endtry try | silent undojoin | catch | endtry
" Replace the file content with the formatted version. " Replace the file content with the formatted version.
if exists('*deletebufline')
call deletebufline(current_buf, len(out), line('$')) call deletebufline(current_buf, len(out), line('$'))
else
silent execute ':' . len(out) . ',' . line('$') . ' delete _'
endif
call setline(1, out) call setline(1, out)
" No errors detected, close the loclist. " No errors detected, close the loclist.

View File

@@ -30,7 +30,7 @@ if !g:ledger_is_hledger
CompilerSet errorformat+=%tarning:\ \"%f\"\\,\ line\ %l:\ %m CompilerSet errorformat+=%tarning:\ \"%f\"\\,\ line\ %l:\ %m
" Skip all other lines: " Skip all other lines:
CompilerSet errorformat+=%-G%.%# CompilerSet errorformat+=%-G%.%#
exe 'CompilerSet makeprg='.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ ' . shellescape(expand(g:ledger_main)) . '\ '.substitute(g:ledger_extra_options, ' ', '\\ ', 'g').'\ source\ ' . shellescape(expand(g:ledger_main)) exe 'CompilerSet makeprg='.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ ' . expand('g:ledger_main::S') . '\ '.substitute(g:ledger_extra_options, ' ', '\\ ', 'g').'\ source\ ' . expand('g:ledger_main::S')
else else
exe 'CompilerSet makeprg=('.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ ' . shellescape(expand(g:ledger_main)) . '\ print\ '.substitute(g:ledger_extra_options, ' ', '\\ ', 'g').'\ >\ /dev/null)' exe 'CompilerSet makeprg=('.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ ' . expand('g:ledger_main::S') . '\ print\ '.substitute(g:ledger_extra_options, ' ', '\\ ', 'g') . '\ >\ /dev/null)'
endif endif

View File

@@ -19,6 +19,6 @@ set lisp
" Comment string " Comment string
setl commentstring=;\ %s setl commentstring=;\ %s
setl comments=:; setl comments=n:;
setl iskeyword+=#,?,.,/ setl iskeyword+=#,?,.,/

View File

@@ -26,7 +26,7 @@ setlocal fo-=t fo+=croql
let b:julia_vim_loaded = 1 let b:julia_vim_loaded = 1
let b:undo_ftplugin = "setlocal include< suffixesadd< comments< commentstring<" let b:undo_ftplugin = "setlocal include< suffixesadd< comments< commentstring<"
\ . " define< fo< shiftwidth< expandtab< indentexpr< indentkeys< cinoptions< omnifunc<" \ . " define< fo< shiftwidth< expandtab< indentexpr< indentkeys< cinoptions< completefunc<"
\ . " | unlet! b:commentary_format" \ . " | unlet! b:commentary_format"
\ . " | unlet! b:smartcomment_force_linemode" \ . " | unlet! b:smartcomment_force_linemode"
\ . " | unlet! b:julia_vim_loaded" \ . " | unlet! b:julia_vim_loaded"

View File

@@ -5,5 +5,5 @@ endif
if exists('b:did_ftplugin') | finish | endif if exists('b:did_ftplugin') | finish | endif
let b:did_ftplugin = 1 let b:did_ftplugin = 1
setlocal comments=:// setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
setlocal commentstring=//\ %s setlocal commentstring=//\ %s

16
ftplugin/mlir.vim Normal file
View File

@@ -0,0 +1,16 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'llvm', 'ftplugin/mlir.vim')
finish
endif
" Vim filetype plugin file
" Language: MLIR Assembly
" Maintainer: The MLIR team
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
setlocal softtabstop=2 shiftwidth=2
setlocal expandtab
setlocal comments+=://

View File

@@ -16,4 +16,4 @@ let b:did_ftplugin=1
" Comment string " Comment string
setl commentstring=;\ %s setl commentstring=;\ %s
setl comments=:; setl comments=n:;

View File

@@ -53,8 +53,8 @@ function GetJuliaNestingStruct(lnum, ...)
let blocks_stack = [] let blocks_stack = []
let num_closed_blocks = 0 let num_closed_blocks = 0
while 1 while 1
let fb = JuliaMatch(a:lnum, line, '@\@<!\<\%(if\|else\%(if\)\?\|while\|for\|try\|catch\|finally\|\%(staged\)\?function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|\%(bare\)\?module\|quote\|do\)\>', s, e) let fb = JuliaMatch(a:lnum, line, '[@.]\@<!\<\%(if\|else\%(if\)\?\|while\|for\|try\|catch\|finally\|\%(staged\)\?function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|\%(bare\)\?module\|quote\|do\)\>', s, e)
let fe = JuliaMatch(a:lnum, line, '@\@<!\<end\>', s, e) let fe = JuliaMatch(a:lnum, line, '[@.]\@<!\<end\>', s, e)
if fb < 0 && fe < 0 if fb < 0 && fe < 0
" No blocks found " No blocks found
@@ -66,13 +66,13 @@ function GetJuliaNestingStruct(lnum, ...)
" Note: some keywords (elseif,else,catch,finally) are both " Note: some keywords (elseif,else,catch,finally) are both
" closing blocks and opening new ones " closing blocks and opening new ones
let i = JuliaMatch(a:lnum, line, '@\@<!\<if\>', s) let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<if\>', s)
if i >= 0 && i == fb if i >= 0 && i == fb
let s = i+1 let s = i+1
call add(blocks_stack, 'if') call add(blocks_stack, 'if')
continue continue
endif endif
let i = JuliaMatch(a:lnum, line, '@\@<!\<elseif\>', s) let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<elseif\>', s)
if i >= 0 && i == fb if i >= 0 && i == fb
let s = i+1 let s = i+1
if len(blocks_stack) > 0 && blocks_stack[-1] == 'if' if len(blocks_stack) > 0 && blocks_stack[-1] == 'if'
@@ -83,7 +83,7 @@ function GetJuliaNestingStruct(lnum, ...)
endif endif
continue continue
endif endif
let i = JuliaMatch(a:lnum, line, '@\@<!\<else\>', s) let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<else\>', s)
if i >= 0 && i == fb if i >= 0 && i == fb
let s = i+1 let s = i+1
if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(else\)\=if\>' if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(else\)\=if\>'
@@ -95,13 +95,13 @@ function GetJuliaNestingStruct(lnum, ...)
continue continue
endif endif
let i = JuliaMatch(a:lnum, line, '@\@<!\<try\>', s) let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<try\>', s)
if i >= 0 && i == fb if i >= 0 && i == fb
let s = i+1 let s = i+1
call add(blocks_stack, 'try') call add(blocks_stack, 'try')
continue continue
endif endif
let i = JuliaMatch(a:lnum, line, '@\@<!\<catch\>', s) let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<catch\>', s)
if i >= 0 && i == fb if i >= 0 && i == fb
let s = i+1 let s = i+1
if len(blocks_stack) > 0 && blocks_stack[-1] == 'try' if len(blocks_stack) > 0 && blocks_stack[-1] == 'try'
@@ -112,7 +112,7 @@ function GetJuliaNestingStruct(lnum, ...)
endif endif
continue continue
endif endif
let i = JuliaMatch(a:lnum, line, '@\@<!\<finally\>', s) let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<finally\>', s)
if i >= 0 && i == fb if i >= 0 && i == fb
let s = i+1 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' || blocks_stack[-1] == 'catch')
@@ -124,7 +124,7 @@ function GetJuliaNestingStruct(lnum, ...)
continue continue
endif endif
let i = JuliaMatch(a:lnum, line, '@\@<!\<\%(bare\)\?module\>', s) let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<\%(bare\)\?module\>', s)
if i >= 0 && i == fb if i >= 0 && i == fb
let s = i+1 let s = i+1
if i == 0 if i == 0
@@ -135,7 +135,7 @@ function GetJuliaNestingStruct(lnum, ...)
continue continue
endif endif
let i = JuliaMatch(a:lnum, line, '@\@<!\<\%(while\|for\|\%(staged\)\?function\|macro\|begin\|\%(mutable\s\+\)\?struct\|\%(abstract\|primitive\)\s\+type\|immutable\|let\|quote\|do\)\>', s) let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<\%(while\|for\|\%(staged\)\?function\|macro\|begin\|\%(mutable\s\+\)\?struct\|\%(abstract\|primitive\)\s\+type\|immutable\|let\|quote\|do\)\>', s)
if i >= 0 && i == fb if i >= 0 && i == fb
if match(line, '\C\<\%(mutable\|abstract\|primitive\)', i) != -1 if match(line, '\C\<\%(mutable\|abstract\|primitive\)', i) != -1
let s = i+11 let s = i+11
@@ -278,7 +278,7 @@ endfunction
function IsInDocString(lnum) function IsInDocString(lnum)
let stack = map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")') let stack = map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")')
call filter(stack, 'v:val =~# "\\<juliaDocString\\(Delim\\)\\?\\>"') call filter(stack, 'v:val =~# "\\<juliaDocString\\(Delim\\|M\\)\\?\\>"')
return len(stack) > 0 return len(stack) > 0
endfunction endfunction

79
indent/mlir.vim Normal file
View File

@@ -0,0 +1,79 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'llvm', 'indent/mlir.vim')
finish
endif
" Vim indent file
" Language: mlir
" Maintainer: The MLIR team
" Adapted from the LLVM vim indent file
" What this indent plugin currently does:
" - If no other rule matches copy indent from previous non-empty,
" non-commented line.
" - On '}' align the same as the line containing the matching '{'.
" - If previous line starts with a block label, increase indentation.
" - If the current line is a block label and ends with ':' indent at the same
" level as the enclosing '{'/'}' block.
" Stuff that would be nice to add:
" - Continue comments on next line.
" - If there is an opening+unclosed parenthesis on previous line indent to
" that.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal shiftwidth=2 expandtab
setlocal indentkeys=0{,0},<:>,!^F,o,O,e
setlocal indentexpr=GetMLIRIndent()
if exists("*GetMLIRIndent")
finish
endif
function! FindOpenBrace(lnum)
call cursor(a:lnum, 1)
return searchpair('{', '', '}', 'bW')
endfun
function! GetMLIRIndent()
" On '}' align the same as the line containing the matching '{'
let thisline = getline(v:lnum)
if thisline =~ '^\s*}'
call cursor(v:lnum, 1)
silent normal %
let opening_lnum = line('.')
if opening_lnum != v:lnum
return indent(opening_lnum)
endif
endif
" Indent labels the same as the current opening block
if thisline =~ '\^\h\+.*:\s*$'
let blockbegin = FindOpenBrace(v:lnum)
if blockbegin > 0
return indent(blockbegin)
endif
endif
" Find a non-blank not-completely commented line above the current line.
let prev_lnum = prevnonblank(v:lnum - 1)
while prev_lnum > 0 && synIDattr(synID(prev_lnum, 1 + indent(prev_lnum), 0), "name") == "mlirComment"
let prev_lnum = prevnonblank(prev_lnum-1)
endwhile
" Hit the start of the file, use zero indent.
if prev_lnum == 0
return 0
endif
let ind = indent(prev_lnum)
let prevline = getline(prev_lnum)
" Add a 'shiftwidth' after lines that start a function, block/labels, or a
" region.
if prevline =~ '{\s*$' || prevline =~ '\^\h\+.*:\s*$'
let ind = ind + &shiftwidth
endif
return ind
endfunction

View File

@@ -12,12 +12,6 @@ if exists("b:did_indent")
finish finish
endif endif
runtime! indent/html.vim
unlet! b:did_indent
let s:html_indent = &l:indentexpr
let b:did_indent = 1
if !exists('g:svelte_indent_script') if !exists('g:svelte_indent_script')
let g:svelte_indent_script = 1 let g:svelte_indent_script = 1
endif endif
@@ -26,6 +20,25 @@ if !exists('g:svelte_indent_style')
let g:svelte_indent_style = 1 let g:svelte_indent_style = 1
endif endif
" Try to mirror Svelte's indent settings so the HTML indenting scripts match.
if g:svelte_indent_script
let b:html_indent_script1 = "inc"
else
let b:html_indent_script1 = "zero"
endif
if g:svelte_indent_style
let b:html_indent_style1 = "inc"
else
let b:html_indent_style1 = "zero"
endif
runtime! indent/html.vim
unlet! b:did_indent
let s:html_indent = &l:indentexpr
let b:did_indent = 1
setlocal indentexpr=GetSvelteIndent() setlocal indentexpr=GetSvelteIndent()
setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],!^F,;,=:else,=:then,=:catch,=/if,=/each,=/await setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],!^F,;,=:else,=:then,=:catch,=/if,=/each,=/await

View File

@@ -11,17 +11,22 @@ endif
syntax case match syntax case match
" Reference documentation:
" https://golang.org/ref/mod#go-mod-file-grammar
" match keywords " match keywords
syntax keyword gomodModule module syntax keyword gomodModule module
syntax keyword gomodGo go contained syntax keyword gomodGo go contained
syntax keyword gomodRequire require syntax keyword gomodRequire require
syntax keyword gomodExclude exclude syntax keyword gomodExclude exclude
syntax keyword gomodReplace replace syntax keyword gomodReplace replace
syntax keyword gomodRetract retract
" require, exclude, replace, and go can be also grouped into block " require, exclude, replace, and go can be also grouped into block
syntax region gomodRequire start='require (' end=')' transparent contains=gomodRequire,gomodVersion syntax region gomodRequire start='require (' end=')' transparent contains=gomodRequire,gomodVersion
syntax region gomodExclude start='exclude (' end=')' transparent contains=gomodExclude,gomodVersion syntax region gomodExclude start='exclude (' end=')' transparent contains=gomodExclude,gomodVersion
syntax region gomodReplace start='replace (' end=')' transparent contains=gomodReplace,gomodVersion syntax region gomodReplace start='replace (' end=')' transparent contains=gomodReplace,gomodVersion
syntax region gomodRetract start='retract (' end=')' transparent contains=gomodVersionRange,gomodVersion
syntax match gomodGo '^go .*$' transparent contains=gomodGo,gomodGoVersion syntax match gomodGo '^go .*$' transparent contains=gomodGo,gomodGoVersion
" set highlights " set highlights
@@ -30,6 +35,7 @@ highlight default link gomodGo Keyword
highlight default link gomodRequire Keyword highlight default link gomodRequire Keyword
highlight default link gomodExclude Keyword highlight default link gomodExclude Keyword
highlight default link gomodReplace Keyword highlight default link gomodReplace Keyword
highlight default link gomodRetract Keyword
" comments are always in form of // ... " comments are always in form of // ...
syntax region gomodComment start="//" end="$" contains=@Spell syntax region gomodComment start="//" end="$" contains=@Spell
@@ -47,7 +53,6 @@ highlight default link gomodReplaceOperator Operator
syntax match gomodGoVersion "1\.\d\+" contained syntax match gomodGoVersion "1\.\d\+" contained
highlight default link gomodGoVersion Identifier highlight default link gomodGoVersion Identifier
" highlight versions: " highlight versions:
" * vX.Y.Z-pre " * vX.Y.Z-pre
" * vX.Y.Z " * vX.Y.Z
@@ -93,4 +98,15 @@ syntax match gomodVersion "v[2-9]\{1}\d*\.\d\+\.\d\+\%(+\%([0-9A-Za-z-]\+\)\%(\.
" ^------- version -------^^---------------- metadata ---------------------^ " ^------- version -------^^---------------- metadata ---------------------^
highlight default link gomodVersion Identifier highlight default link gomodVersion Identifier
" match go version ranges in retract directive
" https://golang.org/ref/mod#go-mod-file-retract
syntax region gomodVersionRange start="\[" end="\]" transparent matchgroup=gomodVersionRangeBracket contains=gomodVersion,gomodVersionRangeSeparator
highlight default link gomodVersionRange Operator
syntax match gomodVersionRangeBracket "\[" contained
syntax match gomodVersionRangeBracket "\]" contained
highlight default link gomodVersionRangeBracket Operator
syntax match gomodVersionRangeSeparator "," contained
highlight default link gomodVersionRangeSeparator Operator
let b:current_syntax = "gomod" let b:current_syntax = "gomod"

View File

@@ -108,7 +108,7 @@ syntax keyword jsDo do skipwhite skipempty next
syntax region jsSwitchCase contained matchgroup=jsLabel start=/\<\%(case\|default\)\>/ end=/:\@=/ contains=@jsExpression,jsLabel skipwhite skipempty nextgroup=jsSwitchColon keepend syntax region jsSwitchCase contained matchgroup=jsLabel start=/\<\%(case\|default\)\>/ end=/:\@=/ contains=@jsExpression,jsLabel skipwhite skipempty nextgroup=jsSwitchColon keepend
syntax keyword jsTry try skipwhite skipempty nextgroup=jsTryCatchBlock syntax keyword jsTry try skipwhite skipempty nextgroup=jsTryCatchBlock
syntax keyword jsFinally contained finally skipwhite skipempty nextgroup=jsFinallyBlock syntax keyword jsFinally contained finally skipwhite skipempty nextgroup=jsFinallyBlock
syntax keyword jsCatch contained catch skipwhite skipempty nextgroup=jsParenCatch syntax keyword jsCatch contained catch skipwhite skipempty nextgroup=jsParenCatch,jsTryCatchBlock
syntax keyword jsException throw syntax keyword jsException throw
syntax keyword jsAsyncKeyword async await syntax keyword jsAsyncKeyword async await
syntax match jsSwitchColon contained /::\@!/ skipwhite skipempty nextgroup=jsSwitchBlock syntax match jsSwitchColon contained /::\@!/ skipwhite skipempty nextgroup=jsSwitchBlock

View File

@@ -36,11 +36,11 @@ let s:julia_highlight_operators = get(g:, "julia_highlight_operators", 1)
" characters which cannot be used in identifiers. This list is very incomplete: " characters which cannot be used in identifiers. This list is very incomplete:
" 1) it only cares about charactes below 256 " 1) it only cares about charactes below 256
" 2) it doesn't distinguish between what's allowed as the 1st char vs in the " 2) it doesn't distinguish between what's allowed as the 1st char vs in the
" rest of an identifier (e.g. digits, `!` and `?`) " rest of an identifier (e.g. digits and `!`)
" Despite these shortcomings, it seems to do a decent job. " Despite these shortcomings, it seems to do a decent job.
" note: \U5B and \U5D are '[' and ']' " note: \U5B and \U5D are '[' and ']'
let s:nonid_chars = "\U01-\U07" . "\U0E-\U1F" . let s:nonid_chars = "\U01-\U07" . "\U0E-\U1F" .
\ "\"#$'(,.:;=@`\\U5B{" . \ "?\"#$'(,.:;=@`\\U5B{" .
\ "\U80-\UA1" . "\UA7\UA8\UAB\UAD\UAF\UB4" . "\UB6-\UB8" . "\UBB\UBF" \ "\U80-\UA1" . "\UA7\UA8\UAB\UAD\UAF\UB4" . "\UB6-\UB8" . "\UBB\UBF"
let s:nonidS_chars = "[:space:])\\U5D}" . s:nonid_chars let s:nonidS_chars = "[:space:])\\U5D}" . s:nonid_chars
@@ -64,7 +64,7 @@ let s:binop_chars = "=+\\U2D*/\\%÷^&|⊻<>≤≥≡≠≢∈∉⋅×∪∩⊆
let s:binop_chars_extra = "\\U214B\\U2190-\\U2194\\U219A\\U219B\\U21A0\\U21A3\\U21A6\\U21AE\\U21CE\\U21CF\\U21D2\\U21D4\\U21F4-\\U21FF\\U2208-\\U220D\\U2213\\U2214\\U2217-\\U2219\\U221D\\U2224-\\U222A\\U2237\\U2238\\U223A\\U223B\\U223D\\U223E\\U2240-\\U228B\\U228D-\\U229C\\U229E-\\U22A3\\U22A9\\U22AC\\U22AE\\U22B0-\\U22B7\\U22BB-\\U22BD\\U22C4-\\U22C7\\U22C9-\\U22D3\\U22D5-\\U22ED\\U22F2-\\U22FF\\U25B7\\U27C8\\U27C9\\U27D1\\U27D2\\U27D5-\\U27D7\\U27F0\\U27F1\\U27F5-\\U27F7\\U27F7\\U27F9-\\U27FF\\U2900-\\U2918\\U291D-\\U2920\\U2944-\\U2970\\U29B7\\U29B8\\U29BC\\U29BE-\\U29C1\\U29E1\\U29E3-\\U29E5\\U29F4\\U29F6\\U29F7\\U29FA\\U29FB\\U2A07\\U2A08\\U2A1D\\U2A22-\\U2A2E\\U2A30-\\U2A3D\\U2A40-\\U2A45\\U2A4A-\\U2A58\\U2A5A-\\U2A63\\U2A66\\U2A67\\U2A6A-\\U2AD9\\U2ADB\\U2AF7-\\U2AFA\\U2B30-\\U2B44\\U2B47-\\U2B4C\\UFFE9-\\UFFEC" let s:binop_chars_extra = "\\U214B\\U2190-\\U2194\\U219A\\U219B\\U21A0\\U21A3\\U21A6\\U21AE\\U21CE\\U21CF\\U21D2\\U21D4\\U21F4-\\U21FF\\U2208-\\U220D\\U2213\\U2214\\U2217-\\U2219\\U221D\\U2224-\\U222A\\U2237\\U2238\\U223A\\U223B\\U223D\\U223E\\U2240-\\U228B\\U228D-\\U229C\\U229E-\\U22A3\\U22A9\\U22AC\\U22AE\\U22B0-\\U22B7\\U22BB-\\U22BD\\U22C4-\\U22C7\\U22C9-\\U22D3\\U22D5-\\U22ED\\U22F2-\\U22FF\\U25B7\\U27C8\\U27C9\\U27D1\\U27D2\\U27D5-\\U27D7\\U27F0\\U27F1\\U27F5-\\U27F7\\U27F7\\U27F9-\\U27FF\\U2900-\\U2918\\U291D-\\U2920\\U2944-\\U2970\\U29B7\\U29B8\\U29BC\\U29BE-\\U29C1\\U29E1\\U29E3-\\U29E5\\U29F4\\U29F6\\U29F7\\U29FA\\U29FB\\U2A07\\U2A08\\U2A1D\\U2A22-\\U2A2E\\U2A30-\\U2A3D\\U2A40-\\U2A45\\U2A4A-\\U2A58\\U2A5A-\\U2A63\\U2A66\\U2A67\\U2A6A-\\U2AD9\\U2ADB\\U2AF7-\\U2AFA\\U2B30-\\U2B44\\U2B47-\\U2B4C\\UFFE9-\\UFFEC"
" a Julia identifier, sort of " a Julia identifier, sort of
let s:idregex = '\%([^' . s:nonidS_chars . '0-9!?' . s:uniop_chars . s:binop_chars . '][^' . s:nonidS_chars . s:uniop_chars . s:binop_chars . s:binop_chars_extra . ']*\)' let s:idregex = '\%([^' . s:nonidS_chars . '0-9!' . s:uniop_chars . s:binop_chars . '][^' . s:nonidS_chars . s:uniop_chars . s:binop_chars . s:binop_chars_extra . ']*\)'
let s:operators = '\%(' . '\.\%([-+*/^÷%|&!]\|//\|\\\|<<\|>>>\?\)\?=' . let s:operators = '\%(' . '\.\%([-+*/^÷%|&!]\|//\|\\\|<<\|>>>\?\)\?=' .
\ '\|' . '[:$<>]=\|||\|&&\||>\|<|\|<:\|>:\|::\|<<\|>>>\?\|//\|[-=]>\|\.\{3\}' . \ '\|' . '[:$<>]=\|||\|&&\||>\|<|\|<:\|>:\|::\|<<\|>>>\?\|//\|[-=]>\|\.\{3\}' .
@@ -74,11 +74,11 @@ let s:operators = '\%(' . '\.\%([-+*/^÷%|&!]\|//\|\\\|<<\|>>>\?\)\?=' .
syn case match syn case match
syntax cluster juliaExpressions contains=@juliaParItems,@juliaStringItems,@juliaKeywordItems,@juliaBlocksItems,@juliaTypesItems,@juliaConstItems,@juliaMacroItems,@juliaSymbolItems,@juliaOperatorItems,@juliaNumberItems,@juliaCommentItems,@juliaErrorItems syntax cluster juliaExpressions contains=@juliaParItems,@juliaStringItems,@juliaKeywordItems,@juliaBlocksItems,@juliaTypesItems,@juliaConstItems,@juliaMacroItems,@juliaSymbolItems,@juliaOperatorItems,@juliaNumberItems,@juliaCommentItems,@juliaErrorItems,@juliaSyntaxRegions
syntax cluster juliaExprsPrintf contains=@juliaExpressions,@juliaPrintfItems syntax cluster juliaExprsPrintf contains=@juliaExpressions,@juliaPrintfItems
syntax cluster juliaParItems contains=juliaParBlock,juliaSqBraIdxBlock,juliaSqBraBlock,juliaCurBraBlock,juliaQuotedParBlock,juliaQuotedQMarkPar syntax cluster juliaParItems contains=juliaParBlock,juliaSqBraIdxBlock,juliaSqBraBlock,juliaCurBraBlock,juliaQuotedParBlock,juliaQuotedQMarkPar
syntax cluster juliaKeywordItems contains=juliaKeyword,juliaImportLine,juliaInfixKeyword,juliaRepKeyword syntax cluster juliaKeywordItems contains=juliaKeyword,juliaWhereKeyword,juliaImportLine,juliaInfixKeyword,juliaRepKeyword
syntax cluster juliaBlocksItems contains=juliaConditionalBlock,juliaWhileBlock,juliaForBlock,juliaBeginBlock,juliaFunctionBlock,juliaMacroBlock,juliaQuoteBlock,juliaTypeBlock,juliaImmutableBlock,juliaExceptionBlock,juliaLetBlock,juliaDoBlock,juliaModuleBlock,juliaStructBlock,juliaMutableStructBlock,juliaAbstractBlock,juliaPrimitiveBlock syntax cluster juliaBlocksItems contains=juliaConditionalBlock,juliaWhileBlock,juliaForBlock,juliaBeginBlock,juliaFunctionBlock,juliaMacroBlock,juliaQuoteBlock,juliaTypeBlock,juliaImmutableBlock,juliaExceptionBlock,juliaLetBlock,juliaDoBlock,juliaModuleBlock,juliaStructBlock,juliaMutableStructBlock,juliaAbstractBlock,juliaPrimitiveBlock
syntax cluster juliaTypesItems contains=juliaBaseTypeBasic,juliaBaseTypeNum,juliaBaseTypeC,juliaBaseTypeError,juliaBaseTypeIter,juliaBaseTypeString,juliaBaseTypeArray,juliaBaseTypeDict,juliaBaseTypeSet,juliaBaseTypeIO,juliaBaseTypeProcess,juliaBaseTypeRange,juliaBaseTypeRegex,juliaBaseTypeFact,juliaBaseTypeFact,juliaBaseTypeSort,juliaBaseTypeRound,juliaBaseTypeSpecial,juliaBaseTypeRandom,juliaBaseTypeDisplay,juliaBaseTypeTime,juliaBaseTypeOther syntax cluster juliaTypesItems contains=juliaBaseTypeBasic,juliaBaseTypeNum,juliaBaseTypeC,juliaBaseTypeError,juliaBaseTypeIter,juliaBaseTypeString,juliaBaseTypeArray,juliaBaseTypeDict,juliaBaseTypeSet,juliaBaseTypeIO,juliaBaseTypeProcess,juliaBaseTypeRange,juliaBaseTypeRegex,juliaBaseTypeFact,juliaBaseTypeFact,juliaBaseTypeSort,juliaBaseTypeRound,juliaBaseTypeSpecial,juliaBaseTypeRandom,juliaBaseTypeDisplay,juliaBaseTypeTime,juliaBaseTypeOther
@@ -93,6 +93,8 @@ syntax cluster juliaOperatorItems contains=juliaOperator,juliaRangeOperator,juli
syntax cluster juliaCommentItems contains=juliaCommentL,juliaCommentM syntax cluster juliaCommentItems contains=juliaCommentL,juliaCommentM
syntax cluster juliaErrorItems contains=juliaErrorPar,juliaErrorEnd,juliaErrorElse,juliaErrorCatch,juliaErrorFinally syntax cluster juliaErrorItems contains=juliaErrorPar,juliaErrorEnd,juliaErrorElse,juliaErrorCatch,juliaErrorFinally
syntax cluster juliaSyntaxRegions contains=juliaParamTypeR,juliaFunctionCallR,juliaTypeOperatorR,juliaWhereR
syntax cluster juliaSpellcheckStrings contains=@spell syntax cluster juliaSpellcheckStrings contains=@spell
syntax cluster juliaSpellcheckDocStrings contains=@spell syntax cluster juliaSpellcheckDocStrings contains=@spell
syntax cluster juliaSpellcheckComments contains=@spell syntax cluster juliaSpellcheckComments contains=@spell
@@ -126,9 +128,21 @@ syntax region juliaParBlock matchgroup=juliaParDelim start="(" end=")" contain
syntax region juliaParBlockInRange matchgroup=juliaParDelim contained start="(" end=")" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeKeyword,juliaComprehensionFor syntax region juliaParBlockInRange matchgroup=juliaParDelim contained start="(" end=")" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeKeyword,juliaComprehensionFor
syntax region juliaSqBraIdxBlock matchgroup=juliaParDelim start="\[" end="\]" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeKeyword,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS syntax region juliaSqBraIdxBlock matchgroup=juliaParDelim start="\[" end="\]" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeKeyword,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS
exec 'syntax region juliaSqBraBlock matchgroup=juliaParDelim start="\%(^\|\s\|' . s:operators . '\)\@'.s:d(3).'<=\[" end="\]" contains=@juliaExpressions,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS' exec 'syntax region juliaSqBraBlock matchgroup=juliaParDelim start="\%(^\|\s\|' . s:operators . '\)\@'.s:d(3).'<=\[" end="\]" contains=@juliaExpressions,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS'
syntax region juliaCurBraBlock matchgroup=juliaParDelim start="{" end="}" contains=@juliaExpressions syntax region juliaCurBraBlock matchgroup=juliaParDelim start="{" end="}" contains=juliaType,@juliaExpressions
exec 'syntax match juliaKeyword display "'.s:nodot.'\<\%(return\|local\|global\|const\|where\)\>"' exec 'syntax match juliaType contained "' . s:idregex . '\%(\.' . s:idregex . '\)*"'
exec 'syntax region juliaFunctionCallR transparent start="' . s:idregex . '\%(\.' . s:idregex . '\)*\s*(" end=")\@'.s:d(1).'<=" contains=juliaFunctionCall,juliaParBlock'
exec 'syntax match juliaFunctionCall contained "\%(' . s:idregex . '\.\)*\zs' . s:idregex . '"'
" note: we would in principle add a "s:nodot" before function/macro/struct/... but it shouldn't come up in valid code
exec 'syntax match juliaFunctionDef contained transparent "\%(\<\%(function\|macro\)\s\+\)\@'.s:d(20).'<=' . s:idregex . '\%(\.' . s:idregex . '\)*\ze\s\+\%(end\>\|$\)" contains=juliaFunctionName'
exec 'syntax region juliaFunctionDefP contained transparent start="\%(\<\%(function\|macro\)\s\+\)\@'.s:d(20).'<=' . s:idregex . '\%(\.' . s:idregex . '\)*\s*(" end=")\@'.s:d(1).'<=" contains=juliaFunctionName,juliaParBlock'
exec 'syntax match juliaFunctionName contained "\%(\<\%(function\|macro\)\s\+\)\@'.s:d(20).'<=\%(' . s:idregex . '\.\)*\zs' . s:idregex . '"'
exec 'syntax match juliaStructR contained transparent "\%(\<\%(\%(mutable\s\+\)\?struct\|\%(abstract\|primitive\)\s\+type\)\s\+\)\@'.s:d(20).'<=\%(' . s:idregex . '\.\)*' . s:idregex . '\>\(\s*(\)\@!" contains=juliaType'
exec 'syntax match juliaKeyword display "'.s:nodot.'\<\%(return\|local\|global\|const\)\>"'
syntax match juliaInfixKeyword display "\%(=\s*\)\@<!\<\%(in\|isa\)\>\S\@!\%(\s*=\)\@!" syntax match juliaInfixKeyword display "\%(=\s*\)\@<!\<\%(in\|isa\)\>\S\@!\%(\s*=\)\@!"
" The import/export/using keywords introduce a sort of special parsing " The import/export/using keywords introduce a sort of special parsing
@@ -144,26 +158,25 @@ exec 'syntax region juliaWhileBlock matchgroup=juliaRepeat start="'.s:nodot.'\
exec 'syntax region juliaForBlock matchgroup=juliaRepeat start="'.s:nodot.'\<for\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaOuter fold' exec 'syntax region juliaForBlock matchgroup=juliaRepeat start="'.s:nodot.'\<for\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaOuter fold'
exec 'syntax region juliaBeginBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<begin\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold' exec 'syntax region juliaBeginBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<begin\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold'
exec 'syntax region juliaFunctionBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<function\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaFunctionDef,juliaFunctionDefP fold' exec 'syntax region juliaFunctionBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<function\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaFunctionDef,juliaFunctionDefP fold'
exec 'syntax region juliaMacroBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<macro\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold' exec 'syntax region juliaMacroBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<macro\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaFunctionDef,juliaFunctionDefP fold'
exec 'syntax region juliaQuoteBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<quote\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold' exec 'syntax region juliaQuoteBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<quote\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold'
exec 'syntax region juliaStructBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<struct\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold' exec 'syntax region juliaStructBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<struct\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaStructR fold'
exec 'syntax region juliaMutableStructBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<mutable\s\+struct\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold' exec 'syntax region juliaMutableStructBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<mutable\s\+struct\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaStructR fold'
exec 'syntax region juliaLetBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<let\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold' exec 'syntax region juliaLetBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<let\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold'
exec 'syntax region juliaDoBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<do\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold' exec 'syntax region juliaDoBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<do\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions fold'
exec 'syntax region juliaModuleBlock matchgroup=juliaBlKeyword start="\%(\%(\.\s*\)\@'.s:d(6).'<!\|\%(@\s*\.\s*\)\@'.s:d(6).'<=\)\<\%(bare\)\?module\>" end="\<end\>" contains=@juliaExpressions fold' exec 'syntax region juliaModuleBlock matchgroup=juliaBlKeyword start="\%(\%(\.\s*\)\@'.s:d(6).'<!\|\%(@\s*\.\s*\)\@'.s:d(6).'<=\)\<\%(bare\)\?module\>" end="\<end\>" contains=@juliaExpressions fold'
exec 'syntax region juliaExceptionBlock matchgroup=juliaException start="'.s:nodot.'\<try\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaCatchBlock,juliaFinallyBlock fold' exec 'syntax region juliaExceptionBlock matchgroup=juliaException start="'.s:nodot.'\<try\>" end="'.s:nodot.'\<end\>" contains=@juliaExpressions,juliaCatchBlock,juliaFinallyBlock fold'
exec 'syntax region juliaCatchBlock matchgroup=juliaException transparent contained start="'.s:nodot.'\<catch\>" end="'.s:nodot.'\<end\>"me=s-1 contains=@juliaExpressions,juliaFinallyBlock' exec 'syntax region juliaCatchBlock matchgroup=juliaException transparent contained start="'.s:nodot.'\<catch\>" end="'.s:nodot.'\<end\>"me=s-1 contains=@juliaExpressions,juliaFinallyBlock'
exec 'syntax region juliaFinallyBlock matchgroup=juliaException transparent contained start="'.s:nodot.'\<finally\>" end="'.s:nodot.'\<end\>"me=s-1 contains=@juliaExpressions' exec 'syntax region juliaFinallyBlock matchgroup=juliaException transparent contained start="'.s:nodot.'\<finally\>" end="'.s:nodot.'\<end\>"me=s-1 contains=@juliaExpressions'
" AbstractBlock needs to come after to take precedence exec 'syntax region juliaAbstractBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<abstract\s\+type\>" end="'.s:nodot.'\<end\>" fold contains=@juliaExpressions,juliaStructR'
exec 'syntax region juliaAbstractBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<abstract\s\+type\>" end="'.s:nodot.'\<end\>" fold contains=@juliaExpressions' exec 'syntax region juliaPrimitiveBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<primitive\s\+type\>" end="'.s:nodot.'\<end\>" fold contains=@juliaExpressions,juliaStructR'
exec 'syntax region juliaPrimitiveBlock matchgroup=juliaBlKeyword start="'.s:nodot.'\<primitive\s\+type\>" end="'.s:nodot.'\<end\>" fold contains=@juliaExpressions'
exec 'syntax region juliaComprehensionFor matchgroup=juliaComprehensionFor transparent contained start="\%([^[:space:],;:({[]\_s*\)\@'.s:d(80).'<=\<for\>" end="\ze[]);]" contains=@juliaExpressions,juliaComprehensionIf,juliaComprehensionFor' exec 'syntax region juliaComprehensionFor matchgroup=juliaComprehensionFor transparent contained start="\%([^[:space:],;:({[]\_s*\)\@'.s:d(80).'<=\<for\>" end="\ze[]);]" contains=@juliaExpressions,juliaComprehensionIf,juliaComprehensionFor'
exec 'syntax match juliaComprehensionIf contained "'.s:nodot.'\<if\>"' exec 'syntax match juliaComprehensionIf contained "'.s:nodot.'\<if\>"'
exec 'syntax match juliaOuter contained "\<outer\ze\s\+' . s:idregex . '\>"' exec 'syntax match juliaOuter contained "\<outer\ze\s\+' . s:idregex . '\>"'
syntax match juliaRangeKeyword display contained "\<\%(begin\|end\)\>" syntax match juliaRangeKeyword contained "\<\%(begin\|end\)\>"
syntax match juliaBaseTypeBasic display "\<\%(\%(N\|Named\)\?Tuple\|Symbol\|Function\|Union\%(All\)\?\|Type\%(Name\|Var\)\?\|Any\|ANY\|Vararg\|Ptr\|Exception\|Module\|Expr\|DataType\|\%(LineNumber\|Quote\)Node\|\%(Weak\|Global\)\?Ref\|Method\|Pair\|Val\|Nothing\|Some\|Missing\)\>" syntax match juliaBaseTypeBasic display "\<\%(\%(N\|Named\)\?Tuple\|Symbol\|Function\|Union\%(All\)\?\|Type\%(Name\|Var\)\?\|Any\|ANY\|Vararg\|Ptr\|Exception\|Module\|Expr\|DataType\|\%(LineNumber\|Quote\)Node\|\%(Weak\|Global\)\?Ref\|Method\|Pair\|Val\|Nothing\|Some\|Missing\)\>"
syntax match juliaBaseTypeNum display "\<\%(U\?Int\%(8\|16\|32\|64\|128\)\?\|Float\%(16\|32\|64\)\|Complex\|Bool\|Char\|Number\|Signed\|Unsigned\|Integer\|AbstractFloat\|Real\|Rational\|\%(Abstract\)\?Irrational\|Enum\|BigInt\|BigFloat\|MathConst\|ComplexF\%(16\|32\|64\)\)\>" syntax match juliaBaseTypeNum display "\<\%(U\?Int\%(8\|16\|32\|64\|128\)\?\|Float\%(16\|32\|64\)\|Complex\|Bool\|Char\|Number\|Signed\|Unsigned\|Integer\|AbstractFloat\|Real\|Rational\|\%(Abstract\)\?Irrational\|Enum\|BigInt\|BigFloat\|MathConst\|ComplexF\%(16\|32\|64\)\)\>"
@@ -201,11 +214,9 @@ syntax match juliaConstIO display "\<\%(std\%(out\|in\|err\)\|devnull\)\>"
syntax match juliaConstC display "\<\%(C_NULL\)\>" syntax match juliaConstC display "\<\%(C_NULL\)\>"
syntax match juliaConstGeneric display "\<\%(nothing\|Main\|undef\|missing\)\>" syntax match juliaConstGeneric display "\<\%(nothing\|Main\|undef\|missing\)\>"
exec 'syntax match juliaFunctionDef contained transparent "\%(\<function\s\+\)\@'.s:d(20).'<=' . s:idregex . '\%(\.' . s:idregex . '\)*\ze\s\+\%(end\>\|$\)" contains=juliaFunctionName' exec 'syntax region juliaParamTypeR transparent start="' . s:idregex . '\%(\.' . s:idregex . '\)*\s*{" end="}\@'.s:d(1).'<=" contains=juliaType,@juliaExpressions'
exec 'syntax region juliaFunctionDefP contained transparent start="\%(\<function\s\+\)\@'.s:d(20).'<=' . s:idregex . '\%(\.' . s:idregex . '\)*\s*(" end=")\@'.s:d(1).'<=" contains=juliaFunctionName,juliaParBlock'
exec 'syntax match juliaFunctionName contained "\%(\<function\s\+\)\@'.s:d(20).'<=' . s:idregex . '\%(\.' . s:idregex . '\)*"'
syntax match juliaPossibleMacro transparent "@" contains=juliaMacroCall,juliaMacroCallP,juliaPrintfMacro syntax match juliaPossibleMacro transparent "@" contains=juliaMacroCall,juliaMacroCallP,juliaPrintfMacro,juliaDocMacro
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]"
@@ -253,11 +264,11 @@ exec 'syntax match juliaNumber contained "' . s:int_regex . '" contains=juliaC
exec 'syntax match juliaFloat contained "' . s:float_regex . '" contains=juliaComplexUnit' exec 'syntax match juliaFloat contained "' . s:float_regex . '" contains=juliaComplexUnit'
syntax match juliaComplexUnit display contained "\<im\>" syntax match juliaComplexUnit display contained "\<im\>"
exec 'syntax match juliaOperator "' . s:operators . '"'
syntax match juliaRangeOperator display ":" syntax match juliaRangeOperator display ":"
exec 'syntax match juliaOperator "' . s:operators . '"'
exec 'syntax region juliaTernaryRegion matchgroup=juliaTernaryOperator start="\s\zs?\ze\s" skip="\%(:\(:\|[^:[:space:]'."'".'"({[]\+\s*\ze:\)\|\%(?\s*\)\@'.s:d(6).'<=:(\)" end=":" contains=@juliaExpressions,juliaErrorSemicol' exec 'syntax region juliaTernaryRegion matchgroup=juliaTernaryOperator start="\s\zs?\ze\s" skip="\%(:\(:\|[^:[:space:]'."'".'"({[]\+\s*\ze:\)\|\%(?\s*\)\@'.s:d(6).'<=:(\)" end=":" contains=@juliaExpressions,juliaErrorSemicol'
let s:interp_dollar = '\([' . s:nonidS_chars . s:uniop_chars . s:binop_chars . '!?]\|^\)\@'.s:d(1).'<=\$' let s:interp_dollar = '\([' . s:nonidS_chars . s:uniop_chars . s:binop_chars . '!]\|^\)\@'.s:d(1).'<=\$'
exec 'syntax match juliaDollarVar display contained "' . s:interp_dollar . s:idregex . '"' exec 'syntax match juliaDollarVar display contained "' . s:interp_dollar . s:idregex . '"'
exec 'syntax region juliaDollarPar matchgroup=juliaDollarVar contained start="' .s:interp_dollar . '(" end=")" contains=@juliaExpressions' exec 'syntax region juliaDollarPar matchgroup=juliaDollarVar contained start="' .s:interp_dollar . '(" end=")" contains=@juliaExpressions'
@@ -269,7 +280,7 @@ syntax match juliaChar display "'\\x\x\{2\}'" contains=juliaHexEscapeChar
syntax match juliaChar display "'\\u\x\{1,4\}'" contains=juliaUniCharSmall syntax match juliaChar display "'\\u\x\{1,4\}'" contains=juliaUniCharSmall
syntax match juliaChar display "'\\U\x\{1,8\}'" contains=juliaUniCharLarge syntax match juliaChar display "'\\U\x\{1,8\}'" contains=juliaUniCharLarge
exec 'syntax match juliaCTransOperator "[[:space:]}' . s:nonid_chars . s:uniop_chars . s:binop_chars . '!?]\@'.s:d(1).'<!\.\?' . "'" . '"' exec 'syntax match juliaCTransOperator "[[:space:]}' . s:nonid_chars . s:uniop_chars . s:binop_chars . '!]\@'.s:d(1).'<!\.\?' . "'" . 'ᵀ\?"'
" TODO: some of these might be specialized; the rest could be just left to the " TODO: some of these might be specialized; the rest could be just left to the
" generic juliaStringPrefixed fallback " generic juliaStringPrefixed fallback
@@ -293,6 +304,9 @@ syntax region juliaPrintfMacro contained transparent start="@s\?printf\s\+" en
syntax region juliaPrintfParBlock contained matchgroup=juliaParDelim start="(" end=")" contains=@juliaExprsPrintf syntax region juliaPrintfParBlock contained matchgroup=juliaParDelim start="(" end=")" contains=@juliaExprsPrintf
syntax region juliaPrintfString contained matchgroup=juliaStringDelim start=+"+ skip=+\%(\\\\\)*\\"+ end=+"+ contains=@juliaSpecialChars,@juliaPrintfChars syntax region juliaPrintfString contained matchgroup=juliaStringDelim start=+"+ skip=+\%(\\\\\)*\\"+ end=+"+ contains=@juliaSpecialChars,@juliaPrintfChars
exec 'syntax region juliaDocMacro contained transparent start=+@doc\s\+\%(' . s:idregex . '\%(\.' . s:idregex . '\)*\)\?\z("\%(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\(\z1\)\@'.s:d(3).'<=+ contains=juliaMacro,juliaDocStringM'
syntax region juliaDocStringM contained fold matchgroup=juliaDocStringDelim fold start=+\z\("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaStringVars,@juliaSpecialChars,@juliaSpellcheckDocStrings
syntax region juliaShellString matchgroup=juliaStringDelim start=+`+ skip=+\%(\\\\\)*\\`+ end=+`+ contains=@juliaStringVars,juliaSpecialChar syntax region juliaShellString matchgroup=juliaStringDelim start=+`+ skip=+\%(\\\\\)*\\`+ end=+`+ contains=@juliaStringVars,juliaSpecialChar
syntax cluster juliaStringVars contains=juliaStringVarsPar,juliaStringVarsSqBra,juliaStringVarsCurBra,juliaStringVarsPla syntax cluster juliaStringVars contains=juliaStringVarsPar,juliaStringVarsSqBra,juliaStringVarsCurBra,juliaStringVarsPla
@@ -326,7 +340,7 @@ syntax match juliaPrintfFmt display contained "\\%%"hs=s+1
syntax match juliaPossibleSymbol transparent ":\ze[^:]" contains=juliaSymbol,juliaQuotedParBlock,juliaQuotedQMarkPar,juliaColon syntax match juliaPossibleSymbol transparent ":\ze[^:]" contains=juliaSymbol,juliaQuotedParBlock,juliaQuotedQMarkPar,juliaColon
let s:quotable = '\%(' . s:idregex . '\|?\|' . s:operators . '\|' . s:float_regex . '\|' . s:int_regex . '\)' let s:quotable = '\%(' . s:idregex . '\|?\|' . s:operators . '\|' . s:float_regex . '\|' . s:int_regex . '\)'
let s:quoting_colon = '\%(\%(^\s*\|\s\{6,\}\|[' . s:nonid_chars . s:uniop_chars . s:binop_chars . '?]\s*\)\@'.s:d(6).'<=\|\%(\<\%(return\|if\|else\%(if\)\?\|while\|try\|begin\)\s\+\)\@'.s:d(9).'<=\)\zs:' let s:quoting_colon = '\%(\%(^\s*\|\s\{6,\}\|[' . s:nonid_chars . s:uniop_chars . s:binop_chars . ']\s*\)\@'.s:d(6).'<=\|\%(\<\%(return\|if\|else\%(if\)\?\|while\|try\|begin\)\s\+\)\@'.s:d(9).'<=\)\zs:'
let s:quoting_colonS = '\s\@'.s:d(1).'<=:' let s:quoting_colonS = '\s\@'.s:d(1).'<=:'
" note: juliaSymbolS only works within whitespace-sensitive contexts, " note: juliaSymbolS only works within whitespace-sensitive contexts,
@@ -346,7 +360,14 @@ exec 'syntax region juliaQuotedParBlockS matchgroup=juliaQParDelim contained s
" force precedence over Symbols " force precedence over Symbols
syntax match juliaOperator display "::" exec 'syntax match juliaTypeOperatorR transparent "[<>:]:\s*\%(' . s:idregex . '\.\)*' . s:idregex . '" contains=juliaTypeOperator,juliaType,@juliaExpressions'
exec 'syntax match juliaTypeOperatorR transparent "' . s:idregex . '\%(\.' . s:idregex . '\)*\s*[<>]:\s*\%(\%(' . s:idregex . '\.\)*' . s:idregex . '\)\?" contains=juliaTypeOperator,juliaType,@juliaExpressions'
exec 'syntax match juliaTypeOperatorR transparent "\<isa\s\+\%(' . s:idregex . '\.\)*' . s:idregex . '" contains=juliaIsaKeyword,juliaType,@juliaExpressions'
syntax match juliaTypeOperator contained "[:<>]:"
syntax match juliaIsaKeyword contained "\<isa\>"
syntax match juliaWhereKeyword "\<where\>"
exec 'syntax match juliaWhereR transparent "\<where\s\+' . s:idregex . '" contains=juliaWhereKeyword,juliaType,juliaTypeOperatorR'
syntax region juliaCommentL matchgroup=juliaCommentDelim excludenl start="#\ze\%([^=]\|$\)" end="$" contains=juliaTodo,@juliaSpellcheckComments syntax region juliaCommentL matchgroup=juliaCommentDelim excludenl start="#\ze\%([^=]\|$\)" end="$" contains=juliaTodo,@juliaSpellcheckComments
syntax region juliaCommentM matchgroup=juliaCommentDelim fold start="#=\ze\%([^#]\|$\)" end="=#" contains=juliaTodo,juliaCommentM,@juliaSpellcheckComments syntax region juliaCommentM matchgroup=juliaCommentDelim fold start="#=\ze\%([^#]\|$\)" end="=#" contains=juliaTodo,juliaCommentM,@juliaSpellcheckComments
@@ -370,15 +391,19 @@ exec 'syntax match juliaMacroName "@' . s:idregex . '\%(\.' . s:idregex . '\)
hi def link juliaParDelim juliaNone hi def link juliaParDelim juliaNone
hi def link juliaSemicolon juliaNone hi def link juliaSemicolon juliaNone
hi def link juliaComma juliaNone hi def link juliaComma juliaNone
hi def link juliaFunctionCall juliaNone
hi def link juliaColon juliaOperator hi def link juliaColon juliaOperator
hi def link juliaFunctionName juliaFunction hi def link juliaFunctionName juliaFunction
hi def link juliaFunctionName1 juliaFunction
hi def link juliaMacroName juliaMacro hi def link juliaMacroName juliaMacro
hi def link juliaKeyword Keyword hi def link juliaKeyword Keyword
hi def link juliaWhereKeyword Keyword
hi def link juliaInfixKeyword Keyword hi def link juliaInfixKeyword Keyword
hi def link juliaIsaKeyword Keyword
hi def link juliaAsKeyword Keyword hi def link juliaAsKeyword Keyword
hi def link juliaRepKeyword Keyword hi def link juliaRepKeyword Keyword
hi def link juliaBlKeyword Keyword hi def link juliaBlKeyword Keyword
@@ -408,6 +433,8 @@ hi def link juliaBaseTypeDisplay Type
hi def link juliaBaseTypeTime Type hi def link juliaBaseTypeTime Type
hi def link juliaBaseTypeOther Type hi def link juliaBaseTypeOther Type
hi def link juliaType Type
" NOTE: deprecated constants are not highlighted as such. For once, " NOTE: deprecated constants are not highlighted as such. For once,
" one can still legitimately use them by importing Base.MathConstants. " one can still legitimately use them by importing Base.MathConstants.
" Plus, one-letter variables like `e` and `γ` can be used with other " Plus, one-letter variables like `e` and `γ` can be used with other
@@ -458,6 +485,7 @@ hi def link juliaint128String juliaString
hi def link juliaPrintfString juliaString hi def link juliaPrintfString juliaString
hi def link juliaShellString juliaString hi def link juliaShellString juliaString
hi def link juliaDocString juliaString hi def link juliaDocString juliaString
hi def link juliaDocStringM juliaDocString
hi def link juliaStringDelim juliaString hi def link juliaStringDelim juliaString
hi def link juliaDocStringDelim juliaDocString hi def link juliaDocStringDelim juliaDocString
hi def link juliaStringVarsPla Identifier hi def link juliaStringVarsPla Identifier
@@ -484,6 +512,7 @@ hi def link juliaOperator juliaOperatorHL
hi def link juliaRangeOperator juliaOperatorHL hi def link juliaRangeOperator juliaOperatorHL
hi def link juliaCTransOperator juliaOperatorHL hi def link juliaCTransOperator juliaOperatorHL
hi def link juliaTernaryOperator juliaOperatorHL hi def link juliaTernaryOperator juliaOperatorHL
hi def link juliaTypeOperator juliaOperatorHL
hi def link juliaCommentL Comment hi def link juliaCommentL Comment
hi def link juliaCommentM Comment hi def link juliaCommentM Comment

View File

@@ -78,8 +78,8 @@ syn match ktComment "/\*\*/"
syn match ktSpecialCharError "\v\\." contained syn match ktSpecialCharError "\v\\." contained
syn match ktSpecialChar "\v\\([tbnr'"$\\]|u\x{4})" contained syn match ktSpecialChar "\v\\([tbnr'"$\\]|u\x{4})" contained
syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError,@Spell
syn region ktString start='"""' end='""""*' contains=ktSimpleInterpolation,ktComplexInterpolation syn region ktString start='"""' end='""""*' contains=ktSimpleInterpolation,ktComplexInterpolation,@Spell
syn match ktCharacter "\v'[^']*'" contains=ktSpecialChar,ktSpecialCharError syn match ktCharacter "\v'[^']*'" contains=ktSpecialChar,ktSpecialCharError
syn match ktCharacter "\v'\\''" contains=ktSpecialChar syn match ktCharacter "\v'\\''" contains=ktSpecialChar
syn match ktCharacter "\v'[^\\]'" syn match ktCharacter "\v'[^\\]'"

View File

@@ -18,7 +18,7 @@ syn case match
" Types. " Types.
" Types also include struct, array, vector, etc. but these don't " Types also include struct, array, vector, etc. but these don't
" benefit as much from having dedicated highlighting rules. " benefit as much from having dedicated highlighting rules.
syn keyword llvmType void half float double x86_fp80 fp128 ppc_fp128 syn keyword llvmType void half bfloat float double x86_fp80 fp128 ppc_fp128
syn keyword llvmType label metadata x86_mmx syn keyword llvmType label metadata x86_mmx
syn keyword llvmType type label opaque token syn keyword llvmType type label opaque token
syn match llvmType /\<i\d\+\>/ syn match llvmType /\<i\d\+\>/
@@ -207,6 +207,7 @@ syn match llvmConstant /\<DIFlag[A-Za-z]\+\>/
syn match llvmSpecialComment /;\s*PR\d*\s*$/ syn match llvmSpecialComment /;\s*PR\d*\s*$/
syn match llvmSpecialComment /;\s*REQUIRES:.*$/ syn match llvmSpecialComment /;\s*REQUIRES:.*$/
syn match llvmSpecialComment /;\s*RUN:.*$/ syn match llvmSpecialComment /;\s*RUN:.*$/
syn match llvmSpecialComment /;\s*ALLOW_RETRIES:.*$/
syn match llvmSpecialComment /;\s*CHECK:.*$/ syn match llvmSpecialComment /;\s*CHECK:.*$/
syn match llvmSpecialComment "\v;\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$" syn match llvmSpecialComment "\v;\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"
syn match llvmSpecialComment /;\s*XFAIL:.*$/ syn match llvmSpecialComment /;\s*XFAIL:.*$/

122
syntax/mlir.vim Normal file
View File

@@ -0,0 +1,122 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'llvm', 'syntax/mlir.vim')
finish
endif
" Vim syntax file
" Language: mlir
" Maintainer: The MLIR team, http://github.com/tensorflow/mlir/
" Version: $Revision$
" Some parts adapted from the LLVM vim syntax file.
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case match
" Types.
syn keyword mlirType index f16 f32 f64
" Integer type.
syn match mlirType /\<i\d\+\>/
" Elemental types inside memref, tensor, or vector types.
syn match mlirType /x\s*\zs\(f16\|f32\|f64\|i\d\+\)/
" Shaped types.
syn match mlirType /\<memref\ze\s*<.*>/
syn match mlirType /\<tensor\ze\s*<.*>/
syn match mlirType /\<vector\ze\s*<.*>/
" vector types inside memref or tensor.
syn match mlirType /x\s*\zsvector/
" Operations.
" Core ops (not exhaustive yet).
" TODO: the list is not exhaustive.
syn keyword mlirOps alloc alloca addf addi call call_indirect cmpf cmpi constant
syn keyword mlirOps dealloc divf dma_start dma_wait dim extract_element
syn keyword mlirOps getTensor index_cast load memref_cast memref_shape_cast
syn keyword mlirOps mulf muli negf prefetch sitofp splat store select subf subi
syn keyword mlirOps subview tensor_cast view
" Affine ops.
syn match mlirOps /\<affine\.apply\>/
syn match mlirOps /\<affine\.dma_start\>/
syn match mlirOps /\<affine\.dma_wait\>/
syn match mlirOps /\<affine\.for\>/
syn match mlirOps /\<affine\.if\>/
syn match mlirOps /\<affine\.load\>/
syn match mlirOps /\<affine\.prefetch\>/
syn match mlirOps /\<affine\.store\>/
syn match mlirOps /\<loop\.for\>/
syn match mlirOps /\<loop\.if\>/
" TODO: dialect name prefixed ops (llvm or std).
" Keywords.
syn keyword mlirKeyword
\ affine_map
\ affine_set
\ dense
\ else
\ func
\ module
\ return
\ step
\ to
" Misc syntax.
syn match mlirNumber /-\?\<\d\+\>/
" Match numbers even in shaped types.
syn match mlirNumber /-\?\<\d\+\ze\s*x/
syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/
syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
syn match mlirFloat /\<0x\x\+\>/
syn keyword mlirBoolean true false
syn match mlirComment /\/\/.*$/
syn region mlirString start=/"/ skip=/\\"/ end=/"/
syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
syn match mlirIdentifier /[%@!]\d\+\>/
syn match mlirMapSetOutline "#.*$"
" Syntax-highlight lit test commands and bug numbers.
syn match mlirSpecialComment /\/\/\s*RUN:.*$/
syn match mlirSpecialComment /\/\/\s*CHECK:.*$/
syn match mlirSpecialComment "\v\/\/\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"
syn match mlirSpecialComment /\/\/\s*expected-error.*$/
syn match mlirSpecialComment /\/\/\s*expected-remark.*$/
syn match mlirSpecialComment /;\s*XFAIL:.*$/
syn match mlirSpecialComment /\/\/\s*PR\d*\s*$/
syn match mlirSpecialComment /\/\/\s*REQUIRES:.*$/
if version >= 508 || !exists("did_c_syn_inits")
if version < 508
let did_c_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink mlirType Type
HiLink mlirOps Statement
HiLink mlirMapSetOutline PreProc
HiLink mlirNumber Number
HiLink mlirComment Comment
HiLink mlirString String
HiLink mlirLabel Label
HiLink mlirKeyword Keyword
HiLink mlirBoolean Boolean
HiLink mlirFloat Float
HiLink mlirConstant Constant
HiLink mlirSpecialComment SpecialComment
HiLink mlirIdentifier Identifier
delcommand HiLink
endif
let b:current_syntax = "mlir"

View File

@@ -35,8 +35,6 @@ syntax keyword svelteKeyword slot contained containedin=htmlTag
" https://github.com/mxw/vim-jsx/blob/master/after/syntax/jsx.vim " https://github.com/mxw/vim-jsx/blob/master/after/syntax/jsx.vim
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 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
syntax region svelteSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
" Block conditionals. " Block conditionals.
syntax match svelteConditional "#if" contained containedin=jsBlock,javascriptBlock syntax match svelteConditional "#if" contained containedin=jsBlock,javascriptBlock
syntax match svelteConditional "/if" contained containedin=jsBlock,javascriptBlock syntax match svelteConditional "/if" contained containedin=jsBlock,javascriptBlock
@@ -117,6 +115,8 @@ for s:language in s:languages
endif endif
endfor endfor
syntax region svelteSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
" Cybernetically enhanced web apps. " Cybernetically enhanced web apps.
let b:current_syntax = "svelte" let b:current_syntax = "svelte"