Neovim: No Crash Incremental Selection
Contents
When I use neovim treesitter incremental selection, it randomly crashes, but I cannot stable reproduce it. And I found some issues and complaints about this issue, but no solution. So I decide to write a blog post to record 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.
this is my treesitter incremental selection configuration:
|
|
sometime when I use v
to expand the selection, it crashes, and it’s a Segmentation fault, and I have the report:
|
|
But I have no idea how to fix it in neovim source code. After many times I updated the neovim and treesitter, the issue still exists. So I decide to disable the incremental selection feature. And implement a new incremental selection feature by myself.
|
|
And it works well, and I can expand the selection by v
and select the parent node by v
and restore the last selection by <BS>
.
if there have many people have the same issue, im willing to create a new tressitter plugin that let you config this altrenative incremental selection in treesitter configuration like as below:
|
|
Author xiantang
LastMod 2024-07-11 (de02bad6)