mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 18:00:07 -04:00
feat: add Objective-C
This commit is contained in:
parent
05df88ebaa
commit
dad1b7cd66
8 changed files with 260 additions and 0 deletions
|
|
@ -281,6 +281,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||||
- [x] [ninja](https://github.com/alemuller/tree-sitter-ninja) (maintained by @alemuller)
|
- [x] [ninja](https://github.com/alemuller/tree-sitter-ninja) (maintained by @alemuller)
|
||||||
- [x] [nix](https://github.com/cstrahan/tree-sitter-nix) (maintained by @leo60228)
|
- [x] [nix](https://github.com/cstrahan/tree-sitter-nix) (maintained by @leo60228)
|
||||||
- [x] [norg](https://github.com/nvim-neorg/tree-sitter-norg) (maintained by @JoeyGrajciar, @vhyrro)
|
- [x] [norg](https://github.com/nvim-neorg/tree-sitter-norg) (maintained by @JoeyGrajciar, @vhyrro)
|
||||||
|
- [x] [objc](https://github.com/amaanq/tree-sitter-objc) (maintained by @amaanq)
|
||||||
- [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
|
- [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
|
||||||
- [x] [ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
|
- [x] [ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
|
||||||
- [x] [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) (maintained by @undu)
|
- [x] [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) (maintained by @undu)
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,9 @@
|
||||||
"norg": {
|
"norg": {
|
||||||
"revision": "1a305093569632de50f9a316ff843dcda25b4ef5"
|
"revision": "1a305093569632de50f9a316ff843dcda25b4ef5"
|
||||||
},
|
},
|
||||||
|
"objc": {
|
||||||
|
"revision": "90773a72d84d3c9a6eb8e373980e9b6b0bb665a0"
|
||||||
|
},
|
||||||
"ocaml": {
|
"ocaml": {
|
||||||
"revision": "f1106bf834703f1f2f795da1a3b5f8f40174ffcc"
|
"revision": "f1106bf834703f1f2f795da1a3b5f8f40174ffcc"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -982,6 +982,14 @@ list.norg = {
|
||||||
maintainers = { "@JoeyGrajciar", "@vhyrro" },
|
maintainers = { "@JoeyGrajciar", "@vhyrro" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.objc = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/amaanq/tree-sitter-objc",
|
||||||
|
files = { "src/parser.c" },
|
||||||
|
},
|
||||||
|
maintainers = { "@amaanq" },
|
||||||
|
}
|
||||||
|
|
||||||
list.ocaml = {
|
list.ocaml = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/tree-sitter/tree-sitter-ocaml",
|
url = "https://github.com/tree-sitter/tree-sitter-ocaml",
|
||||||
|
|
|
||||||
20
queries/objc/folds.scm
Normal file
20
queries/objc/folds.scm
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
; inherits: c
|
||||||
|
|
||||||
|
[
|
||||||
|
(class_declaration)
|
||||||
|
(class_interface)
|
||||||
|
(class_implementation)
|
||||||
|
(protocol_declaration)
|
||||||
|
(property_declaration)
|
||||||
|
(method_declaration)
|
||||||
|
(struct_declaration)
|
||||||
|
(struct_declarator)
|
||||||
|
(try_statement)
|
||||||
|
(catch_statement)
|
||||||
|
(finally_statement)
|
||||||
|
(throw_statement)
|
||||||
|
(block_literal)
|
||||||
|
(ms_asm_block)
|
||||||
|
(dictionary_literal)
|
||||||
|
(array_literal)
|
||||||
|
] @fold
|
||||||
216
queries/objc/highlights.scm
Normal file
216
queries/objc/highlights.scm
Normal file
|
|
@ -0,0 +1,216 @@
|
||||||
|
; inherits: c
|
||||||
|
|
||||||
|
; Preprocs
|
||||||
|
|
||||||
|
(preproc_undef
|
||||||
|
name: (_) @constant) @preproc
|
||||||
|
|
||||||
|
; Includes
|
||||||
|
|
||||||
|
(module_import "@import" @include path: (identifier) @namespace)
|
||||||
|
|
||||||
|
((preproc_include
|
||||||
|
_ @include path: (_))
|
||||||
|
(#any-of? @include "#include" "#import"))
|
||||||
|
|
||||||
|
; Type Qualifiers
|
||||||
|
|
||||||
|
[
|
||||||
|
"@optional"
|
||||||
|
"@required"
|
||||||
|
"__covariant"
|
||||||
|
"__contravariant"
|
||||||
|
(visibility_specification)
|
||||||
|
] @type.qualifier
|
||||||
|
|
||||||
|
; Storageclasses
|
||||||
|
|
||||||
|
[
|
||||||
|
"@autoreleasepool"
|
||||||
|
"@synthesize"
|
||||||
|
"@dynamic"
|
||||||
|
"volatile"
|
||||||
|
(protocol_qualifier)
|
||||||
|
] @storageclass
|
||||||
|
|
||||||
|
; Keywords
|
||||||
|
|
||||||
|
[
|
||||||
|
"@protocol"
|
||||||
|
"@interface"
|
||||||
|
"@implementation"
|
||||||
|
"@compatibility_alias"
|
||||||
|
"@property"
|
||||||
|
"@selector"
|
||||||
|
"@defs"
|
||||||
|
"availability"
|
||||||
|
"@end"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
(class_declaration "@" @keyword "class" @keyword) ; I hate Obj-C for allowing "@ class" :)
|
||||||
|
|
||||||
|
(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
|
||||||
|
|
||||||
|
; 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.builtin
|
||||||
|
|
||||||
|
[ "__real" "__imag" ] @function.macro.builtin
|
||||||
|
|
||||||
|
((call_expression function: (identifier) @function.macro)
|
||||||
|
(#eq? @function.macro "testassert"))
|
||||||
|
|
||||||
|
; 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) ; @interface :(
|
||||||
|
|
||||||
|
(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
|
||||||
|
|
||||||
|
; Operators
|
||||||
|
|
||||||
|
[
|
||||||
|
"^"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
|
||||||
|
(platform) @string.special
|
||||||
|
|
||||||
|
(version_number) @text.uri @number
|
||||||
|
|
||||||
|
; Punctuation
|
||||||
|
|
||||||
|
"@" @punctuation.special
|
||||||
|
|
||||||
|
[ "<" ">" ] @punctuation.bracket
|
||||||
1
queries/objc/indents.scm
Normal file
1
queries/objc/indents.scm
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
; inherits: c
|
||||||
10
queries/objc/injections.scm
Normal file
10
queries/objc/injections.scm
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
; inherits: c
|
||||||
|
|
||||||
|
; TODO(amaanq): uncomment/add when I add asm support
|
||||||
|
; (ms_asm_block "{" _ @asm "}")
|
||||||
|
;
|
||||||
|
; ((asm_specifier (string_literal) @asm)
|
||||||
|
; (#offset! @asm 0 1 0 -1))
|
||||||
|
;
|
||||||
|
; ((asm_statement (string_literal) @asm)
|
||||||
|
; (#offset! @asm 0 1 0 -1))
|
||||||
1
queries/objc/locals.scm
Normal file
1
queries/objc/locals.scm
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
; inherits: c
|
||||||
Loading…
Add table
Add a link
Reference in a new issue