cshuaimin / ssr.nvim

Treesitter based structural search and replace plugin for Neovim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

better selection

max397574 opened this issue · comments

if would be really cool if you could make the selection better
I'm thinking about something like incremental selection from treesitter
perhaps I'm just doing something wrong but to me the selection seems kinda random

The placeholder text in SSR window need to be a complete treesitter node, if you selected part of a node, the placeholder text will be expanded to a full node. I guess that's why you feel selection random..

I use incremental selection from treesitter to select before opening SSR window, so the selection is always a complete node. I use keymaps like (LunarVim):

lvim.builtin.treesitter.incremental_selection = {
  enable = true,
  keymaps = {
    init_selection = "<A-h>",
    node_incremental = "<A-h>",
    node_decremental = "<A-l>",
  },
}

I believe adding incremental selection to SSR may not be a correct way, just use nvim-treesitter's.

didn't realize that you could even use this from visual mode

Oh I now know your feeling! If you only use it in normal mode, it will use the smallest node under cursor (:h tsnode:named_descendant_for_range), and that's very limiting.