jupyter-lsp / jupyterlab-lsp

Coding assistance for JupyterLab (code navigation + hover suggestions + linters + autocompletion + rename) using Language Server Protocol
https://jupyterlab-lsp.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.77k stars 144 forks source link

No methods to use Tab instead of Enter to accept a suggestion in Jupyter LSP Code Completion? #1087

Open blackpancake opened 1 month ago

blackpancake commented 1 month ago

Description

I’ve noticed that when I use autocomplete in JupyterLab running in the browser, the Language Server Protocol (LSP) defaults to using Enter as the shortcut key to accept a selected suggestion, while Tab and the up/down arrows can be used to scroll through the list of suggestions. This is contrary to my usage habits in other editors like VSCode, where pressing Tab always accepts the suggestion. I'm finding methods to change it.

image LSP extension uses a tab as the shortcut key to accept a selected suggestion only when there is just one candidate(enumerate). This matches my usage habits in VSCode.

image

But when there are many candidates(abs, all, any,..), pressing the tab only results in selecting the next candidate instead of accepting "abs".It is the Enter that would make it accepted. That's odd.

what I did:

  1. Open JupyterLab and click on the Settings dropdown menu.
  2. Select Advanced Settings Editor.
  3. Select Keyboard Shortcuts.

I’ve searched through the entire Keyboard Shortcuts, but I couldn’t find a command called ‘Accept a suggestion’, nor could I find an option to change its keybinding. Is there a way to make the behaviors in these two situations consistent?

Information

Version:

$jupyter --version
Selected Jupyter core packages...
IPython          : 8.24.0
ipykernel        : 6.29.4
ipywidgets       : not installed
jupyter_client   : 8.6.2
jupyter_core     : 5.7.2
jupyter_server   : 2.14.0
jupyterlab       : 4.2.1
nbclient         : 0.10.0
nbconvert        : 7.16.4
nbformat         : 5.10.4
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.14.3
$python -V
Python 3.11.9

Some additional and geeky information: the jupyter lab was deployed on Termux.

Browser: Microsoft Edge Version 125.0.2535.67 (official version) (64 bit)

System: Windows 10

krassowski commented 1 month ago

I agree that the keybinding for accepting completions should be customizable. The relevant codebase however is in JupyterLab, not in this extension. Can you open an issue over at https://github.com/jupyterlab/jupyterlab/issues? I can then provide some pointers on how to implement this if you are interested in contributing.

blackpancake commented 1 month ago

https://github.com/jupyterlab/jupyterlab/issues/12583

I agree that the keybinding for accepting completions should be customizable. The relevant codebase however is in JupyterLab, not in this extension. Can you open an issue over at https://github.com/jupyterlab/jupyterlab/issues? I can then provide some pointers on how to implement this if you are interested in contributing.

And I find this is indeed a long-standing issue: https://github.com/jupyterlab/jupyterlab/issues/12583 (opened on May 16, 2022 · 8 comments)