1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:20:04 +08:00
SpaceVim/bundle/trouble.nvim/lua/trouble/providers/qf.lua
2023-07-01 20:30:44 +08:00

40 lines
909 B
Lua

local util = require("trouble.util")
local M = {}
local severities = { E = 1, W = 2, I = 3, H = 4 }
function M.get_list(winid)
local list = winid == nil and vim.fn.getqflist({ all = true }) or vim.fn.getloclist(winid, { all = true })
local ret = {}
for _, item in pairs(list.items) do
local row = (item.lnum == 0 and 1 or item.lnum) - 1
local col = (item.col == 0 and 1 or item.col) - 1
local pitem = {
row = row,
col = col,
message = item.text,
severity = severities[item.type] or 0,
range = {
start = { line = row, character = col },
["end"] = { line = row, character = -1 },
},
}
table.insert(ret, util.process_item(pitem, item.bufnr))
end
return ret
end
function M.loclist(win, _buf, cb, _options)
return cb(M.get_list(win))
end
function M.qflist(_win, _buf, cb, _options)
return cb(M.get_list())
end
return M