mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
feat: allow attaching to local buffers
This commit is contained in:
parent
78adebd82e
commit
e926bdf7a3
1 changed files with 13 additions and 6 deletions
|
@ -205,6 +205,7 @@ vim.api.nvim_create_user_command(
|
||||||
if args.bang then
|
if args.bang then
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
content = buffer_get_content(buf)
|
content = buffer_get_content(buf)
|
||||||
|
-- TODO send content!
|
||||||
end
|
end
|
||||||
codemp.create(args.args, content)
|
codemp.create(args.args, content)
|
||||||
|
|
||||||
|
@ -216,11 +217,17 @@ vim.api.nvim_create_user_command(
|
||||||
vim.api.nvim_create_user_command(
|
vim.api.nvim_create_user_command(
|
||||||
"Attach",
|
"Attach",
|
||||||
function (args)
|
function (args)
|
||||||
local buffer = vim.api.nvim_create_buf(true, true)
|
local buffer = nil
|
||||||
vim.api.nvim_buf_set_option(buffer, 'fileformat', 'unix')
|
if args.bang then
|
||||||
vim.api.nvim_buf_set_option(buffer, 'filetype', 'codemp')
|
buffer = vim.api.nvim_get_current_buf()
|
||||||
vim.api.nvim_buf_set_name(buffer, "codemp::" .. args.args)
|
buffer_set_content(buffer, "")
|
||||||
vim.api.nvim_set_current_buf(buffer)
|
else
|
||||||
|
buffer = vim.api.nvim_create_buf(true, true)
|
||||||
|
vim.api.nvim_buf_set_option(buffer, 'fileformat', 'unix')
|
||||||
|
vim.api.nvim_buf_set_option(buffer, 'filetype', 'codemp')
|
||||||
|
vim.api.nvim_buf_set_name(buffer, "codemp::" .. args.args)
|
||||||
|
vim.api.nvim_set_current_buf(buffer)
|
||||||
|
end
|
||||||
local controller = codemp.attach(args.args)
|
local controller = codemp.attach(args.args)
|
||||||
|
|
||||||
-- TODO map name to uuid
|
-- TODO map name to uuid
|
||||||
|
@ -262,7 +269,7 @@ vim.api.nvim_create_user_command(
|
||||||
|
|
||||||
print(" ++ attached to buffer " .. args.args)
|
print(" ++ attached to buffer " .. args.args)
|
||||||
end,
|
end,
|
||||||
{ nargs = 1 }
|
{ nargs = 1, bang = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
vim.api.nvim_create_user_command(
|
vim.api.nvim_create_user_command(
|
||||||
|
|
Loading…
Reference in a new issue