Skip to content

Commit 4de10f9

Browse files
committed
fix: correctly handle changes from local to remote plugin
1 parent 93a3a6c commit 4de10f9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lua/lazy/core/plugin.lua

+13-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ M.dirty = false
2222
---@field tasks? LazyTask[]
2323
---@field dirty? boolean
2424
---@field updated? {from:string, to:string}
25+
---@field is_local? boolean
26+
---@field is_symlink? boolean
2527

2628
---@class LazyPluginRef
2729
---@field branch? string
@@ -124,12 +126,12 @@ function Spec.revive(spec)
124126
end
125127

126128
function M.update_state(check_clean)
127-
---@type table<"opt"|"start", table<string,boolean>>
129+
---@type table<"opt"|"start", table<string,FileType>>
128130
local installed = { opt = {}, start = {} }
129131
for opt, packs in pairs(installed) do
130132
Util.ls(Config.options.package_path .. "/" .. opt, function(_, name, type)
131133
if type == "directory" or type == "link" then
132-
packs[name] = true
134+
packs[name] = type
133135
end
134136
end)
135137
end
@@ -140,8 +142,12 @@ function M.update_state(check_clean)
140142
plugin.opt = plugin.opt == nil and Config.options.opt or plugin.opt
141143
local opt = plugin.opt and "opt" or "start"
142144
plugin.dir = Config.options.package_path .. "/" .. opt .. "/" .. plugin.name
143-
plugin._.installed = installed[opt][plugin.name] == true
144-
installed[opt][plugin.name] = nil
145+
plugin._.is_local = plugin.uri:sub(1, 4) ~= "http" and plugin.uri:sub(1, 3) ~= "git"
146+
plugin._.is_symlink = installed[opt][plugin.name] == "link"
147+
plugin._.installed = installed[opt][plugin.name] ~= nil
148+
if plugin._.is_local == plugin._.is_symlink then
149+
installed[opt][plugin.name] = nil
150+
end
145151
end
146152

147153
if check_clean then
@@ -153,7 +159,9 @@ function M.update_state(check_clean)
153159
pack = pack,
154160
dir = Config.options.package_path .. "/" .. opt .. "/" .. pack,
155161
opt = opt == "opt",
156-
installed = true,
162+
_ = {
163+
installed = true,
164+
},
157165
})
158166
end
159167
end

0 commit comments

Comments
 (0)