From d13a904c3f10c4c1437254105b9310679a904dc9 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Thu, 15 Feb 2024 09:43:26 -0600 Subject: [PATCH] quick fix helpers --- lua/tools/quick-fix.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lua/tools/quick-fix.lua diff --git a/lua/tools/quick-fix.lua b/lua/tools/quick-fix.lua new file mode 100644 index 0000000..3f29271 --- /dev/null +++ b/lua/tools/quick-fix.lua @@ -0,0 +1,20 @@ +-- Function to remove item from quickfix list +function RemoveQFItem() + local curqfidx = vim.fn.line(".") - 1 + local qfall = vim.fn.getqflist() + table.remove(qfall, curqfidx + 1) -- Lua is 1-indexed + vim.fn.setqflist(qfall, "r") + vim.cmd(curqfidx .. "cfirst") + vim.cmd("copen") +end + +-- Command to call the function +vim.api.nvim_create_user_command("RemoveQFItem", RemoveQFItem, {}) + +-- Auto command to map 'dd' in quickfix window +vim.api.nvim_create_autocmd("FileType", { + pattern = "qf", + callback = function() + vim.keymap.set("n", "dd", RemoveQFItem, { buffer = true, silent = true }) + end, +})