Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(recipes.md): faithfully implement supertab functionality #113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

theol0403
Copy link
Contributor

@theol0403 theol0403 commented Oct 8, 2024

Supertab is awesome, and is one of the best systems for rapidly selecting and accepting completions!

It is awesome that LazyVim provides a recipe for setting up this behavior -- it has been a long time since I've enjoyed a functional supertab implementation (vscode and emacs have rough approximations).

Shortcomings of current recipe

Unfortunately, the corners are still a little rough, and it doesn't faithfully implement what I consider to be one of the best functionalities of supertab:

  1. speed: if you want to accept the 1st suggestion, you only need ONE keystroke (hit TAB). if you want the 2nd suggestion, hit TAB twice, etc. then keep typing as usual. There is no need to scroll the completions, then hit enter to select, etc.
  2. one key for one purpose: Leave enter alone. If you are typing rapidly, and write multiple lines of code... it is not ideal when you realized that every time you pressed enter, it accepted a suggestion instead of making a new line.

Demo

Perhaps these screenshots will help (trying to accept self._initializer, then an n-th suggestion).

Before:

wezterm-gui_2ECYaitRut.mp4

After:

wezterm-gui_3bKNADdIQi.mp4

Solution

  • Don't preselect the first completion (so you can select it by hitting TAB one time)
  • When there isn't a completion selected, enter does not select it, and instead creates a newline

NOTE: this replaces the CR mapping to LazyVim.cmp.confirm. I'm not completely sure what this does, but should the original functionality from LazyVim.cmp.confirm be included somewhere here?

Refs:

I will make a PR to starter once this is merged.

@theol0403 theol0403 changed the title docs: update supertab recipe to faithfully implement supertab functionality docs(recipes.md): faithfully implement supertab functionality Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant