refactor(undotree): use builtin nvim.undotree
This commit is contained in:
@@ -36,7 +36,7 @@ require("pack").setup({
|
|||||||
"https://github.com/nvim-tree/nvim-tree.lua",
|
"https://github.com/nvim-tree/nvim-tree.lua",
|
||||||
"https://github.com/stevearc/oil.nvim",
|
"https://github.com/stevearc/oil.nvim",
|
||||||
"https://github.com/hedyhli/outline.nvim",
|
"https://github.com/hedyhli/outline.nvim",
|
||||||
"https://github.com/jiaoshijie/undotree",
|
"nvim.undotree",
|
||||||
{
|
{
|
||||||
"https://github.com/saghen/blink.cmp",
|
"https://github.com/saghen/blink.cmp",
|
||||||
version = vim.version.range("^1"),
|
version = vim.version.range("^1"),
|
||||||
|
|||||||
+26
-1
@@ -75,6 +75,12 @@ local function load(name, required)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param src string
|
||||||
|
---@return boolean
|
||||||
|
local function is_url(src)
|
||||||
|
return src:find("://") ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
---@param spec string | ow.Pack.PluginSpec
|
---@param spec string | ow.Pack.PluginSpec
|
||||||
---@return vim.pack.Spec
|
---@return vim.pack.Spec
|
||||||
local function to_pack_spec(spec)
|
local function to_pack_spec(spec)
|
||||||
@@ -233,7 +239,26 @@ end
|
|||||||
|
|
||||||
---@param specs (string | ow.Pack.PluginSpec)[]
|
---@param specs (string | ow.Pack.PluginSpec)[]
|
||||||
function M.setup(specs)
|
function M.setup(specs)
|
||||||
local changed = M.install(vim.tbl_map(to_pack_spec, specs), function(data)
|
local pack_specs = {}
|
||||||
|
for _, spec in ipairs(specs) do
|
||||||
|
local src = type(spec) == "string" and spec or spec[1]
|
||||||
|
if is_url(src) then
|
||||||
|
table.insert(pack_specs, to_pack_spec(spec))
|
||||||
|
else
|
||||||
|
vim.cmd.packadd(src)
|
||||||
|
local runtime =
|
||||||
|
vim.api.nvim_get_runtime_file("pack/*/opt/" .. src, false)
|
||||||
|
---@type ow.Pack.Plugin
|
||||||
|
local plugin = {
|
||||||
|
[1] = src,
|
||||||
|
name = src,
|
||||||
|
path = runtime[1] or "",
|
||||||
|
}
|
||||||
|
table.insert(M.plugins, plugin)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local changed = M.install(pack_specs, function(data)
|
||||||
if not data.spec.name then
|
if not data.spec.name then
|
||||||
log.error("Missing name for plugin: %s", data.spec.src)
|
log.error("Missing name for plugin: %s", data.spec.src)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
vim.keymap.set("n", "<leader>u", function()
|
||||||
|
require("undotree").open({ command = "leftabove40vnew" })
|
||||||
|
end)
|
||||||
@@ -1 +0,0 @@
|
|||||||
vim.keymap.set("n", "<leader>u", require("undotree").toggle)
|
|
||||||
Reference in New Issue
Block a user