repos / dotfiles

my dotfiles

commit
c630b21
parent
393cd74
author
Eric Bower
date
2025-09-26 22:13:49 -0400 EDT
refactor(nvim): buffer -> qf just not working for me

terminal buffers are "protected" buffers that don't get replaced from
the qf selection.  Instead it opens a split which I find frustrating for
my workflow.
1 files changed,  +3, -42
M dot_config/nvim/init.lua
+3, -42
 1@@ -11,7 +11,7 @@
 2     - plugins must be integral to workflow
 3 ]]
 4 local vim = vim -- suppress lsp warnings
 5-local cqf, bqf, toggle_qf
 6+local cqf, toggle_qf
 7 local o = vim.opt
 8 o.tabstop = 2
 9 o.shiftwidth = 2
10@@ -49,9 +49,7 @@ map("n", "<C-h>", "<cmd>wincmd h<cr>", opts)
11 map("n", "<C-l>", "<cmd>wincmd l<cr>", opts)
12 map("n", "<leader>t", "<cmd>bd!<cr>", opts)
13 map("n", "<leader>f", "<cmd>term fish<cr>", opts)
14-map("n", "<leader>b", function()
15-	bqf()
16-end)
17+map("n", "<leader>b", ":b ")
18 map({ "n", "v" }, "<leader>u", "<cmd>GitLink<cr>", opts)
19 map("n", "<leader>e", vim.diagnostic.open_float, opts)
20 map("n", "<leader>y", function() -- copy relative filepath to clipboard
21@@ -79,7 +77,7 @@ map("n", "<leader>g", function() -- grep entire project
22 	end)
23 end, opts)
24 map("n", "<leader>d", "<cmd>Qf git diff --name-only<cr>")
25-map("n", "<leader>s", ":Qfa rg --files | rg ") -- fuzzy match files into quickfix
26+map("n", "<leader>s", ":Qfa fd -t f | fzf -f ") -- fuzzy match files into quickfix
27 
28 local augroup = vim.api.nvim_create_augroup("erock.cfg", { clear = true })
29 local autocmd = vim.api.nvim_create_autocmd
30@@ -241,43 +239,6 @@ function cqf(args)
31 	vim.cmd("copen")
32 end
33 
34--- Converts the buffer list into a quickfix list.
35--- It also sorts buffers by recently used.
36-function bqf()
37-	local mru = {} -- file → 1-based index in v:oldfiles
38-	for i, f in ipairs(vim.v.oldfiles) do
39-		mru[vim.fn.fnamemodify(f, ":p")] = i
40-	end
41-
42-	local entries = {}
43-	for _, buf in ipairs(vim.api.nvim_list_bufs()) do
44-		local name = vim.api.nvim_buf_get_name(buf)
45-		if name ~= "" and vim.bo[buf].buflisted then
46-			-- use the MRU index (or a high number if never opened)
47-			local key = mru[vim.fn.fnamemodify(name, ":p")] or 999999
48-			table.insert(entries, { key = key, buf = buf, name = name })
49-		end
50-	end
51-
52-	-- sort by MRU index (smaller = more recent)
53-	table.sort(entries, function(a, b)
54-		return a.key < b.key
55-	end)
56-
57-	local qf = vim.tbl_map(function(e)
58-		return {
59-			bufnr = e.buf,
60-			lnum = 1,
61-			col = 1,
62-			text = vim.fn.fnamemodify(e.name, ":t"),
63-			valid = 1,
64-		}
65-	end, entries)
66-
67-	vim.fn.setqflist(qf)
68-	vim.cmd("copen")
69-end
70-
71 -- A simple toggle for quickfix.
72 -- Designed to be set to a shortcut.
73 function toggle_qf()