From 7ad09214c06d53d3a8e4a28176cbb96202ada8e9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 8 Feb 2025 23:00:48 +0800 Subject: [PATCH] fix(nvim-plug): fix raw plugin support --- bundle/nvim-plug/lua/plug/config.lua | 1 + bundle/nvim-plug/lua/plug/loader.lua | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/bundle/nvim-plug/lua/plug/config.lua b/bundle/nvim-plug/lua/plug/config.lua index ed7d76234..31c8f3317 100644 --- a/bundle/nvim-plug/lua/plug/config.lua +++ b/bundle/nvim-plug/lua/plug/config.lua @@ -21,6 +21,7 @@ function M.setup(opt) M.http_proxy = opt.http_proxy M.https_proxy = opt.https_proxy M.clone_depth = opt.clone_depth or M.clone_depth + M.raw_plugin_dir = opt.raw_plugin_dir or M.raw_plugin_dir end return M diff --git a/bundle/nvim-plug/lua/plug/loader.lua b/bundle/nvim-plug/lua/plug/loader.lua index b3af9913a..e02d64139 100644 --- a/bundle/nvim-plug/lua/plug/loader.lua +++ b/bundle/nvim-plug/lua/plug/loader.lua @@ -28,20 +28,24 @@ local add_raw_rtp = false --- @field type string "git", "raw" or "none" --- @field script_type string "git", "raw" or "none" +--- @param plugSpec PluginSpec +--- @return boolean local function is_local_plugin(plugSpec) if plugSpec.is_local or vim.fn.isdirectory(plugSpec[1]) == 1 then plugSpec.is_local = true return true - end -end - -local function check_name(plugSpec) - if not plugSpec[1] and not plugSpec.url then + else return false end +end +--- @param plugSpec PluginSpec +--- @return string +local function check_name(plugSpec) + if not plugSpec[1] and not plugSpec.url then + return '' + end local s = vim.split(plugSpec[1] or plugSpec.url, '/') - plugSpec.name = s[#s] - return true + return s[#s] end function M.parser(plugSpec) @@ -52,7 +56,9 @@ function M.parser(plugSpec) elseif type(plugSpec.enabled) ~= 'boolean' or plugSpec.enabled == false then plugSpec.enabled = false return plugSpec - elseif not check_name(plugSpec) then + end + plugSpec.name = check_name(plugSpec) + if #plugSpec.name == 0 then plugSpec.enabled = false return plugSpec end @@ -65,9 +71,9 @@ function M.parser(plugSpec) plugSpec.enabled = false return plugSpec else - plugSpec.path = config.raw_plugin_dir .. '/' .. plugSpec.script_type .. plugSpec.name + plugSpec.path = config.raw_plugin_dir .. '/' .. plugSpec.script_type .. '/' .. plugSpec.name if not add_raw_rtp then - vim.opt:append(config.raw_plugin_dir) + vim.opt.runtimepath:append(config.raw_plugin_dir) add_raw_rtp = true end end