mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
feat: send an away cursor when going on other bufs
This commit is contained in:
parent
df47c21629
commit
9b6739b167
1 changed files with 11 additions and 0 deletions
|
@ -33,17 +33,28 @@ end
|
||||||
---@param ws Workspace
|
---@param ws Workspace
|
||||||
local function register_cursor_callback(ws)
|
local function register_cursor_callback(ws)
|
||||||
local controller = ws.cursor
|
local controller = ws.cursor
|
||||||
|
local once = true
|
||||||
vim.api.nvim_create_autocmd({"CursorMoved", "CursorMovedI", "ModeChanged"}, {
|
vim.api.nvim_create_autocmd({"CursorMoved", "CursorMovedI", "ModeChanged"}, {
|
||||||
group = vim.api.nvim_create_augroup("codemp-workspace-" .. ws.name, { clear = true }),
|
group = vim.api.nvim_create_augroup("codemp-workspace-" .. ws.name, { clear = true }),
|
||||||
callback = function (_)
|
callback = function (_)
|
||||||
local cur = utils.cursor.position()
|
local cur = utils.cursor.position()
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
if buffers.map[buf] ~= nil then
|
if buffers.map[buf] ~= nil then
|
||||||
|
once = true
|
||||||
local _ = controller:send({
|
local _ = controller:send({
|
||||||
buffer = buffers.map[buf],
|
buffer = buffers.map[buf],
|
||||||
start = cur[1],
|
start = cur[1],
|
||||||
finish = cur[2],
|
finish = cur[2],
|
||||||
}) -- no need to await here
|
}) -- no need to await here
|
||||||
|
else -- set ourselves "away" only once
|
||||||
|
if once then
|
||||||
|
local _ = controller:send({
|
||||||
|
buffer = "",
|
||||||
|
start = { 0, 0 },
|
||||||
|
finish = { 0, 0 },
|
||||||
|
}) -- no need to await here
|
||||||
|
end
|
||||||
|
once = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue