1
0
Fork 0
codesnap.nvim/plugin/codesnap.lua

30 lines
644 B
Lua
Raw Permalink Normal View History

2024-02-13 06:20:51 +00:00
local codesnap = require("codesnap")
2024-02-21 10:33:44 +00:00
-- local client = require("codesnap.client")
2024-02-13 06:05:36 +00:00
2024-02-21 10:33:44 +00:00
-- vim.api.nvim_create_user_command("CodeSnap", function()
-- client:send("copy")
-- end, {})
2024-02-19 14:27:17 +00:00
2024-02-21 10:33:44 +00:00
vim.api.nvim_create_user_command("CodeSnapPreviewOn", function()
codesnap.open_preview()
end, {})
2024-02-19 14:27:17 +00:00
vim.api.nvim_create_autocmd({ "CursorMoved" }, {
callback = function()
local mode = vim.api.nvim_get_mode().mode
2024-02-21 10:33:44 +00:00
if mode ~= "v" or not codesnap.preview_switch then
2024-02-19 14:27:17 +00:00
return
end
codesnap.preview_code()
end,
})
vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
pattern = "*",
callback = function()
2024-02-21 10:33:44 +00:00
codesnap.stop_client()
2024-02-19 14:27:17 +00:00
end,
})