stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.72k stars 83 forks source link

feature request/tuning: cursor positioning when jumping #279

Closed emmanueltouzery closed 1 year ago

emmanueltouzery commented 1 year ago

when navigating using aerial, to jump to a symbol, aerial jumps at the beginning of the declaration of the symbol, not on the symbol itself. For instance, for class Symbol, the cursor will be at the beginning of class. For export function symbol(), the cursor will be at the start of the function keyword.

I'd prefer for the cursor to be at the start of the symbol... so class |Symbol and export function |symbol() -- to be clear, the cursor would be on top of the first letter of the symbol, not before it. The reason is that this enables further navigation using LSP. For instance, let's say I have a build error in a function, I use aerial to jump to the function declaration, now i'd like to use LSP to find the callers of the function. But my cursor is on the function keyword, not on the function name itself, and therefore the LSP "find references" doesn't work until I jump to the beginning of the next word, which is the function name.

It's totally a detail and a "comfort" issue.. but if possible, it would be a nice bonus. Otherwise aerial really is great, thank you for your work!

stevearc commented 1 year ago

I'm assuming that you're using the treesitter backend, because the LSP backend should already be doing basically this. I've added experimental support for this behavior in treesitter. You can enable it with this config option:

require("aerial").setup({
  treesitter = {
    experimental_selection_range = true,
  }
})
emmanueltouzery commented 1 year ago

thank you! you're correct, i'm using the treesitter backend.

It seems to me that it's working if I'm using the aerial sidebar, however it's not working when using the telescope interface. With the telescope interface, even with the experimental option, the cursor is still positioned at previous location instead of on the symbol :(

Thank you!

stevearc commented 1 year ago

Ah, easy fix. Try again!

emmanueltouzery commented 1 year ago

thank you! this seems to work now. I guess i'll close the issue, and reopen if i find a glitch. Since you named the option 'experimental', if you prefer to keep it open, reopen it of course...