cap153_nvim/lua/pack/configs/peek.lua
2026-04-13 16:33:11 +08:00

34 lines
1.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

if vim.g.vscode then return end
local P = {
name = "peek.nvim",
-- 编译命令:需要环境中安装了 deno
build_cmd = { "deno", "task", "--quiet", "build:fast" },
}
PackUtils.setup_listener(P.name, P.build_cmd)
-- 2. 封装加载逻辑
local function load_peek()
PackUtils.load(P, function()
require("peek").setup({
port = 9000,
app = { "zen", "-private-window" },
-- app = { "firefox-esr", "-private-window" },
-- app = { "google-chrome-stable", "--app=http://localhost:9000/?theme=dark", "--incognito" },
})
end)
end
-- 在插件未加载时,这些命令就存在了。一旦被调用,它们会先加载插件,再执行真正的功能。
vim.api.nvim_create_user_command("PeekOpen", function()
load_peek() -- 触发 PackUtils.load (包含构建检查)
require("peek").open()
end, { desc = "Lazy load and open Peek" })
vim.api.nvim_create_user_command("PeekClose", function()
-- 如果插件没加载Close 命令通常不需要做任何事,或者也触发加载
if PackUtils.is_initialized[P.name] then
require("peek").close()
end
end, { desc = "Close Peek" })