mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
refactor: simplified handler code
This commit is contained in:
parent
17d1653b4a
commit
ecf03a6892
7 changed files with 58 additions and 91 deletions
|
@ -4,18 +4,17 @@ local Loader = require("lazy.core.loader")
|
|||
---@class LazyCmdHandler:LazyHandler
|
||||
local M = {}
|
||||
|
||||
local function _load(plugin, cmd)
|
||||
function M:_load(cmd)
|
||||
vim.api.nvim_del_user_command(cmd)
|
||||
Util.track({ cmd = cmd })
|
||||
Loader.load(plugin, { cmd = cmd })
|
||||
Loader.load(self.active[cmd], { cmd = cmd })
|
||||
Util.track()
|
||||
end
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
---@param cmd string
|
||||
function M:_add(plugin, cmd)
|
||||
function M:_add(cmd)
|
||||
vim.api.nvim_create_user_command(cmd, function(event)
|
||||
_load(plugin, cmd)
|
||||
self:_load(cmd)
|
||||
vim.cmd(
|
||||
("%s %s%s%s %s"):format(
|
||||
event.mods or "",
|
||||
|
@ -29,7 +28,7 @@ function M:_add(plugin, cmd)
|
|||
bang = true,
|
||||
nargs = "*",
|
||||
complete = function(_, line)
|
||||
_load(plugin, cmd)
|
||||
self:_load(cmd)
|
||||
-- NOTE: return the newly loaded command completion
|
||||
return vim.fn.getcompletion(line, "cmdline")
|
||||
end,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue