Update generated nvim config
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
local Search = require("todo-comments.search")
|
||||
local util = require("trouble.util")
|
||||
local Config = require("todo-comments.config")
|
||||
|
||||
local function todo(_win, _buf, cb, opts)
|
||||
Search.search(function(results)
|
||||
local ret = {}
|
||||
for _, item in pairs(results) 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,
|
||||
sign = Config.options.keywords[item.tag].icon,
|
||||
sign_hl = "TodoFg" .. item.tag,
|
||||
-- code = string.lower(item.tag),
|
||||
-- source = "todo",
|
||||
severity = 0,
|
||||
range = {
|
||||
start = { line = row, character = col },
|
||||
["end"] = { line = row, character = -1 },
|
||||
},
|
||||
}
|
||||
|
||||
table.insert(ret, util.process_item(pitem, vim.fn.bufnr(item.filename, true)))
|
||||
end
|
||||
if #ret == 0 then
|
||||
util.warn("no todos found")
|
||||
end
|
||||
cb(ret)
|
||||
end, opts.cmd_options)
|
||||
end
|
||||
|
||||
return todo
|
||||
@ -0,0 +1,54 @@
|
||||
---@diagnostic disable: inject-field
|
||||
local Config = require("todo-comments.config")
|
||||
local Item = require("trouble.item")
|
||||
local Search = require("todo-comments.search")
|
||||
|
||||
---@type trouble.Source
|
||||
local M = {}
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
M.config = {
|
||||
formatters = {
|
||||
todo_icon = function(ctx)
|
||||
return {
|
||||
text = Config.options.keywords[ctx.item.tag].icon,
|
||||
hl = "TodoFg" .. ctx.item.tag,
|
||||
}
|
||||
end,
|
||||
},
|
||||
modes = {
|
||||
todo = {
|
||||
events = { "BufEnter", "BufWritePost" },
|
||||
source = "todo",
|
||||
groups = {
|
||||
{ "tag", format = "{todo_icon} {tag}" },
|
||||
-- { "directory" },
|
||||
{ "filename", format = "{file_icon} {filename} {count}" },
|
||||
},
|
||||
sort = { { buf = 0 }, "filename", "pos", "message" },
|
||||
format = "{todo_icon} {text} {pos}",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
function M.get(cb)
|
||||
Search.search(function(results)
|
||||
local items = {} ---@type trouble.Item[]
|
||||
for _, item in pairs(results) do
|
||||
local row = item.lnum
|
||||
local col = item.col - 1
|
||||
items[#items + 1] = Item.new({
|
||||
buf = vim.fn.bufadd(item.filename),
|
||||
pos = { row, col },
|
||||
end_pos = { row, col + #item.tag },
|
||||
text = item.text,
|
||||
filename = item.filename,
|
||||
item = item,
|
||||
source = "todo",
|
||||
})
|
||||
end
|
||||
cb(items)
|
||||
end, {})
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user