diff options
author | Mathias Fussenegger <f.mathias@zignar.net> | 2024-10-24 10:22:38 +0200 |
---|---|---|
committer | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2024-10-24 13:43:49 +0200 |
commit | 3c51058d7611ef235a23ae77f994403480237700 (patch) | |
tree | 2cf0f427fbcfe5737536a9b8b627a692375a3133 /runtime/lua/vim/lsp/buf.lua | |
parent | 5c44c0240535272064bd4bb11364cb3a64d9b2cb (diff) | |
download | rneovim-3c51058d7611ef235a23ae77f994403480237700.tar.gz rneovim-3c51058d7611ef235a23ae77f994403480237700.tar.bz2 rneovim-3c51058d7611ef235a23ae77f994403480237700.zip |
fix(lsp): set tagstack on jump via goto methods
Follow up to https://github.com/neovim/neovim/pull/30877
Fixes https://github.com/neovim/neovim/issues/30926
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 80ba3c648f..1858095918 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -54,6 +54,9 @@ local function get_locations(method, opts) return end local win = api.nvim_get_current_win() + local from = vim.fn.getpos('.') + from[1] = bufnr + local tagname = vim.fn.expand('<cword>') local remaining = #clients ---@type vim.quickfix.entry[] @@ -89,6 +92,13 @@ local function get_locations(method, opts) if #all_items == 1 then local item = all_items[1] local b = item.bufnr or vim.fn.bufadd(item.filename) + + -- Save position in jumplist + vim.cmd("normal! m'") + -- Push a new item into tagstack + local tagstack = { { tagname = tagname, from = from } } + vim.fn.settagstack(vim.fn.win_getid(win), { items = tagstack }, 't') + vim.bo[b].buflisted = true local w = opts.reuse_win and vim.fn.win_findbuf(b)[1] or win api.nvim_win_set_buf(w, b) |