add autocomplete:cycle

Some (probably lots) of people are used to tabbing through autocomplete.
now, tab is binded to autocomplete:cycle while enter is binded to
autocomplete:complete.
This commit is contained in:
takase1121 2021-09-08 22:46:21 +08:00 committed by Francesco
parent 51f27e47ca
commit 1a21c66353
1 changed files with 9 additions and 2 deletions

View File

@ -502,6 +502,11 @@ command.add(predicate, {
suggestions_idx = math.min(suggestions_idx + 1, #suggestions)
end,
["autocomplete:cycle"] = function()
local newidx = suggestions_idx + 1
suggestions_idx = newidx > #suggestions and 1 or newidx
end,
["autocomplete:cancel"] = function()
reset_suggestions()
end,
@ -511,9 +516,11 @@ command.add(predicate, {
-- Keymaps
--
keymap.add {
["tab"] = "autocomplete:complete",
["return"] = "autocomplete:complete",
["keypad enter"] = "autocomplete:complete",
["up"] = "autocomplete:previous",
["down"] = "autocomplete:next",
["tab"] = "autocomplete:cycle",
["escape"] = "autocomplete:cancel",
}