mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-21 23:04:49 +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(
|
||||
{ "CursorMoved" },
|
||||
{ "CursorMoved", "CursorMovedI" },
|
||||
{
|
||||
callback = function(_)
|
||||
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 })
|
||||
end
|
||||
|
||||
|
||||
vim.api.nvim_create_user_command('Connect',
|
||||
function(args)
|
||||
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,
|
||||
}
|
||||
)
|
||||
if M.jobid <= 0 then
|
||||
print("[!] could not start codemp client")
|
||||
end
|
||||
end,
|
||||
{ nargs='?', bang=true })
|
||||
|
||||
|
@ -83,6 +85,10 @@ vim.api.nvim_create_user_command('Stop',
|
|||
|
||||
vim.api.nvim_create_user_command('Share',
|
||||
function(args)
|
||||
if M.jobid <= 0 then
|
||||
print("[!] connect to codemp server first")
|
||||
return
|
||||
end
|
||||
local path = args.fargs[1]
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
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',
|
||||
function(args)
|
||||
if M.jobid <= 0 then
|
||||
print("[!] connect to codemp server first")
|
||||
return
|
||||
end
|
||||
local path = args.fargs[1]
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
hook_callbacks(path, bufnr)
|
||||
|
|
|
@ -164,10 +164,7 @@ impl Handler for NeovimHandler {
|
|||
if let Err(e) = _b.clear_namespace(ns, 0, -1).await {
|
||||
error!("could not clear previous cursor highlight: {}", e);
|
||||
}
|
||||
if let Err(e) = _b.add_highlight(
|
||||
ns, "ErrorMsg",
|
||||
cur.row as i64 - 1, cur.col as i64 - 1, cur.col as i64
|
||||
).await {
|
||||
if let Err(e) = _b.add_highlight(ns, "ErrorMsg", cur.row-1, cur.col, cur.col+1).await {
|
||||
error!("could not create highlight for cursor: {}", e);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue