codesnap.nvim/plugin/codesnap.lua

35 lines
725 B
Lua
Raw Normal View History

2024-02-12 22:20:51 -08:00
local codesnap = require("codesnap")
2024-02-21 02:33:44 -08:00
-- local client = require("codesnap.client")
2024-02-12 22:05:36 -08:00
2024-02-21 02:33:44 -08:00
-- vim.api.nvim_create_user_command("CodeSnap", function()
-- client:send("copy")
-- end, {})
2024-02-19 06:27:17 -08:00
2024-02-21 02:33:44 -08:00
vim.api.nvim_create_user_command("CodeSnapPreviewOn", function()
codesnap.open_preview()
end, {})
2024-02-19 06:27:17 -08:00
local validModes = {
["v"] = true,
["V"] = true,
["^V"] = true,
}
2024-02-19 06:27:17 -08:00
vim.api.nvim_create_autocmd({ "CursorMoved" }, {
callback = function()
local mode = vim.api.nvim_get_mode().mode
if not validModes[mode] or not codesnap.preview_switch then
2024-02-19 06:27:17 -08:00
return
end
codesnap.preview_code()
end,
})
vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
pattern = "*",
callback = function()
2024-02-21 02:33:44 -08:00
codesnap.stop_client()
2024-02-19 06:27:17 -08:00
end,
})