Neovim: No Crash Incremental Selection
Contents
When I use Neovim Treesitter incremental selection, it randomly crashes, but I cannot consistently reproduce it. I found some issues and complaints about this problem, but no solution. So I decided to write a blog post to document this issue and the solution.
related issues:
- https://www.reddit.com/r/neovim/comments/10wwkft/comment/j7qla2q/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
- https://github.com/neovim/neovim/issues/24336
- https://github.com/neovim/neovim/issues/25254
- https://www.reddit.com/r/neovim/comments/18dn4qt/treesitter_incremental_selection/
TL;DR
Paste this https://github.com/xiantang/nvim-conf/blob/7c0d6cbf6d9fd7b6a8960de887db1109332419bf/lua/plugins/treesitter.lua#L62-L132 into your Neovim configuration file.
Here is my Treesitter incremental selection configuration:
|
|
Sometimes when I use v to expand the selection, it crashes, resulting in a Segmentation fault, and I have the report:
|
|
But I have no idea how to fix it in the Neovim source code. After many updates to Neovim and Treesitter, the issue still exists. So I decided to disable the incremental selection feature and implement a new incremental selection feature myself.
|
|
And it works well; I can expand the selection with v, select the parent node with v, and restore the last selection with <BS>.
If many people have the same issue, I’m willing to create a new Treesitter plugin that lets you configure this alternative incremental selection in Treesitter configuration as shown below:
|
|
Author xiantang
LastMod 2025-12-15 (28330c37)