feat: added support for Windows

This commit is contained in:
Folke Lemaitre 2022-12-20 07:19:55 +01:00
parent 198963fdab
commit bb1c2f4c3e
No known key found for this signature in database
GPG Key ID: 36B7C1C85AAC487F
3 changed files with 12 additions and 5 deletions

View File

@ -21,7 +21,7 @@ M.defaults = {
}, },
dev = { dev = {
-- directory where you store your local plugin projects -- directory where you store your local plugin projects
path = vim.fn.expand("~/projects"), path = "~/projects",
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub ---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
patterns = {}, -- For example {"folke"} patterns = {}, -- For example {"folke"}
}, },
@ -112,12 +112,17 @@ function M.setup(spec, opts)
M.options.performance.cache = require("lazy.core.cache") M.options.performance.cache = require("lazy.core.cache")
table.insert(M.options.install.colorscheme, "habamax") table.insert(M.options.install.colorscheme, "habamax")
M.options.root = Util.norm(M.options.root)
M.options.dev.path = Util.norm(M.options.dev.path)
M.options.lockfile = Util.norm(M.options.lockfile)
M.options.readme.root = Util.norm(M.options.readme.root)
if M.options.performance.reset_packpath then if M.options.performance.reset_packpath then
vim.go.packpath = "" vim.go.packpath = ""
end end
if M.options.performance.rtp.reset then if M.options.performance.rtp.reset then
M.me = debug.getinfo(1, "S").source:sub(2) M.me = debug.getinfo(1, "S").source:sub(2)
M.me = vim.fn.fnamemodify(M.me, ":p:h:h:h:h") M.me = Util.norm(vim.fn.fnamemodify(M.me, ":p:h:h:h:h"))
vim.opt.rtp = { vim.opt.rtp = {
M.me, M.me,
vim.env.VIMRUNTIME, vim.env.VIMRUNTIME,

View File

@ -78,7 +78,7 @@ function Spec:add(plugin, is_dep)
end end
if plugin.dir then if plugin.dir then
plugin.dir = plugin.dir:gsub("~", os.getenv("HOME") or "~") plugin.dir = Util.norm(plugin.dir)
-- local plugin -- local plugin
plugin.name = plugin.name or Spec.get_name(plugin.dir) plugin.name = plugin.name or Spec.get_name(plugin.dir)
elseif plugin.url then elseif plugin.url then
@ -168,7 +168,7 @@ function M.update_state()
---@type table<string,FileType> ---@type table<string,FileType>
local installed = {} local installed = {}
Util.ls(Config.options.root, function(_, name, type) Util.ls(Config.options.root, function(_, name, type)
if type == "directory" or type == "link" then if type == "directory" and name ~= "readme" then
installed[name] = type installed[name] = type
end end
end) end)

View File

@ -220,12 +220,13 @@ function M:reason(reason, opts)
---@type string? ---@type string?
local source = reason.source local source = reason.source
if source then if source then
source = Util.norm(source)
local plugin = Plugin.find(source) local plugin = Plugin.find(source)
if plugin then if plugin then
reason.plugin = plugin.name reason.plugin = plugin.name
reason.source = nil reason.source = nil
else else
local config = vim.fn.stdpath("config") local config = Util.norm(vim.fn.stdpath("config"))
if source == config .. "/init.lua" then if source == config .. "/init.lua" then
reason.source = "init.lua" reason.source = "init.lua"
else else
@ -237,6 +238,7 @@ function M:reason(reason, opts)
end end
end end
if reason.runtime then if reason.runtime then
reason.runtime = Util.norm(reason.runtime)
reason.runtime = reason.runtime:gsub(".*/([^/]+/plugin/.*)", "%1") reason.runtime = reason.runtime:gsub(".*/([^/]+/plugin/.*)", "%1")
reason.runtime = reason.runtime:gsub(".*/([^/]+/after/.*)", "%1") reason.runtime = reason.runtime:gsub(".*/([^/]+/after/.*)", "%1")
reason.runtime = reason.runtime:gsub(".*/([^/]+/ftdetect/.*)", "%1") reason.runtime = reason.runtime:gsub(".*/([^/]+/ftdetect/.*)", "%1")