Skip to content

Commit

Permalink
fix(nvim-plug): fix raw plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdjeg committed Feb 8, 2025
1 parent 68eaa0e commit 7ad0921
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions bundle/nvim-plug/lua/plug/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 13 additions & 7 deletions bundle/nvim-plug/lua/plug/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 false
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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7ad0921

Please sign in to comment.