mirror of
https://github.com/neovim/neovim.git
synced 2026-04-27 17:54:10 +00:00
feat(lsp): respect 'switchbuf' for jump commands, drop reuse_win #38510
Problem: LSP jump operations such as `buf.definition`/`buf.type_definition` do not follow the 'switchbuf' option. Instead their behavior is controlled by `vim.lsp.LocationOpts.reuse_win`. When `reuse_win=true`, the effect is very similar to `set switchbuf=useopen`. Note that functions like `buf.definition` open the quickfix window when there are multiple results, and jumping between quickfix entries already follows 'switchbuf', so unifying the behavior is more intuitive. Solution: Follow the 'switchbuf' option and drop `reuse_win`. We can achieve this behavior by using :cfirst when the quickfix list has only one item, rather than customizing the jump logic as before.
This commit is contained in:
@@ -5326,7 +5326,8 @@ describe('LSP', function()
|
||||
n.feed(':vnew<CR>')
|
||||
api.nvim_win_set_buf(0, result.bufnr)
|
||||
api.nvim_win_set_cursor(0, { 3, 6 })
|
||||
n.feed(':=vim.lsp.buf.definition({ reuse_win = true })<CR>')
|
||||
n.feed(':set switchbuf=usetab<CR>')
|
||||
n.feed(':=vim.lsp.buf.definition()<CR>')
|
||||
eq(displayed_result_win, api.nvim_get_current_win())
|
||||
exec_lua(function()
|
||||
vim.lsp.get_client_by_id(result.client_id):stop()
|
||||
|
||||
Reference in New Issue
Block a user