summaryrefslogtreecommitdiff
path: root/scripts/tests
diff options
context:
space:
mode:
authorSearidang Pa <dangsyncpa@gmail.com>2026-01-09 17:02:09 -0500
committerSearidang Pa <dangsyncpa@gmail.com>2026-01-09 17:02:09 -0500
commitec28aeca307da38fd7888bb0bce077e75da80b79 (patch)
treee635b35ca079ff663d4adb333a6062801238d9a6 /scripts/tests
parent91ea4cfd4a46d756152e9470abe495f4b178e818 (diff)
downloada4-ec28aeca307da38fd7888bb0bce077e75da80b79.tar.xz
a4-ec28aeca307da38fd7888bb0bce077e75da80b79.zip
pin nvim-treesitter in CI
CI now installs a fixed nvim-treesitter commit and minimal tests only require a small parser set, failing fast with a helpful error if parsers are missing.
Diffstat (limited to 'scripts/tests')
-rw-r--r--scripts/tests/minimal.vim45
1 files changed, 34 insertions, 11 deletions
diff --git a/scripts/tests/minimal.vim b/scripts/tests/minimal.vim
index a8d3d7d..928594b 100644
--- a/scripts/tests/minimal.vim
+++ b/scripts/tests/minimal.vim
@@ -21,18 +21,41 @@ runtime! plugin/plenary.vim
runtime! plugin/nvim-treesitter.lua
lua <<EOF
-local required_parsers = {
- 'c', 'cpp', 'go', 'lua', 'php', 'python', 'typescript', 'javascript', 'java', 'ruby', 'tsx', 'c_sharp', 'vue'
-}
-local installed_parsers = require'nvim-treesitter.info'.installed_parsers()
-local to_install = vim.tbl_filter(function(parser)
- return not vim.tbl_contains(installed_parsers, parser)
-end, required_parsers)
+local required_parsers = { "lua", "typescript", "go"}
+
+local function missing_parsers(parsers)
+ local missing = {}
+ local buf = vim.api.nvim_create_buf(false, true) -- false: no list, true: scratch buffer
+ for _, lang in ipairs(parsers) do
+ local ok = pcall(vim.treesitter.get_parser, buf, lang)
+ if not ok then
+ table.insert(missing, lang)
+ end
+ end
+ vim.api.nvim_buf_delete(buf, { force = true })
+ return missing
+end
+
+local to_install = missing_parsers(required_parsers)
if #to_install > 0 then
-- fixes 'pos_delta >= 0' error - https://github.com/nvim-lua/plenary.nvim/issues/52
- vim.cmd('set display=lastline')
- -- make "TSInstall*" available
- vim.cmd 'runtime! plugin/nvim-treesitter.vim'
- vim.cmd('TSInstallSync ' .. table.concat(to_install, ' '))
+ vim.cmd("set display=lastline")
+
+ -- Only attempt installation if nvim-treesitter provided the command.
+ if vim.fn.exists(":TSInstallSync") == 2 then
+ -- make "TSInstall*" available
+ vim.cmd("runtime! plugin/nvim-treesitter.vim")
+ vim.cmd("TSInstallSync " .. table.concat(to_install, " "))
+ end
+
+ -- Re-check and fail fast with a helpful message.
+ local still_missing = missing_parsers(required_parsers)
+ if #still_missing > 0 then
+ error(
+ "Missing Tree-sitter parsers: "
+ .. table.concat(still_missing, ", ")
+ .. "\nInstall them via :TSInstallSync <langs> or ensure nvim-treesitter is on runtimepath."
+ )
+ end
end
EOF