Skip to content

Commit

Permalink
feat(keymaps): toggle quickfix window
Browse files Browse the repository at this point in the history
Toggle quickfix window.
  • Loading branch information
twandylue committed Sep 25, 2023
1 parent a27471a commit 4d7e511
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,30 @@ local opts = {
silent = true,
}

local function toggle_qf()
local qf_exists = false
for _, win in pairs(vim.fn.getwininfo()) do
if win["quickfix"] == 1 then
qf_exists = true
break
end
end
if qf_exists == true then
vim.cmd("cclose")
return
end
if not vim.tbl_isempty(vim.fn.getqflist()) then
vim.cmd("copen")
end
end

map("n", "<ESC>", ":nohlsearch<CR>", opts)
map("n", "<leader>s", ":w<CR>", opts)
map("n", "<leader>q", ":q<CR>", opts)
map("n", "<leader>m", "`", opts)
map("n", "<leader>f", ":cw<CR>", opts)
map("n", "<leader>f", function()
toggle_qf()
end, opts)
map("n", "n", "nzzzv", opts)
map("n", "N", "Nzzzv", opts)
map("n", "<C-d>", "<C-d>zz", opts)
Expand Down

0 comments on commit 4d7e511

Please sign in to comment.