mirror of https://github.com/folke/lazy.nvim.git
fix: correctly handle changes from local to remote plugin
This commit is contained in:
parent
93a3a6ccb5
commit
4de10f9578
|
@ -22,6 +22,8 @@ M.dirty = false
|
||||||
---@field tasks? LazyTask[]
|
---@field tasks? LazyTask[]
|
||||||
---@field dirty? boolean
|
---@field dirty? boolean
|
||||||
---@field updated? {from:string, to:string}
|
---@field updated? {from:string, to:string}
|
||||||
|
---@field is_local? boolean
|
||||||
|
---@field is_symlink? boolean
|
||||||
|
|
||||||
---@class LazyPluginRef
|
---@class LazyPluginRef
|
||||||
---@field branch? string
|
---@field branch? string
|
||||||
|
@ -124,12 +126,12 @@ function Spec.revive(spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.update_state(check_clean)
|
function M.update_state(check_clean)
|
||||||
---@type table<"opt"|"start", table<string,boolean>>
|
---@type table<"opt"|"start", table<string,FileType>>
|
||||||
local installed = { opt = {}, start = {} }
|
local installed = { opt = {}, start = {} }
|
||||||
for opt, packs in pairs(installed) do
|
for opt, packs in pairs(installed) do
|
||||||
Util.ls(Config.options.package_path .. "/" .. opt, function(_, name, type)
|
Util.ls(Config.options.package_path .. "/" .. opt, function(_, name, type)
|
||||||
if type == "directory" or type == "link" then
|
if type == "directory" or type == "link" then
|
||||||
packs[name] = true
|
packs[name] = type
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -140,9 +142,13 @@ function M.update_state(check_clean)
|
||||||
plugin.opt = plugin.opt == nil and Config.options.opt or plugin.opt
|
plugin.opt = plugin.opt == nil and Config.options.opt or plugin.opt
|
||||||
local opt = plugin.opt and "opt" or "start"
|
local opt = plugin.opt and "opt" or "start"
|
||||||
plugin.dir = Config.options.package_path .. "/" .. opt .. "/" .. plugin.name
|
plugin.dir = Config.options.package_path .. "/" .. opt .. "/" .. plugin.name
|
||||||
plugin._.installed = installed[opt][plugin.name] == true
|
plugin._.is_local = plugin.uri:sub(1, 4) ~= "http" and plugin.uri:sub(1, 3) ~= "git"
|
||||||
|
plugin._.is_symlink = installed[opt][plugin.name] == "link"
|
||||||
|
plugin._.installed = installed[opt][plugin.name] ~= nil
|
||||||
|
if plugin._.is_local == plugin._.is_symlink then
|
||||||
installed[opt][plugin.name] = nil
|
installed[opt][plugin.name] = nil
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if check_clean then
|
if check_clean then
|
||||||
Config.to_clean = {}
|
Config.to_clean = {}
|
||||||
|
@ -153,7 +159,9 @@ function M.update_state(check_clean)
|
||||||
pack = pack,
|
pack = pack,
|
||||||
dir = Config.options.package_path .. "/" .. opt .. "/" .. pack,
|
dir = Config.options.package_path .. "/" .. opt .. "/" .. pack,
|
||||||
opt = opt == "opt",
|
opt = opt == "opt",
|
||||||
|
_ = {
|
||||||
installed = true,
|
installed = true,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue