mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 23:44:55 +01:00
fix: move cursor in insert, error if not connected
This commit is contained in:
parent
8ca5128ca9
commit
a52f74d092
2 changed files with 13 additions and 6 deletions
|
@ -27,7 +27,7 @@ local function hook_callbacks(path, buffer)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
vim.api.nvim_create_autocmd(
|
vim.api.nvim_create_autocmd(
|
||||||
{ "CursorMoved" },
|
{ "CursorMoved", "CursorMovedI" },
|
||||||
{
|
{
|
||||||
callback = function(_)
|
callback = function(_)
|
||||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||||
|
@ -49,7 +49,6 @@ local function unhook_callbacks(buffer)
|
||||||
vim.keymap.del('i', '<CR>', { buffer = buffer })
|
vim.keymap.del('i', '<CR>', { buffer = buffer })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('Connect',
|
vim.api.nvim_create_user_command('Connect',
|
||||||
function(args)
|
function(args)
|
||||||
if M.jobid ~= nil then
|
if M.jobid ~= nil then
|
||||||
|
@ -71,6 +70,9 @@ vim.api.nvim_create_user_command('Connect',
|
||||||
on_stderr = function(_, data, _) print(vim.fn.join(data, "\n")) end,
|
on_stderr = function(_, data, _) print(vim.fn.join(data, "\n")) end,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if M.jobid <= 0 then
|
||||||
|
print("[!] could not start codemp client")
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
{ nargs='?', bang=true })
|
{ nargs='?', bang=true })
|
||||||
|
|
||||||
|
@ -83,6 +85,10 @@ vim.api.nvim_create_user_command('Stop',
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('Share',
|
vim.api.nvim_create_user_command('Share',
|
||||||
function(args)
|
function(args)
|
||||||
|
if M.jobid <= 0 then
|
||||||
|
print("[!] connect to codemp server first")
|
||||||
|
return
|
||||||
|
end
|
||||||
local path = args.fargs[1]
|
local path = args.fargs[1]
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||||
|
@ -95,6 +101,10 @@ vim.api.nvim_create_user_command('Share',
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('Join',
|
vim.api.nvim_create_user_command('Join',
|
||||||
function(args)
|
function(args)
|
||||||
|
if M.jobid <= 0 then
|
||||||
|
print("[!] connect to codemp server first")
|
||||||
|
return
|
||||||
|
end
|
||||||
local path = args.fargs[1]
|
local path = args.fargs[1]
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
hook_callbacks(path, bufnr)
|
hook_callbacks(path, bufnr)
|
||||||
|
|
|
@ -164,10 +164,7 @@ impl Handler for NeovimHandler {
|
||||||
if let Err(e) = _b.clear_namespace(ns, 0, -1).await {
|
if let Err(e) = _b.clear_namespace(ns, 0, -1).await {
|
||||||
error!("could not clear previous cursor highlight: {}", e);
|
error!("could not clear previous cursor highlight: {}", e);
|
||||||
}
|
}
|
||||||
if let Err(e) = _b.add_highlight(
|
if let Err(e) = _b.add_highlight(ns, "ErrorMsg", cur.row-1, cur.col, cur.col+1).await {
|
||||||
ns, "ErrorMsg",
|
|
||||||
cur.row as i64 - 1, cur.col as i64 - 1, cur.col as i64
|
|
||||||
).await {
|
|
||||||
error!("could not create highlight for cursor: {}", e);
|
error!("could not create highlight for cursor: {}", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue