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
|
|
|
|
2024-02-23 07:37:39 +00:00
|
|
|
local validModes = {
|
|
|
|
["v"] = true,
|
|
|
|
["V"] = true,
|
|
|
|
["^V"] = true,
|
|
|
|
}
|
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-23 07:37:39 +00:00
|
|
|
if not validModes[mode] 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,
|
|
|
|
})
|