mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat(restore): you can now restore a plugin to a certain commit. Fixes #234
This commit is contained in:
parent
4b29f7e3d5
commit
1283c2b288
3 changed files with 37 additions and 18 deletions
|
@ -164,6 +164,25 @@ function M:setup_patterns()
|
|||
self:diff({ commit = hash })
|
||||
end,
|
||||
}, self.diff)
|
||||
self:on_pattern(ViewConfig.commands.restore.key_plugin, {
|
||||
[commit_pattern] = function(hash)
|
||||
self:restore({ commit = hash })
|
||||
end,
|
||||
}, self.restore)
|
||||
end
|
||||
|
||||
---@param opts? {commit:string}
|
||||
function M:restore(opts)
|
||||
opts = opts or {}
|
||||
local Lockfile = require("lazy.manage.lock")
|
||||
local Commands = require("lazy.view.commands")
|
||||
local plugin = self.render:get_plugin()
|
||||
if plugin then
|
||||
if opts.commit then
|
||||
Lockfile.get(plugin).commit = opts.commit
|
||||
end
|
||||
Commands.cmd("restore", { plugins = { plugin } })
|
||||
end
|
||||
end
|
||||
|
||||
function M:hover()
|
||||
|
@ -246,7 +265,7 @@ function M:setup_modes()
|
|||
Commands.cmd(name)
|
||||
end, m.desc)
|
||||
end
|
||||
if m.key_plugin then
|
||||
if m.key_plugin and name ~= "restore" then
|
||||
self:on_key(m.key_plugin, function()
|
||||
local plugin = self.render:get_plugin()
|
||||
if plugin then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue