]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1763: filetype: kitty config files are not recognized v9.1.1763
authorShawon <mdmoinulhossainshawon@gmail.com>
Mon, 15 Sep 2025 19:10:12 +0000 (19:10 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 15 Sep 2025 19:10:12 +0000 (19:10 +0000)
Problem:  filetype: kitty config files are not recognized
Solution: Detect */kitty/*.conf as kitty filetype, include a syntax
          script (Shawon).

closes: #18280

Signed-off-by: Shawon <mdmoinulhossainshawon@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
.github/MAINTAINERS
runtime/filetype.vim
runtime/syntax/kitty.vim [new file with mode: 0644]
src/testdir/test_filetype.vim
src/version.c

index e94c3cbc555f73dcd199dd978b5fd5fbaa2660f1..43b7fb4a6923c3c9407b0561e20479d5ccf78e0b 100644 (file)
@@ -536,6 +536,7 @@ runtime/syntax/just.vim                                     @pbnj
 runtime/syntax/jq.vim                                  @vito-c
 runtime/syntax/karel.vim                               @kirillmorozov
 runtime/syntax/kconfig.vim                             @chrisbra
+runtime/syntax/kitty.vim                               @OXY2DEV
 runtime/syntax/kivy.vim                                        @prophittcorey
 runtime/syntax/kotlin.vim                              @udalov
 runtime/syntax/kdl.vim                                 @imsnif @jiangyinzuo
index 629d3a1d0dfd47192c515e32b2bbc53a085ff8ab..5d27801f23ce3ab224de915af3233408cd29d860 100644 (file)
@@ -1340,6 +1340,9 @@ au BufNewFile,BufRead *.jl                        setf julia
 " Just
 au BufNewFile,BufRead \c{,*.}justfile,\c*.just setf just
 
+" Kitty
+au BufNewFile,BufRead kitty.conf,*/kitty/*.conf setf kitty
+
 " KAREL
 au BufNewFile,BufRead *.kl setf karel
 if has("fname_case")
diff --git a/runtime/syntax/kitty.vim b/runtime/syntax/kitty.vim
new file mode 100644 (file)
index 0000000..0c7b12b
--- /dev/null
@@ -0,0 +1,118 @@
+" Vim syntax file
+" Language:          Kitty configuration files
+" Maintainer:        MD. Mouinul Hossain Shawon <mdmouinulhossainshawon [at] gmail.com>
+" Last Change:       Sun Sep 14 13:56:41 +06 2025
+
+if exists("b:current_syntax")
+  finish
+endif
+
+syn sync fromstart
+
+" Option """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Format: `<option_name> ...`<
+
+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 <keys> <action>?`
+
+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 <keys> <type> <grabbed> <action>?`
+
+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 <keys>`
+
+syn region kittyMod start="^\s*kitty_mod" end="[\r\n]" contains=kittyModName,kittyMapSeq
+
+syn keyword kittyModName nextgroup=kittyMapSeq contained kitty_mod
+
+" Comment """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Format: `# <content>``
+
+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"
+
index 05194cf33872b5c477432ccd84f33b9441447f00..5752e7c4033d3d5bb1bd41d8dafec86ea47b4c97 100644 (file)
@@ -422,6 +422,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     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'],
index 9e722ac3ff615725f4d6cbd93a39798270b716ed..696fde76f46b17713117b6372eef5b636c6d607f 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1763,
 /**/
     1762,
 /**/