nvim-treesitter/runtime/queries/dingo/highlights.scm
Jack Rudenko 6eb82b6460 feat: add Dingo language parser
Add Tree-sitter parser support for Dingo, a meta-language for Go that transpiles
to idiomatic Go code.

Dingo extends Go with:
- Enums with associated values (sum types)
- Pattern matching with exhaustiveness checking
- Result/Option types with error propagation (`?` operator)
- Lambda expressions (`|x| x + 1` or `x => x + 1`)
- Safe navigation (`x?.y`) and null coalescing (`a ?? b`)

The parser is hosted in the dingo.nvim repository under `tree-sitter-dingo/`.

Files added:
- lua/nvim-treesitter/parsers.lua: dingo parser entry
- runtime/queries/dingo/highlights.scm
- runtime/queries/dingo/folds.scm
- runtime/queries/dingo/indents.scm
- SUPPORTED_LANGUAGES.md: auto-generated update
2025-12-11 10:57:23 +01:00

176 lines
2.1 KiB
Scheme

; Keywords
[
"package"
"import"
"func"
"return"
"type"
"struct"
"interface"
"map"
"chan"
"for"
"if"
"else"
"var"
"const"
"range"
] @keyword
; Dingo-specific keywords
[
"enum"
"match"
] @keyword
; Operators
[
"="
":="
"+"
"-"
"*"
"/"
"%"
"&"
"|"
"^"
"!"
"<"
">"
"=="
"!="
"<="
">="
"&&"
"||"
"<<"
">>"
"<-"
"+="
"-="
"*="
"/="
] @operator
; Dingo special operators
"=>" @operator
"?." @operator
"??" @operator
(error_propagation
"?" @operator)
; Lambda pipes (special highlighting)
(lambda_expression
"|" @punctuation.special)
; Types
(type_declaration
(identifier) @type.definition)
(type_param
(identifier) @type)
(generic_type
(identifier) @type)
(qualified_type
(identifier) @type)
; Dingo enum
(enum_declaration
name: (identifier) @type.definition)
(enum_variant
name: (identifier) @constructor)
(variant_field
(identifier) @property)
; Match patterns
(match_expression
"match" @keyword.conditional)
(variant_match
(identifier) @constructor)
; Functions
(function_declaration
name: (identifier) @function)
(call_expr
(identifier) @function.call)
(call_expr
(selector_expr
(identifier) @function.method.call))
; Parameters
(param_decl
(identifier) @variable.parameter)
(lambda_param
(identifier) @variable.parameter)
; Variables
(var_spec
(identifier) @variable)
(const_spec
(identifier) @constant)
; Literals
(int_literal) @number
(float_literal) @number.float
(string_literal) @string
(rune_literal) @character
; Booleans and nil
"true" @boolean
"false" @boolean
"nil" @constant.builtin
; Comments
(comment) @comment
; Punctuation
[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
[
","
";"
":"
"."
] @punctuation.delimiter
; Import path
(import_spec
(string_literal) @string.special)
; Package name
(package_clause
(identifier) @module)
; Wildcard pattern
"_" @variable.builtin
; Error propagation expression (special styling)
(error_propagation) @punctuation.special
; Safe navigation (special styling)
(safe_navigation) @punctuation.special