feat(cobweb): add support for cobweb

This commit is contained in:
FabricSoul 2025-04-20 23:36:06 -04:00
parent 684eeac91e
commit a8b2798322
3 changed files with 86 additions and 0 deletions

View file

@ -201,6 +201,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [circom](https://github.com/Decurity/tree-sitter-circom) (maintained by @alexandr-martirosyan)
- [x] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @NoahTheDuke)
- [x] [cmake](https://github.com/uyha/tree-sitter-cmake) (maintained by @uyha)
- [x] [cobweb](https://github.com/FabricSoul/tree-sitter-cobweb) (maintained by @FabricSoul)
- [x] [comment](https://github.com/stsewd/tree-sitter-comment) (maintained by @stsewd)
- [x] [commonlisp](https://github.com/theHamsta/tree-sitter-commonlisp) (maintained by @theHamsta)
- [x] [cooklang](https://github.com/addcninblue/tree-sitter-cooklang) (maintained by @addcninblue)

View file

@ -297,6 +297,15 @@ list.cmake = {
maintainers = { "@uyha" },
}
list.cobweb = {
install_info = {
url = "https://github.com/FabricSoul/tree-sitter-cobweb",
files = { "src/parser.c" },
},
maintainers = { "@FabricSoul" },
}
list.comment = {
install_info = {
url = "https://github.com/stsewd/tree-sitter-comment",

View file

@ -0,0 +1,76 @@
; tree-sitter-cobweb/queries/highlights.scm
; === Comments ===
(line_comment) @comment
(block_comment) @comment
; === Sections ===
(section_header) @keyword.control.import ; #manifest, #import, #defs, #commands, #scenes
; === Keywords ===
(keyword) @keyword ; 'as'
; === Literals ===
(string_literal) @string
(escape_sequence) @string.escape
(line_continuation) @string.escape
(number_literal) @constant.numeric
(hex_literal) @constant.numeric ; Often highlighted like numbers or colors
; === Builtin Constants ===
(language_constant) @constant.builtin ; auto, inf, nan
; === Definitions (#defs section) ===
(definition name: (constant_identifier) @variable.constant)
(definition "=" @operator)
; === Constants Usage ===
(constant_usage "$" @constant) ; Highlight the '$' itself
; Highlight all identifiers within the path field of a constant usage
(constant_usage path: (identifier) @constant)
; The PATH_SEPARATOR is captured globally below
; === Manifest & Import Sections ===
(manifest_entry path: (string_literal) @string.special.path) ; Highlight file paths
(manifest_entry alias: (identifier) @variable.alias)
(import_entry source: (identifier) @variable.module) ; Imported manifest key
(import_entry alias: (identifier) @variable.alias)
; === Scenes Section ===
(scene_definition name: (string_literal) @label) ; Scene names
(named_element name: (string_literal) @label) ; Nested element names like "cell"
; === Loadables & Types ===
; General Types
(type_identifier) @type ; Default for uppercase identifiers
; Specific Loadable Types
(struct_loadable type: (type_identifier) @type)
(tuple_loadable type: (type_identifier) @type)
(simple_loadable type: (type_identifier) @type) ; e.g., MainInterface
(generic_loadable type: (type_identifier) @type) ; e.g., Animated
(generic_loadable generic_type: (type_identifier) @type.generic) ; e.g., BackgroundColor inside <>
; Type Identifiers used as Values (Enum Variants)
((field value: (type_identifier)) @constant.builtin.enum) ; e.g., Column in flex_direction:Column
; === Fields ===
(field name: (identifier) @property) ; Field names like 'color', 'text'
(field ":" @punctuation.delimiter)
; === Punctuation ===
"{" @punctuation.bracket
"}" @punctuation.bracket
"(" @punctuation.bracket
")" @punctuation.bracket
"<" @punctuation.bracket
">" @punctuation.bracket
":" @punctuation.delimiter ; Already captured in field, but maybe useful standalone if it occurs elsewhere
"=" @operator ; Already captured in definition
(PATH_SEPARATOR) @punctuation.delimiter ; Highlight '::' globally using the aliased node name
; === Fallback (Optional) ===
; (identifier) @variable ; Generic lowercase identifiers (might catch aliases/module names if not specifically captured)
; === Errors (Optional but Recommended) ===
; (ERROR) @error