feat!(selection): do not display hint immediately

Selection hint that is displayed immediately upon entering visual mode
([<leader>aa: ask, <leader>ae: edit]) gets old pretty quickly. Add a
config option to control when the hint is displayed:

  selection = {
    enabled = true,
    hint_display = "delayed",
  },

The "hint_display" option recognizes the following values:

- "immediate" results in the hint being shown immediately after entering
  visual mode. This is the old behavior.
- "delayed" causes the hint be displayed only if the cursor has not been
  moved for vim.o.updatetime milliseconds. This is the new default.
- "none" suppresses showing the hint completely.

Unfortunately "CursorHold" event is not emitted in visual mode so we
have to emulate it using Utils.debounce().

This is a breaking change because selection behavior was controller by
"hints" config entry which makes little sense, so the config section and
associated commands were renamed to "selection".

Additionally the "hints"/"selection" was mapped to "<leader>ah", but the
very same key combination was used to select from old Avante chat
histories, which overrode the toggle. New selection toggle keymap is
"<leader>aC".
This commit is contained in:
Dmitry Torokhov
2025-07-25 17:48:42 -07:00
committed by yetone
parent bd2079a5cc
commit fed6902c9a
5 changed files with 55 additions and 19 deletions

View File

@@ -528,7 +528,7 @@ M._defaults = {
toggle = {
default = "<leader>at",
debug = "<leader>ad",
hint = "<leader>ah",
selection = "<leader>aC",
suggestion = "<leader>as",
repomap = "<leader>aR",
},
@@ -645,9 +645,14 @@ M._defaults = {
--- Disable by setting to -1.
override_timeoutlen = 500,
},
--- @class AvanteHintsConfig
hints = {
--- Allows selecting code or other data in a buffer and ask LLM questions about it or
--- to perform edits/transformations.
--- @class AvanteSelectionConfig
--- @field enabled boolean
--- @field hint_display "delayed" | "immediate" | "none" When to show key map hints.
selection = {
enabled = true,
hint_display = "delayed",
},
--- @class AvanteRepoMapConfig
repo_map = {