mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat: add TOON parser support
Add tree-sitter grammar for TOON (Token-Oriented Object Notation), a JSON-alternative data format with indentation-based structure. - Add parser config in parsers.lua - Add query files: highlights, folds, indents, locals Parser repository: https://github.com/DanEscher98/tree-sitter-toon TOON spec: https://github.com/toon-format/spec 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
42fc28ba91
commit
79880d8d09
5 changed files with 154 additions and 0 deletions
|
|
@ -2434,6 +2434,15 @@ list.toml = {
|
|||
maintainers = { "@tk-shirasaka" },
|
||||
}
|
||||
|
||||
list.toon = {
|
||||
install_info = {
|
||||
url = "https://github.com/DanEscher98/tree-sitter-toon",
|
||||
files = { "src/parser.c", "src/scanner.c" },
|
||||
branch = "main",
|
||||
},
|
||||
maintainers = { "@DanEscher98" },
|
||||
}
|
||||
|
||||
list.tsv = {
|
||||
install_info = {
|
||||
url = "https://github.com/amaanq/tree-sitter-csv",
|
||||
|
|
|
|||
17
queries/toon/folds.scm
Normal file
17
queries/toon/folds.scm
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
; folds.scm - Folding queries for TOON
|
||||
; Allows collapsing nested structures in editors
|
||||
; Fold objects (nested key-value structures)
|
||||
(pair
|
||||
value: (object)) @fold
|
||||
|
||||
; Fold array declarations with content
|
||||
(array_declaration
|
||||
content: (array_content)) @fold
|
||||
|
||||
; Fold root arrays with content
|
||||
(root_array
|
||||
content: (array_content)) @fold
|
||||
|
||||
; Fold list items with nested objects
|
||||
(list_item
|
||||
(object)) @fold
|
||||
90
queries/toon/highlights.scm
Normal file
90
queries/toon/highlights.scm
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
; highlights.scm - Syntax highlighting queries for TOON
|
||||
; Maps grammar nodes to standard Neovim highlight capture groups
|
||||
; Reference: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md
|
||||
; Literals
|
||||
; --------
|
||||
(null) @constant.builtin
|
||||
|
||||
(true) @boolean
|
||||
|
||||
(false) @boolean
|
||||
|
||||
(number) @number
|
||||
|
||||
(integer) @number
|
||||
|
||||
; Strings
|
||||
(quoted_string) @string
|
||||
|
||||
(unquoted_string) @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
; Properties/Keys
|
||||
; ---------------
|
||||
; Object keys
|
||||
(pair
|
||||
key: (key
|
||||
(identifier) @property))
|
||||
|
||||
(pair
|
||||
key: (key
|
||||
(dotted_key
|
||||
(identifier) @property)))
|
||||
|
||||
(pair
|
||||
key: (key
|
||||
(quoted_string) @property))
|
||||
|
||||
; Array declaration keys
|
||||
(array_declaration
|
||||
key: (key
|
||||
(identifier) @property))
|
||||
|
||||
(array_declaration
|
||||
key: (key
|
||||
(dotted_key
|
||||
(identifier) @property)))
|
||||
|
||||
; Field names in tabular arrays
|
||||
(field_name
|
||||
(identifier) @property)
|
||||
|
||||
(field_name
|
||||
(quoted_string) @property)
|
||||
|
||||
; List item keys (objects as list items)
|
||||
(list_item
|
||||
key: (key
|
||||
(identifier) @property))
|
||||
|
||||
; Punctuation
|
||||
; -----------
|
||||
; Delimiters
|
||||
":" @punctuation.delimiter
|
||||
|
||||
"," @punctuation.delimiter
|
||||
|
||||
"|" @punctuation.delimiter
|
||||
|
||||
"." @punctuation.delimiter
|
||||
|
||||
(delimiter) @punctuation.delimiter
|
||||
|
||||
(field_delimiter) @punctuation.delimiter
|
||||
|
||||
(delimiter_marker) @punctuation.delimiter
|
||||
|
||||
; Brackets
|
||||
"[" @punctuation.bracket
|
||||
|
||||
"]" @punctuation.bracket
|
||||
|
||||
"{" @punctuation.bracket
|
||||
|
||||
"}" @punctuation.bracket
|
||||
|
||||
; Special
|
||||
"\"" @punctuation.special
|
||||
|
||||
(list_marker) @punctuation.special
|
||||
23
queries/toon/indents.scm
Normal file
23
queries/toon/indents.scm
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
; indents.scm - Indentation queries for TOON
|
||||
; Guides automatic indentation in editors
|
||||
; Indent after opening a nested object
|
||||
(pair
|
||||
value: (object) @indent.begin)
|
||||
|
||||
; Indent after array declaration with content
|
||||
(array_declaration
|
||||
content: (array_content) @indent.begin)
|
||||
|
||||
; Indent after root array with content
|
||||
(root_array
|
||||
content: (array_content) @indent.begin)
|
||||
|
||||
; Indent inside list items with nested content
|
||||
(list_item
|
||||
(object) @indent.begin)
|
||||
|
||||
; Dedent at end of objects/arrays (handled by external scanner)
|
||||
; These markers indicate where indentation should decrease
|
||||
(object) @indent.end
|
||||
|
||||
(array_content) @indent.end
|
||||
15
queries/toon/locals.scm
Normal file
15
queries/toon/locals.scm
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
; locals.scm - Local scope and reference queries for TOON
|
||||
; Used for features like go-to-definition, scope highlighting
|
||||
; Each object creates a new scope
|
||||
(object) @local.scope
|
||||
|
||||
; Keys define local names within their scope
|
||||
(pair
|
||||
key: (key) @local.definition)
|
||||
|
||||
; Array declarations define names
|
||||
(array_declaration
|
||||
key: (key) @local.definition)
|
||||
|
||||
; Field names in tabular arrays are definitions
|
||||
(field_name) @local.definition
|
||||
Loading…
Add table
Add a link
Reference in a new issue