nvim-treesitter/queries/objc/highlights.scm

269 lines
4.4 KiB
Scheme
Raw Normal View History

2023-05-18 19:37:56 -04:00
; inherits: c
2023-05-18 19:37:56 -04:00
; Preprocs
(preproc_undef
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
name: (_) @constant) @keyword.directive
2023-05-18 19:37:56 -04:00
; Includes
2024-01-06 15:05:50 +09:00
(module_import
"@import" @keyword.import
path: (identifier) @module)
2023-05-18 19:37:56 -04:00
((preproc_include
2024-01-06 15:05:50 +09:00
_ @keyword.import
path: (_))
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
(#any-of? @keyword.import "#include" "#import"))
2023-05-18 19:37:56 -04:00
; Type Qualifiers
[
"@optional"
"@required"
"__covariant"
"__contravariant"
(visibility_specification)
] @keyword.modifier
2023-05-18 19:37:56 -04:00
; Storageclasses
[
"@autoreleasepool"
"@synthesize"
"@dynamic"
"volatile"
(protocol_qualifier)
] @keyword.modifier
2023-05-18 19:37:56 -04:00
; Keywords
[
"@protocol"
"@interface"
"@implementation"
"@compatibility_alias"
"@property"
"@selector"
"@defs"
"availability"
"@end"
] @keyword
2024-01-06 15:05:50 +09:00
(class_declaration
2024-04-23 12:23:15 -07:00
"@" @keyword.type
"class" @keyword.type) ; I hate Obj-C for allowing "@ class" :)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(method_definition
[
"+"
"-"
] @keyword.function)
(method_declaration
[
"+"
"-"
] @keyword.function)
2023-05-18 19:37:56 -04:00
[
"__typeof__"
"__typeof"
"typeof"
"in"
] @keyword.operator
[
"@synchronized"
"oneway"
] @keyword.coroutine
; Exceptions
[
"@try"
"__try"
"@catch"
"__catch"
"@finally"
"__finally"
"@throw"
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
] @keyword.exception
2023-05-18 19:37:56 -04:00
; Variables
((identifier) @variable.builtin
(#any-of? @variable.builtin "self" "super"))
; Functions & Methods
[
"objc_bridge_related"
"@available"
"__builtin_available"
"va_arg"
"asm"
] @function.builtin
2024-01-06 15:05:50 +09:00
(method_definition
(identifier) @function.method)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(method_declaration
(identifier) @function.method)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(method_identifier
(identifier)? @function.method
":" @function.method
(identifier)? @function.method)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(message_expression
method: (identifier) @function.method.call)
2023-05-18 19:37:56 -04:00
; Constructors
2024-01-06 15:05:50 +09:00
((message_expression
method: (identifier) @constructor)
2023-05-18 19:37:56 -04:00
(#eq? @constructor "init"))
; Attributes
2024-01-06 15:05:50 +09:00
(availability_attribute_specifier
2023-05-18 19:37:56 -04:00
[
2024-01-06 15:05:50 +09:00
"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"
2023-05-18 19:37:56 -04:00
]) @attribute
; Macros
(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
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
[
"__real"
"__imag"
] @function.macro
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
((call_expression
function: (identifier) @function.macro)
2023-05-18 19:37:56 -04:00
(#eq? @function.macro "testassert"))
; Types
2024-01-06 15:05:50 +09:00
(class_declaration
(identifier) @type)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(class_interface
"@interface"
.
(identifier) @type
superclass: _? @type
category: _? @module)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(class_implementation
"@implementation"
.
(identifier) @type
superclass: _? @type
category: _? @module)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(protocol_forward_declaration
(identifier) @type) ; @interface :(
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(protocol_reference_list
(identifier) @type) ; ^
2023-05-18 19:37:56 -04:00
[
"BOOL"
"IMP"
"SEL"
"Class"
"id"
] @type.builtin
; Constants
2024-01-06 15:05:50 +09:00
(property_attribute
(identifier) @constant
"="?)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
[
"__asm"
"__asm__"
] @constant.macro
2023-05-18 19:37:56 -04:00
; Properties
2024-01-06 15:05:50 +09:00
(property_implementation
"@synthesize"
(identifier) @variable.member)
2023-05-18 19:37:56 -04:00
((identifier) @variable.member
(#has-ancestor? @variable.member struct_declaration))
2023-05-18 19:37:56 -04:00
; Parameters
2024-01-06 15:05:50 +09:00
(method_parameter
":" @function.method
(identifier) @variable.parameter)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(method_parameter
declarator: (identifier) @variable.parameter)
2023-05-18 19:37:56 -04:00
2024-01-06 15:05:50 +09:00
(parameter_declaration
declarator: (function_declarator
declarator: (parenthesized_declarator
(block_pointer_declarator
declarator: (identifier) @variable.parameter))))
2023-05-18 19:37:56 -04:00
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
"..." @variable.parameter.builtin
2023-05-18 19:37:56 -04:00
; Operators
2024-01-06 15:05:50 +09:00
"^" @operator
2023-05-18 19:37:56 -04:00
; Literals
(platform) @string.special
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
(version_number) @string.special
2023-05-18 19:37:56 -04:00
; Punctuation
"@" @punctuation.special
2024-01-06 15:05:50 +09:00
[
"<"
">"
] @punctuation.bracket