SpartanJ / ecode

Lightweight multi-platform code editor designed for modern hardware with a focus on responsiveness and performance.
MIT License
940 stars 13 forks source link

Feature request: Autocomplete using keybinds #337

Closed shyperson0 closed 3 weeks ago

shyperson0 commented 2 months ago

I've had autocomplete disabled for as long as I've been using this editor(it's become my set editor for a while, only using something else if ecode can't read some file encoding) because of one simple reason: up/down/enter is as common as it is terrible, what if I'm writing a new line after "Auto" but hitting enter causes me to write "Autocomplete", for a moment I thought this was configurable and took a peek under the hood but the keys are hard coded in the current develop. So the feature request is for the autocomplete plugin to be integrated with the keybinds system, for accessibility and usability.

SpartanJ commented 2 months ago

This is reasonable and something that I should have done properly the first time I implemented it, I'll try to add keybindings support soon. It's a shame that you're missing auto-completion because of this.

SpartanJ commented 2 months ago

Implemented here.

To configure a plugin keybinding user must go to `Settings -> Tools -> Plugin Manager -> click the plugin (pick it) and click on "Preferences", keybindings will be listed in the "keybindings" section, initially will look like;

{
  "config": {
    "max_label_characters": 100,
    "suggestions_syntax_highlight": true
  },
  "keybindings": {
    "autocomplete-close-signature-help": "escape",
    "autocomplete-close-suggestion": "escape",
    "autocomplete-first-suggestion": "home",
    "autocomplete-last-suggestion": "end",
    "autocomplete-next-signature-help": "down",
    "autocomplete-next-suggestion": "down",
    "autocomplete-next-suggestion-page": "pagedown",
    "autocomplete-pick-suggestion": "tab",
    "autocomplete-pick-suggestion-alt": "enter",
    "autocomplete-pick-suggestion-alt-2": "return",
    "autocomplete-prev-signature-help": "up",
    "autocomplete-prev-suggestion": "up",
    "autocomplete-prev-suggestion-page": "pageup",
    "autocomplete-update-suggestions": "mod+space"
  }
}

Any keybinding can be disabled by just clearing out the string (""). Most of them should be self-explanatory. alt is used for "alternative" keybinding, given your explanation you'll want to disable the two alt pick suggestions:

    "autocomplete-pick-suggestion-alt": "",
    "autocomplete-pick-suggestion-alt-2": "",

Feature will be available in next release (0.6.2).