feat(treesitter): replace nvim-treesitter with pack-managed parsers

This commit is contained in:
2026-04-12 11:46:54 +02:00
parent ec81afbab7
commit cf898d1fee
107 changed files with 8555 additions and 13 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
local lsp = require("lsp")
local lua_library_paths = { vim.env.VIMRUNTIME }
vim.list_extend(lua_library_paths, require("pack").paths)
vim.list_extend(lua_library_paths, require("pack").get_paths())
---@type vim.lsp.Config
return {
+130 -1
View File
@@ -21,6 +21,7 @@ for _, file in ipairs(files) do
end
end
local ts = require("ts")
require("pack").setup({
"https://github.com/navarasu/onedark.nvim",
"https://github.com/nvim-lua/plenary.nvim",
@@ -40,7 +41,6 @@ require("pack").setup({
"https://github.com/owallb/mason-auto-install.nvim",
"https://github.com/mfussenegger/nvim-dap",
"https://github.com/igorlfs/nvim-dap-view",
"https://github.com/nvim-treesitter/nvim-treesitter",
"https://github.com/numToStr/Comment.nvim",
"https://github.com/j-hui/fidget.nvim",
"https://github.com/rbong/vim-flog",
@@ -50,4 +50,133 @@ require("pack").setup({
"https://github.com/nvim-tree/nvim-tree.lua",
"https://github.com/stevearc/oil.nvim",
"https://github.com/hedyhli/outline.nvim",
{
"https://github.com/tree-sitter/tree-sitter-bash",
ts_parser = "bash",
},
-- required by cpp
{
"https://github.com/tree-sitter/tree-sitter-c",
ts_parser = "c",
},
{
"https://github.com/stsewd/tree-sitter-comment",
ts_parser = "comment",
},
{
"https://github.com/tree-sitter/tree-sitter-cpp",
ts_parser = "cpp",
},
-- required by scss
{
"https://github.com/tree-sitter/tree-sitter-css",
ts_parser = "css",
},
{
"https://github.com/gbprod/tree-sitter-gitcommit",
ts_parser = "gitcommit",
},
{
"https://github.com/tree-sitter/tree-sitter-go",
ts_parser = "go",
},
{
"https://github.com/ngalaiko/tree-sitter-go-template",
ts_parser = "gotmpl",
},
{
"https://github.com/tree-sitter/tree-sitter-html",
ts_parser = "html",
},
{
"https://github.com/tree-sitter/tree-sitter-json",
ts_parser = "json",
},
{
"https://github.com/tree-sitter-grammars/tree-sitter-luadoc",
ts_parser = "luadoc",
},
{
"https://github.com/tree-sitter/tree-sitter-php",
ts_parser = {
{ lang = "php", location = "php" },
{ lang = "php_only", location = "php_only" },
},
},
{
"https://github.com/tree-sitter/tree-sitter-python",
ts_parser = "python",
},
{
"https://github.com/tree-sitter/tree-sitter-rust",
ts_parser = "rust",
},
{
"https://github.com/serenadeai/tree-sitter-scss",
ts_parser = "scss",
},
{
"https://github.com/derekstride/tree-sitter-sql",
version = "gh-pages",
ts_parser = "sql",
},
{
"https://github.com/tree-sitter-grammars/tree-sitter-svelte",
ts_parser = "svelte",
},
{
"https://github.com/tree-sitter/tree-sitter-typescript",
ts_parser = {
{ lang = "typescript", location = "typescript" },
{ lang = "tsx", location = "tsx" },
},
},
{
"https://github.com/tree-sitter-grammars/tree-sitter-xml",
ts_parser = {
{ lang = "xml", location = "xml" },
{ lang = "dtd", location = "dtd" },
},
},
{
"https://github.com/tree-sitter-grammars/tree-sitter-yaml",
ts_parser = "yaml",
},
{
"https://github.com/georgeharker/tree-sitter-zsh",
ts_parser = "zsh",
},
})
ts.setup({
languages = {
"bash",
"c", -- builtin
"comment",
"cpp",
"css",
"gitcommit",
"go",
"gotmpl",
"html",
"json",
"lua", -- builtin
"luadoc",
"markdown", -- builtin
"markdown_inline", -- builtin
"php",
"python",
"query", -- builtin
"rust",
"scss",
"sql",
"svelte",
"tsx",
"typescript",
"vim", -- builtin
"vimdoc", -- builtin
"xml",
"yaml",
"zsh",
}
})
+1 -1
View File
@@ -17,7 +17,7 @@ end, {
complete = function(lead)
return vim.tbl_filter(function(name)
return name:find(lead, 1, true) == 1
end, require("pack").names)
end, require("pack").get_names())
end,
desc = "Reload a plugin config by name",
})
+29 -8
View File
@@ -24,6 +24,7 @@ end
---@field name? string
---@field version? string | vim.VersionRange
---@field build? string[] | fun(self: ow.Pack.Plugin)
---@field ts_parser? ow.TS.ParserField
---@class ow.Pack.Plugin : ow.Pack.PluginSpec
---@field name string
@@ -55,6 +56,7 @@ local function to_pack_spec(spec)
version = spec.version,
data = {
build = spec.build,
ts_parser = spec.ts_parser,
},
}
end
@@ -75,7 +77,15 @@ local function run_build(plugin)
return
end
log.error("invalid build parameter for %s", plugin.name)
log.error("Invalid build parameter for %s", plugin.name)
end
---@param plugin ow.Pack.Plugin
local function run_ts_build(plugin)
local ts = require("ts")
for _, p in ipairs(ts.normalize(plugin.ts_parser)) do
ts.build(plugin, p)
end
end
---@class ow.Pack.Event.Data
@@ -90,7 +100,7 @@ end
---@param plugin ow.Pack.Plugin
---@param events ow.Pack.Event[]
local function process_events(plugin, events)
if not plugin.build then
if not plugin.build and not plugin.ts_parser then
return
end
@@ -99,10 +109,14 @@ local function process_events(plugin, events)
and ev.event == "PackChanged"
and (ev.data.kind == "install" or ev.data.kind == "update")
then
if plugin.ts_parser then
run_ts_build(plugin)
else
run_build(plugin)
end
end
end
end
---@type uv.uv_fs_event_t?
local watcher = nil
@@ -111,15 +125,21 @@ local watcher = nil
local timers = {}
---@class ow.Pack
---@field names string[]
---@field paths string[]
---@field plugins ow.Pack.Plugin[]
local M = {
names = {},
paths = {},
plugins = {},
}
---@return string[]
function M.get_names()
return vim.tbl_map(function(p) return p.name end, M.plugins)
end
---@return string[]
function M.get_paths()
return vim.tbl_map(function(p) return p.path end, M.plugins)
end
---@param name string
function M.reload(name)
local path = string.format("%s/lua/plugins/%s.lua", config_dir, name)
@@ -247,13 +267,14 @@ function M.setup(specs)
name = data.spec.name,
version = data.spec.version,
build = d.build,
ts_parser = d.ts_parser,
path = data.path,
}
table.insert(M.plugins, plugin)
table.insert(M.names, plugin.name)
table.insert(M.paths, plugin.path)
if not d.ts_parser then
vim.cmd.packadd(plugin.name)
end
end
})
vim.api.nvim_del_autocmd(id)
+159
View File
@@ -0,0 +1,159 @@
local log = require("log")
local M = {}
---@class ow.TS.ParserSpec
---@field lang string
---@field location? string
---@field generate? boolean
---@field from_json? boolean
---@alias ow.TS.ParserField string | ow.TS.ParserSpec | ow.TS.ParserSpec[]
---@param plugin ow.Pack.Plugin
---@param lang string
---@return string
local function parser_path(plugin, lang)
return vim.fs.joinpath(plugin.path, "parser", lang .. ".so")
end
---@param buf integer
local function start_treesitter(buf)
local ok, err = pcall(vim.treesitter.start, buf)
if not ok then
log.error(
"Failed to enable treesitter for buffer %d: %s",
buf,
err
)
return
end
for _, win in ipairs(vim.fn.win_findbuf(buf)) do
vim.wo[win].foldmethod = "expr"
vim.wo[win].foldexpr = "v:lua.vim.treesitter.foldexpr()"
end
end
---@param lang string
local function activate_open_buffers(lang)
local fts = vim.treesitter.language.get_filetypes(lang)
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_loaded(buf)
and vim.list_contains(fts, vim.bo[buf].filetype)
then
start_treesitter(buf)
end
end
end
---@param plugin ow.Pack.Plugin
---@param spec ow.TS.ParserSpec
function M.build(plugin, spec)
local cwd = spec.location
and vim.fs.joinpath(plugin.path, spec.location)
or plugin.path
local out = parser_path(plugin, spec.lang)
vim.fn.mkdir(vim.fs.dirname(out), "p")
local function on_build(r)
if r.code ~= 0 then
log.error(
"Failed to build parser for %s: %s",
spec.lang,
r.stderr or ""
)
return
end
vim.treesitter.language.add(spec.lang, { path = out })
activate_open_buffers(spec.lang)
end
local function do_build()
vim.system(
{ "tree-sitter", "build", "-o", out },
{ cwd = cwd },
vim.schedule_wrap(on_build)
)
end
if spec.generate then
local cmd = {
"tree-sitter", "generate",
"--abi", tostring(vim.treesitter.language_version),
}
if spec.from_json ~= false then
table.insert(cmd, "src/grammar.json")
end
vim.system(cmd, {
cwd = cwd,
env = { TREE_SITTER_JS_RUNTIME = "native" },
}, vim.schedule_wrap(function(r)
if r.code ~= 0 then
log.error(
"Failed to generate parser for %s: %s",
spec.lang,
r.stderr or ""
)
return
end
do_build()
end))
else
do_build()
end
end
---@param field ow.TS.ParserField
---@return ow.TS.ParserSpec[]
function M.normalize(field)
if type(field) == "string" then
return { { lang = field } }
end
if type(field) == "table" then
if type(field.lang) == "string" then
return { field }
end
if type(field[1]) == "table" then
return field
end
end
error("invalid ts_parser value: " .. vim.inspect(field))
end
---@param languages string[]
local function collect_filetypes(languages)
local filetypes = {}
for _, lang in ipairs(languages) do
for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
if not vim.list_contains(filetypes, ft) then
table.insert(filetypes, ft)
end
end
end
return filetypes
end
---@param opts { languages: string[] }
function M.setup(opts)
for _, plugin in ipairs(require("pack").plugins) do
if plugin.ts_parser then
for _, p in ipairs(M.normalize(plugin.ts_parser)) do
local path = parser_path(plugin, p.lang)
if vim.uv.fs_stat(path) then
vim.treesitter.language.add(p.lang, { path = path })
end
end
end
end
vim.api.nvim_create_autocmd("FileType", {
pattern = collect_filetypes(opts.languages),
callback = function(ev)
start_treesitter(ev.buf)
end,
})
end
return M
+85
View File
@@ -85,6 +85,91 @@
"rev": "7ef4d6dccb78ee71e552bbd866176762ad328afa",
"src": "https://github.com/nvim-telescope/telescope.nvim"
},
"tree-sitter-bash": {
"rev": "a06c2e4415e9bc0346c6b86d401879ffb44058f7",
"src": "https://github.com/tree-sitter/tree-sitter-bash"
},
"tree-sitter-c": {
"rev": "ae19b676b13bdcc13b7665397e6d9b14975473dd",
"src": "https://github.com/tree-sitter/tree-sitter-c"
},
"tree-sitter-comment": {
"rev": "66272d2b6c73fb61157541b69dd0a7ce7b42a5ad",
"src": "https://github.com/stsewd/tree-sitter-comment"
},
"tree-sitter-cpp": {
"rev": "8b5b49eb196bec7040441bee33b2c9a4838d6967",
"src": "https://github.com/tree-sitter/tree-sitter-cpp"
},
"tree-sitter-css": {
"rev": "dda5cfc5722c429eaba1c910ca32c2c0c5bb1a3f",
"src": "https://github.com/tree-sitter/tree-sitter-css"
},
"tree-sitter-gitcommit": {
"rev": "33fe8548abcc6e374feaac5724b5a2364bf23090",
"src": "https://github.com/gbprod/tree-sitter-gitcommit"
},
"tree-sitter-go": {
"rev": "2346a3ab1bb3857b48b29d779a1ef9799a248cd7",
"src": "https://github.com/tree-sitter/tree-sitter-go"
},
"tree-sitter-go-template": {
"rev": "aa71f63de226c5592dfbfc1f29949522d7c95fac",
"src": "https://github.com/ngalaiko/tree-sitter-go-template"
},
"tree-sitter-html": {
"rev": "73a3947324f6efddf9e17c0ea58d454843590cc0",
"src": "https://github.com/tree-sitter/tree-sitter-html"
},
"tree-sitter-json": {
"rev": "001c28d7a29832b06b0e831ec77845553c89b56d",
"src": "https://github.com/tree-sitter/tree-sitter-json"
},
"tree-sitter-luadoc": {
"rev": "873612aadd3f684dd4e631bdf42ea8990c57634e",
"src": "https://github.com/tree-sitter-grammars/tree-sitter-luadoc"
},
"tree-sitter-php": {
"rev": "3f2465c217d0a966d41e584b42d75522f2a3149e",
"src": "https://github.com/tree-sitter/tree-sitter-php"
},
"tree-sitter-python": {
"rev": "26855eabccb19c6abf499fbc5b8dc7cc9ab8bc64",
"src": "https://github.com/tree-sitter/tree-sitter-python"
},
"tree-sitter-rust": {
"rev": "77a3747266f4d621d0757825e6b11edcbf991ca5",
"src": "https://github.com/tree-sitter/tree-sitter-rust"
},
"tree-sitter-scss": {
"rev": "c478c6868648eff49eb04a4df90d703dc45b312a",
"src": "https://github.com/serenadeai/tree-sitter-scss"
},
"tree-sitter-sql": {
"rev": "851e9cb257ba7c66cc8c14214a31c44d2f1e954e",
"src": "https://github.com/derekstride/tree-sitter-sql",
"version": "'gh-pages'"
},
"tree-sitter-svelte": {
"rev": "ae5199db47757f785e43a14b332118a5474de1a2",
"src": "https://github.com/tree-sitter-grammars/tree-sitter-svelte"
},
"tree-sitter-typescript": {
"rev": "75b3874edb2dc714fb1fd77a32013d0f8699989f",
"src": "https://github.com/tree-sitter/tree-sitter-typescript"
},
"tree-sitter-xml": {
"rev": "5000ae8f22d11fbe93939b05c1e37cf21117162d",
"src": "https://github.com/tree-sitter-grammars/tree-sitter-xml"
},
"tree-sitter-yaml": {
"rev": "4463985dfccc640f3d6991e3396a2047610cf5f8",
"src": "https://github.com/tree-sitter-grammars/tree-sitter-yaml"
},
"tree-sitter-zsh": {
"rev": "484e2889f3619b9da90c9b73a6f216a71947c09f",
"src": "https://github.com/georgeharker/tree-sitter-zsh"
},
"vim-flog": {
"rev": "665b16ac8915f746bc43c9572b4581a5e9047216",
"src": "https://github.com/rbong/vim-flog"
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+12
View File
@@ -0,0 +1,12 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(function_definition)
(if_statement)
(case_statement)
(for_statement)
(while_statement)
(c_style_for_statement)
(heredoc_redirect)
] @fold
+281
View File
@@ -0,0 +1,281 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
"("
")"
"{"
"}"
"["
"]"
"[["
"]]"
"(("
"))"
] @punctuation.bracket
[
";"
";;"
";&"
";;&"
"&"
] @punctuation.delimiter
[
">"
">>"
"<"
"<<"
"&&"
"|"
"|&"
"||"
"="
"+="
"=~"
"=="
"!="
"&>"
"&>>"
"<&"
">&"
">|"
"<&-"
">&-"
"<<-"
"<<<"
".."
"!"
] @operator
; Do *not* spell check strings since they typically have some sort of
; interpolation in them, or, are typically used for things like filenames, URLs,
; flags and file content.
[
(string)
(raw_string)
(ansi_c_string)
(heredoc_body)
] @string
[
(heredoc_start)
(heredoc_end)
] @label
(variable_assignment
(word) @string)
(command
argument: "$" @string) ; bare dollar
(concatenation
(word) @string)
[
"if"
"then"
"else"
"elif"
"fi"
"case"
"in"
"esac"
] @keyword.conditional
[
"for"
"do"
"done"
"select"
"until"
"while"
] @keyword.repeat
[
"declare"
"typeset"
"readonly"
"local"
"unset"
"unsetenv"
] @keyword
"export" @keyword.import
"function" @keyword.function
(special_variable_name) @constant
(comment) @comment @spell
(test_operator) @operator
(command_substitution
"$(" @punctuation.special
")" @punctuation.special)
(process_substitution
[
"<("
">("
] @punctuation.special
")" @punctuation.special)
(arithmetic_expansion
[
"$(("
"(("
] @punctuation.special
"))" @punctuation.special)
(arithmetic_expansion
"," @punctuation.delimiter)
(ternary_expression
[
"?"
":"
] @keyword.conditional.ternary)
(binary_expression
operator: _ @operator)
(unary_expression
operator: _ @operator)
(postfix_expression
operator: _ @operator)
(function_definition
name: (word) @function)
(command_name
(word) @function.call)
(command_name
(word) @function.builtin
(#any-of? @function.builtin
"." ":" "alias" "bg" "bind" "break" "builtin" "caller" "cd" "command" "compgen" "complete"
"compopt" "continue" "coproc" "dirs" "disown" "echo" "enable" "eval" "exec" "exit" "false" "fc"
"fg" "getopts" "hash" "help" "history" "jobs" "kill" "let" "logout" "mapfile" "popd" "printf"
"pushd" "pwd" "read" "readarray" "return" "set" "shift" "shopt" "source" "suspend" "test" "time"
"times" "trap" "true" "type" "typeset" "ulimit" "umask" "unalias" "wait"))
(command
argument: [
(word) @variable.parameter
(concatenation
(word) @variable.parameter)
])
; help trap
(command
name: (command_name
(word) @_command)
argument: (word) @string.special
(#eq? @_command "trap")
(#any-of? @string.special "EXIT" "DEBUG" "RETURN" "ERR"))
; trap -l
(command
name: (command_name
(word) @_command)
argument: (word) @string.special
(#any-of? @_command "trap" "kill")
(#any-of? @string.special
"SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1"
"SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP"
"SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH"
"SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4"
"SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11"
"SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13"
"SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6"
"SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX"))
(declaration_command
(word) @variable.parameter)
(unset_command
(word) @variable.parameter)
(number) @number
(file_redirect
(word) @string.special.path)
(herestring_redirect
(word) @string)
(file_descriptor) @operator
(simple_expansion
"$" @punctuation.special) @none
(expansion
"${" @punctuation.special
"}" @punctuation.special) @none
(expansion
operator: _ @punctuation.special)
(expansion
"@"
.
operator: _ @character.special)
((expansion
(subscript
index: (word) @character.special))
(#any-of? @character.special "@" "*"))
"``" @punctuation.special
(variable_name) @variable
((variable_name) @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
((variable_name) @variable.builtin
(#any-of? @variable.builtin
; https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Variables.html
"CDPATH" "HOME" "IFS" "MAIL" "MAILPATH" "OPTARG" "OPTIND" "PATH" "PS1" "PS2"
; https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html
"_" "BASH" "BASHOPTS" "BASHPID" "BASH_ALIASES" "BASH_ARGC" "BASH_ARGV" "BASH_ARGV0" "BASH_CMDS"
"BASH_COMMAND" "BASH_COMPAT" "BASH_ENV" "BASH_EXECUTION_STRING" "BASH_LINENO"
"BASH_LOADABLES_PATH" "BASH_REMATCH" "BASH_SOURCE" "BASH_SUBSHELL" "BASH_VERSINFO"
"BASH_VERSION" "BASH_XTRACEFD" "CHILD_MAX" "COLUMNS" "COMP_CWORD" "COMP_LINE" "COMP_POINT"
"COMP_TYPE" "COMP_KEY" "COMP_WORDBREAKS" "COMP_WORDS" "COMPREPLY" "COPROC" "DIRSTACK" "EMACS"
"ENV" "EPOCHREALTIME" "EPOCHSECONDS" "EUID" "EXECIGNORE" "FCEDIT" "FIGNORE" "FUNCNAME"
"FUNCNEST" "GLOBIGNORE" "GROUPS" "histchars" "HISTCMD" "HISTCONTROL" "HISTFILE" "HISTFILESIZE"
"HISTIGNORE" "HISTSIZE" "HISTTIMEFORMAT" "HOSTFILE" "HOSTNAME" "HOSTTYPE" "IGNOREEOF" "INPUTRC"
"INSIDE_EMACS" "LANG" "LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" "LC_NUMERIC" "LC_TIME"
"LINENO" "LINES" "MACHTYPE" "MAILCHECK" "MAPFILE" "OLDPWD" "OPTERR" "OSTYPE" "PIPESTATUS"
"POSIXLY_CORRECT" "PPID" "PROMPT_COMMAND" "PROMPT_DIRTRIM" "PS0" "PS3" "PS4" "PWD" "RANDOM"
"READLINE_ARGUMENT" "READLINE_LINE" "READLINE_MARK" "READLINE_POINT" "REPLY" "SECONDS" "SHELL"
"SHELLOPTS" "SHLVL" "SRANDOM" "TIMEFORMAT" "TMOUT" "TMPDIR" "UID"))
((command
name: (command_name
(word) @_printf)
.
argument: (word) @_v
.
argument: (word) @variable)
(#eq? @_printf "printf")
(#eq? @_v "-v")
(#lua-match? @variable "^[a-zA-Z_][a-zA-Z0-9_]*$"))
(case_item
value: (word) @variable.parameter)
[
(regex)
(extglob_pattern)
] @string.regexp
((program
.
(comment) @keyword.directive @nospell)
(#lua-match? @keyword.directive "^#![ \t]*/"))
+35
View File
@@ -0,0 +1,35 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(if_statement)
(for_statement)
(while_statement)
(case_statement)
(function_definition)
(compound_statement)
(subshell)
(command_substitution)
(do_group)
(case_item)
] @indent.begin
[
"fi"
"done"
"esac"
"}"
")"
"then"
"do"
(elif_clause)
(else_clause)
] @indent.branch
[
"fi"
"done"
"esac"
"}"
")"
] @indent.end
+93
View File
@@ -0,0 +1,93 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((comment) @injection.content
(#set! injection.language "comment"))
((regex) @injection.content
(#set! injection.language "regex"))
(heredoc_redirect
(heredoc_body) @injection.content
(heredoc_end) @injection.language)
; printf 'format'
((command
name: (command_name) @_command
.
argument: [
(string) @injection.content
(concatenation
(string) @injection.content)
(raw_string) @injection.content
(concatenation
(raw_string) @injection.content)
])
(#eq? @_command "printf")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "printf"))
; printf -v var 'format'
((command
name: (command_name) @_command
argument: (word) @_arg
.
(_)
.
argument: [
(string) @injection.content
(concatenation
(string) @injection.content)
(raw_string) @injection.content
(concatenation
(raw_string) @injection.content)
])
(#eq? @_command "printf")
(#eq? @_arg "-v")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "printf"))
; printf -- 'format'
((command
name: (command_name) @_command
argument: (word) @_arg
.
argument: [
(string) @injection.content
(concatenation
(string) @injection.content)
(raw_string) @injection.content
(concatenation
(raw_string) @injection.content)
])
(#eq? @_command "printf")
(#eq? @_arg "--")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "printf"))
((command
name: (command_name) @_command
.
argument: [
(string)
(raw_string)
] @injection.content)
(#eq? @_command "bind")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "readline"))
((command
name: (command_name) @_command
.
argument: [
(string)
(raw_string)
] @injection.content)
(#eq? @_command "trap")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.self))
+17
View File
@@ -0,0 +1,17 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Scopes
(function_definition) @local.scope
; Definitions
(variable_assignment
name: (variable_name) @local.definition.var)
(function_definition
name: (word) @local.definition.function)
; References
(variable_name) @local.reference
(word) @local.reference
+26
View File
@@ -0,0 +1,26 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(for_statement)
(if_statement)
(while_statement)
(do_statement)
(switch_statement)
(case_statement)
(function_definition)
(struct_specifier)
(enum_specifier)
(comment)
(preproc_if)
(preproc_elif)
(preproc_else)
(preproc_ifdef)
(preproc_function_def)
(initializer_list)
(gnu_asm_expression)
(preproc_include)+
] @fold
(compound_statement
(compound_statement) @fold)
+344
View File
@@ -0,0 +1,344 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration.
((identifier) @variable
(#set! priority 95))
(preproc_def
(preproc_arg) @variable)
[
"default"
"goto"
"asm"
"__asm__"
] @keyword
[
"enum"
"struct"
"union"
"typedef"
] @keyword.type
[
"sizeof"
"offsetof"
] @keyword.operator
(alignof_expression
.
_ @keyword.operator)
"return" @keyword.return
[
"while"
"for"
"do"
"continue"
"break"
] @keyword.repeat
[
"if"
"else"
"case"
"switch"
] @keyword.conditional
[
"#if"
"#ifdef"
"#ifndef"
"#else"
"#elif"
"#endif"
"#elifdef"
"#elifndef"
(preproc_directive)
] @keyword.directive
"#define" @keyword.directive.define
"#include" @keyword.import
[
";"
":"
","
"."
"::"
] @punctuation.delimiter
"..." @punctuation.special
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
[
"="
"-"
"*"
"/"
"+"
"%"
"~"
"|"
"&"
"^"
"<<"
">>"
"->"
"<"
"<="
">="
">"
"=="
"!="
"!"
"&&"
"||"
"-="
"+="
"*="
"/="
"%="
"|="
"&="
"^="
">>="
"<<="
"--"
"++"
] @operator
; Make sure the comma operator is given a highlight group after the comma
; punctuator so the operator is highlighted properly.
(comma_expression
"," @operator)
[
(true)
(false)
] @boolean
(conditional_expression
[
"?"
":"
] @keyword.conditional.ternary)
(string_literal) @string
(system_lib_string) @string
(escape_sequence) @string.escape
(null) @constant.builtin
(number_literal) @number
(char_literal) @character
(preproc_defined) @function.macro
((field_expression
(field_identifier) @property) @_parent
(#not-has-parent? @_parent function_declarator call_expression))
(field_designator) @property
((field_identifier) @property
(#has-ancestor? @property field_declaration)
(#not-has-ancestor? @property function_declarator))
(statement_identifier) @label
(declaration
type: (type_identifier) @_type
declarator: (identifier) @label
(#eq? @_type "__label__"))
[
(type_identifier)
(type_descriptor)
] @type
(storage_class_specifier) @keyword.modifier
[
(type_qualifier)
(gnu_asm_qualifier)
"__extension__"
] @keyword.modifier
(linkage_specification
"extern" @keyword.modifier)
(type_definition
declarator: (type_identifier) @type.definition)
(primitive_type) @type.builtin
(sized_type_specifier
_ @type.builtin
type: _?)
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(preproc_def
(preproc_arg) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(enumerator
name: (identifier) @constant)
(case_statement
value: (identifier) @constant)
((identifier) @constant.builtin
; format-ignore
(#any-of? @constant.builtin
"stderr" "stdin" "stdout"
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
"__TIMESTAMP__" "__clang__" "__clang_major__"
"__clang_minor__" "__clang_patchlevel__"
"__clang_version__" "__clang_literal_encoding__"
"__clang_wide_literal_encoding__"
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
"__VA_ARGS__" "__VA_OPT__"))
(preproc_def
(preproc_arg) @constant.builtin
; format-ignore
(#any-of? @constant.builtin
"stderr" "stdin" "stdout"
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
"__TIMESTAMP__" "__clang__" "__clang_major__"
"__clang_minor__" "__clang_patchlevel__"
"__clang_version__" "__clang_literal_encoding__"
"__clang_wide_literal_encoding__"
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
"__VA_ARGS__" "__VA_OPT__"))
(attribute_specifier
(argument_list
(identifier) @variable.builtin))
(attribute_specifier
(argument_list
(call_expression
function: (identifier) @variable.builtin)))
((call_expression
function: (identifier) @function.builtin)
(#lua-match? @function.builtin "^__builtin_"))
((call_expression
function: (identifier) @function.builtin)
(#has-ancestor? @function.builtin attribute_specifier))
; Preproc def / undef
(preproc_def
name: (_) @constant.macro)
(preproc_call
directive: (preproc_directive) @_u
argument: (_) @constant.macro
(#eq? @_u "#undef"))
(preproc_ifdef
name: (identifier) @constant.macro)
(preproc_elifdef
name: (identifier) @constant.macro)
(preproc_defined
(identifier) @constant.macro)
(call_expression
function: (identifier) @function.call)
(call_expression
function: (field_expression
field: (field_identifier) @function.call))
(function_declarator
declarator: (identifier) @function)
(function_declarator
declarator: (parenthesized_declarator
(pointer_declarator
declarator: (field_identifier) @function)))
(preproc_function_def
name: (identifier) @function.macro)
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
; Parameters
(parameter_declaration
declarator: (identifier) @variable.parameter)
(parameter_declaration
declarator: (array_declarator) @variable.parameter)
(parameter_declaration
declarator: (pointer_declarator) @variable.parameter)
; K&R functions
; To enable support for K&R functions,
; add the following lines to your own query config and uncomment them.
; They are commented out as they'll conflict with C++
; Note that you'll need to have `; extends` at the top of your query file.
;
; (parameter_list (identifier) @variable.parameter)
;
; (function_definition
; declarator: _
; (declaration
; declarator: (identifier) @variable.parameter))
;
; (function_definition
; declarator: _
; (declaration
; declarator: (array_declarator) @variable.parameter))
;
; (function_definition
; declarator: _
; (declaration
; declarator: (pointer_declarator) @variable.parameter))
(preproc_params
(identifier) @variable.parameter)
[
"__attribute__"
"__declspec"
"__based"
"__cdecl"
"__clrcall"
"__stdcall"
"__fastcall"
"__thiscall"
"__vectorcall"
(ms_pointer_modifier)
(attribute_declaration)
] @attribute
+102
View File
@@ -0,0 +1,102 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(compound_statement)
(field_declaration_list)
(case_statement)
(enumerator_list)
(compound_literal_expression)
(initializer_list)
(init_declarator)
] @indent.begin
; With current indent logic, if we capture expression_statement with @indent.begin
; It will be affected by _parent_ node with error subnodes deep down the tree
; So narrow indent capture to check for error inside expression statement only,
(expression_statement
(_) @indent.begin
";" @indent.end)
(ERROR
"for"
"(" @indent.begin
";"
";"
")" @indent.end)
((for_statement
body: (_) @_body) @indent.begin
(#not-kind-eq? @_body "compound_statement"))
(while_statement
condition: (_) @indent.begin)
((while_statement
body: (_) @_body) @indent.begin
(#not-kind-eq? @_body "compound_statement"))
((if_statement)
.
(ERROR
"else" @indent.begin))
(if_statement
condition: (_) @indent.begin)
; Supports if without braces (but not both if-else without braces)
(if_statement
consequence: (_
";" @indent.end) @_consequence
(#not-kind-eq? @_consequence "compound_statement")
alternative: (else_clause
"else" @indent.branch
[
(if_statement
(compound_statement) @indent.dedent)? @indent.dedent
(compound_statement)? @indent.dedent
(_)? @indent.dedent
])?) @indent.begin
(else_clause
(_
.
"{" @indent.branch))
(compound_statement
"}" @indent.end)
[
")"
"}"
(statement_identifier)
] @indent.branch
[
"#define"
"#ifdef"
"#ifndef"
"#elif"
"#if"
"#else"
"#endif"
] @indent.zero
[
(preproc_arg)
(string_literal)
] @indent.ignore
((ERROR
(parameter_declaration)) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
([
(argument_list)
(parameter_list)
] @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
(comment) @indent.auto
+131
View File
@@ -0,0 +1,131 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((preproc_arg) @injection.content
(#set! injection.self))
((comment) @injection.content
(#set! injection.language "comment"))
((comment) @injection.content
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
(#set! injection.language "re2c"))
((comment) @injection.content
(#lua-match? @injection.content "/[*/][!*/]<?[^a-zA-Z]")
(#set! injection.language "doxygen"))
((call_expression
function: (identifier) @_function
arguments: (argument_list
.
[
(string_literal
(string_content) @injection.content)
(concatenated_string
(string_literal
(string_content) @injection.content))
]))
; format-ignore
(#any-of? @_function
"printf" "printf_s"
"vprintf" "vprintf_s"
"scanf" "scanf_s"
"vscanf" "vscanf_s"
"wprintf" "wprintf_s"
"vwprintf" "vwprintf_s"
"wscanf" "wscanf_s"
"vwscanf" "vwscanf_s"
"cscanf" "_cscanf"
"printw"
"scanw")
(#set! injection.language "printf"))
((call_expression
function: (identifier) @_function
arguments: (argument_list
(_)
.
[
(string_literal
(string_content) @injection.content)
(concatenated_string
(string_literal
(string_content) @injection.content))
]))
; format-ignore
(#any-of? @_function
"fprintf" "fprintf_s"
"sprintf"
"dprintf"
"fscanf" "fscanf_s"
"sscanf" "sscanf_s"
"vsscanf" "vsscanf_s"
"vfprintf" "vfprintf_s"
"vsprintf"
"vdprintf"
"fwprintf" "fwprintf_s"
"vfwprintf" "vfwprintf_s"
"fwscanf" "fwscanf_s"
"swscanf" "swscanf_s"
"vswscanf" "vswscanf_s"
"vfscanf" "vfscanf_s"
"vfwscanf" "vfwscanf_s"
"wprintw"
"vw_printw" "vwprintw"
"wscanw"
"vw_scanw" "vwscanw")
(#set! injection.language "printf"))
((call_expression
function: (identifier) @_function
arguments: (argument_list
(_)
.
(_)
.
[
(string_literal
(string_content) @injection.content)
(concatenated_string
(string_literal
(string_content) @injection.content))
]))
; format-ignore
(#any-of? @_function
"sprintf_s"
"snprintf" "snprintf_s"
"vsprintf_s"
"vsnprintf" "vsnprintf_s"
"swprintf" "swprintf_s"
"snwprintf_s"
"vswprintf" "vswprintf_s"
"vsnwprintf_s"
"mvprintw"
"mvscanw")
(#set! injection.language "printf"))
((call_expression
function: (identifier) @_function
arguments: (argument_list
(_)
.
(_)
.
(_)
.
[
(string_literal
(string_content) @injection.content)
(concatenated_string
(string_literal
(string_content) @injection.content))
]))
(#any-of? @_function "mvwprintw" "mvwscanw")
(#set! injection.language "printf"))
; TODO: add when asm is added
; (gnu_asm_expression assembly_code: (string_literal) @injection.content
; (#set! injection.language "asm"))
; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @injection.content)
; (#set! injection.language "asm"))
+70
View File
@@ -0,0 +1,70 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Functions definitions
(function_declarator
declarator: (identifier) @local.definition.function)
(preproc_function_def
name: (identifier) @local.definition.macro) @local.scope
(preproc_def
name: (identifier) @local.definition.macro)
(pointer_declarator
declarator: (identifier) @local.definition.var)
(parameter_declaration
declarator: (identifier) @local.definition.parameter)
(init_declarator
declarator: (identifier) @local.definition.var)
(array_declarator
declarator: (identifier) @local.definition.var)
(declaration
declarator: (identifier) @local.definition.var)
(enum_specifier
name: (_) @local.definition.type
(enumerator_list
(enumerator
name: (identifier) @local.definition.var)))
; Type / Struct / Enum
(field_declaration
declarator: (field_identifier) @local.definition.field)
(type_definition
declarator: (type_identifier) @local.definition.type)
(struct_specifier
name: (type_identifier) @local.definition.type)
; goto
(labeled_statement
(statement_identifier) @local.definition)
; References
(identifier) @local.reference
((field_identifier) @local.reference
(#set! reference.kind "field"))
((type_identifier) @local.reference
(#set! reference.kind "type"))
(goto_statement
(statement_identifier) @local.reference)
; Scope
[
(for_statement)
(if_statement)
(while_statement)
(translation_unit)
(function_definition)
(compound_statement) ; a block in curly braces
(struct_specifier)
] @local.scope
+52
View File
@@ -0,0 +1,52 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((tag
(name) @comment.todo @nospell
("(" @punctuation.bracket
(user) @constant
")" @punctuation.bracket)?
":" @punctuation.delimiter)
(#any-of? @comment.todo "TODO" "WIP"))
("text" @comment.todo @nospell
(#any-of? @comment.todo "TODO" "WIP"))
((tag
(name) @comment.note @nospell
("(" @punctuation.bracket
(user) @constant
")" @punctuation.bracket)?
":" @punctuation.delimiter)
(#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST"))
("text" @comment.note @nospell
(#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST"))
((tag
(name) @comment.warning @nospell
("(" @punctuation.bracket
(user) @constant
")" @punctuation.bracket)?
":" @punctuation.delimiter)
(#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX"))
("text" @comment.warning @nospell
(#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX"))
((tag
(name) @comment.error @nospell
("(" @punctuation.bracket
(user) @constant
")" @punctuation.bracket)?
":" @punctuation.delimiter)
(#any-of? @comment.error "FIXME" "BUG" "ERROR"))
("text" @comment.error @nospell
(#any-of? @comment.error "FIXME" "BUG" "ERROR"))
; Issue number (#123)
("text" @number
(#lua-match? @number "^#[0-9]+$"))
(uri) @string.special.url @nospell
+16
View File
@@ -0,0 +1,16 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: c
[
(for_range_loop)
(class_specifier)
(field_declaration
type: (enum_specifier)
default_value: (initializer_list))
(template_declaration)
(namespace_definition)
(try_statement)
(catch_clause)
(lambda_expression)
] @fold
+275
View File
@@ -0,0 +1,275 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: c
((identifier) @variable.member
(#lua-match? @variable.member "^m_.*$"))
(parameter_declaration
declarator: (reference_declarator) @variable.parameter)
; function(Foo ...foo)
(variadic_parameter_declaration
declarator: (variadic_declarator
(_) @variable.parameter))
; int foo = 0
(optional_parameter_declaration
declarator: (_) @variable.parameter)
;(field_expression) @variable.parameter ;; How to highlight this?
((field_expression
(field_identifier) @function.method) @_parent
(#has-parent? @_parent template_method function_declarator))
(field_declaration
(field_identifier) @variable.member)
(field_initializer
(field_identifier) @property)
(function_declarator
declarator: (field_identifier) @function.method)
(concept_definition
name: (identifier) @type.definition)
(alias_declaration
name: (type_identifier) @type.definition)
(auto) @type.builtin
(namespace_identifier) @module
((namespace_identifier) @type
(#lua-match? @type "^[%u]"))
(case_statement
value: (qualified_identifier
(identifier) @constant))
(using_declaration
.
"using"
.
"namespace"
.
[
(qualified_identifier)
(identifier)
] @module)
(destructor_name
(identifier) @function.method)
; functions
(function_declarator
(qualified_identifier
(identifier) @function))
(function_declarator
(qualified_identifier
(qualified_identifier
(identifier) @function)))
(function_declarator
(qualified_identifier
(qualified_identifier
(qualified_identifier
(identifier) @function))))
((qualified_identifier
(qualified_identifier
(qualified_identifier
(qualified_identifier
(identifier) @function)))) @_parent
(#has-ancestor? @_parent function_declarator))
(function_declarator
(template_function
(identifier) @function))
(operator_name) @function
"operator" @function
"static_assert" @function.builtin
(call_expression
(qualified_identifier
(identifier) @function.call))
(call_expression
(qualified_identifier
(qualified_identifier
(identifier) @function.call)))
(call_expression
(qualified_identifier
(qualified_identifier
(qualified_identifier
(identifier) @function.call))))
((qualified_identifier
(qualified_identifier
(qualified_identifier
(qualified_identifier
(identifier) @function.call)))) @_parent
(#has-ancestor? @_parent call_expression))
(call_expression
(template_function
(identifier) @function.call))
(call_expression
(qualified_identifier
(template_function
(identifier) @function.call)))
(call_expression
(qualified_identifier
(qualified_identifier
(template_function
(identifier) @function.call))))
(call_expression
(qualified_identifier
(qualified_identifier
(qualified_identifier
(template_function
(identifier) @function.call)))))
((qualified_identifier
(qualified_identifier
(qualified_identifier
(qualified_identifier
(template_function
(identifier) @function.call))))) @_parent
(#has-ancestor? @_parent call_expression))
; methods
(function_declarator
(template_method
(field_identifier) @function.method))
(call_expression
(field_expression
(field_identifier) @function.method.call))
(call_expression
(field_expression
(template_method
(field_identifier) @function.method.call)))
; constructors
((function_declarator
(qualified_identifier
(identifier) @constructor))
(#lua-match? @constructor "^%u"))
((call_expression
function: (identifier) @constructor)
(#lua-match? @constructor "^%u"))
((call_expression
function: (qualified_identifier
name: (identifier) @constructor))
(#lua-match? @constructor "^%u"))
((call_expression
function: (field_expression
field: (field_identifier) @constructor))
(#lua-match? @constructor "^%u"))
; constructing a type in an initializer list: Constructor (): **SuperType (1)**
((field_initializer
(field_identifier) @constructor
(argument_list))
(#lua-match? @constructor "^%u"))
; Constants
(this) @variable.builtin
(null
"nullptr" @constant.builtin)
(true) @boolean
(false) @boolean
; Literals
(raw_string_literal) @string
; Keywords
[
"try"
"catch"
"noexcept"
"throw"
] @keyword.exception
[
"decltype"
"explicit"
"friend"
"override"
"using"
"requires"
"constexpr"
] @keyword
[
"class"
"namespace"
"template"
"typename"
"concept"
] @keyword.type
[
"co_await"
"co_yield"
"co_return"
] @keyword.coroutine
[
"public"
"private"
"protected"
"final"
"virtual"
] @keyword.modifier
[
"new"
"delete"
"xor"
"bitand"
"bitor"
"compl"
"not"
"xor_eq"
"and_eq"
"or_eq"
"not_eq"
"and"
"or"
] @keyword.operator
"<=>" @operator
"::" @punctuation.delimiter
(template_argument_list
[
"<"
">"
] @punctuation.bracket)
(template_parameter_list
[
"<"
">"
] @punctuation.bracket)
(literal_suffix) @operator
+10
View File
@@ -0,0 +1,10 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: c
(condition_clause) @indent.begin
((field_initializer_list) @indent.begin
(#set! indent.start_at_same_line 1))
(access_specifier) @indent.branch
+11
View File
@@ -0,0 +1,11 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: c
((comment) @injection.content
(#lua-match? @injection.content "/[*/][!*/]<?[^a-zA-Z]")
(#set! injection.language "doxygen"))
(raw_string_literal
delimiter: (raw_string_delimiter) @injection.language
(raw_string_content) @injection.content)
+80
View File
@@ -0,0 +1,80 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: c
; Parameters
(variadic_parameter_declaration
declarator: (variadic_declarator
(identifier) @local.definition.parameter))
(optional_parameter_declaration
declarator: (identifier) @local.definition.parameter)
; Class / struct definitions
(class_specifier) @local.scope
(reference_declarator
(identifier) @local.definition.var)
(variadic_declarator
(identifier) @local.definition.var)
(struct_specifier
name: (qualified_identifier
name: (type_identifier) @local.definition.type))
(class_specifier
name: (type_identifier) @local.definition.type)
(concept_definition
name: (identifier) @local.definition.type)
(class_specifier
name: (qualified_identifier
name: (type_identifier) @local.definition.type))
(alias_declaration
name: (type_identifier) @local.definition.type)
;template <typename T>
(type_parameter_declaration
(type_identifier) @local.definition.type)
(template_declaration) @local.scope
; Namespaces
(namespace_definition
name: (namespace_identifier) @local.definition.namespace
body: (_) @local.scope)
(namespace_definition
name: (nested_namespace_specifier) @local.definition.namespace
body: (_) @local.scope)
((namespace_identifier) @local.reference
(#set! reference.kind "namespace"))
; Function definitions
(template_function
name: (identifier) @local.definition.function) @local.scope
(template_method
name: (field_identifier) @local.definition.method) @local.scope
(function_declarator
declarator: (qualified_identifier
name: (identifier) @local.definition.function)) @local.scope
(field_declaration
declarator: (function_declarator
(field_identifier) @local.definition.method))
(lambda_expression) @local.scope
; Control structures
(try_statement
body: (_) @local.scope)
(catch_clause) @local.scope
(requires_expression) @local.scope
+13
View File
@@ -0,0 +1,13 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
; top-level block statements from https://github.com/tree-sitter/tree-sitter-css/blob/master/grammar.js
; note: (block) is not used due to unideal behavior when node before block node spans multiple lines
(rule_set)
(at_rule)
(supports_statement)
(media_statement)
(keyframe_block)
(import_statement)+
] @fold
+112
View File
@@ -0,0 +1,112 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
"@media"
"@charset"
"@namespace"
"@supports"
"@keyframes"
(at_keyword)
] @keyword.directive
"@import" @keyword.import
[
(to)
(from)
] @keyword
(comment) @comment @spell
(tag_name) @tag
(class_name) @type
(id_name) @constant
[
(property_name)
(feature_name)
] @property
(function_name) @function
[
"~"
">"
"+"
"-"
"*"
"/"
"="
"^="
"|="
"~="
"$="
"*="
] @operator
[
"and"
"or"
"not"
"only"
] @keyword.operator
(important) @keyword.modifier
[
(nesting_selector)
(universal_selector)
] @character.special
(attribute_selector
(plain_value) @string)
(pseudo_element_selector
"::"
(tag_name) @attribute)
(pseudo_class_selector
(class_name) @attribute)
(attribute_name) @tag.attribute
(namespace_name) @module
(keyframes_name) @variable
((property_name) @variable
(#lua-match? @variable "^[-][-]"))
((plain_value) @variable
(#lua-match? @variable "^[-][-]"))
[
(string_value)
(color_value)
(unit)
] @string
(integer_value) @number
(float_value) @number.float
[
"#"
","
"."
":"
"::"
";"
] @punctuation.delimiter
[
"{"
")"
"("
"}"
"["
"]"
] @punctuation.bracket
+14
View File
@@ -0,0 +1,14 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(block)
(declaration)
] @indent.begin
(block
"}" @indent.branch)
"}" @indent.dedent
(comment) @indent.ignore
+5
View File
@@ -0,0 +1,5 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((comment) @injection.content
(#set! injection.language "comment"))
+7
View File
@@ -0,0 +1,7 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(conditionalSect)
(Comment)
] @fold
+151
View File
@@ -0,0 +1,151 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Text declaration
(TextDecl
"xml" @keyword.directive)
(TextDecl
[
"version"
"encoding"
] @tag.attribute)
(TextDecl
(EncName) @string.special)
(TextDecl
(VersionNum) @number)
; Processing instructions
(PI) @keyword.directive
; Element declaration
(elementdecl
"ELEMENT" @keyword.directive.define
(Name) @tag)
(contentspec
(_
(Name) @tag.attribute))
"#PCDATA" @type.builtin
[
"EMPTY"
"ANY"
] @keyword.modifier
[
"*"
"?"
"+"
] @character.special
; Entity declaration
(GEDecl
"ENTITY" @keyword.directive.define
(Name) @constant)
(GEDecl
(EntityValue) @string)
(NDataDecl
"NDATA" @keyword
(Name) @label)
; Parsed entity declaration
(PEDecl
"ENTITY" @keyword.directive.define
"%" @operator
(Name) @function.macro)
(PEDecl
(EntityValue) @string)
; Notation declaration
(NotationDecl
"NOTATION" @keyword.directive
(Name) @label)
; Attlist declaration
(AttlistDecl
"ATTLIST" @keyword.directive.define
(Name) @tag)
(AttDef
(Name) @tag.attribute)
(AttDef
(Enumeration
(Nmtoken) @string))
[
(StringType)
(TokenizedType)
] @type.builtin
(NotationType
"NOTATION" @type.builtin)
[
"#REQUIRED"
"#IMPLIED"
"#FIXED"
] @attribute
; Entities
(EntityRef) @constant
((EntityRef) @constant.builtin
(#any-of? @constant.builtin "&amp;" "&lt;" "&gt;" "&quot;" "&apos;"))
(CharRef) @character
(PEReference) @function.macro
; External references
[
"PUBLIC"
"SYSTEM"
] @keyword
(PubidLiteral) @string.special
(SystemLiteral
(URI) @string.special.url)
; Delimiters & punctuation
[
"<?"
"?>"
"<!"
">"
"<!["
"]]>"
] @tag.delimiter
[
"("
")"
"["
] @punctuation.bracket
[
"\""
"'"
] @punctuation.delimiter
[
","
"|"
"="
] @operator
; Misc
[
"INCLUDE"
"IGNORE"
] @keyword.import
(Comment) @comment @spell
+5
View File
@@ -0,0 +1,5 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((Comment) @injection.content
(#set! injection.language "comment"))
+14
View File
@@ -0,0 +1,14 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(elementdecl
(Name) @local.definition.type)
(elementdecl
(contentspec
(children
(Name) @local.reference)))
(AttlistDecl
.
(Name) @local.reference)
+27
View File
@@ -0,0 +1,27 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(arguments)
(for_in_statement)
(for_statement)
(while_statement)
(arrow_function)
(function_expression)
(function_declaration)
(class_declaration)
(method_definition)
(do_statement)
(with_statement)
(switch_statement)
(switch_case)
(switch_default)
(import_statement)+
(if_statement)
(try_statement)
(catch_clause)
(array)
(object)
(generator_function)
(generator_function_declaration)
] @fold
+395
View File
@@ -0,0 +1,395 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Types
; Javascript
; Variables
;-----------
(identifier) @variable
; Properties
;-----------
(property_identifier) @variable.member
(shorthand_property_identifier) @variable.member
(private_property_identifier) @variable.member
(object_pattern
(shorthand_property_identifier_pattern) @variable)
(object_pattern
(object_assignment_pattern
(shorthand_property_identifier_pattern) @variable))
; Special identifiers
;--------------------
((identifier) @type
(#lua-match? @type "^[A-Z]"))
((identifier) @constant
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
((shorthand_property_identifier) @constant
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
((identifier) @variable.builtin
(#any-of? @variable.builtin "arguments" "module" "console" "window" "document"))
((identifier) @type.builtin
(#any-of? @type.builtin
"Object" "Function" "Boolean" "Symbol" "Number" "Math" "Date" "String" "RegExp" "Map" "Set"
"WeakMap" "WeakSet" "Promise" "Array" "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array"
"Uint16Array" "Int32Array" "Uint32Array" "Float32Array" "Float64Array" "ArrayBuffer" "DataView"
"Error" "EvalError" "InternalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError"
"URIError"))
(statement_identifier) @label
; Function and method definitions
;--------------------------------
(function_expression
name: (identifier) @function)
(function_declaration
name: (identifier) @function)
(generator_function
name: (identifier) @function)
(generator_function_declaration
name: (identifier) @function)
(method_definition
name: [
(property_identifier)
(private_property_identifier)
] @function.method)
(method_definition
name: (property_identifier) @constructor
(#eq? @constructor "constructor"))
(pair
key: (property_identifier) @function.method
value: (function_expression))
(pair
key: (property_identifier) @function.method
value: (arrow_function))
(assignment_expression
left: (member_expression
property: (property_identifier) @function.method)
right: (arrow_function))
(assignment_expression
left: (member_expression
property: (property_identifier) @function.method)
right: (function_expression))
(variable_declarator
name: (identifier) @function
value: (arrow_function))
(variable_declarator
name: (identifier) @function
value: (function_expression))
(assignment_expression
left: (identifier) @function
right: (arrow_function))
(assignment_expression
left: (identifier) @function
right: (function_expression))
; Function and method calls
;--------------------------
(call_expression
function: (identifier) @function.call)
(call_expression
function: (member_expression
property: [
(property_identifier)
(private_property_identifier)
] @function.method.call))
(call_expression
function: (await_expression
(identifier) @function.call))
(call_expression
function: (await_expression
(member_expression
property: [
(property_identifier)
(private_property_identifier)
] @function.method.call)))
; Builtins
;---------
((identifier) @module.builtin
(#eq? @module.builtin "Intl"))
((identifier) @function.builtin
(#any-of? @function.builtin
"eval" "isFinite" "isNaN" "parseFloat" "parseInt" "decodeURI" "decodeURIComponent" "encodeURI"
"encodeURIComponent" "require"))
; Constructor
;------------
(new_expression
constructor: (identifier) @constructor)
; Decorators
;----------
(decorator
"@" @attribute
(identifier) @attribute)
(decorator
"@" @attribute
(call_expression
(identifier) @attribute))
(decorator
"@" @attribute
(member_expression
(property_identifier) @attribute))
(decorator
"@" @attribute
(call_expression
(member_expression
(property_identifier) @attribute)))
; Literals
;---------
[
(this)
(super)
] @variable.builtin
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
[
(true)
(false)
] @boolean
[
(null)
(undefined)
] @constant.builtin
[
(comment)
(html_comment)
] @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
(hash_bang_line) @keyword.directive
((string_fragment) @keyword.directive
(#eq? @keyword.directive "use strict"))
(string) @string
(template_string) @string
(escape_sequence) @string.escape
(regex_pattern) @string.regexp
(regex_flags) @character.special
(regex
"/" @punctuation.bracket) ; Regex delimiters
(number) @number
((identifier) @number
(#any-of? @number "NaN" "Infinity"))
; Punctuation
;------------
[
";"
"."
","
":"
] @punctuation.delimiter
[
"--"
"-"
"-="
"&&"
"+"
"++"
"+="
"&="
"/="
"**="
"<<="
"<"
"<="
"<<"
"="
"=="
"==="
"!="
"!=="
"=>"
">"
">="
">>"
"||"
"%"
"%="
"*"
"**"
">>>"
"&"
"|"
"^"
"??"
"*="
">>="
">>>="
"^="
"|="
"&&="
"||="
"??="
"..."
] @operator
(binary_expression
"/" @operator)
(ternary_expression
[
"?"
":"
] @keyword.conditional.ternary)
(unary_expression
[
"!"
"~"
"-"
"+"
] @operator)
(unary_expression
[
"delete"
"void"
] @keyword.operator)
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(template_substitution
[
"${"
"}"
] @punctuation.special) @none
; Imports
;----------
(namespace_import
"*" @character.special
(identifier) @module)
(namespace_export
"*" @character.special
(identifier) @module)
(export_statement
"*" @character.special)
; Keywords
;----------
[
"if"
"else"
"switch"
"case"
] @keyword.conditional
[
"import"
"from"
"as"
"export"
] @keyword.import
[
"for"
"of"
"do"
"while"
"continue"
] @keyword.repeat
[
"break"
"const"
"debugger"
"extends"
"get"
"let"
"set"
"static"
"target"
"var"
"with"
] @keyword
"class" @keyword.type
[
"async"
"await"
] @keyword.coroutine
[
"return"
"yield"
] @keyword.return
"function" @keyword.function
[
"new"
"delete"
"in"
"instanceof"
"typeof"
] @keyword.operator
[
"throw"
"try"
"catch"
"finally"
] @keyword.exception
(export_statement
"default" @keyword)
(switch_default
"default" @keyword.conditional)
+85
View File
@@ -0,0 +1,85 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(arguments)
(array)
(binary_expression)
(class_body)
(export_clause)
(formal_parameters)
(named_imports)
(object)
(object_pattern)
(parenthesized_expression)
(return_statement)
(statement_block)
(switch_case)
(switch_default)
(switch_statement)
(template_substitution)
(ternary_expression)
] @indent.begin
(arguments
(call_expression) @indent.begin)
(binary_expression
(call_expression) @indent.begin)
(expression_statement
(call_expression) @indent.begin)
(arrow_function
body: (_) @_body
(#not-kind-eq? @_body "statement_block")) @indent.begin
(assignment_expression
right: (_) @_right
(#not-kind-eq? @_right "arrow_function")) @indent.begin
(variable_declarator
value: (_) @_value
(#not-kind-eq? @_value "arrow_function" "call_expression")) @indent.begin
(arguments
")" @indent.end)
(object
"}" @indent.end)
(statement_block
"}" @indent.end)
[
(arguments
(object))
")"
"}"
"]"
] @indent.branch
(statement_block
"{" @indent.branch)
((parenthesized_expression
"("
(_)
")" @indent.end) @_outer
(#not-has-parent? @_outer if_statement))
[
"}"
"]"
] @indent.end
(template_string) @indent.ignore
[
(comment)
(ERROR)
] @indent.auto
(if_statement
consequence: (_) @indent.dedent
(#not-kind-eq? @indent.dedent statement_block)) @indent.begin
+222
View File
@@ -0,0 +1,222 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(((comment) @_jsdoc_comment
(#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content
(#set! injection.language "jsdoc"))
((comment) @injection.content
(#set! injection.language "comment"))
; html(`...`), html`...`, sql(`...`), etc.
(call_expression
function: (identifier) @injection.language
arguments: [
(arguments
(template_string) @injection.content)
(template_string) @injection.content
]
(#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
; Languages excluded from auto-injection due to special rules
; - svg uses the html parser
; - css uses the styled parser
(#not-any-of? @injection.language "svg" "css"))
; svg`...` or svg(`...`)
(call_expression
function: (identifier) @_name
(#eq? @_name "svg")
arguments: [
(arguments
(template_string) @injection.content)
(template_string) @injection.content
]
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "html"))
; Vercel PostgreSQL
; foo.sql`...` or foo.sql(`...`)
(call_expression
function: (member_expression
property: (property_identifier) @injection.language)
arguments: [
(arguments
(template_string) @injection.content)
(template_string) @injection.content
]
(#eq? @injection.language "sql")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children))
; Sanity CMS GROQ query
; defineQuery(`...`)
(call_expression
function: (identifier) @_name
(#eq? @_name "defineQuery")
arguments: (arguments
(template_string) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "groq"))
; gql`...` or gql(`...`)
(call_expression
function: (identifier) @_name
(#eq? @_name "gql")
arguments: [
(arguments
(template_string) @injection.content)
(template_string) @injection.content
]
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "graphql"))
(call_expression
function: (identifier) @_name
(#eq? @_name "hbs")
arguments: (template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "glimmer"))
; css`<css>`, keyframes`<css>`
(call_expression
function: (identifier) @_name
(#any-of? @_name "css" "keyframes")
arguments: (template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled"))
; styled.div`<css>`
(call_expression
function: (member_expression
object: (identifier) @_name
(#eq? @_name "styled"))
arguments: ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled")))
; styled(Component)`<css>`
(call_expression
function: (call_expression
function: (identifier) @_name
(#eq? @_name "styled"))
arguments: ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled")))
; styled.div.attrs({ prop: "foo" })`<css>`
(call_expression
function: (call_expression
function: (member_expression
object: (member_expression
object: (identifier) @_name
(#eq? @_name "styled"))))
arguments: ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled")))
; styled(Component).attrs({ prop: "foo" })`<css>`
(call_expression
function: (call_expression
function: (member_expression
object: (call_expression
function: (identifier) @_name
(#eq? @_name "styled"))))
arguments: ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled")))
((regex_pattern) @injection.content
(#set! injection.language "regex"))
; ((comment) @_gql_comment
; (#eq? @_gql_comment "/* GraphQL */")
; (template_string) @injection.content
; (#set! injection.language "graphql"))
((template_string) @injection.content
(#lua-match? @injection.content "^`#graphql")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "graphql"))
; el.innerHTML = `<html>`
(assignment_expression
left: (member_expression
property: (property_identifier) @_prop
(#any-of? @_prop "outerHTML" "innerHTML"))
right: (template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "html"))
; el.innerHTML = '<html>'
(assignment_expression
left: (member_expression
property: (property_identifier) @_prop
(#any-of? @_prop "outerHTML" "innerHTML"))
right: (string
(string_fragment) @injection.content)
(#set! injection.language "html"))
;---- Angular injections -----
; @Component({
; template: `<html>`
; })
(decorator
(call_expression
function: ((identifier) @_name
(#eq? @_name "Component"))
arguments: (arguments
(object
(pair
key: ((property_identifier) @_prop
(#eq? @_prop "template"))
value: ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "angular")))))))
; @Component({
; styles: [`<css>`]
; })
(decorator
(call_expression
function: ((identifier) @_name
(#eq? @_name "Component"))
arguments: (arguments
(object
(pair
key: ((property_identifier) @_prop
(#eq? @_prop "styles"))
value: (array
((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "css"))))))))
; @Component({
; styles: `<css>`
; })
(decorator
(call_expression
function: ((identifier) @_name
(#eq? @_name "Component"))
arguments: (arguments
(object
(pair
key: ((property_identifier) @_prop
(#eq? @_prop "styles"))
value: ((template_string) @injection.content
(#set! injection.include-children)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "css")))))))
+54
View File
@@ -0,0 +1,54 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Scopes
;-------
(statement_block) @local.scope
(function_expression) @local.scope
(arrow_function) @local.scope
(function_declaration) @local.scope
(method_definition) @local.scope
(for_statement) @local.scope
(for_in_statement) @local.scope
(catch_clause) @local.scope
; Definitions
;------------
(variable_declarator
name: (identifier) @local.definition.var)
(variable_declarator
name: (object_pattern
(shorthand_property_identifier_pattern) @local.definition.var))
(variable_declarator
(object_pattern
(pair_pattern
(identifier) @local.definition.var)))
(import_specifier
(identifier) @local.definition.import)
(namespace_import
(identifier) @local.definition.import)
(function_declaration
(identifier) @local.definition.function
(#set! definition.var.scope parent))
(method_definition
(property_identifier) @local.definition.function
(#set! definition.var.scope parent))
; References
;------------
(identifier) @local.reference
(shorthand_property_identifier) @local.reference
+52
View File
@@ -0,0 +1,52 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(comment) @comment
(generated_comment) @comment
(title) @markup.heading
; (text) @none
(branch) @markup.link
(change) @keyword
(filepath) @string.special.path
(arrow) @punctuation.delimiter
(subject) @markup.heading @spell
(subject
(subject_prefix) @function @nospell)
(prefix
(type) @keyword @nospell)
(prefix
(scope) @variable.parameter @nospell)
(prefix
[
"("
")"
":"
] @punctuation.delimiter)
(prefix
"!" @punctuation.special)
(message) @spell
(trailer
(token) @label)
; (trailer (value) @none)
(breaking_change
(token) @comment.error)
(breaking_change
(value) @none @spell)
(scissor) @comment
+8
View File
@@ -0,0 +1,8 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((diff) @injection.content
(#set! injection.language "diff"))
((rebase_command) @injection.content
(#set! injection.language "git_rebase"))
+22
View File
@@ -0,0 +1,22 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(const_declaration)
(expression_switch_statement)
(expression_case)
(default_case)
(type_switch_statement)
(type_case)
(for_statement)
(func_literal)
(function_declaration)
(if_statement)
(import_declaration)
(method_declaration)
(type_declaration)
(var_declaration)
(composite_literal)
(literal_element)
(block)
] @fold
+249
View File
@@ -0,0 +1,249 @@
; Forked from tree-sitter-go
; Copyright (c) 2014 Max Brunsfeld (The MIT License)
;
; Identifiers
(type_identifier) @type
(type_spec
name: (type_identifier) @type.definition)
(field_identifier) @property
(identifier) @variable
(package_identifier) @module
(parameter_declaration
(identifier) @variable.parameter)
(variadic_parameter_declaration
(identifier) @variable.parameter)
(label_name) @label
(const_spec
name: (identifier) @constant)
; Function calls
(call_expression
function: (identifier) @function.call)
(call_expression
function: (selector_expression
field: (field_identifier) @function.method.call))
; Function definitions
(function_declaration
name: (identifier) @function)
(method_declaration
name: (field_identifier) @function.method)
(method_elem
name: (field_identifier) @function.method)
; Constructors
((call_expression
(identifier) @constructor)
(#lua-match? @constructor "^[nN]ew.+$"))
((call_expression
(identifier) @constructor)
(#lua-match? @constructor "^[mM]ake.+$"))
; Operators
[
"--"
"-"
"-="
":="
"!"
"!="
"..."
"*"
"*="
"/"
"/="
"&"
"&&"
"&="
"&^"
"&^="
"%"
"%="
"^"
"^="
"+"
"++"
"+="
"<-"
"<"
"<<"
"<<="
"<="
"="
"=="
">"
">="
">>"
">>="
"|"
"|="
"||"
"~"
] @operator
; Keywords
[
"break"
"const"
"continue"
"default"
"defer"
"goto"
"range"
"select"
"var"
"fallthrough"
] @keyword
[
"type"
"struct"
"interface"
] @keyword.type
"func" @keyword.function
"return" @keyword.return
"go" @keyword.coroutine
"for" @keyword.repeat
[
"import"
"package"
] @keyword.import
[
"else"
"case"
"switch"
"if"
] @keyword.conditional
; Builtin types
[
"chan"
"map"
] @type.builtin
((type_identifier) @type.builtin
(#any-of? @type.builtin
"any" "bool" "byte" "comparable" "complex128" "complex64" "error" "float32" "float64" "int"
"int16" "int32" "int64" "int8" "rune" "string" "uint" "uint16" "uint32" "uint64" "uint8"
"uintptr"))
; Builtin functions
((identifier) @function.builtin
(#any-of? @function.builtin
"append" "cap" "clear" "close" "complex" "copy" "delete" "imag" "len" "make" "max" "min" "new"
"panic" "print" "println" "real" "recover"))
; Delimiters
[
"."
","
":"
";"
] @punctuation.delimiter
[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
; Literals
(interpreted_string_literal) @string
(raw_string_literal) @string
(rune_literal) @character
(escape_sequence) @string.escape
(int_literal) @number
(float_literal) @number.float
(imaginary_literal) @number
[
(true)
(false)
] @boolean
[
(nil)
(iota)
] @constant.builtin
(keyed_element
.
(literal_element
(identifier) @variable.member))
(field_declaration
name: (field_identifier) @variable.member)
; Comments
(comment) @comment @spell
; Doc Comments
(source_file
.
(comment)+ @comment.documentation)
(source_file
(comment)+ @comment.documentation
.
(const_declaration))
(source_file
(comment)+ @comment.documentation
.
(function_declaration))
(source_file
(comment)+ @comment.documentation
.
(type_declaration))
(source_file
(comment)+ @comment.documentation
.
(var_declaration))
; Spell
((interpreted_string_literal) @spell
(#not-has-parent? @spell import_spec))
; Regex
(call_expression
(selector_expression) @_function
(#any-of? @_function
"regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX"
"regexp.MustCompile" "regexp.MustCompilePOSIX")
(argument_list
.
[
(raw_string_literal
(raw_string_literal_content) @string.regexp)
(interpreted_string_literal
(interpreted_string_literal_content) @string.regexp)
]))
+51
View File
@@ -0,0 +1,51 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(import_declaration)
(const_declaration)
(var_declaration)
(type_declaration)
(func_literal)
(literal_value)
(expression_case)
(communication_case)
(type_case)
(default_case)
(block)
(call_expression)
(parameter_list)
(field_declaration_list)
(interface_type)
] @indent.begin
(literal_value
"}" @indent.branch)
(block
"}" @indent.branch)
(field_declaration_list
"}" @indent.branch)
(interface_type
"}" @indent.branch)
(const_declaration
")" @indent.branch)
(import_spec_list
")" @indent.branch)
(var_spec_list
")" @indent.branch)
[
"}"
")"
] @indent.end
(parameter_list
")" @indent.branch)
(comment) @indent.ignore
+45
View File
@@ -0,0 +1,45 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((comment) @injection.content
(#set! injection.language "comment"))
(call_expression
(selector_expression) @_function
(#any-of? @_function
"regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX"
"regexp.MustCompile" "regexp.MustCompilePOSIX")
(argument_list
.
[
(raw_string_literal
(raw_string_literal_content) @injection.content)
(interpreted_string_literal
(interpreted_string_literal_content) @injection.content)
]
(#set! injection.language "regex")))
((comment) @injection.content
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
(#set! injection.language "re2c"))
((call_expression
function: (selector_expression
field: (field_identifier) @_method)
arguments: (argument_list
.
(interpreted_string_literal
(interpreted_string_literal_content) @injection.content)))
(#any-of? @_method "Printf" "Sprintf" "Fatalf" "Scanf" "Errorf" "Skipf" "Logf")
(#set! injection.language "printf"))
((call_expression
function: (selector_expression
field: (field_identifier) @_method)
arguments: (argument_list
(_)
.
(interpreted_string_literal
(interpreted_string_literal_content) @injection.content)))
(#any-of? @_method "Fprintf" "Fscanf" "Appendf" "Sscanf")
(#set! injection.language "printf"))
+91
View File
@@ -0,0 +1,91 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((function_declaration
name: (identifier) @local.definition.function) ; @function
)
((method_declaration
name: (field_identifier) @local.definition.method) ; @function.method
)
(short_var_declaration
left: (expression_list
(identifier) @local.definition.var))
(var_spec
name: (identifier) @local.definition.var)
(parameter_declaration
(identifier) @local.definition.var)
(variadic_parameter_declaration
(identifier) @local.definition.var)
(for_statement
(range_clause
left: (expression_list
(identifier) @local.definition.var)))
(const_declaration
(const_spec
name: (identifier) @local.definition.var))
(type_declaration
(type_spec
name: (type_identifier) @local.definition.type))
; reference
(identifier) @local.reference
(type_identifier) @local.reference
(field_identifier) @local.reference
((package_identifier) @local.reference
(#set! reference.kind "namespace"))
(package_clause
(package_identifier) @local.definition.namespace)
(import_spec_list
(import_spec
name: (package_identifier) @local.definition.namespace))
; Call references
((call_expression
function: (identifier) @local.reference)
(#set! reference.kind "call"))
((call_expression
function: (selector_expression
field: (field_identifier) @local.reference))
(#set! reference.kind "call"))
((call_expression
function: (parenthesized_expression
(identifier) @local.reference))
(#set! reference.kind "call"))
((call_expression
function: (parenthesized_expression
(selector_expression
field: (field_identifier) @local.reference)))
(#set! reference.kind "call"))
; Scopes
(func_literal) @local.scope
(source_file) @local.scope
(function_declaration) @local.scope
(if_statement) @local.scope
(block) @local.scope
(expression_switch_statement) @local.scope
(for_statement) @local.scope
(method_declaration) @local.scope
+11
View File
@@ -0,0 +1,11 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(if_action)
(range_action)
(block_action)
(with_action)
(define_action)
(comment)
] @fold
+143
View File
@@ -0,0 +1,143 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Priorities of the highlight queries are raised, so that they overrule the
; often surrounding and overlapping highlights from the non-gotmpl injections.
;
; Identifiers
([
(field)
(field_identifier)
] @variable.member
(#set! priority 110))
((variable) @variable
(#set! priority 110))
; Function calls
(function_call
function: (identifier) @function
(#set! priority 110))
(method_call
method: (selector_expression
field: (field_identifier) @function
(#set! priority 110)))
; Builtin functions
(function_call
function: (identifier) @function.builtin
(#set! priority 110)
(#any-of? @function.builtin
"and" "call" "html" "index" "slice" "js" "len" "not" "or" "print" "printf" "println" "urlquery"
"eq" "ne" "lt" "ge" "gt" "ge"))
; Operators
([
"|"
"="
":="
] @operator
(#set! priority 110))
; Delimiters
([
"."
","
] @punctuation.delimiter
(#set! priority 110))
([
"{{"
"}}"
"{{-"
"-}}"
")"
"("
] @punctuation.bracket
(#set! priority 110))
; Actions
(if_action
[
"if"
"else"
"end"
] @keyword.conditional
(#set! priority 110))
(range_action
[
"range"
"else"
"end"
] @keyword.repeat
(#set! priority 110))
(template_action
"template" @function.builtin
(#set! priority 110))
(block_action
[
"block"
"end"
] @keyword.directive
(#set! priority 110))
(define_action
[
"define"
"end"
] @keyword.directive.define
(#set! priority 110))
(with_action
[
"with"
"else"
"end"
] @keyword.conditional
(#set! priority 110))
(continue_action
"continue" @keyword.repeat
(#set! priority 110))
(break_action
"break" @keyword.repeat
(#set! priority 110))
; Literals
([
(interpreted_string_literal)
(raw_string_literal)
] @string
(#set! priority 110))
((rune_literal) @string.special.symbol
(#set! priority 110))
((escape_sequence) @string.escape
(#set! priority 110))
([
(int_literal)
(imaginary_literal)
] @number
(#set! priority 110))
((float_literal) @number.float
(#set! priority 110))
([
(true)
(false)
] @boolean
(#set! priority 110))
((nil) @constant.builtin
(#set! priority 110))
((comment) @comment @spell
(#set! priority 110))
+38
View File
@@ -0,0 +1,38 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((comment) @injection.content
(#set! injection.language "comment"))
; {{"put" | printf "%s%s" "out" | printf "%q"}}
(function_call
function: (identifier) @_function
arguments: (argument_list
.
(interpreted_string_literal) @injection.content)
(#eq? @_function "printf")
(#set! injection.language "printf"))
; {{ js "var a = 1 + 1" }}
(function_call
function: (identifier) @_function
arguments: (argument_list
.
(interpreted_string_literal) @injection.content)
(#eq? @_function "js")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "javascript"))
; {{ html "<h1>hello</h1>" }}
(function_call
function: (identifier) @_function
arguments: (argument_list
.
(interpreted_string_literal) @injection.content)
(#eq? @_function "html")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "html"))
((text) @injection.content
(#set! injection.language "html")
(#set! injection.combined))
+15
View File
@@ -0,0 +1,15 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(if_action)
(range_action)
(block_action)
(with_action)
(define_action)
] @local.scope
(variable_definition
variable: (variable) @local.definition.var)
(variable) @local.reference
+8
View File
@@ -0,0 +1,8 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(element)
(style_element)
(script_element)
] @fold
+9
View File
@@ -0,0 +1,9 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: html_tags
(doctype) @constant
"<!" @tag.delimiter
(entity) @character.special
+3
View File
@@ -0,0 +1,3 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: html_tags
+29
View File
@@ -0,0 +1,29 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: html_tags
(element
(start_tag
(tag_name) @_py_script)
(text) @injection.content
(#any-of? @_py_script "py-script" "py-repl")
(#set! injection.language "python"))
(script_element
(start_tag
(attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @_type)))
(raw_text) @injection.content
(#eq? @_attr "type")
; not adding type="py" here as it's handled by html_tags
(#any-of? @_type "pyscript" "py-script")
(#set! injection.language "python"))
(element
(start_tag
(tag_name) @_py_config)
(text) @injection.content
(#eq? @_py_config "py-config")
(#set! injection.language "toml"))
+4
View File
@@ -0,0 +1,4 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(element) @local.scope
+111
View File
@@ -0,0 +1,111 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(tag_name) @tag @nospell
; (erroneous_end_tag_name) @error ; we do not lint syntax errors
(comment) @comment @spell
(attribute_name) @tag.attribute @nospell
(attribute_value) @nospell
((attribute
(quoted_attribute_value) @string)
(#set! priority 99))
(text) @none @spell
((element
(start_tag
(tag_name) @_tag)
(text) @markup.heading)
(#eq? @_tag "title"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.heading.1)
(#eq? @_tag "h1"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.heading.2)
(#eq? @_tag "h2"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.heading.3)
(#eq? @_tag "h3"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.heading.4)
(#eq? @_tag "h4"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.heading.5)
(#eq? @_tag "h5"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.heading.6)
(#eq? @_tag "h6"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.strong)
(#any-of? @_tag "strong" "b"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.italic)
(#any-of? @_tag "em" "i"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.strikethrough)
(#any-of? @_tag "s" "del"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.underline)
(#eq? @_tag "u"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.raw)
(#any-of? @_tag "code" "kbd"))
((element
(start_tag
(tag_name) @_tag)
(text) @markup.link.label)
(#eq? @_tag "a"))
((attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @string.special.url))
(#any-of? @_attr "href" "src")
(#set! @string.special.url url @string.special.url))
[
"<"
">"
"</"
"/>"
] @tag.delimiter
"=" @operator
+40
View File
@@ -0,0 +1,40 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((element
(start_tag
(tag_name) @_not_void_element))
(#not-any-of? @_not_void_element
"area" "base" "basefont" "bgsound" "br" "col" "command" "embed" "frame" "hr" "image" "img"
"input" "isindex" "keygen" "link" "menuitem" "meta" "nextid" "param" "source" "track" "wbr")) @indent.begin
(element
(self_closing_tag)) @indent.begin
((start_tag
(tag_name) @_void_element)
(#any-of? @_void_element
"area" "base" "basefont" "bgsound" "br" "col" "command" "embed" "frame" "hr" "image" "img"
"input" "isindex" "keygen" "link" "menuitem" "meta" "nextid" "param" "source" "track" "wbr")) @indent.begin
; These are the nodes that will be captured when we do `normal o`
; But last element has already been ended, so capturing this
; to mark end of last element
(element
(end_tag
">" @indent.end))
(element
(self_closing_tag
"/>" @indent.end))
; Script/style elements aren't indented, so only branch the end tag of other elements
(element
(end_tag) @indent.branch)
[
">"
"/>"
] @indent.branch
(comment) @indent.ignore
+118
View File
@@ -0,0 +1,118 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((comment) @injection.content
(#set! injection.language "comment"))
; <style>...</style>
; <style blocking> ...</style>
; Add "lang" to predicate check so that vue/svelte can inherit this
; without having this element being captured twice
((style_element
(start_tag) @_no_type_lang
(raw_text) @injection.content)
(#not-lua-match? @_no_type_lang "%slang%s*=")
(#not-lua-match? @_no_type_lang "%stype%s*=")
(#set! injection.language "css"))
((style_element
(start_tag
(attribute
(attribute_name) @_type
(quoted_attribute_value
(attribute_value) @_css)))
(raw_text) @injection.content)
(#eq? @_type "type")
(#eq? @_css "text/css")
(#set! injection.language "css"))
; <script>...</script>
; <script defer>...</script>
((script_element
(start_tag) @_no_type_lang
(raw_text) @injection.content)
(#not-lua-match? @_no_type_lang "%slang%s*=")
(#not-lua-match? @_no_type_lang "%stype%s*=")
(#set! injection.language "javascript"))
; <script type="foo/bar">
(script_element
(start_tag
(attribute
(attribute_name) @_attr
(#eq? @_attr "type")
(quoted_attribute_value
(attribute_value) @injection.language)))
(raw_text) @injection.content
(#gsub! @injection.language "(.+)/(.+)" "%2"))
; <script type="importmap">
((script_element
(start_tag
(attribute
(attribute_name) @_attr
(#eq? @_attr "type")
(quoted_attribute_value
(attribute_value) @_type)))
(raw_text) @injection.content)
(#eq? @_type "importmap")
(#set! injection.language "json"))
; <script type="module">
((script_element
(start_tag
(attribute
(attribute_name) @_attr
(#eq? @_attr "type")
(quoted_attribute_value
(attribute_value) @_type)))
(raw_text) @injection.content)
(#eq? @_type "module")
(#set! injection.language "javascript"))
; <a style="/* css */">
((attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @injection.content))
(#eq? @_attr "style")
(#set! injection.language "css"))
; lit-html style template interpolation
; <a @click=${e => console.log(e)}>
; <a @click="${e => console.log(e)}">
((attribute
(quoted_attribute_value
(attribute_value) @injection.content))
(#lua-match? @injection.content "%${")
(#offset! @injection.content 0 2 0 -1)
(#set! injection.language "javascript"))
((attribute
(attribute_value) @injection.content)
(#lua-match? @injection.content "%${")
(#offset! @injection.content 0 2 0 -2)
(#set! injection.language "javascript"))
; <input pattern="[0-9]"> or <input pattern=[0-9]>
(element
(_
(tag_name) @_tagname
(#eq? @_tagname "input")
(attribute
(attribute_name) @_attr
[
(quoted_attribute_value
(attribute_value) @injection.content)
(attribute_value) @injection.content
]
(#eq? @_attr "pattern"))
(#set! injection.language "regex")))
; <input type="checkbox" onchange="this.closest('form').elements.output.value = this.checked">
(attribute
(attribute_name) @_name
(#lua-match? @_name "^on[a-z]+$")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
+8
View File
@@ -0,0 +1,8 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(pair)
(object)
(array)
] @fold
+43
View File
@@ -0,0 +1,43 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(true)
(false)
] @boolean
(null) @constant.builtin
(number) @number
(pair
key: (string) @property)
(pair
value: (string) @string)
(array
(string) @string)
[
","
":"
] @punctuation.delimiter
[
"["
"]"
"{"
"}"
] @punctuation.bracket
("\"" @conceal
(#set! conceal ""))
(escape_sequence) @string.escape
((escape_sequence) @conceal
(#eq? @conceal "\\\"")
(#set! conceal "\""))
(comment) @comment @spell
+14
View File
@@ -0,0 +1,14 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(object)
(array)
] @indent.begin
[
"}"
"]"
] @indent.branch
(comment) @indent.ignore
+5
View File
@@ -0,0 +1,5 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((comment) @injection.content
(#set! injection.language "comment"))
+7
View File
@@ -0,0 +1,7 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(object)
(array)
] @local.scope
+4
View File
@@ -0,0 +1,4 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(jsx_element) @fold
+160
View File
@@ -0,0 +1,160 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(jsx_element
open_tag: (jsx_opening_element
[
"<"
">"
] @tag.delimiter))
(jsx_element
close_tag: (jsx_closing_element
[
"</"
">"
] @tag.delimiter))
(jsx_self_closing_element
[
"<"
"/>"
] @tag.delimiter)
(jsx_attribute
(property_identifier) @tag.attribute)
(jsx_opening_element
name: (identifier) @tag.builtin)
(jsx_closing_element
name: (identifier) @tag.builtin)
(jsx_self_closing_element
name: (identifier) @tag.builtin)
(jsx_opening_element
((identifier) @tag
(#lua-match? @tag "^[A-Z]")))
; Handle the dot operator effectively - <My.Component>
(jsx_opening_element
(member_expression
(identifier) @tag.builtin
(property_identifier) @tag))
(jsx_closing_element
((identifier) @tag
(#lua-match? @tag "^[A-Z]")))
; Handle the dot operator effectively - </My.Component>
(jsx_closing_element
(member_expression
(identifier) @tag.builtin
(property_identifier) @tag))
(jsx_self_closing_element
((identifier) @tag
(#lua-match? @tag "^[A-Z]")))
; Handle the dot operator effectively - <My.Component />
(jsx_self_closing_element
(member_expression
(identifier) @tag.builtin
(property_identifier) @tag))
(html_character_reference) @tag
(jsx_text) @none @spell
(html_character_reference) @character.special
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.heading)
(#eq? @_tag "title"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.heading.1)
(#eq? @_tag "h1"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.heading.2)
(#eq? @_tag "h2"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.heading.3)
(#eq? @_tag "h3"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.heading.4)
(#eq? @_tag "h4"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.heading.5)
(#eq? @_tag "h5"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.heading.6)
(#eq? @_tag "h6"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.strong)
(#any-of? @_tag "strong" "b"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.italic)
(#any-of? @_tag "em" "i"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.strikethrough)
(#any-of? @_tag "s" "del"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.underline)
(#eq? @_tag "u"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.raw)
(#any-of? @_tag "code" "kbd"))
((jsx_element
(jsx_opening_element
name: (identifier) @_tag)
(jsx_text) @markup.link.label)
(#eq? @_tag "a"))
((jsx_attribute
(property_identifier) @_attr
(string
(string_fragment) @string.special.url))
(#any-of? @_attr "href" "src"))
((jsx_element) @_jsx_element
(#set! @_jsx_element bo.commentstring "{/* %s */}"))
((jsx_attribute) @_jsx_attribute
(#set! @_jsx_attribute bo.commentstring "// %s"))
+24
View File
@@ -0,0 +1,24 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(jsx_element)
(jsx_self_closing_element)
(jsx_expression)
] @indent.begin
(jsx_closing_element
">" @indent.end)
(jsx_self_closing_element
"/>" @indent.end)
[
(jsx_closing_element)
">"
] @indent.branch
; <button
; />
(jsx_self_closing_element
"/>" @indent.branch)
+14
View File
@@ -0,0 +1,14 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Styled Jsx <style jsx>
(jsx_element
(jsx_opening_element
(identifier) @_name
(#eq? @_name "style")
(jsx_attribute) @_attr
(#eq? @_attr "jsx"))
(jsx_expression
((template_string) @injection.content
(#set! injection.language "css"))
(#offset! @injection.content 0 1 0 -1)))
+200
View File
@@ -0,0 +1,200 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Keywords
[
"@module"
"@package"
] @keyword.import @nospell
[
"@class"
"@type"
"@param"
"@alias"
"@field"
"@generic"
"@vararg"
"@diagnostic"
"@cast"
"@deprecated"
"@meta"
"@source"
"@version"
"@operator"
"@nodiscard"
"@overload"
"@enum"
"@language"
"@see"
"@as"
"extends"
(diagnostic_identifier)
] @keyword @nospell
"@async" @keyword.coroutine @nospell
(language_injection
"@language"
(identifier) @keyword @nospell)
(function_type
[
"fun"
"function"
] @keyword.function @nospell)
(source_annotation
filename: (identifier) @string.special.path @nospell
extension: (identifier) @string.special.path @nospell)
(version_annotation
version: _ @constant.builtin @nospell)
"@return" @keyword.return @nospell
; Qualifiers
[
"public"
"protected"
"private"
"package"
"@public"
"@protected"
"@private"
"(exact)"
"(key)"
] @keyword.modifier @nospell
; Variables
(identifier) @variable @nospell
[
"..."
"self"
] @variable.builtin @nospell
; Macros
(alias_annotation
(identifier) @function.macro @nospell)
; Parameters
(param_annotation
(identifier) @variable.parameter @nospell)
(parameter
(identifier) @variable.parameter @nospell)
; Fields
(field_annotation
(identifier) @variable.member @nospell)
(table_literal_type
field: (identifier) @variable.member @nospell)
(member_type
[
"#"
"."
]
.
(identifier) @variable.member @nospell)
(member_type
(identifier) @module @nospell)
(member_type
(identifier) @type @nospell .)
; Types
(table_type
"table" @type.builtin @nospell)
(builtin_type) @type.builtin @nospell
(class_annotation
(identifier) @type @nospell)
(enum_annotation
(identifier) @type @nospell)
((array_type
[
"["
"]"
] @type)
(#set! priority 105))
(type) @type
; Operators
[
"|"
"+"
"-"
] @operator
; Literals
[
(string)
(literal_type)
"`"
] @string
(module_annotation
(string) @module @nospell)
[
(number)
(numeric_literal_type)
] @number
; Punctuation
[
"["
"]"
"[["
"]]"
"[=["
"]=]"
] @punctuation.bracket
[
"{"
"}"
] @punctuation.bracket
[
"("
")"
] @punctuation.bracket
[
"<"
">"
] @punctuation.bracket
[
","
"."
"#"
":"
] @punctuation.delimiter
[
"@"
"?"
] @punctuation.special
; Comments
(comment) @comment @spell
(at_comment
(identifier) @type @nospell
(_) @comment @spell)
(class_at_comment
(identifier) @type @nospell
("extends"?
(identifier)? @type @nospell)
(_) @comment @spell)
+31
View File
@@ -0,0 +1,31 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(function_definition)
(class_definition)
(while_statement)
(for_statement)
(if_statement)
(with_statement)
(try_statement)
(match_statement)
(import_from_statement)
(parameters)
(argument_list)
(parenthesized_expression)
(generator_expression)
(list_comprehension)
(set_comprehension)
(dictionary_comprehension)
(tuple)
(list)
(set)
(dictionary)
(string)
] @fold
[
(import_statement)
(import_from_statement)
]+ @fold
+456
View File
@@ -0,0 +1,456 @@
; From tree-sitter-python licensed under MIT License
; Copyright (c) 2016 Max Brunsfeld
; Variables
(identifier) @variable
; Reset highlighting in f-string interpolations
(interpolation) @none @nospell
; Identifier naming conventions
((identifier) @type
(#lua-match? @type "^[A-Z].*[a-z]"))
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
((identifier) @constant.builtin
(#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
((identifier) @constant.builtin
(#any-of? @constant.builtin
; https://docs.python.org/3/library/constants.html
"NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license"))
"_" @character.special ; match wildcard
((assignment
left: (identifier) @type.definition
(type
(identifier) @_annotation))
(#eq? @_annotation "TypeAlias"))
((assignment
left: (identifier) @type.definition
right: (call
function: (identifier) @_func))
(#any-of? @_func "TypeVar" "NewType"))
; Function definitions
(function_definition
name: (identifier) @function)
(type
(identifier) @type)
(type
(subscript
(identifier) @type)) ; type subscript: Tuple[int]
((call
function: (identifier) @_isinstance
arguments: (argument_list
(_)
(identifier) @type))
(#eq? @_isinstance "isinstance"))
; Literals
(none) @constant.builtin
[
(true)
(false)
] @boolean
(integer) @number
(float) @number.float
(comment) @comment @spell
((module
.
(comment) @keyword.directive @nospell)
(#lua-match? @keyword.directive "^#!/"))
(string) @string
[
(escape_sequence)
(escape_interpolation)
] @string.escape
; doc-strings
(expression_statement
(string
(string_content) @spell) @string.documentation)
; Tokens
[
"-"
"-="
":="
"!="
"*"
"**"
"**="
"*="
"/"
"//"
"//="
"/="
"&"
"&="
"%"
"%="
"^"
"^="
"+"
"+="
"<"
"<<"
"<<="
"<="
"<>"
"="
"=="
">"
">="
">>"
">>="
"@"
"@="
"|"
"|="
"~"
"->"
] @operator
; Keywords
[
"and"
"in"
"is"
"not"
"or"
"is not"
"not in"
"del"
] @keyword.operator
[
"def"
"lambda"
] @keyword.function
[
"assert"
"exec"
"global"
"nonlocal"
"pass"
"print"
"with"
"as"
] @keyword
[
"type"
"class"
] @keyword.type
[
"async"
"await"
] @keyword.coroutine
[
"return"
"yield"
] @keyword.return
(yield
"from" @keyword.return)
(future_import_statement
"from" @keyword.import
"__future__" @module.builtin)
(import_from_statement
"from" @keyword.import)
"import" @keyword.import
(aliased_import
"as" @keyword.import)
(wildcard_import
"*" @character.special)
(import_statement
name: (dotted_name
(identifier) @module))
(import_statement
name: (aliased_import
name: (dotted_name
(identifier) @module)
alias: (identifier) @module))
(import_from_statement
module_name: (dotted_name
(identifier) @module))
(import_from_statement
module_name: (relative_import
(dotted_name
(identifier) @module)))
[
"if"
"elif"
"else"
"match"
"case"
] @keyword.conditional
[
"for"
"while"
"break"
"continue"
] @keyword.repeat
[
"try"
"except"
"raise"
"finally"
] @keyword.exception
(raise_statement
"from" @keyword.exception)
(try_statement
(else_clause
"else" @keyword.exception))
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(interpolation
"{" @punctuation.special
"}" @punctuation.special)
(format_expression
"{" @punctuation.special
"}" @punctuation.special)
(line_continuation) @punctuation.special
(type_conversion) @function.macro
[
","
"."
":"
";"
(ellipsis)
] @punctuation.delimiter
((identifier) @type.builtin
(#any-of? @type.builtin
; https://docs.python.org/3/library/exceptions.html
"BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError"
"AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError"
"ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" "MemoryError" "NameError"
"NotImplementedError" "OSError" "OverflowError" "RecursionError" "ReferenceError" "RuntimeError"
"StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError" "SystemError"
"SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError"
"UnicodeDecodeError" "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError"
"IOError" "WindowsError" "BlockingIOError" "ChildProcessError" "ConnectionError"
"BrokenPipeError" "ConnectionAbortedError" "ConnectionRefusedError" "ConnectionResetError"
"FileExistsError" "FileNotFoundError" "InterruptedError" "IsADirectoryError"
"NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning"
"UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning"
"FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning"
; https://docs.python.org/3/library/stdtypes.html
"bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview"
"set" "frozenset" "dict" "type" "object"))
; Normal parameters
(parameters
(identifier) @variable.parameter)
; Lambda parameters
(lambda_parameters
(identifier) @variable.parameter)
(lambda_parameters
(tuple_pattern
(identifier) @variable.parameter))
; Default parameters
(keyword_argument
name: (identifier) @variable.parameter)
; Naming parameters on call-site
(default_parameter
name: (identifier) @variable.parameter)
(typed_parameter
(identifier) @variable.parameter)
(typed_default_parameter
name: (identifier) @variable.parameter)
; Variadic parameters *args, **kwargs
(parameters
(list_splat_pattern ; *args
(identifier) @variable.parameter))
(parameters
(dictionary_splat_pattern ; **kwargs
(identifier) @variable.parameter))
; Typed variadic parameters
(parameters
(typed_parameter
(list_splat_pattern ; *args: type
(identifier) @variable.parameter)))
(parameters
(typed_parameter
(dictionary_splat_pattern ; *kwargs: type
(identifier) @variable.parameter)))
; Lambda parameters
(lambda_parameters
(list_splat_pattern
(identifier) @variable.parameter))
(lambda_parameters
(dictionary_splat_pattern
(identifier) @variable.parameter))
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
((identifier) @variable.builtin
(#eq? @variable.builtin "cls"))
; After @type.builtin bacause builtins (such as `type`) are valid as attribute name
((attribute
attribute: (identifier) @variable.member)
(#lua-match? @variable.member "^[%l_].*$"))
; Class definitions
(class_definition
name: (identifier) @type)
(class_definition
body: (block
(function_definition
name: (identifier) @function.method)))
(class_definition
superclasses: (argument_list
(identifier) @type))
((class_definition
body: (block
(expression_statement
(assignment
left: (identifier) @variable.member))))
(#lua-match? @variable.member "^[%l_].*$"))
((class_definition
body: (block
(expression_statement
(assignment
left: (_
(identifier) @variable.member)))))
(#lua-match? @variable.member "^[%l_].*$"))
((class_definition
(block
(function_definition
name: (identifier) @constructor)))
(#any-of? @constructor "__new__" "__init__"))
; Function calls
(call
function: (identifier) @function.call)
(call
function: (attribute
attribute: (identifier) @function.method.call))
((call
function: (identifier) @constructor)
(#lua-match? @constructor "^%u"))
((call
function: (attribute
attribute: (identifier) @constructor))
(#lua-match? @constructor "^%u"))
; Builtin functions
((call
function: (identifier) @function.builtin)
(#any-of? @function.builtin
"abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr"
"classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec"
"filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id"
"input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview"
"min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed"
"round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type"
"vars" "zip" "__import__"))
; Regex from the `re` module
(call
function: (attribute
object: (identifier) @_re)
arguments: (argument_list
(string
(string_content) @string.regexp))
(#eq? @_re "re"))
(call
function: (attribute
object: (identifier) @_re)
arguments: (argument_list
(concatenated_string
(string
(string_content) @string.regexp)))
(#eq? @_re "re"))
; Decorators
((decorator
"@" @attribute)
(#set! priority 101))
(decorator
(identifier) @attribute)
(decorator
(attribute
attribute: (identifier) @attribute))
(decorator
(call
(identifier) @attribute))
(decorator
(call
(attribute
attribute: (identifier) @attribute)))
((decorator
(identifier) @attribute.builtin)
(#any-of? @attribute.builtin "classmethod" "property" "staticmethod"))
+216
View File
@@ -0,0 +1,216 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(import_from_statement)
(generator_expression)
(list_comprehension)
(set_comprehension)
(dictionary_comprehension)
(tuple_pattern)
(list_pattern)
(binary_operator)
(lambda)
(concatenated_string)
] @indent.begin
((list) @indent.align
(#set! indent.open_delimiter "[")
(#set! indent.close_delimiter "]"))
((dictionary) @indent.align
(#set! indent.open_delimiter "{")
(#set! indent.close_delimiter "}"))
((set) @indent.align
(#set! indent.open_delimiter "{")
(#set! indent.close_delimiter "}"))
((parenthesized_expression) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
((for_statement) @indent.begin
(#set! indent.immediate 1))
((if_statement) @indent.begin
(#set! indent.immediate 1))
((while_statement) @indent.begin
(#set! indent.immediate 1))
((try_statement) @indent.begin
(#set! indent.immediate 1))
(ERROR
"try"
.
":"
(#set! indent.immediate 1)) @indent.begin
(ERROR
"try"
.
":"
(ERROR
(block
(expression_statement
(identifier) @_except) @indent.branch))
(#eq? @_except "except"))
((function_definition) @indent.begin
(#set! indent.immediate 1))
((class_definition) @indent.begin
(#set! indent.immediate 1))
((with_statement) @indent.begin
(#set! indent.immediate 1))
((match_statement) @indent.begin
(#set! indent.immediate 1))
((case_clause) @indent.begin
(#set! indent.immediate 1))
; if (cond1
; or cond2
; or cond3):
; pass
;
(if_statement
condition: (parenthesized_expression) @indent.align
(#lua-match? @indent.align "^%([^\n]")
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
; while (
; cond1
; or cond2
; or cond3):
; pass
;
(while_statement
condition: (parenthesized_expression) @indent.align
(#lua-match? @indent.align "[^\n ]%)$")
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
; if (
; cond1
; or cond2
; or cond3):
; pass
;
(if_statement
condition: (parenthesized_expression) @indent.align
(#lua-match? @indent.align "[^\n ]%)$")
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
(ERROR
"(" @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
.
(_))
((argument_list) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
((parameters) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
((parameters) @indent.align
(#lua-match? @indent.align "[^\n ]%)$")
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
((tuple) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
(ERROR
"[" @indent.align
(#set! indent.open_delimiter "[")
(#set! indent.close_delimiter "]")
.
(_))
(ERROR
"{" @indent.align
(#set! indent.open_delimiter "{")
(#set! indent.close_delimiter "}")
.
(_))
[
(break_statement)
(continue_statement)
] @indent.dedent
(ERROR
(_) @indent.branch
":"
.
(#lua-match? @indent.branch "^else"))
(ERROR
(_) @indent.branch @indent.dedent
":"
.
(#lua-match? @indent.branch "^elif"))
(generator_expression
")" @indent.end)
(list_comprehension
"]" @indent.end)
(set_comprehension
"}" @indent.end)
(dictionary_comprehension
"}" @indent.end)
(tuple_pattern
")" @indent.end)
(list_pattern
"]" @indent.end)
(return_statement
[
(_) @indent.end
(_
[
(_)
")"
"}"
"]"
] @indent.end .)
(attribute
attribute: (_) @indent.end)
(call
arguments: (_
")" @indent.end))
"return" @indent.end
] .)
[
")"
"]"
"}"
(elif_clause)
(else_clause)
(except_clause)
(finally_clause)
] @indent.branch
(string) @indent.auto
+33
View File
@@ -0,0 +1,33 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(call
function: (attribute
object: (identifier) @_re)
arguments: (argument_list
(string
(string_content) @injection.content))
(#eq? @_re "re")
(#set! injection.language "regex"))
(call
function: (attribute
object: (identifier) @_re)
arguments: (argument_list
(concatenated_string
[
(string
(string_content) @injection.content)
(comment)
]+))
(#eq? @_re "re")
(#set! injection.language "regex"))
((binary_operator
left: (string
(string_content) @injection.content)
operator: "%")
(#set! injection.language "printf"))
((comment) @injection.content
(#set! injection.language "comment"))
+127
View File
@@ -0,0 +1,127 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Program structure
(module) @local.scope
(class_definition
body: (block
(expression_statement
(assignment
left: (identifier) @local.definition.field)))) @local.scope
(class_definition
body: (block
(expression_statement
(assignment
left: (_
(identifier) @local.definition.field))))) @local.scope
; Imports
(aliased_import
alias: (identifier) @local.definition.import) @local.scope
(import_statement
name: (dotted_name
(identifier) @local.definition.import)) @local.scope
(import_from_statement
name: (dotted_name
(identifier) @local.definition.import)) @local.scope
; Function with parameters, defines parameters
(parameters
(identifier) @local.definition.parameter)
(default_parameter
(identifier) @local.definition.parameter)
(typed_parameter
(identifier) @local.definition.parameter)
(typed_default_parameter
(identifier) @local.definition.parameter)
; *args parameter
(parameters
(list_splat_pattern
(identifier) @local.definition.parameter))
; **kwargs parameter
(parameters
(dictionary_splat_pattern
(identifier) @local.definition.parameter))
; Function defines function and scope
((function_definition
name: (identifier) @local.definition.function) @local.scope
(#set! definition.function.scope "parent"))
((class_definition
name: (identifier) @local.definition.type) @local.scope
(#set! definition.type.scope "parent"))
(class_definition
body: (block
(function_definition
name: (identifier) @local.definition.method)))
; Loops
; not a scope!
(for_statement
left: (pattern_list
(identifier) @local.definition.var))
(for_statement
left: (tuple_pattern
(identifier) @local.definition.var))
(for_statement
left: (identifier) @local.definition.var)
; not a scope!
;(while_statement) @local.scope
; for in list comprehension
(for_in_clause
left: (identifier) @local.definition.var)
(for_in_clause
left: (tuple_pattern
(identifier) @local.definition.var))
(for_in_clause
left: (pattern_list
(identifier) @local.definition.var))
(dictionary_comprehension) @local.scope
(list_comprehension) @local.scope
(set_comprehension) @local.scope
; Assignments
(assignment
left: (identifier) @local.definition.var)
(assignment
left: (pattern_list
(identifier) @local.definition.var))
(assignment
left: (tuple_pattern
(identifier) @local.definition.var))
(assignment
left: (attribute
(identifier)
(identifier) @local.definition.field))
; Walrus operator x := 1
(named_expression
(identifier) @local.definition.var)
(as_pattern
alias: (as_pattern_target) @local.definition.var)
; REFERENCES
(identifier) @local.reference
+28
View File
@@ -0,0 +1,28 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(mod_item)
(foreign_mod_item)
(function_item)
(struct_item)
(trait_item)
(enum_item)
(impl_item)
(type_item)
(union_item)
(const_item)
(let_declaration)
(loop_expression)
(for_expression)
(while_expression)
(if_expression)
(match_expression)
(call_expression)
(array_expression)
(macro_definition)
(macro_invocation)
(attribute_item)
(block)
(use_declaration)+
] @fold
+534
View File
@@ -0,0 +1,534 @@
; Forked from https://github.com/tree-sitter/tree-sitter-rust
; Copyright (c) 2017 Maxim Sokolov
; Licensed under the MIT license.
; Identifier conventions
(shebang) @keyword.directive
(identifier) @variable
((identifier) @type
(#lua-match? @type "^[A-Z]"))
(const_item
name: (identifier) @constant)
; Assume all-caps names are constants
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
; Other identifiers
(type_identifier) @type
(primitive_type) @type.builtin
(field_identifier) @variable.member
(shorthand_field_identifier) @variable.member
(shorthand_field_initializer
(identifier) @variable.member)
(mod_item
name: (identifier) @module)
(self) @variable.builtin
"_" @character.special
(label
[
"'"
(identifier)
] @label)
; Function definitions
(function_item
(identifier) @function)
(function_signature_item
(identifier) @function)
(parameter
[
(identifier)
"_"
] @variable.parameter)
(parameter
(ref_pattern
[
(mut_pattern
(identifier) @variable.parameter)
(identifier) @variable.parameter
]))
(closure_parameters
(_) @variable.parameter)
; Function calls
(call_expression
function: (identifier) @function.call)
(call_expression
function: (scoped_identifier
(identifier) @function.call .))
(call_expression
function: (field_expression
field: (field_identifier) @function.call))
(generic_function
function: (identifier) @function.call)
(generic_function
function: (scoped_identifier
name: (identifier) @function.call))
(generic_function
function: (field_expression
field: (field_identifier) @function.call))
; Assume other uppercase names are enum constructors
((field_identifier) @constant
(#lua-match? @constant "^[A-Z]"))
(enum_variant
name: (identifier) @constant)
; Assume that uppercase names in paths are types
(scoped_identifier
path: (identifier) @module)
(scoped_identifier
(scoped_identifier
name: (identifier) @module))
(scoped_type_identifier
path: (identifier) @module)
(scoped_type_identifier
path: (identifier) @type
(#lua-match? @type "^[A-Z]"))
(scoped_type_identifier
(scoped_identifier
name: (identifier) @module))
((scoped_identifier
path: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
((scoped_identifier
name: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
((scoped_identifier
name: (identifier) @constant)
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
((scoped_identifier
path: (identifier) @type
name: (identifier) @constant)
(#lua-match? @type "^[A-Z]")
(#lua-match? @constant "^[A-Z]"))
((scoped_type_identifier
path: (identifier) @type
name: (type_identifier) @constant)
(#lua-match? @type "^[A-Z]")
(#lua-match? @constant "^[A-Z]"))
[
(crate)
(super)
] @module
(scoped_use_list
path: (identifier) @module)
(scoped_use_list
path: (scoped_identifier
(identifier) @module))
(use_list
(scoped_identifier
(identifier) @module
.
(_)))
(use_list
(identifier) @type
(#lua-match? @type "^[A-Z]"))
(use_as_clause
alias: (identifier) @type
(#lua-match? @type "^[A-Z]"))
; Correct enum constructors
(call_expression
function: (scoped_identifier
"::"
name: (identifier) @constant)
(#lua-match? @constant "^[A-Z]"))
; Assume uppercase names in a match arm are constants.
((match_arm
pattern: (match_pattern
(identifier) @constant))
(#lua-match? @constant "^[A-Z]"))
((match_arm
pattern: (match_pattern
(scoped_identifier
name: (identifier) @constant)))
(#lua-match? @constant "^[A-Z]"))
((identifier) @constant.builtin
(#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
; Macro definitions
"$" @function.macro
(metavariable) @function.macro
(macro_definition
"macro_rules!" @function.macro)
; Attribute macros
(attribute_item
(attribute
(identifier) @function.macro))
(inner_attribute_item
(attribute
(identifier) @function.macro))
(attribute
(scoped_identifier
(identifier) @function.macro .))
; Derive macros (assume all arguments are types)
; (attribute
; (identifier) @_name
; arguments: (attribute (attribute (identifier) @type))
; (#eq? @_name "derive"))
; Function-like macros
(macro_invocation
macro: (identifier) @function.macro)
(macro_invocation
macro: (scoped_identifier
(identifier) @function.macro .))
; Literals
(boolean_literal) @boolean
(integer_literal) @number
(float_literal) @number.float
[
(raw_string_literal)
(string_literal)
] @string
(escape_sequence) @string.escape
(char_literal) @character
; Keywords
[
"use"
"mod"
] @keyword.import
(use_as_clause
"as" @keyword.import)
[
"default"
"impl"
"let"
"move"
"unsafe"
"where"
] @keyword
[
"enum"
"struct"
"union"
"trait"
"type"
] @keyword.type
[
"async"
"await"
"gen"
] @keyword.coroutine
"try" @keyword.exception
[
"ref"
"pub"
"raw"
(mutable_specifier)
"const"
"static"
"dyn"
"extern"
] @keyword.modifier
(lifetime
"'" @keyword.modifier)
(lifetime
(identifier) @attribute)
(lifetime
(identifier) @attribute.builtin
(#any-of? @attribute.builtin "static" "_"))
"fn" @keyword.function
[
"return"
"yield"
] @keyword.return
(type_cast_expression
"as" @keyword.operator)
(qualified_type
"as" @keyword.operator)
(use_list
(self) @module)
(scoped_use_list
(self) @module)
(scoped_identifier
[
(crate)
(super)
(self)
] @module)
(visibility_modifier
[
(crate)
(super)
(self)
] @module)
[
"if"
"else"
"match"
] @keyword.conditional
[
"break"
"continue"
"in"
"loop"
"while"
] @keyword.repeat
"for" @keyword
(for_expression
"for" @keyword.repeat)
; Operators
[
"!"
"!="
"%"
"%="
"&"
"&&"
"&="
"*"
"*="
"+"
"+="
"-"
"-="
".."
"..="
"..."
"/"
"/="
"<"
"<<"
"<<="
"<="
"="
"=="
">"
">="
">>"
">>="
"?"
"@"
"^"
"^="
"|"
"|="
"||"
] @operator
(use_wildcard
"*" @character.special)
(remaining_field_pattern
".." @character.special)
(range_pattern
[
".."
"..="
"..."
] @character.special)
; Punctuation
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(closure_parameters
"|" @punctuation.bracket)
(type_arguments
[
"<"
">"
] @punctuation.bracket)
(type_parameters
[
"<"
">"
] @punctuation.bracket)
(bracketed_type
[
"<"
">"
] @punctuation.bracket)
(for_lifetimes
[
"<"
">"
] @punctuation.bracket)
[
","
"."
":"
"::"
";"
"->"
"=>"
] @punctuation.delimiter
(attribute_item
"#" @punctuation.special)
(inner_attribute_item
[
"!"
"#"
] @punctuation.special)
(macro_invocation
"!" @function.macro)
(never_type
"!" @type.builtin)
(macro_invocation
macro: (identifier) @_identifier @keyword.exception
"!" @keyword.exception
(#eq? @_identifier "panic"))
(macro_invocation
macro: (identifier) @_identifier @keyword.exception
"!" @keyword.exception
(#contains? @_identifier "assert"))
(macro_invocation
macro: (identifier) @_identifier @keyword.debug
"!" @keyword.debug
(#eq? @_identifier "dbg"))
; Comments
[
(line_comment)
(block_comment)
] @comment @spell
[
(outer_doc_comment_marker)
(inner_doc_comment_marker)
] @comment.documentation
(line_comment
(doc_comment)) @comment.documentation
(block_comment
(doc_comment)) @comment.documentation
(call_expression
function: (scoped_identifier
path: (identifier) @_regex
(#any-of? @_regex "Regex" "ByteRegexBuilder")
name: (identifier) @_new
(#eq? @_new "new"))
arguments: (arguments
(raw_string_literal
(string_content) @string.regexp)))
(call_expression
function: (scoped_identifier
path: (scoped_identifier
(identifier) @_regex
(#any-of? @_regex "Regex" "ByteRegexBuilder") .)
name: (identifier) @_new
(#eq? @_new "new"))
arguments: (arguments
(raw_string_literal
(string_content) @string.regexp)))
(call_expression
function: (scoped_identifier
path: (identifier) @_regex
(#any-of? @_regex "RegexSet" "RegexSetBuilder")
name: (identifier) @_new
(#eq? @_new "new"))
arguments: (arguments
(array_expression
(raw_string_literal
(string_content) @string.regexp))))
(call_expression
function: (scoped_identifier
path: (scoped_identifier
(identifier) @_regex
(#any-of? @_regex "RegexSet" "RegexSetBuilder") .)
name: (identifier) @_new
(#eq? @_new "new"))
arguments: (arguments
(array_expression
(raw_string_literal
(string_content) @string.regexp))))
+136
View File
@@ -0,0 +1,136 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(mod_item)
(struct_item)
(enum_item)
(impl_item)
(struct_expression)
(struct_pattern)
(tuple_struct_pattern)
(tuple_expression)
(tuple_type)
(tuple_pattern)
(match_block)
(call_expression)
(assignment_expression)
(arguments)
(block)
(where_clause)
(use_list)
(array_expression)
(ordered_field_declaration_list)
(field_declaration_list)
(enum_variant_list)
(parameters)
(token_tree)
(token_repetition)
(macro_definition)
] @indent.begin
(trait_item
body: (_) @indent.begin)
(string_literal
(escape_sequence)) @indent.begin
; Typing in "(" inside macro definitions breaks the tree entirely
; Making macro_definition becoming errors
; Offset this by adding back one indent for start of macro rules
(ERROR
.
"macro_rules!"
[
"("
"{"
"["
] @indent.begin
(#set! indent.immediate)
(#set! indent.start_at_same_line))
(macro_definition
[
")"
"}"
"]"
] @indent.end)
(trait_item
body: (_) @indent.begin)
(string_literal
(escape_sequence)) @indent.begin
(block
"}" @indent.end)
(enum_item
body: (enum_variant_list
"}" @indent.end))
(impl_item
body: (declaration_list
"}" @indent.end))
(match_expression
body: (match_block
"}" @indent.end))
(mod_item
body: (declaration_list
"}" @indent.end))
(struct_item
body: (field_declaration_list
"}" @indent.end))
(struct_expression
body: (field_initializer_list
"}" @indent.end))
(struct_pattern
"}" @indent.end)
(tuple_struct_pattern
")" @indent.end)
; Typing in "(" inside macro definitions breaks the tree entirely
; Making macro_definition becoming errors
; Offset this by adding back one indent for start of macro rules
(ERROR
.
"macro_rules!"
"(" @indent.begin
(#set! indent.immediate)
(#set! indent.start_at_same_line))
(tuple_type
")" @indent.end)
(tuple_pattern
")" @indent.end)
(trait_item
body: (declaration_list
"}" @indent.end))
(impl_item
(where_clause) @indent.dedent)
[
"where"
")"
"]"
"}"
] @indent.branch
(impl_item
(declaration_list) @indent.branch)
[
(line_comment)
(string_literal)
] @indent.ignore
(raw_string_literal) @indent.auto
+92
View File
@@ -0,0 +1,92 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(macro_invocation
macro: [
(scoped_identifier
name: (_) @_macro_name)
(identifier) @_macro_name
]
(token_tree) @injection.content
(#not-any-of? @_macro_name "slint" "html" "json" "xml")
(#set! injection.language "rust")
(#set! injection.include-children))
(macro_invocation
macro: [
(scoped_identifier
name: (_) @injection.language)
(identifier) @injection.language
]
(token_tree) @injection.content
(#any-of? @injection.language "slint" "html" "json" "xml")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children))
(macro_definition
(macro_rule
left: (token_tree_pattern) @injection.content
(#set! injection.language "rust")))
(macro_definition
(macro_rule
right: (token_tree) @injection.content
(#set! injection.language "rust")))
([
(line_comment)
(block_comment)
] @injection.content
(#set! injection.language "comment"))
(call_expression
function: (scoped_identifier
path: (identifier) @_regex
(#any-of? @_regex "Regex" "RegexBuilder")
name: (identifier) @_new
(#eq? @_new "new"))
arguments: (arguments
(raw_string_literal
(string_content) @injection.content))
(#set! injection.language "regex"))
(call_expression
function: (scoped_identifier
path: (scoped_identifier
(identifier) @_regex
(#any-of? @_regex "Regex" "RegexBuilder") .)
name: (identifier) @_new
(#eq? @_new "new"))
arguments: (arguments
(raw_string_literal
(string_content) @injection.content))
(#set! injection.language "regex"))
(call_expression
function: (scoped_identifier
path: (identifier) @_regex
(#any-of? @_regex "RegexSet" "RegexSetBuilder")
name: (identifier) @_new
(#eq? @_new "new"))
arguments: (arguments
(array_expression
(raw_string_literal
(string_content) @injection.content)))
(#set! injection.language "regex"))
(call_expression
function: (scoped_identifier
path: (scoped_identifier
(identifier) @_regex
(#any-of? @_regex "RegexSet" "RegexSetBuilder") .)
name: (identifier) @_new
(#eq? @_new "new"))
arguments: (arguments
(array_expression
(raw_string_literal
(string_content) @injection.content)))
(#set! injection.language "regex"))
((block_comment) @injection.content
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
(#set! injection.language "re2c"))
+101
View File
@@ -0,0 +1,101 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; Imports
(extern_crate_declaration
name: (identifier) @local.definition.import)
(use_declaration
argument: (scoped_identifier
name: (identifier) @local.definition.import))
(use_as_clause
alias: (identifier) @local.definition.import)
(use_list
(identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio};
; Functions
(function_item
name: (identifier) @local.definition.function)
(function_item
name: (identifier) @local.definition.method
parameters: (parameters
(self_parameter)))
; Variables
(parameter
pattern: (identifier) @local.definition.var)
(let_declaration
pattern: (identifier) @local.definition.var)
(const_item
name: (identifier) @local.definition.var)
(tuple_pattern
(identifier) @local.definition.var)
(let_condition
pattern: (_
(identifier) @local.definition.var))
(tuple_struct_pattern
(identifier) @local.definition.var)
(closure_parameters
(identifier) @local.definition.var)
(self_parameter
(self) @local.definition.var)
(for_expression
pattern: (identifier) @local.definition.var)
; Types
(struct_item
name: (type_identifier) @local.definition.type)
(enum_item
name: (type_identifier) @local.definition.type)
; Fields
(field_declaration
name: (field_identifier) @local.definition.field)
(enum_variant
name: (identifier) @local.definition.field)
; References
(identifier) @local.reference
((type_identifier) @local.reference
(#set! reference.kind "type"))
((field_identifier) @local.reference
(#set! reference.kind "field"))
; Macros
(macro_definition
name: (identifier) @local.definition.macro)
; Module
(mod_item
name: (identifier) @local.definition.namespace)
; Scopes
[
(block)
(function_item)
(closure_expression)
(while_expression)
(for_expression)
(loop_expression)
(if_expression)
(match_expression)
(match_arm)
(struct_item)
(enum_item)
(impl_item)
] @local.scope
+3
View File
@@ -0,0 +1,3 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: css
+89
View File
@@ -0,0 +1,89 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: css
[
"@at-root"
"@debug"
"@error"
"@extend"
"@forward"
"@mixin"
"@use"
"@warn"
] @keyword
"@function" @keyword.function
"@return" @keyword.return
"@include" @keyword.import
[
"@while"
"@each"
"@for"
"from"
"through"
"in"
] @keyword.repeat
(single_line_comment) @comment @spell
(function_name) @function
[
">="
"<="
] @operator
(mixin_statement
(name) @function)
(mixin_statement
(parameters
(parameter) @variable.parameter))
(function_statement
(name) @function)
(function_statement
(parameters
(parameter) @variable.parameter))
(plain_value) @string
(keyword_query) @function
(identifier) @variable
(variable_name) @variable
(each_statement
(key) @variable.parameter)
(each_statement
(value) @variable.parameter)
(each_statement
(variable_value) @variable.parameter)
(for_statement
(variable) @variable.parameter)
(for_statement
(_
(variable_value) @variable.parameter))
(argument) @variable.parameter
(arguments
(variable_value) @variable.parameter)
[
"["
"]"
] @punctuation.bracket
(include_statement
(identifier) @function)
+9
View File
@@ -0,0 +1,9 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: css
[
(mixin_statement)
(while_statement)
(each_statement)
] @indent.begin
+5
View File
@@ -0,0 +1,5 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((single_line_comment) @injection.content
(#set! injection.language "comment"))
+4
View File
@@ -0,0 +1,4 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(statement) @fold
+462
View File
@@ -0,0 +1,462 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(invocation
(object_reference
name: (identifier) @function.call))
[
(keyword_gist)
(keyword_btree)
(keyword_hash)
(keyword_spgist)
(keyword_gin)
(keyword_brin)
(keyword_array)
(keyword_object_id)
] @function.call
((object_reference
name: (identifier) @type) @_obj_ref
(#not-has-parent? @_obj_ref invocation))
(cte
(identifier) @type)
(relation
alias: (identifier) @variable)
(field
name: (identifier) @variable.member)
(column_definition
name: (identifier) @variable.member)
(term
alias: (identifier) @variable)
(term
value: (cast
name: (keyword_cast) @function.call
parameter: (literal)?))
(literal) @string
(comment) @comment @spell
(marginalia) @comment
((literal) @number
(#lua-match? @number "^%d+$"))
((literal) @number.float
(#lua-match? @number.float "^[-]?%d*%.%d*$"))
(parameter) @variable.parameter
[
(keyword_true)
(keyword_false)
] @boolean
[
(keyword_asc)
(keyword_desc)
(keyword_terminated)
(keyword_escaped)
(keyword_unsigned)
(keyword_nulls)
(keyword_last)
(keyword_delimited)
(keyword_replication)
(keyword_auto_increment)
(keyword_default)
(keyword_collate)
(keyword_concurrently)
(keyword_engine)
(keyword_always)
(keyword_generated)
(keyword_preceding)
(keyword_following)
(keyword_first)
(keyword_current_timestamp)
(keyword_immutable)
(keyword_atomic)
(keyword_parallel)
(keyword_leakproof)
(keyword_safe)
(keyword_cost)
(keyword_strict)
] @attribute
[
(keyword_materialized)
(keyword_recursive)
(keyword_temp)
(keyword_temporary)
(keyword_unlogged)
(keyword_external)
(keyword_parquet)
(keyword_csv)
(keyword_rcfile)
(keyword_textfile)
(keyword_orc)
(keyword_avro)
(keyword_jsonfile)
(keyword_sequencefile)
(keyword_volatile)
] @keyword.modifier
[
(keyword_case)
(keyword_when)
(keyword_then)
(keyword_else)
] @keyword.conditional
[
(keyword_select)
(keyword_from)
(keyword_where)
(keyword_index)
(keyword_join)
(keyword_primary)
(keyword_delete)
(keyword_create)
(keyword_show)
(keyword_unload)
(keyword_insert)
(keyword_merge)
(keyword_distinct)
(keyword_replace)
(keyword_update)
(keyword_into)
(keyword_overwrite)
(keyword_matched)
(keyword_values)
(keyword_value)
(keyword_attribute)
(keyword_set)
(keyword_left)
(keyword_right)
(keyword_outer)
(keyword_inner)
(keyword_full)
(keyword_order)
(keyword_partition)
(keyword_group)
(keyword_with)
(keyword_without)
(keyword_as)
(keyword_having)
(keyword_limit)
(keyword_offset)
(keyword_table)
(keyword_tables)
(keyword_key)
(keyword_references)
(keyword_foreign)
(keyword_constraint)
(keyword_force)
(keyword_use)
(keyword_include)
(keyword_for)
(keyword_if)
(keyword_exists)
(keyword_column)
(keyword_columns)
(keyword_cross)
(keyword_lateral)
(keyword_natural)
(keyword_alter)
(keyword_drop)
(keyword_add)
(keyword_view)
(keyword_end)
(keyword_is)
(keyword_using)
(keyword_between)
(keyword_window)
(keyword_no)
(keyword_data)
(keyword_type)
(keyword_rename)
(keyword_to)
(keyword_schema)
(keyword_owner)
(keyword_authorization)
(keyword_all)
(keyword_any)
(keyword_some)
(keyword_returning)
(keyword_begin)
(keyword_commit)
(keyword_rollback)
(keyword_transaction)
(keyword_only)
(keyword_like)
(keyword_similar)
(keyword_over)
(keyword_change)
(keyword_modify)
(keyword_after)
(keyword_before)
(keyword_range)
(keyword_rows)
(keyword_groups)
(keyword_exclude)
(keyword_current)
(keyword_ties)
(keyword_others)
(keyword_zerofill)
(keyword_format)
(keyword_fields)
(keyword_row)
(keyword_sort)
(keyword_compute)
(keyword_comment)
(keyword_location)
(keyword_cached)
(keyword_uncached)
(keyword_lines)
(keyword_stored)
(keyword_virtual)
(keyword_partitioned)
(keyword_analyze)
(keyword_explain)
(keyword_verbose)
(keyword_truncate)
(keyword_rewrite)
(keyword_optimize)
(keyword_vacuum)
(keyword_cache)
(keyword_language)
(keyword_called)
(keyword_conflict)
(keyword_declare)
(keyword_filter)
(keyword_function)
(keyword_input)
(keyword_name)
(keyword_oid)
(keyword_oids)
(keyword_precision)
(keyword_regclass)
(keyword_regnamespace)
(keyword_regproc)
(keyword_regtype)
(keyword_restricted)
(keyword_return)
(keyword_returns)
(keyword_separator)
(keyword_setof)
(keyword_stable)
(keyword_support)
(keyword_tblproperties)
(keyword_trigger)
(keyword_unsafe)
(keyword_admin)
(keyword_connection)
(keyword_cycle)
(keyword_database)
(keyword_encrypted)
(keyword_increment)
(keyword_logged)
(keyword_none)
(keyword_owned)
(keyword_password)
(keyword_reset)
(keyword_role)
(keyword_sequence)
(keyword_start)
(keyword_restart)
(keyword_tablespace)
(keyword_split)
(keyword_tablets)
(keyword_until)
(keyword_user)
(keyword_valid)
(keyword_action)
(keyword_definer)
(keyword_invoker)
(keyword_security)
(keyword_extension)
(keyword_version)
(keyword_out)
(keyword_inout)
(keyword_variadic)
(keyword_ordinality)
(keyword_session)
(keyword_isolation)
(keyword_level)
(keyword_serializable)
(keyword_repeatable)
(keyword_read)
(keyword_write)
(keyword_committed)
(keyword_uncommitted)
(keyword_deferrable)
(keyword_names)
(keyword_zone)
(keyword_immediate)
(keyword_deferred)
(keyword_constraints)
(keyword_snapshot)
(keyword_characteristics)
(keyword_off)
(keyword_follows)
(keyword_precedes)
(keyword_each)
(keyword_instead)
(keyword_of)
(keyword_initially)
(keyword_old)
(keyword_new)
(keyword_referencing)
(keyword_statement)
(keyword_execute)
(keyword_procedure)
(keyword_copy)
(keyword_delimiter)
(keyword_encoding)
(keyword_escape)
(keyword_force_not_null)
(keyword_force_null)
(keyword_force_quote)
(keyword_freeze)
(keyword_header)
(keyword_match)
(keyword_program)
(keyword_quote)
(keyword_stdin)
(keyword_extended)
(keyword_main)
(keyword_plain)
(keyword_storage)
(keyword_compression)
(keyword_duplicate)
] @keyword
(keyword_while) @keyword.repeat
[
(keyword_restrict)
(keyword_unbounded)
(keyword_unique)
(keyword_cascade)
(keyword_delayed)
(keyword_high_priority)
(keyword_low_priority)
(keyword_ignore)
(keyword_nothing)
(keyword_check)
(keyword_option)
(keyword_local)
(keyword_cascaded)
(keyword_wait)
(keyword_nowait)
(keyword_metadata)
(keyword_incremental)
(keyword_bin_pack)
(keyword_noscan)
(keyword_stats)
(keyword_statistics)
(keyword_maxvalue)
(keyword_minvalue)
] @keyword.modifier
[
(keyword_int)
(keyword_null)
(keyword_boolean)
(keyword_binary)
(keyword_varbinary)
(keyword_image)
(keyword_bit)
(keyword_inet)
(keyword_character)
(keyword_smallserial)
(keyword_serial)
(keyword_bigserial)
(keyword_smallint)
(keyword_mediumint)
(keyword_bigint)
(keyword_tinyint)
(keyword_decimal)
(keyword_float)
(keyword_double)
(keyword_numeric)
(keyword_real)
(double)
(keyword_money)
(keyword_smallmoney)
(keyword_char)
(keyword_nchar)
(keyword_varchar)
(keyword_nvarchar)
(keyword_varying)
(keyword_text)
(keyword_string)
(keyword_uuid)
(keyword_json)
(keyword_jsonb)
(keyword_xml)
(keyword_bytea)
(keyword_enum)
(keyword_date)
(keyword_datetime)
(keyword_time)
(keyword_datetime2)
(keyword_datetimeoffset)
(keyword_smalldatetime)
(keyword_timestamp)
(keyword_timestamptz)
(keyword_geometry)
(keyword_geography)
(keyword_box2d)
(keyword_box3d)
(keyword_interval)
] @type.builtin
[
(keyword_in)
(keyword_and)
(keyword_or)
(keyword_not)
(keyword_by)
(keyword_on)
(keyword_do)
(keyword_union)
(keyword_except)
(keyword_intersect)
] @keyword.operator
[
"+"
"-"
"*"
"/"
"%"
"^"
":="
"="
"<"
"<="
"!="
">="
">"
"<>"
(op_other)
(op_unary_other)
] @operator
[
"("
")"
] @punctuation.bracket
[
";"
","
"."
] @punctuation.delimiter
+32
View File
@@ -0,0 +1,32 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(select)
(cte)
(column_definitions)
(case)
(subquery)
(insert)
(when_clause)
] @indent.begin
(block
(keyword_begin)) @indent.begin
(column_definitions
")" @indent.branch)
(subquery
")" @indent.branch)
(cte
")" @indent.branch)
[
(keyword_end)
(keyword_values)
(keyword_into)
] @indent.branch
(keyword_end) @indent.end
+8
View File
@@ -0,0 +1,8 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((comment) @injection.content
(#set! injection.language "comment"))
((marginalia) @injection.content
(#set! injection.language "comment"))
+15
View File
@@ -0,0 +1,15 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: html
[
(if_statement)
(else_if_block)
(else_block)
(each_statement)
(await_statement)
(then_block)
(catch_block)
(key_statement)
(snippet_statement)
] @fold
+45
View File
@@ -0,0 +1,45 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: html
(raw_text) @none
[
"as"
"key"
"html"
"snippet"
"render"
] @keyword
"const" @keyword.modifier
[
"if"
"else if"
"else"
"then"
] @keyword.conditional
"each" @keyword.repeat
[
"await"
"then"
] @keyword.coroutine
"catch" @keyword.exception
"debug" @keyword.debug
[
"{"
"}"
] @punctuation.bracket
[
"#"
":"
"/"
"@"
] @tag.delimiter
+36
View File
@@ -0,0 +1,36 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: html
[
(if_statement)
(each_statement)
(await_statement)
(key_statement)
(snippet_statement)
] @indent.begin
(if_end
"}" @indent.end)
(each_end
"}" @indent.end)
(await_end
"}" @indent.end)
(key_end
"}" @indent.end)
(snippet_end
"}" @indent.end)
[
(if_end)
(else_if_block)
(else_block)
(each_end)
(await_end)
(key_end)
(snippet_end)
] @indent.branch
+49
View File
@@ -0,0 +1,49 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: html_tags
((style_element
(start_tag
(attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @_lang)))
(raw_text) @injection.content)
(#eq? @_attr "lang")
(#any-of? @_lang "scss" "postcss" "less")
(#set! injection.language "scss"))
((svelte_raw_text) @injection.content
(#set! injection.language "javascript"))
((script_element
(start_tag
(attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @_lang)))
(raw_text) @injection.content)
(#eq? @_attr "lang")
(#any-of? @_lang "ts" "typescript")
(#set! injection.language "typescript"))
((script_element
(start_tag
(attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @_lang)))
(raw_text) @injection.content)
(#eq? @_attr "lang")
(#any-of? @_lang "js" "javascript")
(#set! injection.language "javascript"))
((element
(start_tag
(attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @injection.language)))
(text) @injection.content)
(#eq? @_attr "lang")
(#eq? @injection.language "pug"))
+3
View File
@@ -0,0 +1,3 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: html
+10
View File
@@ -0,0 +1,10 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: ecma
[
(interface_declaration)
(internal_module)
(type_alias_declaration)
(enum_declaration)
] @fold
+210
View File
@@ -0,0 +1,210 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: ecma
"require" @keyword.import
(import_require_clause
source: (string) @string.special.url)
[
"declare"
"implements"
"type"
"override"
"module"
"asserts"
"infer"
"is"
"using"
] @keyword
[
"namespace"
"interface"
"enum"
] @keyword.type
[
"keyof"
"satisfies"
] @keyword.operator
(as_expression
"as" @keyword.operator)
(mapped_type_clause
"as" @keyword.operator)
[
"abstract"
"private"
"protected"
"public"
"readonly"
] @keyword.modifier
; types
(type_identifier) @type
(predefined_type) @type.builtin
(import_statement
"type"
(import_clause
(named_imports
(import_specifier
name: (identifier) @type))))
(template_literal_type) @string
(non_null_expression
"!" @operator)
; punctuation
(type_arguments
[
"<"
">"
] @punctuation.bracket)
(type_parameters
[
"<"
">"
] @punctuation.bracket)
(object_type
[
"{|"
"|}"
] @punctuation.bracket)
(union_type
"|" @punctuation.delimiter)
(intersection_type
"&" @punctuation.delimiter)
(type_annotation
":" @punctuation.delimiter)
(type_predicate_annotation
":" @punctuation.delimiter)
(index_signature
":" @punctuation.delimiter)
(omitting_type_annotation
"-?:" @punctuation.delimiter)
(adding_type_annotation
"+?:" @punctuation.delimiter)
(opting_type_annotation
"?:" @punctuation.delimiter)
"?." @punctuation.delimiter
(abstract_method_signature
"?" @punctuation.special)
(method_signature
"?" @punctuation.special)
(method_definition
"?" @punctuation.special)
(property_signature
"?" @punctuation.special)
(optional_parameter
"?" @punctuation.special)
(optional_type
"?" @punctuation.special)
(public_field_definition
[
"?"
"!"
] @punctuation.special)
(flow_maybe_type
"?" @punctuation.special)
(template_type
[
"${"
"}"
] @punctuation.special)
(conditional_type
[
"?"
":"
] @keyword.conditional.ternary)
; Parameters
(required_parameter
pattern: (identifier) @variable.parameter)
(optional_parameter
pattern: (identifier) @variable.parameter)
(required_parameter
(rest_pattern
(identifier) @variable.parameter))
; ({ a }) => null
(required_parameter
(object_pattern
(shorthand_property_identifier_pattern) @variable.parameter))
; ({ a = b }) => null
(required_parameter
(object_pattern
(object_assignment_pattern
(shorthand_property_identifier_pattern) @variable.parameter)))
; ({ a: b }) => null
(required_parameter
(object_pattern
(pair_pattern
value: (identifier) @variable.parameter)))
; ([ a ]) => null
(required_parameter
(array_pattern
(identifier) @variable.parameter))
; a => null
(arrow_function
parameter: (identifier) @variable.parameter)
; global declaration
(ambient_declaration
"global" @module)
; function signatures
(ambient_declaration
(function_signature
name: (identifier) @function))
; method signatures
(method_signature
name: (_) @function.method)
(abstract_method_signature
name: (property_identifier) @function.method)
; property signatures
(property_signature
name: (property_identifier) @function.method
type: (type_annotation
[
(union_type
(parenthesized_type
(function_type)))
(function_type)
]))
+9
View File
@@ -0,0 +1,9 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: ecma
[
(enum_declaration)
(interface_declaration)
(object_type)
] @indent.begin
+30
View File
@@ -0,0 +1,30 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: ecma
; styled.div<{}>`<css>`
(call_expression
function: (non_null_expression
(instantiation_expression
(member_expression
object: (identifier) @_name
(#eq? @_name "styled")
property: (property_identifier))
type_arguments: (type_arguments)))
arguments: ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled")))
; styled.div<T>`<css>`
(binary_expression
left: (binary_expression
left: (member_expression
object: (identifier) @_name
(#eq? @_name "styled")
property: (property_identifier))
right: (identifier))
right: (template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled"))
+33
View File
@@ -0,0 +1,33 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; inherits: ecma
(required_parameter
(identifier) @local.definition)
(optional_parameter
(identifier) @local.definition)
; x => x
(arrow_function
parameter: (identifier) @local.definition.parameter)
; ({ a }) => null
(required_parameter
(object_pattern
(shorthand_property_identifier_pattern) @local.definition.parameter))
; ({ a: b }) => null
(required_parameter
(object_pattern
(pair_pattern
value: (identifier) @local.definition.parameter)))
; ([ a ]) => null
(required_parameter
(array_pattern
(identifier) @local.definition.parameter))
(required_parameter
(rest_pattern
(identifier) @local.definition.parameter))
+8
View File
@@ -0,0 +1,8 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(element)
(doctypedecl)
(Comment)
] @fold
+201
View File
@@ -0,0 +1,201 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; XML declaration
(XMLDecl
"xml" @keyword.directive)
(XMLDecl
[
"version"
"encoding"
"standalone"
] @tag.attribute)
(XMLDecl
(EncName) @string.special)
(XMLDecl
(VersionNum) @number)
(XMLDecl
[
"yes"
"no"
] @boolean)
; Processing instructions
(PI) @keyword.directive
; Element declaration
(elementdecl
"ELEMENT" @keyword.directive.define
(Name) @tag)
(contentspec
(_
(Name) @tag.attribute))
"#PCDATA" @type.builtin
[
"EMPTY"
"ANY"
] @keyword.modifier
[
"*"
"?"
"+"
] @character.special
; Entity declaration
(GEDecl
"ENTITY" @keyword.directive.define
(Name) @constant)
(GEDecl
(EntityValue) @string)
(NDataDecl
"NDATA" @keyword
(Name) @label)
; Parsed entity declaration
(PEDecl
"ENTITY" @keyword.directive.define
"%" @operator
(Name) @function.macro)
(PEDecl
(EntityValue) @string)
; Notation declaration
(NotationDecl
"NOTATION" @keyword.directive
(Name) @label)
; Attlist declaration
(AttlistDecl
"ATTLIST" @keyword.directive.define
(Name) @tag)
(AttDef
(Name) @tag.attribute)
(AttDef
(Enumeration
(Nmtoken) @string))
[
(StringType)
(TokenizedType)
] @type.builtin
(NotationType
"NOTATION" @type.builtin)
[
"#REQUIRED"
"#IMPLIED"
"#FIXED"
] @attribute
; Entities
(EntityRef) @constant
((EntityRef) @constant.builtin
(#any-of? @constant.builtin "&amp;" "&lt;" "&gt;" "&quot;" "&apos;"))
(CharRef) @character
(PEReference) @function.macro
; External references
[
"PUBLIC"
"SYSTEM"
] @keyword
(PubidLiteral) @string.special
(SystemLiteral
(URI) @string.special.url)
; Processing instructions
(XmlModelPI
"xml-model" @keyword.directive)
(StyleSheetPI
"xml-stylesheet" @keyword.directive)
(PseudoAtt
(Name) @tag.attribute)
(PseudoAtt
(PseudoAttValue) @string)
; Doctype declaration
(doctypedecl
"DOCTYPE" @keyword.directive.define)
(doctypedecl
(Name) @type.definition)
; Tags
(STag
(Name) @tag)
(ETag
(Name) @tag)
(EmptyElemTag
(Name) @tag)
; Attributes
(Attribute
(Name) @tag.attribute)
(Attribute
(AttValue) @string)
; Delimiters & punctuation
[
"<?"
"?>"
"<"
">"
"</"
"/>"
"<!"
"]]>"
] @tag.delimiter
[
"("
")"
"["
"]"
] @punctuation.bracket
[
"\""
"'"
] @punctuation.delimiter
[
","
"|"
"="
] @operator
; Text
(CharData) @none @spell
(CDSect
(CDStart) @module
(CData) @markup.raw
"]]>" @module)
; Misc
(Comment) @comment @spell
+19
View File
@@ -0,0 +1,19 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(element) @indent.begin
[
(Attribute)
(AttlistDecl)
(contentspec)
] @indent.align
(ETag) @indent.branch
(doctypedecl) @indent.ignore
[
(Comment)
(ERROR)
] @indent.auto
+35
View File
@@ -0,0 +1,35 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
((Comment) @injection.content
(#set! injection.language "comment"))
; SVG style
((element
(STag
(Name) @_name)
(content) @injection.content)
(#eq? @_name "style")
(#set! injection.combined)
(#set! injection.include-children)
(#set! injection.language "css"))
; SVG script
((element
(STag
(Name) @_name)
(content) @injection.content)
(#eq? @_name "script")
(#set! injection.combined)
(#set! injection.include-children)
(#set! injection.language "javascript"))
; phpMyAdmin dump
((element
(STag
(Name) @_name)
(content) @injection.content)
(#eq? @_name "pma:table")
(#set! injection.combined)
(#set! injection.include-children)
(#set! injection.language "sql"))
+38
View File
@@ -0,0 +1,38 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
; tags
(elementdecl
(Name) @local.definition.type)
(elementdecl
(contentspec
(children
(Name) @local.reference)))
(AttlistDecl
.
(Name) @local.reference)
(STag
(Name) @local.reference)
(ETag
(Name) @local.reference)
(EmptyElemTag
(Name) @local.reference)
; attributes
(AttDef
(Name) @local.definition.field)
(Attribute
(Name) @local.reference)
; entities
(GEDecl
(Name) @local.definition.macro)
(EntityRef
(Name) @local.reference)
+7
View File
@@ -0,0 +1,7 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
[
(block_mapping_pair)
(block_sequence_item)
] @fold
+102
View File
@@ -0,0 +1,102 @@
; SPDX-License-Identifier: Apache-2.0
; Source: nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter)
(boolean_scalar) @boolean
(null_scalar) @constant.builtin
(double_quote_scalar) @string
(single_quote_scalar) @string
((block_scalar) @string
(#set! priority 99))
(string_scalar) @string
(escape_sequence) @string.escape
(integer_scalar) @number
(float_scalar) @number
(comment) @comment @spell
[
(anchor_name)
(alias_name)
] @label
(tag) @type
[
(yaml_directive)
(tag_directive)
(reserved_directive)
] @keyword.directive
(block_mapping_pair
key: (flow_node
[
(double_quote_scalar)
(single_quote_scalar)
] @property))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar) @property)))
(flow_mapping
(_
key: (flow_node
[
(double_quote_scalar)
(single_quote_scalar)
] @property)))
(flow_mapping
(_
key: (flow_node
(plain_scalar
(string_scalar) @property))))
[
","
"-"
":"
">"
"?"
"|"
] @punctuation.delimiter
[
"["
"]"
"{"
"}"
] @punctuation.bracket
[
"*"
"&"
"---"
"..."
] @punctuation.special
; help deal with for yaml's norway problem https://www.bram.us/2022/01/11/yaml-the-norway-problem/
; only using `true` and `false`, since Treesitter parser targets YAML spec 1.2 https://github.com/nvim-treesitter/nvim-treesitter/pull/7512#issuecomment-2565397302
(block_mapping_pair
value: (block_node
(block_sequence
(block_sequence_item
(flow_node
(plain_scalar
(string_scalar) @boolean
(#any-of? @boolean "TRUE" "FALSE" "True" "False")))))))
(block_mapping_pair
value: (flow_node
(plain_scalar
(string_scalar) @boolean
(#any-of? @boolean "TRUE" "FALSE" "True" "False"))))

Some files were not shown because too many files have changed in this diff Show More