feat: improve quickfixlist window

This commit is contained in:
2025-10-16 03:33:32 +02:00
parent 4102d8dd21
commit 010d2f096e
4 changed files with 118 additions and 2 deletions
+39
View File
@@ -1,3 +1,42 @@
vim.fn.sign_define("QfError", { text = "E", texthl = "DiagnosticError" })
vim.fn.sign_define("QfWarn", { text = "W", texthl = "DiagnosticWarn" })
vim.fn.sign_define("QfInfo", { text = "I", texthl = "DiagnosticInfo" })
vim.fn.sign_define("QfNote", { text = "N", texthl = "DiagnosticHint" })
vim.api.nvim_create_autocmd("FileType", {
desc = "Add signs to quickfix entries",
pattern = "qf",
callback = function(event)
vim.fn.sign_unplace("quickfix_signs")
local qflist = vim.fn.getqflist()
require("log").debug(vim.inspect(qflist))
for i, item in ipairs(qflist) do
if item.valid == 1 then
local sign_name = nil
if item.type == "E" then
sign_name = "QfError"
elseif item.type == "W" then
sign_name = "QfWarn"
elseif item.type == "I" then
sign_name = "QfInfo"
elseif item.type == "N" then
sign_name = "QfNote"
end
if sign_name then
vim.fn.sign_place(
0,
"quickfix_signs",
sign_name,
event.buf,
{ lnum = i }
)
end
end
end
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "help",
callback = function()
+3
View File
@@ -146,6 +146,9 @@ vim.keymap.set("n", "<Leader>r", function()
end
end)
vim.keymap.set("n", "]c", ":cn<CR>")
vim.keymap.set("n", "[c", ":cp<CR>")
-- Default bindings that are good to know:
-- insert mode:
-- <C-T> - indent, see :h i_CTRL-T
+47 -2
View File
@@ -149,5 +149,50 @@ vim.opt.statusline = " %{expand('%:.')}%4( %m%) %{%v:lua._status_line_git()%} %=
.. " %{&filetype} %-6.6{&fileencoding}"
.. " %-4.4{&fileformat} %4.4(%p%%%)%6.6l:%-3.3v"
vim.cmd("syntax on")
vim.cmd("filetype plugin indent on")
function _G._quickfix_text_func(info)
local items
if info.quickfix == 1 then
items = vim.fn.getqflist({ id = info.id, items = 1 }).items
else
items = vim.fn.getloclist(info.winid, { id = info.id, items = 1 }).items
end
local lines = {}
for i = info.start_idx, info.end_idx do
local item = items[i]
local line = ""
local name = ""
if item.bufnr ~= 0 then
name = vim.fn.bufname(item.bufnr)
end
if vim.fn.strchars(name) == 0 then
name = " "
end
line = line .. name
if item.lnum > 0 then
line = line .. ":" .. item.lnum
if item.col > 0 then
line = line .. ":" .. item.col
end
line = line .. ": "
end
line = line .. item.text
table.insert(lines, line)
end
return lines
end
vim.cmd [[
syntax on
filetype plugin indent on
function! QuickfixTextFunc(info) abort
return v:lua._quickfix_text_func(a:info)
endfunction
set quickfixtextfunc=QuickfixTextFunc
]]