Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(treesitter): nvim-treesitter crashes - #3404

Open
KorigamiK wants to merge 1 commit into
NvChad:v2.5from
KorigamiK:fix-treesitter-main-loading
Open

fix(treesitter): nvim-treesitter crashes#3404
KorigamiK wants to merge 1 commit into
NvChad:v2.5from
KorigamiK:fix-treesitter-main-loading

Conversation

@KorigamiK

Copy link
Copy Markdown
Contributor

nvim-treesitter main is now an incompatible rewrite and explicitly does not support lazy-loading. NvChad already migrated partially, but the plugin spec still lazy-loads treesitter and still references removed legacy commands.

also made treesitter loaded eagerly, which helps a lot in stability of the editor experience.

Copilot AI review requested due to automatic review settings May 1, 2026 17:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates NvChad’s nvim-treesitter integration to accommodate the upstream rewrite (which is incompatible with lazy-loading and removed legacy commands), aiming to prevent editor crashes and improve stability.

Changes:

  • Switch nvim-treesitter to eager loading (lazy = false) and replace legacy cmd/event/build usage with a Lua build function.
  • Add a config hook intended to apply install_dir.
  • Update the custom :TSInstallAll command to use the new install API with summary = true and add a command description.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lua/nvchad/plugins/init.lua Makes Treesitter eager and adds new build/config logic to install/update parsers.
lua/nvchad/autocmds.lua Updates :TSInstallAll to install configured parsers using the new API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +162 to +170
local spec = require("lazy.core.config").plugins["nvim-treesitter"]
local opts = type(spec.opts) == "table" and spec.opts or {}

if opts.install_dir then
ts.setup { install_dir = opts.install_dir }
end

if opts.ensure_installed then
ts.install(opts.ensure_installed, { summary = true }):wait(300000)

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spec.opts for this plugin is configured as a function (see opts = function() ... end below), so type(spec.opts) == "table" will be false and opts becomes {}. That means opts.install_dir / opts.ensure_installed are never applied during build, so no parsers get installed/updated as intended. Consider resolving opts when it’s a function (e.g., call it) and falling back to {} only when nil/invalid.

Copilot uses AI. Check for mistakes.
return require "nvchad.configs.treesitter"
end,
config = function(_, opts)
require("nvim-treesitter").setup { install_dir = opts.install_dir }

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining config here overrides lazy.nvim’s default behavior of calling the plugin’s setup with the full opts table. As written, only install_dir is passed to setup, so other opts (e.g. ensure_installed from nvchad.configs.treesitter) are ignored at runtime. Adjust config to apply the full opts (or merge install_dir into opts before calling setup).

Suggested change
require("nvim-treesitter").setup { install_dir = opts.install_dir }
require("nvim-treesitter").setup(opts)

Copilot uses AI. Check for mistakes.
Comment thread lua/nvchad/autocmds.lua
Comment on lines 39 to +44
local spec = require("lazy.core.config").plugins["nvim-treesitter"]
local opts = type(spec.opts) == "table" and spec.opts or {}
require("nvim-treesitter").install(opts.ensure_installed)
end, {})

if opts.ensure_installed then
require("nvim-treesitter").install(opts.ensure_installed, { summary = true })
end

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as in the plugin spec: spec.opts is a function in this repo, so type(spec.opts) == "table" results in opts = {} and opts.ensure_installed is always nil. This makes :TSInstallAll a no-op. Resolve spec.opts when it’s a function (call it) before reading ensure_installed.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants