Skip to content

Commit

Permalink
quickfix list ergonomics
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjahn committed Feb 16, 2024
1 parent 9673c48 commit a940b49
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions config/nvim/lua/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,32 @@ vim.keymap.set('i', 'jj', '<ESC>', bufopts)

-- live substitution
vim.o.inccommand = "split"

-- Quickfix list toggle
local M = {}
M.toggle_qf = function()
local qf_exists = false

for _, win in pairs(vim.fn.getwininfo()) do
if win["quickfix"] == 1 then
qf_exists = true
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
vim.keymap.set("n", "qf", M.toggle_qf, bufopts)

-- Close quickfix menu after selecting choice
vim.api.nvim_create_autocmd(
"FileType", {
pattern = { "qf" },
command = [[nnoremap <buffer> <CR> <CR>:cclose<CR>]]
})

0 comments on commit a940b49

Please sign in to comment.