Skip to content

Commit 42d8ea9

Browse files
author
Venkata Subramani Renduchintala
committed
fix(treesitter): stop treesitter for markdown to fix nvim 0.12 injection crash
nvim 0.12 changed _apply_directives to pass TSNode[] instead of TSNode for captures. nvim-treesitter's set-lang-from-info-string! predicate calls node:range() on the array, crashing both the highlighter and vim-matchup. Stop treesitter for markdown via FileType autocmd and disable matchup's treesitter engine for markdown via vim.g.matchup_treesitter_disabled. Revert the ineffective nvim-treesitter module-level disable that was added in the previous commit.
1 parent fa79cb0 commit 42d8ea9

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

lua/autocmds.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ vim.filetype.add({
3434
},
3535
})
3636

37+
-- nvim-treesitter is incompatible with nvim 0.12's captures API for markdown
38+
-- injections (TSNode[] vs TSNode mismatch in set-lang-from-info-string!),
39+
-- causing crashes in both the highlighter and vim-matchup. Stop treesitter
40+
-- for markdown until upstream fixes the predicate handler.
41+
vim.api.nvim_create_autocmd("FileType", {
42+
pattern = "markdown",
43+
callback = function()
44+
vim.treesitter.stop()
45+
end,
46+
})
47+
3748
-- Disable automatic line breaks
3849
vim.api.nvim_create_autocmd("FileType", {
3950
pattern = "*",

lua/plugins/configs/matchup.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ return {
22
"andymass/vim-matchup",
33
config = function()
44
vim.g.matchup_matchparen_offscreen = { method = "popup" }
5+
-- disable matchup's treesitter engine for markdown (same nvim 0.12 incompatibility)
6+
vim.g.matchup_treesitter_disabled = { "markdown" }
57
end,
68
}

lua/plugins/configs/treesitter.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ return {
117117
-- enables vim-matchup integration
118118
enable = true,
119119
enable_quotes = true,
120-
-- markdown injections (bash/sh code blocks) trigger a nil-node crash
121-
-- in the treesitter injection layer; fall back to regex matching there
122-
disable = { "markdown" },
123120
},
124121
-- incremental_selection = {
125122
-- enable = true,

0 commit comments

Comments
 (0)