Closed imaia closed 6 years ago
You'd still like for the tab to work normally when there is no pattern in front that could be completed?
Then a small custom function would've to be written that checks the current context at the cursor. If it matches anything useful on tab then do editor-complete
, otherwise editor-smart-tab
.
Otherwise, if you do not need tab you could add the following snippet to your init.lua
configuration file.
howl.bindings.push {
editor = {
tab = 'editor-complete'
}
}
You'd still like for the tab to work normally when there is no pattern in front that could be completed?
Yes, I would. By the way, how can I not trigger autocomplete on pushing "enter"? Just have a normal enter behavior.
Then a small custom function would've to be written that checks the current context at the cursor. If it matches anything useful on tab then do editor-complete, otherwise editor-smart-tab.
Any suggestions on how to do that?
The dot is there because it is not included inside the word pattern the Lua bundle uses. This means that when there is either a dot or something that counts as a new word completion triggers, otherwise it runs the editor-smart-tab
command. To work for a broader set of languages this might have to be tweaked a bit (especially the dot part).
howl.bindings.push {
editor = {
tab = function (editor)
if editor.current_context.word_prefix == "" and editor.current_context.prev_char ~= "." then
howl.command["editor-smart-tab"]()
else
howl.command["editor-complete"]()
end
end
}
}
Regarding the enter question, you mean you'd like to go to the next element in the autocomplete popup instead of choosing the highlighted option when pressing enter?
When I press enter, I wish to just go to the next line in text. That is the same behavior vscode gives me and as I'm used to it I would rather keep it.
Just like this?
howl.bindings.push {
editor = {
['return'] = 'cursor-down'
}
}
Or with an additional move to the beginning or end of line?
howl.bindings.push {
editor = {
['return'] = function (e)
howl.command['cursor-down']()
howl.command['cursor-home']()
-- or this: howl.command['cursor-line-end']()
end
}
}
Any chance for further side effects? Shouldn't I change the return behavior only when a autocomplete "window" pops-up? Any idea where can I see the whole mapping, @rokf ?
It is currently not possible to change the return
behavior in a MenuPopup
(such as the completion popup) via init
file configuration. You'd have to change the howl/lib/howl/ui/menu_popup.moon
file to do that. It might get configurable in the future.
You could probably monkey-patch the classes though...
This has come up in the past, so I'm marking this as a feature request. I'm thinking we could probably cover most peoples needs by having an option for the different behaviours (which I believe is primarily whether to use tab
or enter
accepting completions, but another thing would be to support tabbing through items using tab
as well).
Hello, how can I change the autocomplete binding from enter to tab, disabling the enter action for triggering autocomplete? I usually use enter to change line and tab to confirm autocomplete.