fix(qf): update quickfixtextfunc
This commit is contained in:
@@ -80,7 +80,7 @@ vim.opt.statusline = "%{expand('%:.')} %{%v:lua.require('git').status()%} %3(%m%
|
|||||||
.. " %{&filetype} %{&fileencoding} %{&fileformat}"
|
.. " %{&filetype} %{&fileencoding} %{&fileformat}"
|
||||||
.. " %4(%p%%%) %4l:%-3v"
|
.. " %4(%p%%%) %4l:%-3v"
|
||||||
|
|
||||||
function _G._quickfix_text_func(info)
|
function _G.quickfix_text_func(info)
|
||||||
local items
|
local items
|
||||||
if info.quickfix == 1 then
|
if info.quickfix == 1 then
|
||||||
items = vim.fn.getqflist({ id = info.id, items = 1 }).items
|
items = vim.fn.getqflist({ id = info.id, items = 1 }).items
|
||||||
@@ -97,7 +97,7 @@ function _G._quickfix_text_func(info)
|
|||||||
if item.bufnr ~= 0 then
|
if item.bufnr ~= 0 then
|
||||||
name = vim.fn.fnamemodify(vim.fn.bufname(item.bufnr), ":.")
|
name = vim.fn.fnamemodify(vim.fn.bufname(item.bufnr), ":.")
|
||||||
end
|
end
|
||||||
if vim.fn.strchars(name) == 0 then
|
if name == "" then
|
||||||
name = " "
|
name = " "
|
||||||
end
|
end
|
||||||
line = line .. name
|
line = line .. name
|
||||||
@@ -110,20 +110,17 @@ function _G._quickfix_text_func(info)
|
|||||||
line = line .. ": "
|
line = line .. ": "
|
||||||
end
|
end
|
||||||
|
|
||||||
line = line .. item.text
|
line = line
|
||||||
|
.. (item.text:gsub("^%s*(.-)%s*$", "%1"):gsub("%s*\n%s*", "\n "))
|
||||||
table.insert(lines, line)
|
table.insert(lines, line)
|
||||||
end
|
end
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
end
|
end
|
||||||
|
|
||||||
|
vim.opt.quickfixtextfunc = "v:lua.quickfix_text_func"
|
||||||
|
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
syntax on
|
syntax on
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
|
|
||||||
function! QuickfixTextFunc(info) abort
|
|
||||||
return v:lua._quickfix_text_func(a:info)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
set quickfixtextfunc=QuickfixTextFunc
|
|
||||||
]])
|
]])
|
||||||
|
|||||||
Reference in New Issue
Block a user