folke / trouble.nvim

🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.
Apache License 2.0
5.11k stars 173 forks source link

bug: unable to open multiple trouble splits within same keymap #474

Closed rebelot closed 1 month ago

rebelot commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

latest

Operating system/version

macOS

Describe the bug

I'd like to open symbols and lsp modes at once in vertical splits on the right of the editor (as in screenshot), but it seems that window id is not updated during the execution of the keymap

Steps To Reproduce

vim.keymap.set("n", "<leader>xp", "<cmd>Trouble symbols toggle focus=true<CR><cmd>Trouble lsp toggle focus=false win.position=bottom win.relative=win win.size=.5<CR>")

however, lsp mode is always relative to the main window, and not to trouble symbols

Expected Behavior

two vertically stacked splits on the right of the window from where the command was issued

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/trouble.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
folke commented 1 month ago

That's working how it's supposed to work. The relative=win, is the main window that opened trouble. Use edgy.nvim to do what you want. You can check the LazyVim edgy config on how you can achieve this.