- commit
- 4e0ca35
- parent
- eeaedb7
- author
- Eric Bower
- date
- 2025-09-23 08:03:25 -0400 EDT
chore(nvim): more Qf work! handles more cmds <leader>f now opens fish term
1 files changed,
+43,
-25
+43,
-25
1@@ -9,6 +9,7 @@
2 - use default colorschemes
3 - plugins must be integral to workflow
4 ]]
5+local cqf
6 local o = vim.opt
7 o.tabstop = 2
8 o.shiftwidth = 2
9@@ -39,30 +40,6 @@ vim.diagnostic.config({
10 severity_sort = true,
11 })
12
13-local function cqf(cmd, jump)
14- jump = jump or false
15- if cmd == nil then
16- return
17- end
18-
19- local files = vim.fn.systemlist(cmd)
20- if #files == 0 then
21- vim.notify("no files found: " .. cmd)
22- return
23- end
24- if jump and #files == 1 then
25- vim.cmd(string.format("edit %s", files[1]))
26- return
27- end
28-
29- vim.fn.setqflist({}, "r", {
30- title = cmd,
31- lines = files,
32- efm = "%f",
33- })
34- vim.cmd("copen")
35-end
36-
37 vim.api.nvim_create_user_command("Qf", function(opts)
38 cqf(opts.args, false)
39 end, { nargs = "+", desc = "convert command to quickfix" })
40@@ -76,6 +53,7 @@ map("n", "<C-j>", "<cmd>wincmd j<cr>", opts)
41 map("n", "<C-h>", "<cmd>wincmd h<cr>", opts)
42 map("n", "<C-l>", "<cmd>wincmd l<cr>", opts)
43 map("n", "<leader>t", "<cmd>bd!<cr>", opts)
44+map("n", "<leader>f", "<cmd>term fish<cr>", opts)
45 map("n", "<leader>e", vim.diagnostic.open_float, opts)
46 map("n", "<leader>r", function()
47 local loclist_win = vim.fn.getloclist(0, { winid = 0 }).winid
48@@ -137,7 +115,10 @@ local function setup_lsp()
49 map("n", "grd", vim.lsp.buf.definition, bufopts)
50 map("i", "<C-k>", vim.lsp.completion.get, bufopts) -- open completion menu manually
51 local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
52- vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
53+ local methods = vim.lsp.protocol.Methods
54+ if client:supports_method(methods.textDocument_completion) then
55+ vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
56+ end
57 end,
58 })
59 end
60@@ -211,3 +192,40 @@ setup_lsp()
61 require("treesitter-context").setup({ max_lines = 3, separator = ">", mode = "topline" })
62 require("neoscroll").setup({ duration_multiplier = 0.3 })
63 require("gitlinker").setup()
64+
65+---Attempts to convert a command that returns a list of filepaths into a quickfix.
66+---It assumes the filepaths are in the first column without spaces.
67+---@param cmd string The system command to run
68+---@param jump boolean Should we auto navigate to first entry?
69+function cqf(cmd, jump)
70+ jump = jump or false
71+ if cmd == nil then
72+ return
73+ end
74+
75+ local files = vim.fn.systemlist(cmd)
76+ local fz = {}
77+ for _, file in ipairs(files) do
78+ local word = file:match("%S+")
79+ if word then
80+ table.insert(fz, word .. ":1:1:" .. word)
81+ end
82+ end
83+
84+ if #fz == 0 then
85+ vim.notify("no files found: " .. cmd)
86+ return
87+ end
88+
89+ if jump and #fz == 1 then
90+ vim.cmd(string.format("edit %s", files[1]))
91+ return
92+ end
93+
94+ vim.fn.setqflist({}, "r", {
95+ title = cmd,
96+ lines = fz,
97+ efm = "%f:%l:%c:%m",
98+ })
99+ vim.cmd("copen")
100+end