From 8e9c112be3424fd229538226f75c57d981633a41 Mon Sep 17 00:00:00 2001 From: 10000DOO Date: Fri, 10 Apr 2026 22:34:22 +0900 Subject: [PATCH 1/3] Add C, C++, and Objective-C language support for sourcekit-lsp Migrate from deprecated `language` field to `languages` array and register sourcekit-lsp for C, C++, and Objective-C in addition to Swift. sourcekit-lsp natively supports these languages via its built-in clangd integration. This mirrors the approach taken by the official VSCode Swift extension, which declares support for all sourcekit-lsp-supported languages. Closes #47 Co-Authored-By: Claude Opus 4.6 (1M context) --- extension.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extension.toml b/extension.toml index 92b23ac..289ec67 100644 --- a/extension.toml +++ b/extension.toml @@ -11,7 +11,13 @@ repository = "https://github.com/zed-extensions/swift" [language_servers.sourcekit-lsp] name = "sourcekit-lsp" -language = "Swift" +languages = ["Swift", "C", "C++", "Objective-C"] + +[language_servers.sourcekit-lsp.language_ids] +Swift = "swift" +C = "c" +"C++" = "cpp" +"Objective-C" = "objective-c" [grammars.swift] repository = "https://github.com/alex-pinkus/tree-sitter-swift" From f0ab9e2dbea2c02c1c5fdfbcf3ae820bbd97874b Mon Sep 17 00:00:00 2001 From: 10000DOO Date: Sat, 11 Apr 2026 15:47:48 +0900 Subject: [PATCH 2/3] Add Objective-C and Objective-C++ language definitions Without language definitions, Zed cannot recognize .m/.mm/.h files as Objective-C, causing sourcekit-lsp to never start for these files. - Add tree-sitter-objc grammar - Add languages/objective-c/ with config.toml and highlights.scm - Add languages/objective-cpp/ for .mm file support - Add Objective-C++ to sourcekit-lsp language routing --- extension.toml | 7 +- languages/objective-c/config.toml | 15 ++ languages/objective-c/highlights.scm | 344 +++++++++++++++++++++++++ languages/objective-cpp/config.toml | 15 ++ languages/objective-cpp/highlights.scm | 344 +++++++++++++++++++++++++ 5 files changed, 724 insertions(+), 1 deletion(-) create mode 100644 languages/objective-c/config.toml create mode 100644 languages/objective-c/highlights.scm create mode 100644 languages/objective-cpp/config.toml create mode 100644 languages/objective-cpp/highlights.scm diff --git a/extension.toml b/extension.toml index 289ec67..d7d2120 100644 --- a/extension.toml +++ b/extension.toml @@ -11,17 +11,22 @@ repository = "https://github.com/zed-extensions/swift" [language_servers.sourcekit-lsp] name = "sourcekit-lsp" -languages = ["Swift", "C", "C++", "Objective-C"] +languages = ["Swift", "C", "C++", "Objective-C", "Objective-C++"] [language_servers.sourcekit-lsp.language_ids] Swift = "swift" C = "c" "C++" = "cpp" "Objective-C" = "objective-c" +"Objective-C++" = "objective-cpp" [grammars.swift] repository = "https://github.com/alex-pinkus/tree-sitter-swift" commit = "33e56e4e2a6455f3fd4e04cfe5c7a314d498612d" +[grammars.objc] +repository = "https://github.com/amaanq/tree-sitter-objc" +commit = "181a81b8f23a2d593e7ab4259981f50122909fda" + [debug_adapters.Swift] schema_path = "debug_adapter_schemas/Swift.json" diff --git a/languages/objective-c/config.toml b/languages/objective-c/config.toml new file mode 100644 index 0000000..50c74d7 --- /dev/null +++ b/languages/objective-c/config.toml @@ -0,0 +1,15 @@ +name = "Objective-C" +grammar = "objc" +path_suffixes = ["m", "h"] +line_comments = ["// "] +block_comment = ["/*", "*/"] +autoclose_before = ";:.,=}])> \n\t" +brackets = [ + { start = "{", end = "}", close = true, newline = true }, + { start = "[", end = "]", close = true, newline = true }, + { start = "(", end = ")", close = true, newline = true }, + { start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] }, + { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] }, + { start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] }, +] +word_characters = ["_"] diff --git a/languages/objective-c/highlights.scm b/languages/objective-c/highlights.scm new file mode 100644 index 0000000..6e7b582 --- /dev/null +++ b/languages/objective-c/highlights.scm @@ -0,0 +1,344 @@ +; ============================================================ +; C base highlights (compatible with tree-sitter-objc) +; ============================================================ + +(identifier) @variable + +((identifier) @constant + (#match? @constant "^[A-Z][A-Z\\d_]*$")) + +; C Keywords + +[ + "break" + "case" + "const" + "continue" + "default" + "do" + "else" + "enum" + "extern" + "for" + "if" + "inline" + "return" + "sizeof" + "static" + "struct" + "switch" + "typedef" + "union" + "volatile" + "while" +] @keyword + +; Preprocessor + +(preproc_directive) @keyword + +; #include / #import — highlight the whole node as keyword, path as string +(preproc_include) @keyword +(preproc_include path: (string_literal) @string) +(preproc_include path: (system_lib_string) @string) + +; #define — keyword + macro name as constant + value as string +(preproc_def) @keyword +(preproc_def name: (identifier) @constant) +(preproc_def value: (preproc_arg) @string) + +(preproc_function_def) @keyword +(preproc_function_def name: (identifier) @function.special) +(preproc_function_def value: (preproc_arg) @string) + +; #if / #ifdef / #ifndef / #elif / #else / #endif +(preproc_if) @keyword +(preproc_ifdef) @keyword +(preproc_elif) @keyword +(preproc_else) @keyword +(preproc_call) @keyword + +; C Operators + +[ + "--" + "-" + "-=" + "->" + "=" + "!=" + "!" + "*" + "&" + "&&" + "+" + "++" + "+=" + "<" + "==" + ">" + ">=" + "<=" + "||" + "|" + "~" + "%" + "/" + "?" + ":" +] @operator + +; Delimiters + +[ + "." + ";" + "," +] @delimiter + +; Strings and Literals + +(string_literal) @string +(system_lib_string) @string +(concatenated_string) @string +(escape_sequence) @string.escape + +(null) @constant +(number_literal) @number +(char_literal) @number +(true) @constant.builtin +(false) @constant.builtin + +; Fields and Types + +(field_identifier) @property +(statement_identifier) @label +(type_identifier) @type +(primitive_type) @type +(sized_type_specifier) @type + +; Function calls + +(call_expression + function: (identifier) @function) +(call_expression + function: (field_expression + field: (field_identifier) @function)) +(function_declarator + declarator: (identifier) @function) +(preproc_function_def + name: (identifier) @function.special) + +; Comments + +(comment) @comment + +; Brackets + +["(" ")" "[" "]" "{" "}"] @punctuation.bracket + +; ============================================================ +; Objective-C specific highlights +; ============================================================ + +; Preprocs + +(preproc_undef + name: (_) @constant) @preproc + +; @import module +(module_import "@import" @keyword path: (identifier) @namespace) + +; Type Qualifiers + +[ + "@optional" + "@required" + "__covariant" + "__contravariant" + (visibility_specification) +] @type.qualifier + +; Storageclasses + +[ + "@autoreleasepool" + "@synthesize" + "@dynamic" + (protocol_qualifier) +] @storageclass + +; ObjC Keywords + +[ + "@protocol" + "@interface" + "@implementation" + "@compatibility_alias" + "@property" + "@selector" + "@defs" + "availability" + "@end" +] @keyword + +(class_declaration "@" @keyword "class" @keyword) + +(method_definition ["+" "-"] @keyword.function) +(method_declaration ["+" "-"] @keyword.function) + +[ + "__typeof__" + "__typeof" + "typeof" + "in" +] @keyword.operator + +[ + "@synchronized" + "oneway" +] @keyword.coroutine + +; Exceptions + +[ + "@try" + "__try" + "@catch" + "__catch" + "@finally" + "__finally" + "@throw" +] @exception + +; Variables + +((identifier) @variable.builtin + (#any-of? @variable.builtin "self" "super")) + +; Functions & Methods + +[ + "objc_bridge_related" + "@available" + "__builtin_available" + "va_arg" + "asm" +] @function.builtin + +(method_definition (identifier) @method) + +(method_declaration (identifier) @method) + +(method_identifier (identifier)? @method ":" @method (identifier)? @method) + +(message_expression method: (identifier) @method.call) + +; Constructors + +((message_expression method: (identifier) @constructor) + (#eq? @constructor "init")) + +; Attributes + +(availability_attribute_specifier + [ + "CF_FORMAT_FUNCTION" "NS_AVAILABLE" "__IOS_AVAILABLE" "NS_AVAILABLE_IOS" + "API_AVAILABLE" "API_UNAVAILABLE" "API_DEPRECATED" "NS_ENUM_AVAILABLE_IOS" + "NS_DEPRECATED_IOS" "NS_ENUM_DEPRECATED_IOS" "NS_FORMAT_FUNCTION" "DEPRECATED_MSG_ATTRIBUTE" + "__deprecated_msg" "__deprecated_enum_msg" "NS_SWIFT_NAME" "NS_SWIFT_UNAVAILABLE" + "NS_EXTENSION_UNAVAILABLE_IOS" "NS_CLASS_AVAILABLE_IOS" "NS_CLASS_DEPRECATED_IOS" "__OSX_AVAILABLE_STARTING" + "NS_ROOT_CLASS" "NS_UNAVAILABLE" "NS_REQUIRES_NIL_TERMINATION" "CF_RETURNS_RETAINED" + "CF_RETURNS_NOT_RETAINED" "DEPRECATED_ATTRIBUTE" "UI_APPEARANCE_SELECTOR" "UNAVAILABLE_ATTRIBUTE" + ]) @attribute + +; ObjC Macros / Type Qualifiers + +(type_qualifier + [ + "_Complex" + "_Nonnull" + "_Nullable" + "_Nullable_result" + "_Null_unspecified" + "__autoreleasing" + "__block" + "__bridge" + "__bridge_retained" + "__bridge_transfer" + "__complex" + "__kindof" + "__nonnull" + "__nullable" + "__ptrauth_objc_class_ro" + "__ptrauth_objc_isa_pointer" + "__ptrauth_objc_super_pointer" + "__strong" + "__thread" + "__unsafe_unretained" + "__unused" + "__weak" + ]) @function.macro.builtin + +[ "__real" "__imag" ] @function.macro.builtin + +; ObjC Types + +(class_declaration (identifier) @type) + +(class_interface "@interface" . (identifier) @type superclass: _? @type category: _? @namespace) + +(class_implementation "@implementation" . (identifier) @type superclass: _? @type category: _? @namespace) + +(protocol_forward_declaration (identifier) @type) + +(protocol_reference_list (identifier) @type) + +[ + "BOOL" + "IMP" + "SEL" + "Class" + "id" +] @type.builtin + +; Constants + +(property_attribute (identifier) @constant "="?) + +[ "__asm" "__asm__" ] @constant.macro + +; Properties + +(property_implementation "@synthesize" (identifier) @property) + +((identifier) @property + (#has-ancestor? @property struct_declaration)) + +; Parameters + +(method_parameter ":" @method (identifier) @parameter) + +(method_parameter declarator: (identifier) @parameter) + +(parameter_declaration + declarator: (function_declarator + declarator: (parenthesized_declarator + (block_pointer_declarator + declarator: (identifier) @parameter)))) + +"..." @parameter.builtin + +; ObjC Operators + +"^" @operator + +; ObjC Literals + +(platform) @string.special + +(version_number) @number + +; ObjC Punctuation + +"@" @punctuation.special diff --git a/languages/objective-cpp/config.toml b/languages/objective-cpp/config.toml new file mode 100644 index 0000000..39f281b --- /dev/null +++ b/languages/objective-cpp/config.toml @@ -0,0 +1,15 @@ +name = "Objective-C++" +grammar = "objc" +path_suffixes = ["mm"] +line_comments = ["// "] +block_comment = ["/*", "*/"] +autoclose_before = ";:.,=}])> \n\t" +brackets = [ + { start = "{", end = "}", close = true, newline = true }, + { start = "[", end = "]", close = true, newline = true }, + { start = "(", end = ")", close = true, newline = true }, + { start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] }, + { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] }, + { start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] }, +] +word_characters = ["_"] diff --git a/languages/objective-cpp/highlights.scm b/languages/objective-cpp/highlights.scm new file mode 100644 index 0000000..6e7b582 --- /dev/null +++ b/languages/objective-cpp/highlights.scm @@ -0,0 +1,344 @@ +; ============================================================ +; C base highlights (compatible with tree-sitter-objc) +; ============================================================ + +(identifier) @variable + +((identifier) @constant + (#match? @constant "^[A-Z][A-Z\\d_]*$")) + +; C Keywords + +[ + "break" + "case" + "const" + "continue" + "default" + "do" + "else" + "enum" + "extern" + "for" + "if" + "inline" + "return" + "sizeof" + "static" + "struct" + "switch" + "typedef" + "union" + "volatile" + "while" +] @keyword + +; Preprocessor + +(preproc_directive) @keyword + +; #include / #import — highlight the whole node as keyword, path as string +(preproc_include) @keyword +(preproc_include path: (string_literal) @string) +(preproc_include path: (system_lib_string) @string) + +; #define — keyword + macro name as constant + value as string +(preproc_def) @keyword +(preproc_def name: (identifier) @constant) +(preproc_def value: (preproc_arg) @string) + +(preproc_function_def) @keyword +(preproc_function_def name: (identifier) @function.special) +(preproc_function_def value: (preproc_arg) @string) + +; #if / #ifdef / #ifndef / #elif / #else / #endif +(preproc_if) @keyword +(preproc_ifdef) @keyword +(preproc_elif) @keyword +(preproc_else) @keyword +(preproc_call) @keyword + +; C Operators + +[ + "--" + "-" + "-=" + "->" + "=" + "!=" + "!" + "*" + "&" + "&&" + "+" + "++" + "+=" + "<" + "==" + ">" + ">=" + "<=" + "||" + "|" + "~" + "%" + "/" + "?" + ":" +] @operator + +; Delimiters + +[ + "." + ";" + "," +] @delimiter + +; Strings and Literals + +(string_literal) @string +(system_lib_string) @string +(concatenated_string) @string +(escape_sequence) @string.escape + +(null) @constant +(number_literal) @number +(char_literal) @number +(true) @constant.builtin +(false) @constant.builtin + +; Fields and Types + +(field_identifier) @property +(statement_identifier) @label +(type_identifier) @type +(primitive_type) @type +(sized_type_specifier) @type + +; Function calls + +(call_expression + function: (identifier) @function) +(call_expression + function: (field_expression + field: (field_identifier) @function)) +(function_declarator + declarator: (identifier) @function) +(preproc_function_def + name: (identifier) @function.special) + +; Comments + +(comment) @comment + +; Brackets + +["(" ")" "[" "]" "{" "}"] @punctuation.bracket + +; ============================================================ +; Objective-C specific highlights +; ============================================================ + +; Preprocs + +(preproc_undef + name: (_) @constant) @preproc + +; @import module +(module_import "@import" @keyword path: (identifier) @namespace) + +; Type Qualifiers + +[ + "@optional" + "@required" + "__covariant" + "__contravariant" + (visibility_specification) +] @type.qualifier + +; Storageclasses + +[ + "@autoreleasepool" + "@synthesize" + "@dynamic" + (protocol_qualifier) +] @storageclass + +; ObjC Keywords + +[ + "@protocol" + "@interface" + "@implementation" + "@compatibility_alias" + "@property" + "@selector" + "@defs" + "availability" + "@end" +] @keyword + +(class_declaration "@" @keyword "class" @keyword) + +(method_definition ["+" "-"] @keyword.function) +(method_declaration ["+" "-"] @keyword.function) + +[ + "__typeof__" + "__typeof" + "typeof" + "in" +] @keyword.operator + +[ + "@synchronized" + "oneway" +] @keyword.coroutine + +; Exceptions + +[ + "@try" + "__try" + "@catch" + "__catch" + "@finally" + "__finally" + "@throw" +] @exception + +; Variables + +((identifier) @variable.builtin + (#any-of? @variable.builtin "self" "super")) + +; Functions & Methods + +[ + "objc_bridge_related" + "@available" + "__builtin_available" + "va_arg" + "asm" +] @function.builtin + +(method_definition (identifier) @method) + +(method_declaration (identifier) @method) + +(method_identifier (identifier)? @method ":" @method (identifier)? @method) + +(message_expression method: (identifier) @method.call) + +; Constructors + +((message_expression method: (identifier) @constructor) + (#eq? @constructor "init")) + +; Attributes + +(availability_attribute_specifier + [ + "CF_FORMAT_FUNCTION" "NS_AVAILABLE" "__IOS_AVAILABLE" "NS_AVAILABLE_IOS" + "API_AVAILABLE" "API_UNAVAILABLE" "API_DEPRECATED" "NS_ENUM_AVAILABLE_IOS" + "NS_DEPRECATED_IOS" "NS_ENUM_DEPRECATED_IOS" "NS_FORMAT_FUNCTION" "DEPRECATED_MSG_ATTRIBUTE" + "__deprecated_msg" "__deprecated_enum_msg" "NS_SWIFT_NAME" "NS_SWIFT_UNAVAILABLE" + "NS_EXTENSION_UNAVAILABLE_IOS" "NS_CLASS_AVAILABLE_IOS" "NS_CLASS_DEPRECATED_IOS" "__OSX_AVAILABLE_STARTING" + "NS_ROOT_CLASS" "NS_UNAVAILABLE" "NS_REQUIRES_NIL_TERMINATION" "CF_RETURNS_RETAINED" + "CF_RETURNS_NOT_RETAINED" "DEPRECATED_ATTRIBUTE" "UI_APPEARANCE_SELECTOR" "UNAVAILABLE_ATTRIBUTE" + ]) @attribute + +; ObjC Macros / Type Qualifiers + +(type_qualifier + [ + "_Complex" + "_Nonnull" + "_Nullable" + "_Nullable_result" + "_Null_unspecified" + "__autoreleasing" + "__block" + "__bridge" + "__bridge_retained" + "__bridge_transfer" + "__complex" + "__kindof" + "__nonnull" + "__nullable" + "__ptrauth_objc_class_ro" + "__ptrauth_objc_isa_pointer" + "__ptrauth_objc_super_pointer" + "__strong" + "__thread" + "__unsafe_unretained" + "__unused" + "__weak" + ]) @function.macro.builtin + +[ "__real" "__imag" ] @function.macro.builtin + +; ObjC Types + +(class_declaration (identifier) @type) + +(class_interface "@interface" . (identifier) @type superclass: _? @type category: _? @namespace) + +(class_implementation "@implementation" . (identifier) @type superclass: _? @type category: _? @namespace) + +(protocol_forward_declaration (identifier) @type) + +(protocol_reference_list (identifier) @type) + +[ + "BOOL" + "IMP" + "SEL" + "Class" + "id" +] @type.builtin + +; Constants + +(property_attribute (identifier) @constant "="?) + +[ "__asm" "__asm__" ] @constant.macro + +; Properties + +(property_implementation "@synthesize" (identifier) @property) + +((identifier) @property + (#has-ancestor? @property struct_declaration)) + +; Parameters + +(method_parameter ":" @method (identifier) @parameter) + +(method_parameter declarator: (identifier) @parameter) + +(parameter_declaration + declarator: (function_declarator + declarator: (parenthesized_declarator + (block_pointer_declarator + declarator: (identifier) @parameter)))) + +"..." @parameter.builtin + +; ObjC Operators + +"^" @operator + +; ObjC Literals + +(platform) @string.special + +(version_number) @number + +; ObjC Punctuation + +"@" @punctuation.special From 1d38d3cb111f8bbbf26479047ec09e87bb0a1ef1 Mon Sep 17 00:00:00 2001 From: MrSubidubi Date: Mon, 20 Jul 2026 19:46:03 +0200 Subject: [PATCH 3/3] Make more minimal --- extension.toml | 4 - languages/objective-c/config.toml | 15 -- languages/objective-c/highlights.scm | 344 ------------------------- languages/objective-cpp/config.toml | 15 -- languages/objective-cpp/highlights.scm | 344 ------------------------- 5 files changed, 722 deletions(-) delete mode 100644 languages/objective-c/config.toml delete mode 100644 languages/objective-c/highlights.scm delete mode 100644 languages/objective-cpp/config.toml delete mode 100644 languages/objective-cpp/highlights.scm diff --git a/extension.toml b/extension.toml index d7d2120..2189ab2 100644 --- a/extension.toml +++ b/extension.toml @@ -24,9 +24,5 @@ C = "c" repository = "https://github.com/alex-pinkus/tree-sitter-swift" commit = "33e56e4e2a6455f3fd4e04cfe5c7a314d498612d" -[grammars.objc] -repository = "https://github.com/amaanq/tree-sitter-objc" -commit = "181a81b8f23a2d593e7ab4259981f50122909fda" - [debug_adapters.Swift] schema_path = "debug_adapter_schemas/Swift.json" diff --git a/languages/objective-c/config.toml b/languages/objective-c/config.toml deleted file mode 100644 index 50c74d7..0000000 --- a/languages/objective-c/config.toml +++ /dev/null @@ -1,15 +0,0 @@ -name = "Objective-C" -grammar = "objc" -path_suffixes = ["m", "h"] -line_comments = ["// "] -block_comment = ["/*", "*/"] -autoclose_before = ";:.,=}])> \n\t" -brackets = [ - { start = "{", end = "}", close = true, newline = true }, - { start = "[", end = "]", close = true, newline = true }, - { start = "(", end = ")", close = true, newline = true }, - { start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] }, - { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] }, - { start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] }, -] -word_characters = ["_"] diff --git a/languages/objective-c/highlights.scm b/languages/objective-c/highlights.scm deleted file mode 100644 index 6e7b582..0000000 --- a/languages/objective-c/highlights.scm +++ /dev/null @@ -1,344 +0,0 @@ -; ============================================================ -; C base highlights (compatible with tree-sitter-objc) -; ============================================================ - -(identifier) @variable - -((identifier) @constant - (#match? @constant "^[A-Z][A-Z\\d_]*$")) - -; C Keywords - -[ - "break" - "case" - "const" - "continue" - "default" - "do" - "else" - "enum" - "extern" - "for" - "if" - "inline" - "return" - "sizeof" - "static" - "struct" - "switch" - "typedef" - "union" - "volatile" - "while" -] @keyword - -; Preprocessor - -(preproc_directive) @keyword - -; #include / #import — highlight the whole node as keyword, path as string -(preproc_include) @keyword -(preproc_include path: (string_literal) @string) -(preproc_include path: (system_lib_string) @string) - -; #define — keyword + macro name as constant + value as string -(preproc_def) @keyword -(preproc_def name: (identifier) @constant) -(preproc_def value: (preproc_arg) @string) - -(preproc_function_def) @keyword -(preproc_function_def name: (identifier) @function.special) -(preproc_function_def value: (preproc_arg) @string) - -; #if / #ifdef / #ifndef / #elif / #else / #endif -(preproc_if) @keyword -(preproc_ifdef) @keyword -(preproc_elif) @keyword -(preproc_else) @keyword -(preproc_call) @keyword - -; C Operators - -[ - "--" - "-" - "-=" - "->" - "=" - "!=" - "!" - "*" - "&" - "&&" - "+" - "++" - "+=" - "<" - "==" - ">" - ">=" - "<=" - "||" - "|" - "~" - "%" - "/" - "?" - ":" -] @operator - -; Delimiters - -[ - "." - ";" - "," -] @delimiter - -; Strings and Literals - -(string_literal) @string -(system_lib_string) @string -(concatenated_string) @string -(escape_sequence) @string.escape - -(null) @constant -(number_literal) @number -(char_literal) @number -(true) @constant.builtin -(false) @constant.builtin - -; Fields and Types - -(field_identifier) @property -(statement_identifier) @label -(type_identifier) @type -(primitive_type) @type -(sized_type_specifier) @type - -; Function calls - -(call_expression - function: (identifier) @function) -(call_expression - function: (field_expression - field: (field_identifier) @function)) -(function_declarator - declarator: (identifier) @function) -(preproc_function_def - name: (identifier) @function.special) - -; Comments - -(comment) @comment - -; Brackets - -["(" ")" "[" "]" "{" "}"] @punctuation.bracket - -; ============================================================ -; Objective-C specific highlights -; ============================================================ - -; Preprocs - -(preproc_undef - name: (_) @constant) @preproc - -; @import module -(module_import "@import" @keyword path: (identifier) @namespace) - -; Type Qualifiers - -[ - "@optional" - "@required" - "__covariant" - "__contravariant" - (visibility_specification) -] @type.qualifier - -; Storageclasses - -[ - "@autoreleasepool" - "@synthesize" - "@dynamic" - (protocol_qualifier) -] @storageclass - -; ObjC Keywords - -[ - "@protocol" - "@interface" - "@implementation" - "@compatibility_alias" - "@property" - "@selector" - "@defs" - "availability" - "@end" -] @keyword - -(class_declaration "@" @keyword "class" @keyword) - -(method_definition ["+" "-"] @keyword.function) -(method_declaration ["+" "-"] @keyword.function) - -[ - "__typeof__" - "__typeof" - "typeof" - "in" -] @keyword.operator - -[ - "@synchronized" - "oneway" -] @keyword.coroutine - -; Exceptions - -[ - "@try" - "__try" - "@catch" - "__catch" - "@finally" - "__finally" - "@throw" -] @exception - -; Variables - -((identifier) @variable.builtin - (#any-of? @variable.builtin "self" "super")) - -; Functions & Methods - -[ - "objc_bridge_related" - "@available" - "__builtin_available" - "va_arg" - "asm" -] @function.builtin - -(method_definition (identifier) @method) - -(method_declaration (identifier) @method) - -(method_identifier (identifier)? @method ":" @method (identifier)? @method) - -(message_expression method: (identifier) @method.call) - -; Constructors - -((message_expression method: (identifier) @constructor) - (#eq? @constructor "init")) - -; Attributes - -(availability_attribute_specifier - [ - "CF_FORMAT_FUNCTION" "NS_AVAILABLE" "__IOS_AVAILABLE" "NS_AVAILABLE_IOS" - "API_AVAILABLE" "API_UNAVAILABLE" "API_DEPRECATED" "NS_ENUM_AVAILABLE_IOS" - "NS_DEPRECATED_IOS" "NS_ENUM_DEPRECATED_IOS" "NS_FORMAT_FUNCTION" "DEPRECATED_MSG_ATTRIBUTE" - "__deprecated_msg" "__deprecated_enum_msg" "NS_SWIFT_NAME" "NS_SWIFT_UNAVAILABLE" - "NS_EXTENSION_UNAVAILABLE_IOS" "NS_CLASS_AVAILABLE_IOS" "NS_CLASS_DEPRECATED_IOS" "__OSX_AVAILABLE_STARTING" - "NS_ROOT_CLASS" "NS_UNAVAILABLE" "NS_REQUIRES_NIL_TERMINATION" "CF_RETURNS_RETAINED" - "CF_RETURNS_NOT_RETAINED" "DEPRECATED_ATTRIBUTE" "UI_APPEARANCE_SELECTOR" "UNAVAILABLE_ATTRIBUTE" - ]) @attribute - -; ObjC Macros / Type Qualifiers - -(type_qualifier - [ - "_Complex" - "_Nonnull" - "_Nullable" - "_Nullable_result" - "_Null_unspecified" - "__autoreleasing" - "__block" - "__bridge" - "__bridge_retained" - "__bridge_transfer" - "__complex" - "__kindof" - "__nonnull" - "__nullable" - "__ptrauth_objc_class_ro" - "__ptrauth_objc_isa_pointer" - "__ptrauth_objc_super_pointer" - "__strong" - "__thread" - "__unsafe_unretained" - "__unused" - "__weak" - ]) @function.macro.builtin - -[ "__real" "__imag" ] @function.macro.builtin - -; ObjC Types - -(class_declaration (identifier) @type) - -(class_interface "@interface" . (identifier) @type superclass: _? @type category: _? @namespace) - -(class_implementation "@implementation" . (identifier) @type superclass: _? @type category: _? @namespace) - -(protocol_forward_declaration (identifier) @type) - -(protocol_reference_list (identifier) @type) - -[ - "BOOL" - "IMP" - "SEL" - "Class" - "id" -] @type.builtin - -; Constants - -(property_attribute (identifier) @constant "="?) - -[ "__asm" "__asm__" ] @constant.macro - -; Properties - -(property_implementation "@synthesize" (identifier) @property) - -((identifier) @property - (#has-ancestor? @property struct_declaration)) - -; Parameters - -(method_parameter ":" @method (identifier) @parameter) - -(method_parameter declarator: (identifier) @parameter) - -(parameter_declaration - declarator: (function_declarator - declarator: (parenthesized_declarator - (block_pointer_declarator - declarator: (identifier) @parameter)))) - -"..." @parameter.builtin - -; ObjC Operators - -"^" @operator - -; ObjC Literals - -(platform) @string.special - -(version_number) @number - -; ObjC Punctuation - -"@" @punctuation.special diff --git a/languages/objective-cpp/config.toml b/languages/objective-cpp/config.toml deleted file mode 100644 index 39f281b..0000000 --- a/languages/objective-cpp/config.toml +++ /dev/null @@ -1,15 +0,0 @@ -name = "Objective-C++" -grammar = "objc" -path_suffixes = ["mm"] -line_comments = ["// "] -block_comment = ["/*", "*/"] -autoclose_before = ";:.,=}])> \n\t" -brackets = [ - { start = "{", end = "}", close = true, newline = true }, - { start = "[", end = "]", close = true, newline = true }, - { start = "(", end = ")", close = true, newline = true }, - { start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] }, - { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] }, - { start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] }, -] -word_characters = ["_"] diff --git a/languages/objective-cpp/highlights.scm b/languages/objective-cpp/highlights.scm deleted file mode 100644 index 6e7b582..0000000 --- a/languages/objective-cpp/highlights.scm +++ /dev/null @@ -1,344 +0,0 @@ -; ============================================================ -; C base highlights (compatible with tree-sitter-objc) -; ============================================================ - -(identifier) @variable - -((identifier) @constant - (#match? @constant "^[A-Z][A-Z\\d_]*$")) - -; C Keywords - -[ - "break" - "case" - "const" - "continue" - "default" - "do" - "else" - "enum" - "extern" - "for" - "if" - "inline" - "return" - "sizeof" - "static" - "struct" - "switch" - "typedef" - "union" - "volatile" - "while" -] @keyword - -; Preprocessor - -(preproc_directive) @keyword - -; #include / #import — highlight the whole node as keyword, path as string -(preproc_include) @keyword -(preproc_include path: (string_literal) @string) -(preproc_include path: (system_lib_string) @string) - -; #define — keyword + macro name as constant + value as string -(preproc_def) @keyword -(preproc_def name: (identifier) @constant) -(preproc_def value: (preproc_arg) @string) - -(preproc_function_def) @keyword -(preproc_function_def name: (identifier) @function.special) -(preproc_function_def value: (preproc_arg) @string) - -; #if / #ifdef / #ifndef / #elif / #else / #endif -(preproc_if) @keyword -(preproc_ifdef) @keyword -(preproc_elif) @keyword -(preproc_else) @keyword -(preproc_call) @keyword - -; C Operators - -[ - "--" - "-" - "-=" - "->" - "=" - "!=" - "!" - "*" - "&" - "&&" - "+" - "++" - "+=" - "<" - "==" - ">" - ">=" - "<=" - "||" - "|" - "~" - "%" - "/" - "?" - ":" -] @operator - -; Delimiters - -[ - "." - ";" - "," -] @delimiter - -; Strings and Literals - -(string_literal) @string -(system_lib_string) @string -(concatenated_string) @string -(escape_sequence) @string.escape - -(null) @constant -(number_literal) @number -(char_literal) @number -(true) @constant.builtin -(false) @constant.builtin - -; Fields and Types - -(field_identifier) @property -(statement_identifier) @label -(type_identifier) @type -(primitive_type) @type -(sized_type_specifier) @type - -; Function calls - -(call_expression - function: (identifier) @function) -(call_expression - function: (field_expression - field: (field_identifier) @function)) -(function_declarator - declarator: (identifier) @function) -(preproc_function_def - name: (identifier) @function.special) - -; Comments - -(comment) @comment - -; Brackets - -["(" ")" "[" "]" "{" "}"] @punctuation.bracket - -; ============================================================ -; Objective-C specific highlights -; ============================================================ - -; Preprocs - -(preproc_undef - name: (_) @constant) @preproc - -; @import module -(module_import "@import" @keyword path: (identifier) @namespace) - -; Type Qualifiers - -[ - "@optional" - "@required" - "__covariant" - "__contravariant" - (visibility_specification) -] @type.qualifier - -; Storageclasses - -[ - "@autoreleasepool" - "@synthesize" - "@dynamic" - (protocol_qualifier) -] @storageclass - -; ObjC Keywords - -[ - "@protocol" - "@interface" - "@implementation" - "@compatibility_alias" - "@property" - "@selector" - "@defs" - "availability" - "@end" -] @keyword - -(class_declaration "@" @keyword "class" @keyword) - -(method_definition ["+" "-"] @keyword.function) -(method_declaration ["+" "-"] @keyword.function) - -[ - "__typeof__" - "__typeof" - "typeof" - "in" -] @keyword.operator - -[ - "@synchronized" - "oneway" -] @keyword.coroutine - -; Exceptions - -[ - "@try" - "__try" - "@catch" - "__catch" - "@finally" - "__finally" - "@throw" -] @exception - -; Variables - -((identifier) @variable.builtin - (#any-of? @variable.builtin "self" "super")) - -; Functions & Methods - -[ - "objc_bridge_related" - "@available" - "__builtin_available" - "va_arg" - "asm" -] @function.builtin - -(method_definition (identifier) @method) - -(method_declaration (identifier) @method) - -(method_identifier (identifier)? @method ":" @method (identifier)? @method) - -(message_expression method: (identifier) @method.call) - -; Constructors - -((message_expression method: (identifier) @constructor) - (#eq? @constructor "init")) - -; Attributes - -(availability_attribute_specifier - [ - "CF_FORMAT_FUNCTION" "NS_AVAILABLE" "__IOS_AVAILABLE" "NS_AVAILABLE_IOS" - "API_AVAILABLE" "API_UNAVAILABLE" "API_DEPRECATED" "NS_ENUM_AVAILABLE_IOS" - "NS_DEPRECATED_IOS" "NS_ENUM_DEPRECATED_IOS" "NS_FORMAT_FUNCTION" "DEPRECATED_MSG_ATTRIBUTE" - "__deprecated_msg" "__deprecated_enum_msg" "NS_SWIFT_NAME" "NS_SWIFT_UNAVAILABLE" - "NS_EXTENSION_UNAVAILABLE_IOS" "NS_CLASS_AVAILABLE_IOS" "NS_CLASS_DEPRECATED_IOS" "__OSX_AVAILABLE_STARTING" - "NS_ROOT_CLASS" "NS_UNAVAILABLE" "NS_REQUIRES_NIL_TERMINATION" "CF_RETURNS_RETAINED" - "CF_RETURNS_NOT_RETAINED" "DEPRECATED_ATTRIBUTE" "UI_APPEARANCE_SELECTOR" "UNAVAILABLE_ATTRIBUTE" - ]) @attribute - -; ObjC Macros / Type Qualifiers - -(type_qualifier - [ - "_Complex" - "_Nonnull" - "_Nullable" - "_Nullable_result" - "_Null_unspecified" - "__autoreleasing" - "__block" - "__bridge" - "__bridge_retained" - "__bridge_transfer" - "__complex" - "__kindof" - "__nonnull" - "__nullable" - "__ptrauth_objc_class_ro" - "__ptrauth_objc_isa_pointer" - "__ptrauth_objc_super_pointer" - "__strong" - "__thread" - "__unsafe_unretained" - "__unused" - "__weak" - ]) @function.macro.builtin - -[ "__real" "__imag" ] @function.macro.builtin - -; ObjC Types - -(class_declaration (identifier) @type) - -(class_interface "@interface" . (identifier) @type superclass: _? @type category: _? @namespace) - -(class_implementation "@implementation" . (identifier) @type superclass: _? @type category: _? @namespace) - -(protocol_forward_declaration (identifier) @type) - -(protocol_reference_list (identifier) @type) - -[ - "BOOL" - "IMP" - "SEL" - "Class" - "id" -] @type.builtin - -; Constants - -(property_attribute (identifier) @constant "="?) - -[ "__asm" "__asm__" ] @constant.macro - -; Properties - -(property_implementation "@synthesize" (identifier) @property) - -((identifier) @property - (#has-ancestor? @property struct_declaration)) - -; Parameters - -(method_parameter ":" @method (identifier) @parameter) - -(method_parameter declarator: (identifier) @parameter) - -(parameter_declaration - declarator: (function_declarator - declarator: (parenthesized_declarator - (block_pointer_declarator - declarator: (identifier) @parameter)))) - -"..." @parameter.builtin - -; ObjC Operators - -"^" @operator - -; ObjC Literals - -(platform) @string.special - -(version_number) @number - -; ObjC Punctuation - -"@" @punctuation.special