-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmini.lua
35 lines (30 loc) · 877 Bytes
/
mini.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--- @class MiniPicker: GoDocPicker
local M = {}
--- @param adapter GoDocAdapter
--- @param config GoDocConfig
--- @param callback fun(choice: string|nil)
function M.show(adapter, config, callback)
local minipick = require("mini.pick")
-- Create picker configuration
local opts = {
source = {
items = adapter.get_items(),
name = "Select item",
preview = function(buf_id, item)
vim.notify(vim.inspect(buf_id))
local content = adapter.get_content(item)
local syntax_info = adapter.get_syntax_info()
vim.api.nvim_buf_set_lines(buf_id, 0, -1, false, content)
vim.api.nvim_set_option_value("filetype", syntax_info.filetype, { buf = buf_id })
end,
choose = function(item)
callback(item)
end,
},
}
if config.picker.mini then
opts = vim.tbl_deep_extend("force", opts, config.picker.mini)
end
minipick.start(opts)
end
return M