mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-12 00:10:04 -04:00
See https://github.com/NLnetLabs/tree-sitter-roto for the parser repo. This only works if the filetype for Roto is added explicitly: ```lua vim.filetype.add({ extension = { roto = "roto" } }) ``` After that the queries seem to work well when testing it on all the example Roto scripts from https://github.com/NLnetLabs/roto/tree/main/examples. I have a [PR to Vim](https://github.com/vim/vim/pull/19195) aiming to add `.roto` as a recognized extension for a `roto` filetype. Once there, NeoVim should eventually pull it in and users will not need to add the filetype themselves.
111 lines
1.6 KiB
Scheme
111 lines
1.6 KiB
Scheme
; Identifiers
|
|
(identifier) @variable
|
|
|
|
; Assume that uppercase names in paths are types
|
|
((identifier) @type
|
|
(#match? @type "^[A-Z]"))
|
|
|
|
(optional_type) @type
|
|
|
|
(type_name) @type
|
|
|
|
(unit) @type.builtin
|
|
|
|
(never) @type.builtin
|
|
|
|
(record_type) @type
|
|
|
|
(type_name
|
|
(path
|
|
(identifier) @type.builtin)
|
|
(#match? @type.builtin "^(u8|u16|u32|u64|i8|i16|i32|i64|f32|f64|String|bool|Asn|IpAddr|Prefix)$"))
|
|
|
|
; Assume all-caps names are constants
|
|
((identifier) @constant
|
|
(#match? @constant "^[A-Z][A-Z\\d_]+$'"))
|
|
|
|
; Function calls
|
|
; Unfortunately, we can't really distinguish them from methods if it's called
|
|
; on a path
|
|
(call_expression
|
|
function: (path
|
|
(identifier) @function .))
|
|
|
|
(call_expression
|
|
function: (access_expression
|
|
(identifier) @function.method .))
|
|
|
|
; Calling a function with an uppercase letter: it's an enum constructor
|
|
(call_expression
|
|
function: (path
|
|
(identifier) @constructor .)
|
|
(#match? @constructor "^[A-Z]"))
|
|
|
|
; Function definitions
|
|
(function_item
|
|
(identifier) @function)
|
|
|
|
(filtermap_item
|
|
(identifier) @function)
|
|
|
|
(test_item
|
|
(identifier) @function)
|
|
|
|
(line_comment) @comment
|
|
|
|
(parameter
|
|
(identifier) @variable.parameter)
|
|
|
|
[
|
|
"*"
|
|
"="
|
|
"=="
|
|
"!="
|
|
"&&"
|
|
"|"
|
|
"||"
|
|
"-"
|
|
"+"
|
|
"/"
|
|
">"
|
|
"<"
|
|
">="
|
|
"<="
|
|
"?"
|
|
] @operator
|
|
|
|
[
|
|
"("
|
|
")"
|
|
"{"
|
|
"}"
|
|
"["
|
|
"]"
|
|
] @punctuation.bracket
|
|
|
|
[
|
|
":"
|
|
"."
|
|
","
|
|
";"
|
|
"->"
|
|
] @punctuation.delimiter
|
|
|
|
[
|
|
"filter"
|
|
"filtermap"
|
|
"fn"
|
|
"test"
|
|
] @keyword.function
|
|
|
|
"in" @keyword
|
|
|
|
; "dep" @keyword
|
|
; "std" @keyword
|
|
; "super" @keyword
|
|
; "pkg" @keyword
|
|
"not" @keyword.operator
|
|
|
|
(string_literal) @string
|
|
|
|
(unit_literal) @constant.builtin
|