codesnap.nvim/lua/codesnap/init.lua

34 lines
758 B
Lua
Raw Normal View History

2024-02-19 06:27:17 -08:00
local table_utils = require("codesnap.utils.table")
local static = require("codesnap.static")
2024-02-19 06:27:17 -08:00
local client = require("codesnap.client")
local visual_utils = require("codesnap.utils.visual")
2024-02-21 02:33:44 -08:00
local main = {
cwd = static.cwd,
preview_switch = static.preview_switch,
}
2024-02-12 22:05:36 -08:00
function main.setup(config)
2024-02-19 06:27:17 -08:00
static.config = table_utils.merge(static.config, config == nil and {} or config)
if static.config.auto_load then
client:start()
end
client:send("config_setup", static.config)
end
function main.preview_code()
client:send("preview_code", { content = visual_utils.get_selected_text(), language = vim.bo.filetype })
2024-02-12 22:05:36 -08:00
end
2024-02-21 02:33:44 -08:00
function main.open_preview()
client:send("open_preview")
end
function main.stop_client()
client:stop()
end
2024-02-12 22:05:36 -08:00
return main