feat: override timeoutlen while hovering over diff (#781)
This commit is contained in:
committed by
GitHub
parent
f8d80d87c5
commit
19ab7d51d5
@@ -299,15 +299,16 @@ local function register_cursor_move_events(bufnr)
|
||||
})
|
||||
end
|
||||
|
||||
api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI", "WinLeave" }, {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
callback = function(event)
|
||||
local position = get_current_position(bufnr)
|
||||
|
||||
if position then
|
||||
if (event.event == "CursorMoved" or event.event == "CursorMovedI") and position then
|
||||
show_keybinding_hint(position.current.range_start + 1)
|
||||
M.override_timeoutlen(bufnr)
|
||||
else
|
||||
api.nvim_buf_clear_namespace(bufnr, KEYBINDING_NAMESPACE, 0, -1)
|
||||
M.restore_timeoutlen(bufnr)
|
||||
end
|
||||
end,
|
||||
})
|
||||
@@ -377,6 +378,24 @@ H.clear_buffer_mappings = function(bufnr)
|
||||
if vim.fn.hasmapto(mapping, "n") > 0 then api.nvim_buf_del_keymap(bufnr, "n", mapping) end
|
||||
end
|
||||
vim.b[bufnr].avante_conflict_mappings_set = false
|
||||
M.restore_timeoutlen(bufnr)
|
||||
end
|
||||
|
||||
---@param bufnr integer
|
||||
M.override_timeoutlen = function(bufnr)
|
||||
if vim.b[bufnr].avante_original_timeoutlen then return end
|
||||
if Config.diff.override_timeoutlen > 0 then
|
||||
vim.b[bufnr].avante_original_timeoutlen = vim.o.timeoutlen
|
||||
vim.o.timeoutlen = Config.diff.override_timeoutlen
|
||||
end
|
||||
end
|
||||
|
||||
---@param bufnr integer
|
||||
M.restore_timeoutlen = function(bufnr)
|
||||
if vim.b[bufnr].avante_original_timeoutlen then
|
||||
vim.o.timeoutlen = vim.b[bufnr].avante_original_timeoutlen
|
||||
vim.b[bufnr].avante_original_timeoutlen = nil
|
||||
end
|
||||
end
|
||||
|
||||
M.augroup = api.nvim_create_augroup(AUGROUP_NAME, { clear = true })
|
||||
|
||||
Reference in New Issue
Block a user