mirror of
https://github.com/folke/snacks.nvim
synced 2025-07-15 17:15:13 +00:00
24 lines
723 B
Lua
24 lines
723 B
Lua
local M = {}
|
|
|
|
---@param opts snacks.picker.lines.Config
|
|
---@type snacks.picker.finder
|
|
function M.lines(opts, ctx)
|
|
local buf = opts.buf or ctx.filter.current_buf
|
|
buf = buf == 0 and vim.api.nvim_get_current_buf() or buf
|
|
local extmarks = require("snacks.picker.util.highlight").get_highlights({ buf = buf, extmarks = true })
|
|
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
|
|
local items = {} ---@type snacks.picker.finder.Item[]
|
|
for l, line in ipairs(lines) do
|
|
---@type snacks.picker.finder.Item
|
|
local item = {
|
|
buf = buf,
|
|
text = line,
|
|
pos = { l, (line:find("%S") or 1) - 1 },
|
|
highlights = extmarks[l],
|
|
}
|
|
items[#items + 1] = item
|
|
end
|
|
return items
|
|
end
|
|
|
|
return M
|