Add autosizing whenever we open/close an edge panel, meaning we always

keep the relative width/height of the main windows
This commit is contained in:
Martin Larsson 2024-07-05 16:50:17 +02:00
parent 7c45912194
commit 7316bef23d
3 changed files with 65 additions and 12 deletions

View file

@ -1,25 +1,68 @@
local wm = require("window_management")
local is_trouble_window = false
local function setup_autosize_callback()
local auname = "TroubleWinEnter"
local augroup = vim.api.nvim_create_augroup(auname, { clear = true })
vim.api.nvim_create_autocmd("WinEnter", {
group = augroup,
callback = function()
if not is_trouble_window then
return
end
is_trouble_window = false
wm.autosize_windows()
end,
})
end
return {
"folke/trouble.nvim",
config = function()
require("trouble").setup({})
local trouble = require("trouble")
trouble.setup({})
setup_autosize_callback()
require("utils").add_keymaps({
n = {
["<leader>x"] = {
cmd = "<cmd>Trouble diagnostics toggle<cr>",
cmd = function()
is_trouble_window = true
trouble.toggle({
mode = "diagnostics",
focus = true,
})
end
},
["<leader>ls"] = {
cmd = "<cmd>Trouble symbols toggle focus=false<cr>",
cmd = function()
is_trouble_window = true
trouble.toggle({
mode = "symbols",
focus = true,
})
end
},
-- Stick with using the references feature fom lspsaga for now, might change later
-- ["<leader>cl"] = {
-- cmd = "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
-- },
["<leader>ll"] = {
cmd = "<cmd>Trouble loclist toggle<cr>",
cmd = function()
is_trouble_window = true
trouble.toggle({
mode = "loclist",
focus = true,
})
end
},
["<leader>lq"] = {
cmd = "<cmd>Trouble qflist toggle<cr>",
cmd = function()
is_trouble_window = true
trouble.toggle({
mode = "quickfix",
focus = true,
})
end
},
}
})