hedyhli / outline.nvim

Code outline sidebar powered by LSP. Significantly enhanced & refactored fork of symbols-outline.nvim.
https://sr.ht/~hedy/outline.nvim
MIT License
543 stars 15 forks source link

Same mapping to focus and open #71

Closed bdillahu closed 2 months ago

bdillahu commented 2 months ago

I expect this is my not knowing vim key mapping well enough, but is there a way to have the same keymap (leader-o for instance) open the Outline if it isn't open, and focus it if it is open?

Thanks!

bdillahu commented 2 months ago

Looks like mapping to

"<cmd>OutlineOpen<CR><cmd>OutlineFollow<CR>"

will pretty much work... using OutlineFocus doesn't at times...

hedyhli commented 2 months ago

Calling OutlineOpen and immediately OutlineFocusOutline should work. If you want your cursor to be set to the current symbol in the outline, you can call OutlineFollow right after. You can also substitute these commands with their Lua functions.

Kindly take a look at the detailed docs: https://github.com/hedyhli/outline.nvim#commands

I've pushed a fix to OutlineOpen that will also focus on the outline if the outline is already open. So now, you can just set your keybinding to OutlineOpen to do what you wanted. Optionally call OutlineFollow to set your cursor to the current symbol too.

hedyhli commented 2 months ago

using OutlineFocus doesn't at times...

OutlineFocus toggles focus between the code and the outline, as described in the docs :)

bdillahu commented 2 months ago

Good deal, thanks!