diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-07-25 09:55:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-25 09:55:59 +0800 |
commit | 0cdeb06db0062951f2f2d2998510e2fff7e0faee (patch) | |
tree | 9742e89b2e7c5e520d74f7067d185db840200375 | |
parent | b4b4cf46a7a2b6d7b4e997179166444b0e338ac8 (diff) | |
download | rneovim-0cdeb06db0062951f2f2d2998510e2fff7e0faee.tar.gz rneovim-0cdeb06db0062951f2f2d2998510e2fff7e0faee.tar.bz2 rneovim-0cdeb06db0062951f2f2d2998510e2fff7e0faee.zip |
vim-patch:ddbb6fe: runtime(vim): Update base-syntax, improve :set highlighting (#29850)
- Match bang, "all" and "termcap" options, and trailing command
separator "|".
- Highlight set assignment operators.
- Match multiline :set and multiline option values.
- Mention the newer "0o" octal prefix at :help :set=.
closes: vim/vim#15329
https://github.com/vim/vim/commit/ddbb6fe2d0344e93436c5602b7a06169f49a9b52
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
-rw-r--r-- | runtime/doc/options.txt | 3 | ||||
-rw-r--r-- | runtime/syntax/vim.vim | 22 | ||||
-rw-r--r-- | src/nvim/generators/gen_vimvim.lua | 7 |
3 files changed, 22 insertions, 10 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 7dcaa5260a..adc6dfc890 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -58,7 +58,8 @@ achieve special effects. These options come in three forms: :se[t] {option}:{value} Set string or number option to {value}. For numeric options the value can be given in decimal, - hex (preceded with 0x) or octal (preceded with '0'). + hex (preceded with 0x) or octal (preceded with '0' or + '0o'). The old value can be inserted by typing 'wildchar' (by default this is a <Tab>). Many string options with fixed syntax also support completing known values. diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 1c6aa72448..8dd72d76e5 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -36,8 +36,8 @@ syn keyword vimOnlyOption contained nobiosk nobioskey noconsk noconskey nocp noc " Invertible setting variants syn keyword vimOnlyOption contained invbiosk invbioskey invconsk invconskey invcp invcompatible invguipty invmacatsui invsn invshortname invta invtextauto invtx invtextmode invtf invttyfast invtbi invttybuiltin invwiv invweirdinvert " termcap codes (which can also be set) {{{2 -" GEN_SYN_VIM: vimOption term output code, START_STR='syn keyword vimOption contained', END_STR='' -syn keyword vimOption contained t_AB t_AF t_AU t_AL t_al t_bc t_BE t_BD t_cd t_ce t_Ce t_CF t_cl t_cm t_Co t_CS t_Cs t_cs t_CV t_da t_db t_DL t_dl t_ds t_Ds t_EC t_EI t_fs t_fd t_fe t_GP t_IE t_IS t_ke t_ks t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RF t_RB t_RC t_RI t_Ri t_RK t_RS t_RT t_RV t_Sb t_SC t_se t_Sf t_SH t_SI t_Si t_so t_SR t_sr t_ST t_Te t_te t_TE t_ti t_TI t_Ts t_ts t_u7 t_ue t_us t_Us t_ut t_vb t_ve t_vi t_VS t_vs t_WP t_WS t_XM t_xn t_xs t_ZH t_ZR t_8f t_8b t_8u +" GEN_SYN_VIM: vimOption term output code, START_STR='syn keyword vimOption contained', END_STR='skipwhite nextgroup=vimSetEqual,vimSetMod' +syn keyword vimOption contained t_AB t_AF t_AU t_AL t_al t_bc t_BE t_BD t_cd t_ce t_Ce t_CF t_cl t_cm t_Co t_CS t_Cs t_cs t_CV t_da t_db t_DL t_dl t_ds t_Ds t_EC t_EI t_fs t_fd t_fe t_GP t_IE t_IS t_ke t_ks t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RF t_RB t_RC t_RI t_Ri t_RK t_RS t_RT t_RV t_Sb t_SC t_se t_Sf t_SH t_SI t_Si t_so t_SR t_sr t_ST t_Te t_te t_TE t_ti t_TI t_Ts t_ts t_u7 t_ue t_us t_Us t_ut t_vb t_ve t_vi t_VS t_vs t_WP t_WS t_XM t_xn t_xs t_ZH t_ZR t_8f t_8b t_8u t_xo skipwhite nextgroup=vimSetEqual,vimSetMod " term key codes syn keyword vimOption contained t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ku syn match vimTermOption contained "t_%1" @@ -497,11 +497,15 @@ syn match vimCmplxRepeat '[^a-zA-Z_/\\()]q[0-9a-zA-Z"]\>'lc=1 syn match vimCmplxRepeat '@[0-9a-z".=@:]\ze\($\|[^a-zA-Z]\>\)' " Set command and associated set-options (vimOptions) with comment {{{2 -syn region vimSet matchgroup=vimCommand start="\<\%(setl\%[ocal]\|setg\%[lobal]\|se\%[t]\)\>" skip="\%(\\\\\)*\\.\n\@!" end="$" end="|" matchgroup=vimNotation end="<[cC][rR]>" keepend contains=vimSetEqual,vimOption,vimErrSetting,@vimComment,vimSetString,vimSetMod -syn region vimSetEqual contained start="[=:]\|[-+^]=" skip="\\\\\|\\\s" end="[| \t]"me=e-1 end="$" contains=vimCtrlChar,vimSetSep,vimNotation,vimEnvvar -syn region vimSetString contained start=+="+hs=s+1 skip=+\\\\\|\\"+ end=+"+ contains=vimCtrlChar +syn match vimSet "\<\%(setl\%[ocal]\|setg\%[lobal]\|se\%[t]\)\>" skipwhite nextgroup=vimSetBang,vimSetRegion +syn region vimSetRegion contained start="\S" skip=+\\\\\|\\|\|\n\s*\\\|\n\s*["#]\\ + matchgroup=vimCmdSep end="|" end="$" matchgroup=vimNotation end="<[cC][rR]>" keepend contains=@vimComment,@vimContinue,vimErrSetting,vimOption,vimSetAll,vimSetTermcap +syn region vimSetEqual contained matchgroup=vimOper start="[=:]\|[-+^]=" skip=+\\\\\|\\|\|\\\s\|\n\s*\\\|\n\s*["#]\\ \|^\s*\\\|^\s*["#]\\ + matchgroup=vimCmdSep end="|" end="\ze\s" end="$" contains=@vimContinue,vimCtrlChar,vimEnvvar,vimNotation,vimSetSep +syn match vimSetBang contained "\a\@1<=!" skipwhite nextgroup=vimSetAll,vimSetTermcap +syn keyword vimSetAll contained all nextgroup=vimSetMod +syn keyword vimSetTermcap contained termcap +syn region vimSetString contained start=+="+hs=s+1 skip=+\\\\\|\\"+ end=+"+ contains=vimCtrlChar syn match vimSetSep contained "[,:]" -syn match vimSetMod contained "&vim\=\|[!&?<]\|all&" +syn match vimSetMod contained "\a\@1<=\%(&vim\=\|[!&?<]\)" " Variable Declarations: {{{2 " ===================== @@ -1228,9 +1232,13 @@ if !exists("skip_vim_syntax_inits") hi def link vimSearchDelim Statement hi def link vimSearch vimString hi def link vimSep Delimiter + hi def link vimSet vimCommand + hi def link vimSetAll vimOption + hi def link vimSetBang vimBang hi def link vimSetMod vimOption - hi def link vimSetSep Statement + hi def link vimSetSep vimSep hi def link vimSetString vimString + hi def link vimSetTermcap vimOption hi def link vimShebang PreProc hi def link vimSleep vimCommand hi def link vimSleepArg Constant diff --git a/src/nvim/generators/gen_vimvim.lua b/src/nvim/generators/gen_vimvim.lua index fcdc5bddc2..0675f04b73 100644 --- a/src/nvim/generators/gen_vimvim.lua +++ b/src/nvim/generators/gen_vimvim.lua @@ -80,12 +80,13 @@ for _, cmd_desc in ipairs(ex_cmds.cmds) do end local vimopt_start = 'syn keyword vimOption contained ' +local vimopt_end = ' skipwhite nextgroup=vimSetEqual,vimSetMod' w('\n\n' .. vimopt_start) for _, opt_desc in ipairs(options.options) do if not opt_desc.immutable then if lld.line_length > 850 then - w('\n' .. vimopt_start) + w(vimopt_end .. '\n' .. vimopt_start) end w(' ' .. opt_desc.full_name) if opt_desc.abbreviation then @@ -102,7 +103,9 @@ for _, opt_desc in ipairs(options.options) do end end -w('\n\nsyn case ignore') +w(vimopt_end .. '\n') + +w('\nsyn case ignore') local vimau_start = 'syn keyword vimAutoEvent contained ' w('\n\n' .. vimau_start) |