fix(marks): 🐛 marks dont display in quickfix and telescope

This commit is contained in:
tomasky 2022-07-05 16:21:14 +08:00
parent 0bfad8f327
commit 23e31a83fc
4 changed files with 11 additions and 5 deletions

View File

@ -152,7 +152,7 @@ M.bookmark_list = function()
allmarks[k] = nil
end
for l, v in pairs(ma) do
table.insert(marklist, k .. "|" .. l .. "|" .. v.m .. "|" .. (v.a or ""))
table.insert(marklist, { filename = k, lnum = l, text = v.m .. "|" .. (v.a or "") })
end
end
utils.setqflist(marklist)
@ -172,6 +172,11 @@ M.refresh = function(bufnr)
type = v.a and "ann" or "add",
lnum = tonumber(k),
}
local pref = string.sub(v.a or "", 1, 2)
local text = config.keywords[pref]
if text then
ma["text"] = text
end
signs:remove(bufnr, ma.lnum)
table.insert(signlines, ma)
end

View File

@ -32,7 +32,7 @@ function M:add(bufnr, signs)
if not self:contains(bufnr, s.lnum) then
isExt = false
local cs = cfg[s.type]
local text = cs.text
local text = s.text or cs.text
api.nvim_buf_set_extmark(bufnr, self.ns, s.lnum - 1, -1, {
id = s.lnum,

View File

@ -161,7 +161,7 @@ function M.setqflist(content, opts)
end
opts = opts or {}
opts.open = (opts.open ~= nil) and opts.open or true
vim.fn.setqflist({}, " ", { title = "Todo", id = "$", items = content })
vim.fn.setqflist({}, " ", { title = "Bookmarks", id = "$", items = content })
if opts.open then
vim.cmd [[copen]]
end

View File

@ -5,6 +5,7 @@ if not has_telescope then
end
local finders = require "telescope.finders"
local pickers = require "telescope.pickers"
local entry_display = require "telescope.pickers.entry_display"
local conf = require("telescope.config").values
local config = require("bookmarks.config").config
local utils = require "telescope.utils"
@ -31,7 +32,7 @@ local function bookmark(opts)
end
end
local display = function(entry)
local displayer = pickers.entry_display.create {
local displayer = entry_display.create {
separator = "",
items = {
{ width = 5 },
@ -54,7 +55,7 @@ local function bookmark(opts)
return {
valid = true,
value = entry,
display = display(entry),
display = display,
ordinal = entry.filename .. entry.text,
filename = entry.filename,
lnum = entry.lnum,