ixru / nvim-markdown

Markdown Vim Mode
http://plasticboy.com/markdown-vim-mode/
88 stars 11 forks source link

(Feature Request) Close TOC Location List on select #24

Open jrebs opened 2 months ago

jrebs commented 2 months ago

Hi, I'd post this as a discussion if they were enabled on this repo, but they aren't. I was hoping that it would be possible to add a configuration option to have he TOC location list automatically close when I hit enter on a section item in that list, popping me back to the markdown file at the selected section header. I tried digging around in the plugin source to see how that might be possible so I could contribute a patch myself, but I don't really know the first thing about plugin development for vim. Any chance of seeing this feature added?

ixru commented 1 month ago

Yes I see how this could be useful. There's the other usecase of discovery too though, where you want to keep it open to jump around. Maybe even keep the cursor in it when you jump, which it doesn't do currently. I think something like the 'gO' binding from vim docs could be nice. Then you do the keybind if you want the quick jump that closes the window, and :Toc if you want it to stay open. example using treesitter for implementation maybe

You can do autocmd FileType qf nmap <buffer> <cr> <cr>:lcl<cr> if you want a quick fix, but it will mess with all loclist buffers. If you want to implement it, it only involves making a gO keymap that calls the toc function and adds the same keymap as the autocmd.