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".
Between Utils.prepend_line_number() and its only caller, there is a lot
of conversions from list to string to list and back to string. Simplify
all of this by making it accept and return a list of strings, which
avoids unnecessary splitting and joining.
The implementation was updated to use vim.iter():map() and
string.format() for better performance and to align with the idiomatic
functional style used elsewhere in the project.
The name of the function has also been tweaked and is now
"prepend_line_numbers()" to better reflect that it operates on a list of
strings.
The caller has been updated to match the new function signature.
Instead of implementing synchronous call to a command line utility via
vim.uv.spawn() switch to using vim.system(). Its return value (object)
wait() method allows to specify timeout too.
This makes code much simpler.
As discussed in https://github.com/yetone/avante.nvim/pull/2536 the
project should either use luv bindings from luals or luvit-meta
library, but not both, as they conflict with each other (especially
with uv.uv_timer_t). Given that other projects such as kickstart.nvim
and lazydev.nvim are switching to use the former, we should do the same
and drop luvit-meta dependency.
Also adjust code that was using luvit-meta's annotations for timers.