mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
This commit is contained in:
parent
758bbfa13a
commit
e2c1c527e4
1 changed files with 21 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
|||
---@field title? string
|
||||
---@field split_layout? boolean
|
||||
---@field opts? snacks.picker.previewers.Config
|
||||
---@field _spinner? snacks.util.Spinner
|
||||
local M = {}
|
||||
M.__index = M
|
||||
|
||||
|
|
@ -164,6 +165,7 @@ function M:show(picker, opts)
|
|||
self.item = item
|
||||
self.filter = picker:filter()
|
||||
self.pos = item and item.pos or nil
|
||||
self:spinner(false)
|
||||
if item then
|
||||
local buf = self.win.buf
|
||||
local ok, err = pcall(
|
||||
|
|
@ -232,6 +234,7 @@ function M:reset()
|
|||
end
|
||||
vim.api.nvim_buf_clear_namespace(self.win.buf, -1, 0, -1)
|
||||
self:set_title()
|
||||
self:spinner(false)
|
||||
vim.treesitter.stop(self.win.buf)
|
||||
vim.bo[self.win.buf].modifiable = true
|
||||
self:set_lines({})
|
||||
|
|
@ -289,6 +292,10 @@ function M:highlight(opts)
|
|||
end
|
||||
end
|
||||
|
||||
function M:ns()
|
||||
return ns
|
||||
end
|
||||
|
||||
-- show the item location
|
||||
function M:loc()
|
||||
vim.api.nvim_buf_clear_namespace(self.win.buf, ns_loc, 0, -1)
|
||||
|
|
@ -434,4 +441,18 @@ function M:markdown()
|
|||
end
|
||||
end
|
||||
|
||||
function M:spinner(enable)
|
||||
if enable == false then
|
||||
if self._spinner then
|
||||
self._spinner:stop()
|
||||
self._spinner = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
assert(self.win:buf_valid(), "invalid buffer")
|
||||
local ret = Snacks.picker.util.spinner(self.win.buf)
|
||||
self._spinner = ret
|
||||
return ret
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue