mirror of https://github.com/folke/lazy.nvim.git
feat: symlinking local plugins is no longer needed
This commit is contained in:
parent
7b272b6ed6
commit
37c7366ab0
|
@ -16,7 +16,6 @@ local M = {}
|
||||||
---@field dirty? boolean
|
---@field dirty? boolean
|
||||||
---@field updated? {from:string, to:string}
|
---@field updated? {from:string, to:string}
|
||||||
---@field is_local boolean
|
---@field is_local boolean
|
||||||
---@field is_symlink? boolean
|
|
||||||
---@field cloned? boolean
|
---@field cloned? boolean
|
||||||
---@field dep? boolean True if this plugin is only in the spec as a dependency
|
---@field dep? boolean True if this plugin is only in the spec as a dependency
|
||||||
|
|
||||||
|
@ -165,11 +164,13 @@ function M.update_state()
|
||||||
or plugin.cmd
|
or plugin.cmd
|
||||||
plugin.lazy = lazy and true or false
|
plugin.lazy = lazy and true or false
|
||||||
end
|
end
|
||||||
plugin.dir = Config.root .. "/" .. plugin.name
|
if plugin.uri:sub(1, 4) ~= "http" and plugin.uri:sub(1, 3) ~= "git" then
|
||||||
plugin._.is_local = plugin.uri:sub(1, 4) ~= "http" and plugin.uri:sub(1, 3) ~= "git"
|
plugin._.is_local = true
|
||||||
plugin._.is_symlink = installed[plugin.name] == "link"
|
plugin.dir = plugin.uri
|
||||||
plugin._.installed = installed[plugin.name] ~= nil
|
plugin._.installed = true -- user should make sure the directory exists
|
||||||
if plugin._.is_local == plugin._.is_symlink then
|
else
|
||||||
|
plugin.dir = Config.root .. "/" .. plugin.name
|
||||||
|
plugin._.installed = installed[plugin.name] ~= nil
|
||||||
installed[plugin.name] = nil
|
installed[plugin.name] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -240,11 +241,8 @@ end
|
||||||
-- Finds the plugin that has this path
|
-- Finds the plugin that has this path
|
||||||
---@param path string
|
---@param path string
|
||||||
function M.find(path)
|
function M.find(path)
|
||||||
if path:find(Config.root, 1, true) == 1 then
|
local name = path:match("/([^/]+)/lua") or path:match("/([^/]+)/?$")
|
||||||
local plugin = path:sub(#Config.root + 2)
|
return name and Config.plugins[name] or nil
|
||||||
local idx = plugin:find("/", 1, true)
|
|
||||||
return idx and Config.plugins[plugin:sub(1, idx - 1)] or nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -54,7 +54,6 @@ end
|
||||||
function M.install(opts)
|
function M.install(opts)
|
||||||
M.run({
|
M.run({
|
||||||
pipeline = {
|
pipeline = {
|
||||||
"fs.symlink",
|
|
||||||
"git.clone",
|
"git.clone",
|
||||||
"git.checkout",
|
"git.checkout",
|
||||||
"plugin.docs",
|
"plugin.docs",
|
||||||
|
@ -72,7 +71,6 @@ function M.update(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
M.run({
|
M.run({
|
||||||
pipeline = {
|
pipeline = {
|
||||||
"fs.symlink",
|
|
||||||
"git.branch",
|
"git.branch",
|
||||||
"git.fetch",
|
"git.fetch",
|
||||||
{ "git.checkout", lockfile = opts.lockfile },
|
{ "git.checkout", lockfile = opts.lockfile },
|
||||||
|
|
|
@ -1,52 +1,31 @@
|
||||||
local Util = require("lazy.util")
|
local Util = require("lazy.util")
|
||||||
|
local Config = require("lazy.core.config")
|
||||||
|
|
||||||
---@type table<string, LazyTaskDef>
|
---@type table<string, LazyTaskDef>
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.clean = {
|
M.clean = {
|
||||||
|
skip = function(plugin)
|
||||||
|
return plugin._.is_local
|
||||||
|
end,
|
||||||
run = function(self)
|
run = function(self)
|
||||||
local dir = self.plugin.dir:gsub("/+$", "")
|
local dir = self.plugin.dir:gsub("/+$", "")
|
||||||
local stat = vim.loop.fs_lstat(dir)
|
assert(dir:find(Config.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
|
||||||
|
|
||||||
if stat.type == "directory" then
|
local stat = vim.loop.fs_lstat(dir)
|
||||||
Util.walk(dir, function(path, _, type)
|
assert(stat.type == "directory", self.plugin.dir .. " should be a directory!")
|
||||||
if type == "directory" then
|
|
||||||
vim.loop.fs_rmdir(path)
|
Util.walk(dir, function(path, _, type)
|
||||||
else
|
if type == "directory" then
|
||||||
vim.loop.fs_unlink(path)
|
vim.loop.fs_rmdir(path)
|
||||||
end
|
else
|
||||||
end)
|
vim.loop.fs_unlink(path)
|
||||||
vim.loop.fs_rmdir(dir)
|
end
|
||||||
else
|
end)
|
||||||
vim.loop.fs_unlink(dir)
|
vim.loop.fs_rmdir(dir)
|
||||||
end
|
|
||||||
|
|
||||||
self.plugin._.installed = false
|
self.plugin._.installed = false
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
M.symlink = {
|
|
||||||
skip = function(plugin)
|
|
||||||
if not plugin._.is_local then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return not plugin._.is_symlink and plugin._.installed
|
|
||||||
end,
|
|
||||||
run = function(self)
|
|
||||||
local stat = vim.loop.fs_lstat(self.plugin.dir)
|
|
||||||
if stat then
|
|
||||||
if vim.loop.fs_realpath(self.plugin.uri) == vim.loop.fs_realpath(self.plugin.dir) then
|
|
||||||
self.plugin._.installed = true
|
|
||||||
return
|
|
||||||
else
|
|
||||||
vim.loop.fs_unlink(self.plugin.dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
vim.loop.fs_symlink(self.plugin.uri, self.plugin.dir, { dir = true })
|
|
||||||
vim.opt.runtimepath:append(self.plugin.uri)
|
|
||||||
self.plugin._.installed = true
|
|
||||||
self.plugin._.cloned = true
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue