Skip to content

Commit

Permalink
runtime(vim): Update base-syntax file, improve :z matching
Browse files Browse the repository at this point in the history
Improve matching of the :z command.

Exclude this from the autogenerated ex-command list as it is handled
specially.
  • Loading branch information
dkearns committed Feb 16, 2024
1 parent d00fb4b commit baf55d0
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 11 deletions.
2 changes: 1 addition & 1 deletion runtime/syntax/generator/gen_syntax_vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function! s:get_vim_command_type(cmd_name)
\ 'autocmd', 'doautocmd', 'doautoall',
\ 'echo', 'echohl', 'execute',
\ 'behave', 'augroup', 'normal', 'syntax',
\ 'append', 'insert',
\ 'append', 'insert', 'z',
\ 'Next', 'Print', 'X',
\ ]
" Required for original behavior
Expand Down
16 changes: 12 additions & 4 deletions runtime/syntax/generator/vim.vim.base
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ syn cluster vimCommentGroup contains=vimTodo,@Spell

syn keyword vimCommand contained 2mat[ch] 3mat[ch]

syn match vimCommand contained "\<z[-+^.=]\=\>"
syn keyword vimStdPlugin contained Arguments Asm Break Cfilter Clear Continue DiffOrig Evaluate Finish Gdb Lfilter Man Over Program Run S Source Step Stop Termdebug TermdebugCommand TOhtml Until Winbar XMLent XMLns

" vimOptions are caught only when contained in a vimSet {{{2
Expand Down Expand Up @@ -164,7 +163,8 @@ syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vi
syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment

" All vimCommands are contained by vimIsCommand. {{{2
syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimEcho,vimEchoHL,vimExecute,vimIsCommand,vimExtCmd,vimFilter,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd
syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimEcho,vimEchoHL,vimExecute,vimIsCommand,vimExtCmd,vimFilter,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd,vimZ
syn match vimBang contained "\a\@1<=!"
syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand
syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>"
syn match vimVar "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
Expand All @@ -174,6 +174,12 @@ syn match vimVar "\s\zs&t_k;"
syn match vimFBVar contained "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
syn keyword vimCommand contained in

" Context lines: z {{{2
" =======================

syn match vimZ /\<z!\=#\=[-+^.=]\=\d*\%([[:space:]|"]\|$\)\@=/ contains=vimBang,vimZCount
syn match vimZCount contained "\d\+"

" Insertions And Appends: insert append {{{2
" (buftype != nofile test avoids having append, change, insert show up in the command window)
" =======================
Expand Down Expand Up @@ -929,7 +935,7 @@ if !exists("skip_vim_syntax_inits")
hi def link vimAutoCmdMod Special
hi def link vimAutoSet vimCommand
hi def link vimBang vimOper
hi def link vimBehaveBang vimBang
hi def link vimBehaveBang vimBang
hi def link vimBehaveModel vimBehave
hi def link vimBehave vimCommand
hi def link vimBracket Delimiter
Expand Down Expand Up @@ -1091,6 +1097,8 @@ if !exists("skip_vim_syntax_inits")
hi def link vimUserFunc Normal
hi def link vimVar Identifier
hi def link vimWarn WarningMsg
hi def link vimZ vimCommand
hi def link vimZCount vimNumber
endif

" Current Syntax Variable: {{{2
Expand All @@ -1108,4 +1116,4 @@ delc VimFoldr
delc VimFoldt
let &cpo = s:keepcpo
unlet s:keepcpo
" vim:ts=18 fdm=marker
" vim:ft=vim ts=18 fdm=marker
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/vim_ex_z_00.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
>"+0#0000e05#ffffff0| |V|i|m| |:|z| |c|o|m@1|a|n|d| +0#0000000&@58
@75
|e|r@1|z| @70
|z|e|r@1| @70
|e|r@1|z|e|r@1| @67
@75
|z+0#af5f00255&| +0#0000000&@73
|:|z+0#af5f00255&| +0#0000000&@72
|||z+0#af5f00255&| +0#0000000&@72
|^+0#0000e05&|@|z+0#af5f00255&| +0#0000000&@71
@75
|z+0#af5f00255&||+0#0000000&| @72
|z+0#af5f00255&|^+0#0000e05&|@| +0#0000000&@71
|z+0#af5f00255&|"+0#0000000&| |c|o|m@1|e|n|t| @64
@75
|z+0#af5f00255&| +0#0000000&@73
|z+0#af5f00255&|!| +0#0000000&@72
|z+0#af5f00255&|#| +0#0000000&@72
@75
|"|i|n|p|u|t|/|v|i|m|_|e|x|_|z|.|v|i|m|"| |7|6|L|,| |3|4|9|B| @26|1|,|1| @10|T|o|p|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/vim_ex_z_01.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|z+0#af5f00255#ffffff0|"+0#0000000&| |c|o|m@1|e|n|t| @64
@75
|z+0#af5f00255&| +0#0000000&@73
|z+0#af5f00255&|!| +0#0000000&@72
|z+0#af5f00255&|#| +0#0000000&@72
> @74
|z+0#af5f00255&|+| +0#0000000&@72
|z+0#af5f00255&|-| +0#0000000&@72
|z+0#af5f00255&|^| +0#0000000&@72
|z+0#af5f00255&|.| +0#0000000&@72
|z+0#af5f00255&|=| +0#0000000&@72
@75
|z+0#af5f00255&|!|+| +0#0000000&@71
|z+0#af5f00255&|!|-| +0#0000000&@71
|z+0#af5f00255&|!|^| +0#0000000&@71
|z+0#af5f00255&|!|.| +0#0000000&@71
|z+0#af5f00255&|!|=| +0#0000000&@71
@75
|z+0#af5f00255&|#|+| +0#0000000&@71
@57|1|9|,|0|-|1| @7|2@1|%|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/vim_ex_z_02.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|z+0#af5f00255#ffffff0|#|+| +0#0000000&@71
|z+0#af5f00255&|#|-| +0#0000000&@71
|z+0#af5f00255&|#|^| +0#0000000&@71
|z+0#af5f00255&|#|.| +0#0000000&@71
|z+0#af5f00255&|#|=| +0#0000000&@71
> @74
|z+0#af5f00255&|!|#|+| +0#0000000&@70
|z+0#af5f00255&|!|#|-| +0#0000000&@70
|z+0#af5f00255&|!|#|^| +0#0000000&@70
|z+0#af5f00255&|!|#|.| +0#0000000&@70
|z+0#af5f00255&|!|#|=| +0#0000000&@70
@75
|z+0#af5f00255&|4+0#e000002&|2| +0#0000000&@71
|z+0#af5f00255&|!|4+0#e000002&|2| +0#0000000&@70
|z+0#af5f00255&|#|4+0#e000002&|2| +0#0000000&@70
@75
|z+0#af5f00255&|+|4+0#e000002&|2| +0#0000000&@70
|z+0#af5f00255&|-|4+0#e000002&|2| +0#0000000&@70
|z+0#af5f00255&|^|4+0#e000002&|2| +0#0000000&@70
@57|3|7|,|0|-|1| @7|5|4|%|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/vim_ex_z_03.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|z+0#af5f00255#ffffff0|^|4+0#e000002&|2| +0#0000000&@70
|z+0#af5f00255&|.|4+0#e000002&|2| +0#0000000&@70
|z+0#af5f00255&|=|4+0#e000002&|2| +0#0000000&@70
@75
|z+0#af5f00255&|!|+|4+0#e000002&|2| +0#0000000&@69
>z+0#af5f00255&|!|-|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|!|^|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|!|.|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|!|=|4+0#e000002&|2| +0#0000000&@69
@75
|z+0#af5f00255&|#|+|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|#|-|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|#|^|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|#|.|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|#|=|4+0#e000002&|2| +0#0000000&@69
@75
|z+0#af5f00255&|!|#|+|4+0#e000002&|2| +0#0000000&@68
|z+0#af5f00255&|!|#|-|4+0#e000002&|2| +0#0000000&@68
|z+0#af5f00255&|!|#|^|4+0#e000002&|2| +0#0000000&@68
@57|5@1|,|1| @9|8|5|%|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/vim_ex_z_04.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|z+0#af5f00255#ffffff0|!|#|^|4+0#e000002&|2| +0#0000000&@68
|z+0#af5f00255&|!|#|.|4+0#e000002&|2| +0#0000000&@68
|z+0#af5f00255&|!|#|=|4+0#e000002&|2| +0#0000000&@68
@75
|1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|+|4+0#e000002&|2| +0#0000000&@65
>1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|-|4+0#e000002&|2| +0#0000000&@65
|1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|^|4+0#e000002&|2| +0#0000000&@65
|1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|.|4+0#e000002&|2| +0#0000000&@65
|1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|=|4+0#e000002&|2| +0#0000000&@65
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|7|3|,|1| @9|B|o|t|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/vim_ex_z_99.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|z+0#af5f00255#ffffff0|!|=|4+0#e000002&|2| +0#0000000&@69
@75
|z+0#af5f00255&|#|+|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|#|-|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|#|^|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|#|.|4+0#e000002&|2| +0#0000000&@69
|z+0#af5f00255&|#|=|4+0#e000002&|2| +0#0000000&@69
@75
|z+0#af5f00255&|!|#|+|4+0#e000002&|2| +0#0000000&@68
|z+0#af5f00255&|!|#|-|4+0#e000002&|2| +0#0000000&@68
|z+0#af5f00255&|!|#|^|4+0#e000002&|2| +0#0000000&@68
|z+0#af5f00255&|!|#|.|4+0#e000002&|2| +0#0000000&@68
|z+0#af5f00255&|!|#|=|4+0#e000002&|2| +0#0000000&@68
@75
|1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|+|4+0#e000002&|2| +0#0000000&@65
|1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|-|4+0#e000002&|2| +0#0000000&@65
|1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|^|4+0#e000002&|2| +0#0000000&@65
|1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|.|4+0#e000002&|2| +0#0000000&@65
>1+0#e000002&|3| +0#0000000&|z+0#af5f00255&|!|#|=|4+0#e000002&|2| +0#0000000&@65
@57|7|6|,|1| @9|B|o|t|
Binary file added runtime/syntax/testdir/input/vim_ex_z.vim
Binary file not shown.
20 changes: 14 additions & 6 deletions runtime/syntax/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <[email protected]>
" URL: https://github.com/vim-jp/syntax-vim-ex
" Last Change: Feb 14, 2024
" Last Change: Feb 17, 2024
" Former Maintainer: Charles E. Campbell <[email protected]>
" Base File URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_VIM
" Base File Version: 9.0-25
Expand Down Expand Up @@ -34,15 +34,14 @@ syn keyword vimCommand contained foldd[oopen] folddoc[losed] foldo[pen] for fu[n
syn keyword vimCommand contained lo[adview] loadk[eymap] loc[kmarks] lockv[ar] lol[der] lop[en] lp[revious] lpf[ile] lr[ewind] lt[ag] lua luad[o] luaf[ile] lv[imgrep] lvimgrepa[dd] lw[indow] ls m[ove] ma[rk] mak[e] marks mat[ch] menut[ranslate] mes[sages] mk[exrc] mks[ession] mksp[ell] mkv[imrc] mkvie[w] mod[e] mz[scheme] mzf[ile] n[ext] nb[key] nbc[lose] nbs[tart] new noa[utocmd] noh[lsearch] nos[wapfile] nu[mber] o[pen] ol[dfiles] on[ly] opt[ions] ow[nsyntax] p[rint] pa[ckadd] packl[oadall] pc[lose] pe[rl] perld[o] ped[it] po[p] popu[p] pp[op] pre[serve] prev[ious] pro[mptfind] promptr[epl] prof[ile] profd[el] ps[earch] pt[ag] ptN[ext] ptf[irst] ptj[ump] ptl[ast] ptn[ext] ptp[revious] ptr[ewind] pts[elect] pu[t] pub[lic] pw[d] py[thon] pyd[o] pyf[ile] py3 py3d[o]
syn keyword vimCommand contained python3 py3f[ile] pyx pyxd[o] pythonx pyxf[ile] q[uit] quita[ll] qa[ll] r[ead] rec[over] red[o] redi[r] redr[aw] redraws[tatus] redrawt[abline] reg[isters] res[ize] ret[ab] retu[rn] rew[ind] ri[ght] rightb[elow] ru[ntime] rub[y] rubyd[o] rubyf[ile] rund[o] rv[iminfo] sN[ext] sa[rgument] sal[l] san[dbox] sav[eas] sb[uffer] sbN[ext] sba[ll] sbf[irst] sbl[ast] sbm[odified] sbn[ext] sbp[revious] sbr[ewind] sc[riptnames] scripte[ncoding] scriptv[ersion] scs[cope] setf[iletype] sf[ind] sfir[st] sh[ell] si[malt] sig[n] sil[ent] sl[eep] sla[st] sn[ext] so[urce] sor[t] sp[lit] spe[llgood] spelld[ump] spelli[nfo] spellr[epall] spellra[re] spellu[ndo] spellw[rong] spr[evious] sr[ewind] st[op] sta[g] star[tinsert] startg[replace] startr[eplace]
syn keyword vimCommand contained stat[ic] stopi[nsert] stj[ump] sts[elect] sun[hide] sus[pend] sv[iew] sw[apname] synti[me] sync[bind] smi[le] t tN[ext] ta[g] tags tab tabc[lose] tabd[o] tabe[dit] tabf[ind] tabfir[st] tabm[ove] tabl[ast] tabn[ext] tabnew tabo[nly] tabp[revious] tabN[ext] tabr[ewind] tabs tc[d] tch[dir] tcl tcld[o] tclf[ile] te[aroff] ter[minal] tf[irst] th[row] thi[s] tj[ump] tl[ast] tm[enu] tn[ext] to[pleft] tp[revious] tr[ewind] try ts[elect] tu[nmenu] ty[pe] u[ndo] undoj[oin] undol[ist] una[bbreviate] unh[ide] unl[et] unlo[ckvar] uns[ilent] up[date] v[global] ve[rsion] verb[ose] vert[ical] vi[sual] vie[w] vim[grep] vimgrepa[dd] vim9[cmd] vim9s[cript] viu[sage] vne[w] vs[plit] w[rite] wN[ext] wa[ll] wh[ile] wi[nsize] winc[md] wind[o] winp[os]
syn keyword vimCommand contained wn[ext] wp[revious] wq wqa[ll] wu[ndo] wv[iminfo] x[it] xa[ll] xr[estore] y[ank] z dl dell delel deletl deletel dp dep delp delep deletp deletep a i
syn keyword vimCommand contained wn[ext] wp[revious] wq wqa[ll] wu[ndo] wv[iminfo] x[it] xa[ll] xr[estore] y[ank] dl dell delel deletl deletel dp dep delp delep deletp deletep a i
syn keyword vimCommand contained am[enu] an[oremenu] aun[menu] cme[nu] cnoreme[nu] cunme[nu] ime[nu] inoreme[nu] iunme[nu] me[nu] nme[nu] nnoreme[nu] noreme[nu] nunme[nu] ome[nu] onoreme[nu] ounme[nu] sme[nu] snoreme[nu] sunme[nu] tlm[enu] tln[oremenu] tlu[nmenu] unme[nu] vme[nu] vnoreme[nu] vunme[nu] xme[nu] xnoreme[nu] xunme[nu]
syn keyword vimCommand contained cm[ap] cno[remap] im[ap] ino[remap] lm[ap] ln[oremap] nm[ap] nn[oremap] no[remap] om[ap] ono[remap] smap snor[emap] tma[p] tno[remap] vm[ap] vn[oremap] xm[ap] xn[oremap]
syn keyword vimCommand contained cmapc[lear] imapc[lear] lmapc[lear] mapc[lear] nmapc[lear] omapc[lear] smapc[lear] tmapc[lear] vmapc[lear] xmapc[lear]
syn keyword vimCommand contained cu[nmap] iu[nmap] lu[nmap] nun[map] ou[nmap] sunm[ap] tunma[p] unm[ap] vu[nmap] xu[nmap]

syn keyword vimCommand contained 2mat[ch] 3mat[ch]

syn match vimCommand contained "\<z[-+^.=]\=\>"
syn keyword vimStdPlugin contained Arguments Asm Break Cfilter Clear Continue DiffOrig Evaluate Finish Gdb Lfilter Man Over Program Run S Source Step Stop Termdebug TermdebugCommand TOhtml Until Winbar XMLent XMLns

" vimOptions are caught only when contained in a vimSet {{{2
Expand Down Expand Up @@ -206,7 +205,8 @@ syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vi
syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment

" All vimCommands are contained by vimIsCommand. {{{2
syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimEcho,vimEchoHL,vimExecute,vimIsCommand,vimExtCmd,vimFilter,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd
syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimEcho,vimEchoHL,vimExecute,vimIsCommand,vimExtCmd,vimFilter,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd,vimZ
syn match vimBang contained "\a\@1<=!"
syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand
syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>"
syn match vimVar "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
Expand All @@ -216,6 +216,12 @@ syn match vimVar "\s\zs&t_k;"
syn match vimFBVar contained "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
syn keyword vimCommand contained in

" Context lines: z {{{2
" =======================

syn match vimZ /\<z!\=#\=[-+^.=]\=\d*\%([[:space:]|"]\|$\)\@=/ contains=vimBang,vimZCount
syn match vimZCount contained "\d\+"

" Insertions And Appends: insert append {{{2
" (buftype != nofile test avoids having append, change, insert show up in the command window)
" =======================
Expand Down Expand Up @@ -977,7 +983,7 @@ if !exists("skip_vim_syntax_inits")
hi def link vimAutoCmdMod Special
hi def link vimAutoSet vimCommand
hi def link vimBang vimOper
hi def link vimBehaveBang vimBang
hi def link vimBehaveBang vimBang
hi def link vimBehaveModel vimBehave
hi def link vimBehave vimCommand
hi def link vimBracket Delimiter
Expand Down Expand Up @@ -1139,6 +1145,8 @@ if !exists("skip_vim_syntax_inits")
hi def link vimUserFunc Normal
hi def link vimVar Identifier
hi def link vimWarn WarningMsg
hi def link vimZ vimCommand
hi def link vimZCount vimNumber
endif

" Current Syntax Variable: {{{2
Expand All @@ -1156,4 +1164,4 @@ delc VimFoldr
delc VimFoldt
let &cpo = s:keepcpo
unlet s:keepcpo
" vim:ts=18 fdm=marker
" vim:ft=vim ts=18 fdm=marker

0 comments on commit baf55d0

Please sign in to comment.