RRethy / vim-illuminate

illuminate.vim - (Neo)Vim plugin for automatically highlighting other uses of the word under the cursor using either LSP, Tree-sitter, or regex matching.
2.12k stars 44 forks source link

[Feature Request] Jump back to previous position after moving to next/previous highlight by `CTRL-O` #109

Closed hmgle closed 1 year ago

hmgle commented 1 year ago

I know next_reference{reverse=true,wrap=true} will jump back to previous highlight, but like the other jump-motions, I'm used to using CTRL-O or '' to go to the older cursor position.

What about adding current position to jumplist before calling vim.api.nvim_win_set_cursor() to support this feature?

Ths patch is like this:

 local function move_cursor(row, col)
+    vim.cmd("normal! m'")
     if not paused_bufs[vim.api.nvim_get_current_buf()] then
         augroup(vim.api.nvim_get_current_buf(), function()
             vim.api.nvim_win_set_cursor(0, {row, col})