Skip to content

Commit a30acd3

Browse files
committed
fix(compat): support nvim 0.12 with targeted workarounds
nvim 0.12 injection parsing bug (languagetree nil node) affects: - treesitter-context: disable (no configurable workaround) - quickfile: disable (triggers built-in highlighter injection path) - rainbow-delimiters: force global strategy (local triggers is_in_node_range) - snacks indent.scope: disable (treesitter scope detection hits same bug) Re-enable when nvim 0.12.1 / upstream fixes land.
1 parent 130f041 commit a30acd3

3 files changed

Lines changed: 12 additions & 32 deletions

File tree

lua/modules/configs/editor/rainbow_delims.lua

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,16 @@
11
return function()
2-
---@param threshold number @Use global strategy if nr of lines exceeds this value
3-
local function init_strategy(threshold)
4-
return function()
5-
-- Disable on very large files
6-
local line_count = vim.api.nvim_buf_line_count(0)
7-
if line_count > 15000 then
8-
return nil
9-
end
10-
11-
-- Disable on parser error
12-
local errors = 200
13-
vim.treesitter.get_parser():for_each_tree(function(lt)
14-
if lt:root():has_error() and errors >= 0 then
15-
errors = errors - 1
16-
end
17-
end)
18-
if errors < 0 then
19-
return nil
20-
end
21-
22-
return line_count > threshold and require("rainbow-delimiters").strategy["global"]
23-
or require("rainbow-delimiters").strategy["local"]
24-
end
25-
end
2+
-- local strategy triggers vim.treesitter.is_in_node_range() which hits
3+
-- a nil node bug in nvim 0.12 injection parsing; use global only.
4+
local global = require("rainbow-delimiters").strategy["global"]
265

276
vim.g.rainbow_delimiters = {
287
strategy = {
29-
[""] = init_strategy(500),
30-
c = init_strategy(300),
31-
cpp = init_strategy(300),
32-
lua = init_strategy(500),
33-
vimdoc = init_strategy(300),
34-
vim = init_strategy(300),
8+
[""] = global,
9+
c = global,
10+
cpp = global,
11+
lua = global,
12+
vimdoc = global,
13+
vim = global,
3514
},
3615
query = {
3716
[""] = "rainbow-delimiters",

lua/modules/configs/ui/snacks.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ return function()
7474
duration = { step = 20, total = 300 },
7575
},
7676
scope = {
77-
enabled = true,
77+
enabled = false, -- nvim 0.12 injection parsing bug triggers via treesitter scope
7878
char = "",
7979
underline = false,
8080
},
@@ -127,7 +127,7 @@ return function()
127127
},
128128
},
129129
terminal = { enabled = true },
130-
quickfile = { enabled = true },
130+
quickfile = { enabled = false }, -- nvim 0.12 injection parsing bug via highlighter
131131
picker = {
132132
enabled = true,
133133
sources = {

lua/modules/plugins/editor.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ editor["nvim-treesitter/nvim-treesitter"] = {
152152
},
153153
{
154154
"nvim-treesitter/nvim-treesitter-context",
155+
enabled = false, -- nvim 0.12 injection parsing bug via parse(range, callback)
155156
config = require("editor.ts-context"),
156157
},
157158
{

0 commit comments

Comments
 (0)