diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 3e3829d1..031e7054 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -94,8 +94,21 @@ map("n", "l", "Lazy", { desc = "Lazy" }) -- new file map("n", "fn", "enew", { desc = "New File" }) -map("n", "xl", "lopen", { desc = "Location List" }) -map("n", "xq", "copen", { desc = "Quickfix List" }) +-- location list +map("n", "xl", function() + local success, err = pcall(vim.fn.getloclist(0, { winid = 0 }).winid ~= 0 and vim.cmd.lclose or vim.cmd.lopen) + if not success and err then + vim.notify(err, vim.log.levels.ERROR) + end +end, { desc = "Location List" }) + +-- quickfix list +map("n", "xq", function() + local success, err = pcall(vim.fn.getqflist({ winid = 0 }).winid ~= 0 and vim.cmd.cclose or vim.cmd.copen) + if not success and err then + vim.notify(err, vim.log.levels.ERROR) + end +end, { desc = "Quickfix List" }) map("n", "[q", vim.cmd.cprev, { desc = "Previous Quickfix" }) map("n", "]q", vim.cmd.cnext, { desc = "Next Quickfix" })