cap153_nvim/lua/pack/configs/peek.lua
2026-04-23 21:29:50 +08:00

29 lines
1,017 B
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)
-- 在插件未加载时,这些命令就存在了。一旦被调用,它们会先加载插件,再执行真正的功能。
vim.api.nvim_create_user_command("PeekToggle", function()
local peek = require("peek")
if not peek.is_open() and vim.bo[vim.api.nvim_get_current_buf()].filetype == 'markdown' then
PackUtils.load(P, function()
require("peek").setup({
port = 9000,
-- app = { "zen", "-private-window" },
-- app = { "firefox-esr", "-private-window" },
app = { "chromium", "--app=http://localhost:9000/?theme=dark", "--incognito" },
})
end)
peek.open()
else -- 只有加载了插件的情况下执行关闭这样可以跳过非markdown文件
if PackUtils.plugin_loaded[P.name] then
peek.close()
end
end
end, { desc = "Lazy load and open Peek" })