aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/check-queries.lua
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2024-03-03 11:00:11 +0100
committerGitHub <noreply@github.com>2024-03-03 11:00:11 +0100
commit99ddf573531c4dbe53f743ecbc1595af5eb1d32f (patch)
treebb70e8d72e309554c50aee3807c51f2a0433cbfe /scripts/check-queries.lua
parentci: teach bot about conventional commits (diff)
downloadnvim-treesitter-99ddf573531c4dbe53f743ecbc1595af5eb1d32f.tar
nvim-treesitter-99ddf573531c4dbe53f743ecbc1595af5eb1d32f.tar.gz
nvim-treesitter-99ddf573531c4dbe53f743ecbc1595af5eb1d32f.tar.bz2
nvim-treesitter-99ddf573531c4dbe53f743ecbc1595af5eb1d32f.tar.lz
nvim-treesitter-99ddf573531c4dbe53f743ecbc1595af5eb1d32f.tar.xz
nvim-treesitter-99ddf573531c4dbe53f743ecbc1595af5eb1d32f.tar.zst
nvim-treesitter-99ddf573531c4dbe53f743ecbc1595af5eb1d32f.zip
feat(highlights)!: enforce documented captures (#6232)
Problem: Allowing undocumented "secret" (sub)captures makes it harder to write comprehensive colorschemes and catch inconsistent captures. Solution: Only allow captures listed in CONTRIBUTING.md. Add useful (cross-language) subcaptures and drop language-specific or too niche ones. Follow-up: Adding further `*.builtin` captures and changing queries to use them. Language-specific subcaptures should instead be added in user config or a custom language plugin.
Diffstat (limited to 'scripts/check-queries.lua')
-rwxr-xr-xscripts/check-queries.lua14
1 files changed, 2 insertions, 12 deletions
diff --git a/scripts/check-queries.lua b/scripts/check-queries.lua
index 5e83bdcad..f3b45ea1a 100755
--- a/scripts/check-queries.lua
+++ b/scripts/check-queries.lua
@@ -1,4 +1,5 @@
#!/usr/bin/env -S nvim -l
+vim.opt.rtp:prepend "./"
-- Equivalent to print(), but this will ensure consistent output regardless of
-- operating system.
@@ -35,15 +36,6 @@ local function extract_captures()
return captures
end
-local function list_any(list, predicate)
- for _, v in pairs(list) do
- if predicate(v) then
- return true
- end
- end
- return false
-end
-
local function do_check()
local timings = {}
local queries = require "nvim-treesitter.query"
@@ -72,9 +64,7 @@ local function do_check()
for _, capture in ipairs(query.captures) do
local is_valid = (
vim.startswith(capture, "_") -- Helpers.
- or list_any(captures[query_type], function(documented_capture)
- return vim.startswith(capture, documented_capture)
- end)
+ or vim.tbl_contains(captures[query_type], capture)
)
if not is_valid then
local error = string.format("(x) Invalid capture @%s in %s for %s.", capture, query_type, lang)