From 114336ac1d26063dc819c4ef607dfec5631acc4f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Sep 2025 08:26:49 +0800 Subject: [PATCH 1/3] vim-patch:9.1.1763: filetype: kitty config files are not recognized Problem: filetype: kitty config files are not recognized Solution: Detect */kitty/*.conf as kitty filetype, include a syntax script (Shawon). closes: vim/vim#18280 https://github.com/vim/vim/commit/a946ccf5ffdb7bbc2631c5cbebde18b75a5e284b Co-authored-by: Shawon --- runtime/lua/vim/filetype.lua | 2 + runtime/syntax/kitty.vim | 118 +++++++++++++++++++++++++++++ test/old/testdir/test_filetype.vim | 1 + 3 files changed, 121 insertions(+) create mode 100644 runtime/syntax/kitty.vim diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index f1beff1558..3e516a9a6e 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1702,6 +1702,7 @@ local filename = { Kconfig = 'kconfig', ['Kconfig.debug'] = 'kconfig', ['Config.in'] = 'kconfig', + ['kitty.conf'] = 'kitty', ['ldaprc'] = 'ldapconf', ['.ldaprc'] = 'ldapconf', ['ldap.conf'] = 'ldapconf', @@ -2302,6 +2303,7 @@ local pattern = { ['^${GNUPGHOME}/gpg%.conf$'] = 'gpg', ['/boot/grub/grub%.conf$'] = 'grub', ['/hypr/.*%.conf$'] = 'hyprlang', + ['/kitty/.*%.conf$'] = 'kitty', ['^lilo%.conf'] = starsetf('lilo'), ['^named.*%.conf$'] = 'named', ['^rndc.*%.conf$'] = 'named', diff --git a/runtime/syntax/kitty.vim b/runtime/syntax/kitty.vim new file mode 100644 index 0000000000..0c7b12b35e --- /dev/null +++ b/runtime/syntax/kitty.vim @@ -0,0 +1,118 @@ +" Vim syntax file +" Language: Kitty configuration files +" Maintainer: MD. Mouinul Hossain Shawon +" Last Change: Sun Sep 14 13:56:41 +06 2025 + +if exists("b:current_syntax") + finish +endif + +syn sync fromstart + +" Option """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Format: ` ...`< + +syn match kittyString /\S\+/ contains=Alpha contained +syn match kittyNumber /[+\-*\/]\{0,1}[0-9.]\+/ contained +syn match kittyAlpha /@[0-9.]\+/ contained +syn match kittyColor /#[0-9a-fA-F]\{3,6}/ nextgroup=Alpha contained +syn keyword kittyBoolean contained yes no +syn keyword kittyConstant contained none auto monospace bold italic ratio always never + +syn match kittyFlag /[+-]\{1,2}[a-zA-Z0-9-_]\+/ contained +syn match kittyParameter /-\{1,2}[a-zA-Z0-9-]\+=\S\+/ contained + +syn cluster kittyPrimitive contains=kittyNumber,kittyBoolean,kittyConstant,kittyColor,kittyString,kittyFlag,kittyParameter,kittyAlpha + +syn region kittyOption start="^\w" skip="[\n\r][ \t]*\\" end="[\r\n]" contains=kittyOptionName +syn match kittyOptionName /\w\+/ nextgroup=kittyOptionValue skipwhite contained +syn region kittyOptionValue start="\S" skip="[\r\n][ \t]*\\" end="\ze[\r\n]" contains=@kittyPrimitive contained + +" Keyboard shortcut """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Format: `map ?` + +syn match kittyKey /[^ \t\r\n+>]\+/ contained +syn match kittyCtrl /\<\(ctrl\|control\)\>\|\^/ contained +syn match kittyAlt /\<\(alt\|opt\|option\)\>\|⌥/ contained +syn match kittyShift /\<\(shift\)\>\|⇧/ contained +syn match kittySuper /\<\(cmd\|super\|command\)\>\|⌘/ contained + +syn match kittyAnd /+/ contained +syn match kittyWith />/ contained + +syn region kittyMap start="^\s*map" skip="[\r\n][ \t]*\\" end="[\r\n]" contains=kittyMapName,kittyMapValue + +syn keyword kittyMapName nextgroup=kittyMapValue skipwhite contained map +syn region kittyMapValue start="\S" skip="[\r\n][ \t]*\\" end="\ze[\r\n]" contains=kittyMapSeq,kittyMapAction contained + +syn region kittyMapAction start="\S" skip="[\r\n][ \t]*\\" end="\ze[\r\n]" contains=@kittyPrimitive contained +syn region kittyMapSeq start="\S" end="\ze\s\|^\ze[ \t]*\\" nextgroup=kittyMapAction,kittyMouseMapType skipwhite contains=kittyCtrl,kittyAlt,kittyShift,kittySuper,kittyAnd,kittyWith,kittyKey contained + +" Mouse shortcut """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Format: `mouse_map ?` + +syn region kittyMouseMap start="^\s*mouse_map" skip="[\r\n][ \t]*\\" end="[\r\n]" contains=kittyMouseMapName,kittyMouseMapValue + +syn keyword kittyMouseMapName nextgroup=kittyMouseMapValue contained mouse_map +syn region kittyMouseMapValue start="\S" skip="[\r\n][ \t]*\\" end="\ze[\r\n]" contains=kittyMapSeq,kittyMouseMapType,kittyMouseMapGrabbed contained + +syn region kittyMouseMapAction start="\S" skip="[\r\n][ \t]*\\" end="\ze[\r\n]" contains=@kittyPrimitive contained + +syn keyword kittyMouseMapType nextgroup=kittyMouseMapGrabbed skipwhite contained press release doublepress triplepress click doubleclick +syn match kittyMouseMapGrabbed /\(grabbed\|ungrabbed\)\%(,\(grabbed\|ungrabbed\)\)\?/ nextgroup=kittyMouseMapAction skipwhite contained + +" Kitty modifier """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Format: `kitty_mod ` + +syn region kittyMod start="^\s*kitty_mod" end="[\r\n]" contains=kittyModName,kittyMapSeq + +syn keyword kittyModName nextgroup=kittyMapSeq contained kitty_mod + +" Comment """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Format: `# `` + +syn match kittyComment /^#.*$/ + +" Line continuation """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Allows continuing lines by adding `\` at the start of a line. +" May have leading spaces & tabs. + +syn match kittyLineContinue /^[ \t]*\\[ \t]*/ containedin=kittyOptionValue,kittyMap,kittyMapAction,kittyMouseMap,kittyMouseMapValue contained + +" Highlight groups """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +hi link kittyString String +hi link kittyNumber Number +hi link kittyAlpha Type +hi link kittyColor Constant +hi link kittyBoolean Boolean +hi link kittyConstant Constant + +hi link kittyFlag Constant +hi link kittyParameter Specual + +hi link kittyOptionName Keyword +hi link kittyModName Keyword + +hi link kittyKey Special +hi link kittyCtrl Constant +hi link kittyAlt Constant +hi link kittyShift Constant +hi link kittySuper Constant + +hi link kittyAnd Operator +hi link kittyWith Operator + +hi link kittyMapName Function + +hi link kittyMouseMapName Function +hi link kittyMouseMapType Type +hi link kittyMouseMapGrabbed Constant + +hi link kittyComment Comment +hi link kittyLineContinue Comment + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +let b:current_syntax = "kitty" + diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 533e09befb..dee5c13842 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -420,6 +420,7 @@ func s:GetFilenameChecks() abort \ 'karel': ['file.kl', 'file.KL'], \ 'kconfig': ['Kconfig', 'Kconfig.debug', 'Kconfig.file', 'Config.in', 'Config.in.host'], \ 'kdl': ['file.kdl'], + \ 'kitty': ['kitty.conf', '~/.config/kitty/colorscheme.conf'], \ 'kivy': ['file.kv'], \ 'kix': ['file.kix'], \ 'kotlin': ['file.kt', 'file.ktm', 'file.kts'], From 72616693bd72f1bcaa3434b4a882696f3207cb0a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Sep 2025 08:30:33 +0800 Subject: [PATCH 2/3] vim-patch:b2113e5: runtime(kitty): fix typo in syntax script related: vim/vim#18280 https://github.com/vim/vim/commit/b2113e511f49761e5fd4fb20781115e379765608 Co-authored-by: Christian Brabandt --- runtime/syntax/kitty.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/syntax/kitty.vim b/runtime/syntax/kitty.vim index 0c7b12b35e..813161dffc 100644 --- a/runtime/syntax/kitty.vim +++ b/runtime/syntax/kitty.vim @@ -89,7 +89,7 @@ hi link kittyBoolean Boolean hi link kittyConstant Constant hi link kittyFlag Constant -hi link kittyParameter Specual +hi link kittyParameter Special hi link kittyOptionName Keyword hi link kittyModName Keyword From 8bc89f46b7565c22075af3cd0819e79b288dcf79 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Sep 2025 08:30:50 +0800 Subject: [PATCH 3/3] vim-patch:115b533: runtime(kitty): Fix typo in syntax file for kitty closes: vim/vim#18312 https://github.com/vim/vim/commit/115b5338da6035f76c07eaae9340e065f9bd4c60 Co-authored-by: Shawon --- runtime/syntax/kitty.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/syntax/kitty.vim b/runtime/syntax/kitty.vim index 813161dffc..6d37b664db 100644 --- a/runtime/syntax/kitty.vim +++ b/runtime/syntax/kitty.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Kitty configuration files " Maintainer: MD. Mouinul Hossain Shawon -" Last Change: Sun Sep 14 13:56:41 +06 2025 +" Last Change: Tue Sep 16 19:10:59 +06 2025 if exists("b:current_syntax") finish @@ -12,10 +12,10 @@ syn sync fromstart " Option """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Format: ` ...`< -syn match kittyString /\S\+/ contains=Alpha contained +syn match kittyString /\S\+/ contains=kittyAlpha contained syn match kittyNumber /[+\-*\/]\{0,1}[0-9.]\+/ contained syn match kittyAlpha /@[0-9.]\+/ contained -syn match kittyColor /#[0-9a-fA-F]\{3,6}/ nextgroup=Alpha contained +syn match kittyColor /#[0-9a-fA-F]\{3,6}/ nextgroup=kittyAlpha contained syn keyword kittyBoolean contained yes no syn keyword kittyConstant contained none auto monospace bold italic ratio always never