refactor(kitty): Simplified queries

This commit is contained in:
Shawon 2025-09-28 21:21:39 +06:00
parent e8f1235837
commit 79c6c6d4b6
3 changed files with 125 additions and 409 deletions

View file

@ -1207,7 +1207,7 @@ return {
},
kitty = {
install_info = {
revision = '2662b50382cd43b283f8fcf5afdd0c8f5068cde8',
revision = '49f877cff80ab613808b34bde170ea477ec182fe',
url = 'https://github.com/OXY2DEV/tree-sitter-kitty',
},
maintainers = { '@OXY2DEV' },

View file

@ -1,10 +1,8 @@
; Extra Nodes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(line_continuation) @comment
(comment
(comment_content) @spell) @comment
; Primitive data types ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[
(pixel)
(percentage)
@ -12,27 +10,19 @@
] @number
[
"px"
"%"
] @type
"steps"
"cubic-bezier"
] @function.call
(boolean) @boolean
(layout_type) @type
; Hexadecimal colors.
(color) @constant
; Color names & `none`.
((color) @constant
(#match? @constant "^[^#]"))
(string) @string
(time
duration: (number) @number
suffix: (time_suffix) @type)
[
(ctrl)
(alt)
@ -40,402 +30,80 @@
(function)
(super)
(mouse_button)
(up)
(left)
(right)
(middle)
(down)
] @constant.builtin
[
"+"
">"
":"
"-"
(separator)
"="
","
"'"
":"
] @punctuation.delimiter
(special) @variable.builtin
(key) @character
; Actions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(generic_action) @function.call
(action_name) @function.call
(copy_to_buffer
buffer: (string) @character)
(paste_from_buffer
buffer: (string) @character)
(keyboard_mode
[
"normal"
"application"
"kitty"
"all"
] @constant)
(show_kitty_doc
topic: (string) @label)
(signal_child
signal: (signal_name) @type)
(clear_terminal
action: (clear_action) @constant
target: (clear_target) @type)
(combine_action
(separator) @punctuation.delimiter)
(disable_ligatures_in
target: (ligature_target) @type
type: (ligature_disabled) @constant)
(kitten
target: (string) @type)
; Command flags(`--flag`) should be highlighted *differently*.
(kitten_arguments
(string) @variable.parameter
(#match? @variable.parameter "^-"))
; Launch ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(flag) @constant
"=" @punctuation.delimiter
"," @punctuation.delimiter
(launch_type
type: _ @type)
(launch_source_window
pattern: (string) @string.regexp)
(launch_cwd
directory: (string) @string.special.path)
(launch_env
variable: (string) @variable.builtin)
(launch_var
variable: (string) @variable.builtin)
(launch_window_location
location: (window_location) @type)
(launch_next_to
pattern: (string) @string.regexp)
(launch_remote_password
[
"'"
"\""
] @punctuation.delimiter)
(launch_remote_password
password: (password) @string.special)
(remote_actions
(string) @constant.macro)
(launch_stdin_source
source: (stdin_source) @type)
(markers
type: (marker_type) @type)
(marker_entry
id: (marker_id) @label
pattern: (string) @string.regexp)
(launch_os_window_class
class: (string) @type)
(launch_os_window_name
name: (string) @string.special)
(launch_os_window_title
title: (string) @string.special)
(launch_os_window_state
state: (window_state) @type)
(launch_logo
path: (string) @string.special.path)
(launch_logo_position
position: (logo_position) @type)
(launch_color
name: (color_option_name) @variable.builtin)
(launch_spacing
name: (string) @variable.builtin)
; OS Panel ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; `option` may include any of the `os_panel_*` nodes.
; The first child of these nodes are **always** the
; option name.
(launch_os_panel
option: (_
(option) @variable.builtin))
(launch_watcher
path: (string) @string.special.path)
(load_config_file
path: (string)? @string.special.path)
(open_url
url: (string) @string.special.url)
(remote_control_script
path: (string) @string.special.path)
(handle_click_actions
_ @type)
(mouse_selection
selection: (mouse_selection_type) @type)
(scroll_to_prompt
prompt_number: (number) @number
lines_above: (number)? @operator)
(goto_tab
tab: (number) @label)
(set_tab_title
title: (title)? @string.special)
(set_window_title
title: (title) @string.special)
(move_window
direction: (direction) @constant)
(neighboring_window
direction: (direction) @constant)
(nth_window
window: (number) @label)
(resize_window
layout: (window_layout) @type)
(change_font_size
target: (os_window) @type)
(font_change_amount
sign: (font_change_sign)? @operator)
(close_window_with_confirmation
"ignore-shell"? @type)
(detach_window
into: (detach_into)? @type)
((background_alpha) @constant
(#eq? @constant "default"))
(nth_os_window
window: (number) @label)
(goto_layout
":" @punctuation.delimiter)
; Strings are mostly pre-defined keywords.
(layout_option
value: (string) @constant)
(aliased_action
name: (string) @function.call)
(pass_selection_to_program
program: (string) @string.special)
(new_window
program: (string)? @string.special
"@selection"? @type)
(kitty_shell
open_as: (kitty_shell_open_as)? @type)
; Colors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set_colors
"set_colors" @function.call)
(color_match
(string) @string.regexp)
(color_match_tab
(string) @string.regexp)
(color_option
name: (color_option_name) @keyword)
(color_value
.
(color_data
path: (string) @string.special.path))
(color_data
name: (color_option_name) @variable.builtin)
; Includes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(include
"include" @keyword
path: (string) @string.special.path)
(include
"globinclude" @keyword
glob: (string) @string.regexp)
(include
"geninclude" @keyword
path: (string) @string.special.path)
(include
"envinclude" @keyword
environment_variable: (string) @variable.builtin)
; Keyboard shortcut ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(keyboard_shortcut
"map" @keyword)
(key_focus_on
"--when-focus-on" @constant
condition: (string) @string.special)
; Mouse shortcuts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(mouse_shortcut
"mouse_map" @keyword
event_type: (mouse_event) @type)
(mouse_mode
[
"grabbed"
"ungrabbed"
] @variable.parameter)
; Options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(option_name) @keyword
(font_value
(string) @string.special)
(font_value
.
(string) @constant
(#any-of? @constant "auto" "monospace" "bold" "italic" "bold-italic") .)
(font_property
name: (string) @variable.parameter)
(symbol_map
codepoints: (string) @constant
font_name: (string) @string.special)
(narrow_symbols
codepoints: (string) @constant)
(font_features
font: (string)? @constant)
(font_features
"none" @constant)
(feature_list
(string) @string.special)
(modify_font
type: (font_modification_type) @type)
(undercurl_style
"-" @punctuation.delimiter)
(undercurl_style
[
"thin"
"thick"
"sparse"
"dense"
] @constant)
((composition_value) @constant
(#eq? @constant "platform"))
(fg_override_threshold
[
"ratio"
"%"
] @type)
(cursor) @type
((ease) @type
(#any-of? @type
"linear" "ease" "ease-in-out" "ease-in" "ease-out" "step-start" "step-end" "ease" "ease-in"
"ease-out" "ease-in-out"))
[
"("
")"
] @punctuation.bracket
(ease_step
"steps" @function.call)
(special) @variable.builtin
(ease_step
position: (ease_step_position) @type)
(key) @character
(cubic_bezier
"cubic-bezier" @function.call)
(path) @string.special.path
(scrollback_pager
command: (string) @string.special)
(label) @label
(url_prefix_list
(string) @constant)
(constant) @constant
(url_excluded_characters
characters: (string) @string.special)
(direction) @constant
(border_width
[
"px"
"pt"
] @type)
(pattern) @string.regexp
(transparent_color
"@" @punctuation.special
(alpha) @number)
(flag) @constant
(remote_control_password
password: (string) @string.special)
((string) @constant
(#match? @constant "^-"))
(remote_actions
(string) @type)
(generic_action) @function.call
(env
variable: (string) @variable.builtin)
((filter_sequence) @constant
(#eq? @constant "all"))
(boolean_operator) @keyword.operator
(filter_element
[
"title"
"body"
"app"
"type"
] @variable.parameter
":" @punctuation.delimiter
(string) @string.regexp)
(action_name) @function.call
[
"pt"
"px"
"%"
"ratio"
(signal_name)
(clear_target)
(ligature_target)
(window_location)
(stdin_source)
(marker_type)
(window_state)
(logo_position)
(mouse_selection_type)
(window_layout)
(os_window)
"ignore-shell"
(detach_into)
"@selection"
(kitty_shell_open_as)
(mouse_event)
(font_modification_type)
(ease_step_position)
"c"
(filter_element_type)
"all"
(ligature_disabled)
(clipboard_action)
(shell_feature)
(source_strategy)
@ -443,25 +111,68 @@
(paste_action)
(pointer)
(layout)
(launch_type_value)
(os_window_class)
(layout_type)
(time_suffix)
(cursor)
(spacing_type)
(remote_action)
(font_feature)
] @type
(kitten
target: (string) @type)
[
(color_option_name)
"map"
"mouse_map"
(option_name)
] @keyword
(open_url
value: (string) @string.special.url)
(handle_click_actions
_ @type)
(title) @string.special
(font_change_amount
sign: (font_change_sign) @operator)
(aliased_action
name: (string) @function.call)
(set_colors
"set_colors" @function.call)
(include
environment_variable: (string) @variable.builtin)
(key_focus_on
condition: (string) @string.special)
(mouse_mode
[
"grabbed"
"ungrabbed"
] @variable.parameter)
(font_property
name: (string) @variable.parameter)
(url_excluded_characters
value: (string) @character)
(transparent_color
"@" @punctuation.special
(alpha) @number)
(env
variable: (string) @variable.builtin)
(boolean_operator) @keyword.operator
(notification_action) @function.call
(notification_action
"command"
command: (string) @string.special)
(menu_map
value: (string) @string.special)
((titlebar_color) @constant
(#any-of? @constant "system" "background"))
(confirm_os_window_close
count_background: (string) @constant)
(initial_window_size
"c" @type)
(action_alias
name: (string) @string.special)

View file

@ -1,31 +1,36 @@
(launch_source_window
pattern: (string) @injection.content
value: (string) @injection.content
(#set! injection.language "regex"))
(launch_next_to
pattern: (string) @injection.content
value: (string) @injection.content
(#set! injection.language "regex"))
(marker_entry
pattern: (string) @injection.content
(pattern) @injection.content
(#set! injection.language "regex"))
(color_match
(string) @injection.content
(pattern) @injection.content
(#set! injection.language "regex"))
(color_match_tab
(string) @injection.content
(pattern) @injection.content
(#set! injection.language "regex"))
(include
glob: (string) @injection.content
glob: (pattern) @injection.content
(#set! injection.language "regex"))
(filter_element
(string) @injection.content
(pattern) @injection.content
(#set! injection.language "regex"))
(comment
(comment_content) @injection.content
(#set! injection.language "comment"))
; Integration for `doctext`.
; (comment
; (comment_content) @injection.content
; (#set! injection.language "comment"))