Skip to content

Commit 24595a6

Browse files
committed
feat: add Strive remove plugin support
1 parent 4725482 commit 24595a6

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

lua/strive/init.lua

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,22 @@ function M.clean()
17221722
end)()
17231723
end
17241724

1725+
function M.remove(plugin)
1726+
local path = vim.fs.joinpath(OPT_DIR, plugin)
1727+
if not isdir(path) then
1728+
path = vim.fs.joinpath(START_DIR, plugin)
1729+
if not isdir(path) then
1730+
return
1731+
end
1732+
end
1733+
1734+
local ok, result = pcall(vim.fn.delete, path, 'rf')
1735+
if not ok or result ~= 0 then
1736+
return M.log('Info', 'Failed to remove')
1737+
end
1738+
M.log('warn', ('Plugin %s removed successful'):format(plugin))
1739+
end
1740+
17251741
-- use uv instead of calling clock_time with ffi
17261742
local function startuptime()
17271743
if vim.g.strive_startup_time ~= nil then
@@ -1772,10 +1788,14 @@ api.nvim_create_autocmd('UIEnter', {
17721788
end,
17731789
})
17741790

1775-
local t = { install = 1, update = 2, clean = 3 }
1791+
local t = { install = 1, update = 2, clean = 3, remove = 4 }
17761792
api.nvim_create_user_command('Strive', function(args)
1777-
if t[args.args] then
1778-
M[args.args]()
1793+
if #args.fargs == 0 then
1794+
return
1795+
end
1796+
1797+
if t[args.fargs[1]] then
1798+
M[args.fargs[1]](args.fargs[2])
17791799
end
17801800
end, {
17811801
desc = 'Install plugins',

0 commit comments

Comments
 (0)