1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-13 23:07:59 +08:00

feat(nvim-plug): support local plugins

This commit is contained in:
Eric Wong 2025-02-05 00:55:49 +08:00
parent 8a4834b360
commit a842704063
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
2 changed files with 22 additions and 2 deletions

View File

@ -55,6 +55,9 @@ local function install_plugin(plugSpec)
if processes >= config.max_processes then
table.insert(installation_queue, plugSpec)
return
elseif vim.fn.isdirectory(plugSpec.path) == 1 then
-- if the directory exists, skip installation
return
end
local cmd = { 'git', 'clone', '--depth', '1' }
if plugSpec.branch then

View File

@ -20,10 +20,27 @@ local config = require('plug.config')
--- @field url string
--- @field path string
--- @field build string|table<string>
--- @field is_local boolean true for local plugin
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 unique_name(plugSpec)
local s = vim.split(plugSpec, '/')
return s[#s]
end
function M.parser(plugSpec)
plugSpec.name = vim.split(plugSpec[1], '/')[2]
if not plugSpec.type or plugSpec.type == 'none' then
plugSpec.name = unique_name(plugSpec)
if is_local_plugin(plugSpec) then
plugSpec.rtp = plugSpec[1]
plugSpec.path = plugSpec[1]
plugSpec.url = nil
elseif not plugSpec.type or plugSpec.type == 'none' then
plugSpec.rtp = config.bundle_dir .. '/' .. plugSpec[1]
plugSpec.path = config.bundle_dir .. '/' .. plugSpec[1]
plugSpec.url = config.base_url .. '/' .. plugSpec[1]