diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2021-03-10 17:22:05 +0100 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2021-03-10 17:22:05 +0100 | 
| commit | eda351ca897ca0270ed8b01798af3679914683a1 (patch) | |
| tree | 5340822acd25ecd12063f08b1e6d0bed4a891a82 | |
| parent | cc63193ce82c1e7b9ee2ad7d0ddd14e8394211ef (diff) | |
| download | vim-polyglot-eda351ca897ca0270ed8b01798af3679914683a1.tar.gz vim-polyglot-eda351ca897ca0270ed8b01798af3679914683a1.zip  | |
Update
Diffstat (limited to '')
| -rw-r--r-- | after/ftplugin/llvm.vim | 14 | ||||
| -rw-r--r-- | autoload/LaTeXtoUnicode.vim | 108 | ||||
| -rw-r--r-- | autoload/julia/doc.vim | 2 | ||||
| -rw-r--r-- | autoload/ledger.vim | 75 | ||||
| -rw-r--r-- | autoload/zig/fmt.vim | 6 | ||||
| -rw-r--r-- | compiler/ledger.vim | 4 | ||||
| -rw-r--r-- | ftplugin/dune.vim | 2 | ||||
| -rw-r--r-- | ftplugin/julia.vim | 2 | ||||
| -rw-r--r-- | ftplugin/kotlin.vim | 2 | ||||
| -rw-r--r-- | ftplugin/mlir.vim | 16 | ||||
| -rw-r--r-- | ftplugin/sexplib.vim | 2 | ||||
| -rw-r--r-- | indent/julia.vim | 22 | ||||
| -rw-r--r-- | indent/mlir.vim | 79 | ||||
| -rw-r--r-- | indent/svelte.vim | 25 | ||||
| -rw-r--r-- | syntax/gomod.vim | 18 | ||||
| -rw-r--r-- | syntax/javascript.vim | 2 | ||||
| -rw-r--r-- | syntax/julia.vim | 79 | ||||
| -rw-r--r-- | syntax/kotlin.vim | 4 | ||||
| -rw-r--r-- | syntax/llvm.vim | 3 | ||||
| -rw-r--r-- | syntax/mlir.vim | 122 | ||||
| -rw-r--r-- | syntax/svelte.vim | 4 | 
21 files changed, 490 insertions, 101 deletions
diff --git a/after/ftplugin/llvm.vim b/after/ftplugin/llvm.vim index bb1ee63e..79fbac35 100644 --- a/after/ftplugin/llvm.vim +++ b/after/ftplugin/llvm.vim @@ -329,7 +329,7 @@ function! s:extract_identifier(word) abort              return ''          endif -        if a:word[1] == '"' +        if a:word[1] ==# '"'              let idx = stridx(a:word, '"', 2)              if idx == -1                  return '' @@ -343,7 +343,7 @@ function! s:extract_identifier(word) abort      endif      if prefix ==# '#' -        return matchstr(a:word, '^#\d\+') +        return matchstr(a:word, '^#\d\+\>')      endif      return '' @@ -478,8 +478,14 @@ function! s:run_lli(...) abort      let tmpfile = tempname()      call writefile(getline(1, '$'), tmpfile)      let Cleanup = {ch -> filereadable(tmpfile) ? delete(tmpfile) : 0} -    let bufnr = term_start([g:llvm_ext_lli_executable, tmpfile], {'close_cb': Cleanup, 'exit_cb': Cleanup}) -    echo 'Run lli in termnal buffer(' . bufnr . ')' +    try +        let bufnr = term_start([g:llvm_ext_lli_executable, tmpfile], {'close_cb': Cleanup, 'exit_cb': Cleanup}) +        echo 'Run lli in termnal buffer(' . bufnr . ')' +    catch +        if filereadable(tmpfile) +            delete(tmpfile) +        endif +    endtry  endfunction  if !exists(':LLI') diff --git a/autoload/LaTeXtoUnicode.vim b/autoload/LaTeXtoUnicode.vim index 79827318..fed23032 100644 --- a/autoload/LaTeXtoUnicode.vim +++ b/autoload/LaTeXtoUnicode.vim @@ -42,10 +42,6 @@ function! s:L2U_Setup()    let b:l2u_found_completion = 0    " Is the cursor just after a single backslash    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?    let b:l2u_tab_completing = 0    " Are we calling the tab fallback? @@ -68,7 +64,7 @@ function! s:L2U_SetupGlobal()    call s:L2U_deprecated_options()    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    endif @@ -161,6 +157,14 @@ function! s:L2U_deprecated_options()        exec "let g:" . new . " = g:" . old      endif    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  function! s:L2U_file_type_regex(ft) @@ -239,22 +243,23 @@ function! s:L2U_longest_common_prefix(partmatches)    return common  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:  "  *) keeps track of the previous completion attempt  "  *) sets some info to be used by the fallback function  "  *) either returns a list of completions if a partial match is found, or a  "     Unicode char if an exact match is found  "  *) 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      " 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        let b:l2u_in_fallback = 0        return -3      endif -    let b:l2u_in_fallback = 0 +    call s:L2U_SetCompleteopt() +    call s:L2U_InsertCompleteDoneAutocommand()      " set info for the callback      let b:l2u_found_completion = 1      " analyse current line @@ -385,27 +390,20 @@ function! LaTeXtoUnicode#Tab()    " reset the in_fallback info    let b:l2u_in_fallback = 0    let b:l2u_tab_completing = 1 -  " temporary change to completeopt to use the `longest` setting, which 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 +  " invoke completion; failure to perform LaTeX-to-Unicode completion is    " handled by the CompleteDone autocommand. -  call feedkeys("\<C-X>\<C-O>", 'n') +  call feedkeys("\<C-X>\<C-U>", 'n')    return ""  endfunction  " This function is called at every CompleteDone event, and is meant to handle  " the failures of LaTeX-to-Unicode completion by calling a fallback  function! LaTeXtoUnicode#FallbackCallback() +  call s:L2U_RemoveCompleteDoneAutocommand() +  call s:L2U_RestoreCompleteopt()    if !b:l2u_tab_completing      " completion was not initiated by L2U, nothing to do      return -  else -    " completion was initiated by L2U, restore completeopt -    let &completeopt = b:l2u_backup_commpleteopt    endif    " at this point L2U tab completion is over    let b:l2u_tab_completing = 0 @@ -467,9 +465,56 @@ function! LaTeXtoUnicode#CmdTab(trigger)    return ''  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  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>'])      if type(b:l2u_cmdtab_keys) != type([]) " avoid using v:t_list for backward compatibility        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)      return    endif -  if !get(g:, "latex_to_unicode_tab", 1) || !b:l2u_enabled +  if !opt_do_instab || !b:l2u_enabled      return    endif -  " Backup the previous omnifunc (the check is probably not really needed) -  if get(b:, "prev_omnifunc", "") != "LaTeXtoUnicode#omnifunc" -    let b:prev_omnifunc = &omnifunc +  " Backup the previous completefunc (the check is probably not really needed) +  if get(b:, "prev_completefunc", "") != "LaTeXtoUnicode#completefunc" +    let b:prev_completefunc = &completefunc    endif -  setlocal omnifunc=LaTeXtoUnicode#omnifunc +  setlocal completefunc=LaTeXtoUnicode#completefunc    call s:L2U_SetFallbackMapping('<Tab>', s:l2u_fallback_trigger)    imap <buffer> <Tab> <Plug>L2UTab    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  endfunction @@ -521,16 +560,13 @@ function! s:L2U_UnsetTab()    if !b:l2u_tab_set      return    endif -  exec "setlocal omnifunc=" . get(b:, "prev_omnifunc", "") +  exec "setlocal completefunc=" . get(b:, "prev_completefunc", "")    iunmap <buffer> <Tab>    if empty(maparg("<Tab>", "i"))      call s:L2U_SetFallbackMapping(s:l2u_fallback_trigger, '<Tab>')    endif    iunmap <buffer> <Plug>L2UTab    exe 'iunmap <buffer> ' . s:l2u_fallback_trigger -  augroup L2UTab -    autocmd! * <buffer> -  augroup END    let b:l2u_tab_set = 0  endfunction diff --git a/autoload/julia/doc.vim b/autoload/julia/doc.vim index dfac90a0..fe311222 100644 --- a/autoload/julia/doc.vim +++ b/autoload/julia/doc.vim @@ -97,7 +97,7 @@ function! s:write_to_preview_window(content, ftype, buffername)    else      " We couldn't make it to the preview window, so as a fallback we dump the      " contents in the status area. -    execute printf("echo '%s'", join(a:content, "\n")) +    echo join(a:content, "\n")    endif  endfunction diff --git a/autoload/ledger.vim b/autoload/ledger.vim index 1006430c..90c88802 100644 --- a/autoload/ledger.vim +++ b/autoload/ledger.vim @@ -79,6 +79,69 @@ function! ledger#transaction_date_set(lnum, type, ...) abort    call setline(trans['head'], trans.format_head())  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 ==  function! ledger#transaction_from_lnum(lnum) abort @@ -178,8 +241,10 @@ function! s:transaction.from_lnum(lnum) abort dict "{{{2  endf "}}}  function! s:transaction.set_state(char) abort dict "{{{2 -  if has_key(self, 'state') && a:char =~# '^\s*$' -    call remove(self, 'state') +  if a:char =~# '^\s*$' +    if has_key(self, 'state') +      call remove(self, 'state') +    endif    else      let self['state'] = a:char    endif @@ -426,7 +491,9 @@ function! ledger#align_commodity() abort      " Remove everything after the account name (including spaces):      call setline('.', substitute(l:line, '\m^\s\+[^[:space:]].\{-}\zs\(\t\|  \).*$', '', ''))      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:        let pos = s:decimalpos(rhs)      endif @@ -435,7 +502,7 @@ function! ledger#align_commodity() abort        let pos = matchend(rhs, '\m\d[^[:space:]]*')      endif      " 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)      else        call s:goto_col(g:ledger_align_at - strdisplaywidth(rhs) - 2, 2) diff --git a/autoload/zig/fmt.vim b/autoload/zig/fmt.vim index 7b31febd..3474f34a 100644 --- a/autoload/zig/fmt.vim +++ b/autoload/zig/fmt.vim @@ -31,7 +31,11 @@ function! zig#fmt#Format() abort      try | silent undojoin | catch | endtry      " Replace the file content with the formatted version. -    call deletebufline(current_buf, len(out), line('$')) +    if exists('*deletebufline') +      call deletebufline(current_buf, len(out), line('$')) +    else +      silent execute ':' . len(out) . ',' . line('$') . ' delete _' +    endif      call setline(1, out)      " No errors detected, close the loclist. diff --git a/compiler/ledger.vim b/compiler/ledger.vim index 92348ba3..3fca6442 100644 --- a/compiler/ledger.vim +++ b/compiler/ledger.vim @@ -30,7 +30,7 @@ if !g:ledger_is_hledger  	CompilerSet errorformat+=%tarning:\ \"%f\"\\,\ line\ %l:\ %m  	" Skip all other lines:  	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 -	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 diff --git a/ftplugin/dune.vim b/ftplugin/dune.vim index 9d86d0a5..4f78d7c6 100644 --- a/ftplugin/dune.vim +++ b/ftplugin/dune.vim @@ -19,6 +19,6 @@ set lisp  " Comment string  setl commentstring=;\ %s -setl comments=:; +setl comments=n:;  setl iskeyword+=#,?,.,/ diff --git a/ftplugin/julia.vim b/ftplugin/julia.vim index 618e16d8..08aa2f8e 100644 --- a/ftplugin/julia.vim +++ b/ftplugin/julia.vim @@ -26,7 +26,7 @@ setlocal fo-=t fo+=croql  let b:julia_vim_loaded = 1  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:smartcomment_force_linemode"        \ . " | unlet! b:julia_vim_loaded" diff --git a/ftplugin/kotlin.vim b/ftplugin/kotlin.vim index e06ce043..ca0b35fc 100644 --- a/ftplugin/kotlin.vim +++ b/ftplugin/kotlin.vim @@ -5,5 +5,5 @@ endif  if exists('b:did_ftplugin') | finish | endif  let b:did_ftplugin = 1 -setlocal comments=:// +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://  setlocal commentstring=//\ %s diff --git a/ftplugin/mlir.vim b/ftplugin/mlir.vim new file mode 100644 index 00000000..baedaee4 --- /dev/null +++ b/ftplugin/mlir.vim @@ -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+=:// diff --git a/ftplugin/sexplib.vim b/ftplugin/sexplib.vim index d98f2d15..976e3897 100644 --- a/ftplugin/sexplib.vim +++ b/ftplugin/sexplib.vim @@ -16,4 +16,4 @@ let b:did_ftplugin=1  " Comment string  setl commentstring=;\ %s -setl comments=:; +setl comments=n:; diff --git a/indent/julia.vim b/indent/julia.vim index c4c17245..b40823c0 100644 --- a/indent/julia.vim +++ b/indent/julia.vim @@ -53,8 +53,8 @@ function GetJuliaNestingStruct(lnum, ...)    let blocks_stack = []    let num_closed_blocks = 0    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 fe = JuliaMatch(a:lnum, line, '@\@<!\<end\>', 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)      if fb < 0 && fe < 0        " No blocks found @@ -66,13 +66,13 @@ function GetJuliaNestingStruct(lnum, ...)        " Note: some keywords (elseif,else,catch,finally) are both        "       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          let s = i+1          call add(blocks_stack, 'if')          continue        endif -      let i = JuliaMatch(a:lnum, line, '@\@<!\<elseif\>', s) +      let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<elseif\>', s)        if i >= 0 && i == fb          let s = i+1          if len(blocks_stack) > 0 && blocks_stack[-1] == 'if' @@ -83,7 +83,7 @@ function GetJuliaNestingStruct(lnum, ...)          endif          continue        endif -      let i = JuliaMatch(a:lnum, line, '@\@<!\<else\>', s) +      let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<else\>', s)        if i >= 0 && i == fb          let s = i+1          if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(else\)\=if\>' @@ -95,13 +95,13 @@ function GetJuliaNestingStruct(lnum, ...)          continue        endif -      let i = JuliaMatch(a:lnum, line, '@\@<!\<try\>', s) +      let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<try\>', s)        if i >= 0 && i == fb          let s = i+1          call add(blocks_stack, 'try')          continue        endif -      let i = JuliaMatch(a:lnum, line, '@\@<!\<catch\>', s) +      let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<catch\>', s)        if i >= 0 && i == fb          let s = i+1          if len(blocks_stack) > 0 && blocks_stack[-1] == 'try' @@ -112,7 +112,7 @@ function GetJuliaNestingStruct(lnum, ...)          endif          continue        endif -      let i = JuliaMatch(a:lnum, line, '@\@<!\<finally\>', s) +      let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<finally\>', s)        if i >= 0 && i == fb          let s = i+1          if len(blocks_stack) > 0 && (blocks_stack[-1] == 'try' || blocks_stack[-1] == 'catch') @@ -124,7 +124,7 @@ function GetJuliaNestingStruct(lnum, ...)          continue        endif -      let i = JuliaMatch(a:lnum, line, '@\@<!\<\%(bare\)\?module\>', s) +      let i = JuliaMatch(a:lnum, line, '[@.]\@<!\<\%(bare\)\?module\>', s)        if i >= 0 && i == fb          let s = i+1          if i == 0 @@ -135,7 +135,7 @@ function GetJuliaNestingStruct(lnum, ...)          continue        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 match(line, '\C\<\%(mutable\|abstract\|primitive\)', i) != -1            let s = i+11 @@ -278,7 +278,7 @@ endfunction  function IsInDocString(lnum)    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  endfunction diff --git a/indent/mlir.vim b/indent/mlir.vim new file mode 100644 index 00000000..a74c3506 --- /dev/null +++ b/indent/mlir.vim @@ -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 diff --git a/indent/svelte.vim b/indent/svelte.vim index fa01f563..cb01c424 100644 --- a/indent/svelte.vim +++ b/indent/svelte.vim @@ -12,12 +12,6 @@ if exists("b:did_indent")    finish  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')    let g:svelte_indent_script = 1  endif @@ -26,6 +20,25 @@ if !exists('g:svelte_indent_style')    let g:svelte_indent_style = 1  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 indentkeys=o,O,*<Return>,<>>,{,},0),0],!^F,;,=:else,=:then,=:catch,=/if,=/each,=/await diff --git a/syntax/gomod.vim b/syntax/gomod.vim index 0de3d9d9..4f120ffd 100644 --- a/syntax/gomod.vim +++ b/syntax/gomod.vim @@ -11,17 +11,22 @@ endif  syntax case match +" Reference documentation: +" https://golang.org/ref/mod#go-mod-file-grammar +  " match keywords  syntax keyword gomodModule  module  syntax keyword gomodGo      go      contained  syntax keyword gomodRequire require  syntax keyword gomodExclude exclude  syntax keyword gomodReplace replace +syntax keyword gomodRetract retract  " require, exclude, replace, and go can be also grouped into block  syntax region gomodRequire start='require (' end=')' transparent contains=gomodRequire,gomodVersion  syntax region gomodExclude start='exclude (' end=')' transparent contains=gomodExclude,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  " set highlights @@ -30,6 +35,7 @@ highlight default link gomodGo      Keyword  highlight default link gomodRequire Keyword  highlight default link gomodExclude Keyword  highlight default link gomodReplace Keyword +highlight default link gomodRetract Keyword  " comments are always in form of // ...  syntax region gomodComment  start="//" end="$" contains=@Spell @@ -47,7 +53,6 @@ highlight default link gomodReplaceOperator Operator  syntax match gomodGoVersion "1\.\d\+" contained  highlight default link gomodGoVersion Identifier -  " highlight versions:  "  * vX.Y.Z-pre  "  * vX.Y.Z @@ -93,4 +98,15 @@ syntax match gomodVersion "v[2-9]\{1}\d*\.\d\+\.\d\+\%(+\%([0-9A-Za-z-]\+\)\%(\.  "                          ^------- version -------^^---------------- metadata ---------------------^  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" diff --git a/syntax/javascript.vim b/syntax/javascript.vim index dbd1c4ed..615862dc 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -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 keyword jsTry                    try             skipwhite skipempty nextgroup=jsTryCatchBlock  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 jsAsyncKeyword           async await  syntax match   jsSwitchColon   contained /::\@!/        skipwhite skipempty nextgroup=jsSwitchBlock diff --git a/syntax/julia.vim b/syntax/julia.vim index 5d9a7ae1..1a08f62d 100644 --- a/syntax/julia.vim +++ b/syntax/julia.vim @@ -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:  " 1) it only cares about charactes below 256  " 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.  " note: \U5B and \U5D are '[' and ']'  let s:nonid_chars = "\U01-\U07" . "\U0E-\U1F" . -      \             "\"#$'(,.:;=@`\\U5B{" . +      \             "?\"#$'(,.:;=@`\\U5B{" .        \             "\U80-\UA1" . "\UA7\UA8\UAB\UAD\UAF\UB4" . "\UB6-\UB8" . "\UBB\UBF"  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"  " 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 = '\%(' . '\.\%([-+*/^÷%|&!]\|//\|\\\|<<\|>>>\?\)\?=' .        \           '\|'  . '[:$<>]=\|||\|&&\||>\|<|\|<:\|>:\|::\|<<\|>>>\?\|//\|[-=]>\|\.\{3\}' . @@ -74,11 +74,11 @@ let s:operators = '\%(' . '\.\%([-+*/^÷%|&!]\|//\|\\\|<<\|>>>\?\)\?=' .  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 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 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 juliaErrorItems		contains=juliaErrorPar,juliaErrorEnd,juliaErrorElse,juliaErrorCatch,juliaErrorFinally +syntax cluster juliaSyntaxRegions	contains=juliaParamTypeR,juliaFunctionCallR,juliaTypeOperatorR,juliaWhereR +  syntax cluster juliaSpellcheckStrings		contains=@spell  syntax cluster juliaSpellcheckDocStrings	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  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' -syntax region  juliaCurBraBlock		matchgroup=juliaParDelim start="{" end="}" contains=@juliaExpressions +syntax region  juliaCurBraBlock		matchgroup=juliaParDelim start="{" end="}" contains=juliaType,@juliaExpressions + +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\|where\)\>"' +exec 'syntax match   juliaKeyword		display "'.s:nodot.'\<\%(return\|local\|global\|const\)\>"'  syntax match   juliaInfixKeyword	display "\%(=\s*\)\@<!\<\%(in\|isa\)\>\S\@!\%(\s*=\)\@!"  " 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  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  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  juliaStructBlock		matchgroup=juliaBlKeyword start="'.s:nodot.'\<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 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,juliaStructR 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  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  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' -" 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' -exec 'syntax region  juliaPrimitiveBlock	matchgroup=juliaBlKeyword start="'.s:nodot.'\<primitive\s\+type\>" end="'.s:nodot.'\<end\>" fold contains=@juliaExpressions' +exec 'syntax region  juliaFinallyBlock		matchgroup=juliaException transparent contained start="'.s:nodot.'\<finally\>" end="'.s:nodot.'\<end\>"me=s-1 contains=@juliaExpressions' +exec 'syntax region  juliaAbstractBlock		matchgroup=juliaBlKeyword start="'.s:nodot.'\<abstract\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,juliaStructR'  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   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   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   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  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 . '\)*"' +exec 'syntax region  juliaParamTypeR	transparent start="' . s:idregex . '\%(\.' . s:idregex . '\)*\s*{" end="}\@'.s:d(1).'<=" contains=juliaType,@juliaExpressions' -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 . '\)*"'  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'  syntax match   juliaComplexUnit		display	contained "\<im\>" -exec 'syntax match   juliaOperator	"' . s:operators . '"'  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' -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 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,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  "       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  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 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  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).'<=:'  " note: juliaSymbolS only works within whitespace-sensitive contexts, @@ -336,7 +350,7 @@ let s:quoting_colonS = '\s\@'.s:d(1).'<=:'  " (Note that such `a :b` expressions only allows at most 5 spaces between  " the identifier and the colon anyway.) -exec 'syntax match   juliaSymbol	contained "' .s:quoting_colon . s:quotable . '"' +exec 'syntax match   juliaSymbol	contained "' . s:quoting_colon . s:quotable . '"'  exec 'syntax match   juliaSymbolS	contained "' . s:quoting_colonS . s:quotable . '"'  " same as above for quoted expressions such as :(expr) @@ -346,7 +360,14 @@ exec 'syntax region   juliaQuotedParBlockS	matchgroup=juliaQParDelim contained s  " 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  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 juliaSemicolon		juliaNone  hi def link juliaComma			juliaNone +hi def link juliaFunctionCall		juliaNone  hi def link juliaColon			juliaOperator  hi def link juliaFunctionName		juliaFunction +hi def link juliaFunctionName1		juliaFunction  hi def link juliaMacroName		juliaMacro  hi def link juliaKeyword		Keyword +hi def link juliaWhereKeyword		Keyword  hi def link juliaInfixKeyword		Keyword +hi def link juliaIsaKeyword		Keyword  hi def link juliaAsKeyword		Keyword  hi def link juliaRepKeyword		Keyword  hi def link juliaBlKeyword		Keyword @@ -408,6 +433,8 @@ hi def link juliaBaseTypeDisplay	Type  hi def link juliaBaseTypeTime		Type  hi def link juliaBaseTypeOther		Type +hi def link juliaType			Type +  " NOTE: deprecated constants are not highlighted as such. For once,  " one can still legitimately use them by importing Base.MathConstants.  " 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 juliaShellString		juliaString  hi def link juliaDocString		juliaString +hi def link juliaDocStringM		juliaDocString  hi def link juliaStringDelim		juliaString  hi def link juliaDocStringDelim		juliaDocString  hi def link juliaStringVarsPla		Identifier @@ -484,6 +512,7 @@ hi def link juliaOperator		juliaOperatorHL  hi def link juliaRangeOperator		juliaOperatorHL  hi def link juliaCTransOperator		juliaOperatorHL  hi def link juliaTernaryOperator	juliaOperatorHL +hi def link juliaTypeOperator		juliaOperatorHL  hi def link juliaCommentL		Comment  hi def link juliaCommentM		Comment diff --git a/syntax/kotlin.vim b/syntax/kotlin.vim index 762c3068..c3ad6884 100644 --- a/syntax/kotlin.vim +++ b/syntax/kotlin.vim @@ -78,8 +78,8 @@ syn match ktComment "/\*\*/"  syn match ktSpecialCharError "\v\\." 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='"""' end='""""*' contains=ktSimpleInterpolation,ktComplexInterpolation +syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError,@Spell +syn region ktString start='"""' end='""""*' contains=ktSimpleInterpolation,ktComplexInterpolation,@Spell  syn match ktCharacter "\v'[^']*'" contains=ktSpecialChar,ktSpecialCharError  syn match ktCharacter "\v'\\''" contains=ktSpecialChar  syn match ktCharacter "\v'[^\\]'" diff --git a/syntax/llvm.vim b/syntax/llvm.vim index 57bb3d6f..cc5f50bb 100644 --- a/syntax/llvm.vim +++ b/syntax/llvm.vim @@ -18,7 +18,7 @@ syn case match  " Types.  " Types also include struct, array, vector, etc. but these don't  " 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 type label opaque token  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*REQUIRES:.*$/  syn match  llvmSpecialComment /;\s*RUN:.*$/ +syn match  llvmSpecialComment /;\s*ALLOW_RETRIES:.*$/  syn match  llvmSpecialComment /;\s*CHECK:.*$/  syn match  llvmSpecialComment "\v;\s*CHECK-(NEXT|NOT|DAG|SAME|LABEL):.*$"  syn match  llvmSpecialComment /;\s*XFAIL:.*$/ diff --git a/syntax/mlir.vim b/syntax/mlir.vim new file mode 100644 index 00000000..9bfd7f35 --- /dev/null +++ b/syntax/mlir.vim @@ -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" diff --git a/syntax/svelte.vim b/syntax/svelte.vim index ce454db0..d872826c 100644 --- a/syntax/svelte.vim +++ b/syntax/svelte.vim @@ -35,8 +35,6 @@ syntax keyword svelteKeyword slot contained containedin=htmlTag  "   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 svelteSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent -  " Block conditionals.  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  endfor +syntax region svelteSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent +  " Cybernetically enhanced web apps.  let b:current_syntax = "svelte"  | 
