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.76k stars 143 forks source link

We should enable filtering completion items after trigger #728

Open krassowski opened 2 years ago

krassowski commented 2 years ago

What are you trying to do?

While nice language servers perform server-side filtering of completion items, the LSP protocol itself does not make it mandatory; moreover the long-standing request to make it part of the protocol (https://github.com/microsoft/language-server-protocol/issues/898) was closed in October and will not be enacted.

How is it done today, and what are the limits of current practice?

Currently we do not filter the response to the initial request after trigger to match the current token:

Screenshot from 2021-12-19 18-38-54

This means thousands of irrelevant completion items and delay in rendering of completer list for servers which do not filter on the server side (like typescript-language-server).

What is new in your approach and why do you think it will be successful?

https://github.com/microsoft/language-server-protocol/issues/898#issuecomment-593968008 describes how clients should behave (and how they should not filter completion items with text edits).

bollwyvl commented 2 years ago

Sure, I guess if it's what we need.

Some questions for discussion:

krassowski commented 2 years ago

We do not want to filter messages - we want to filter things shown in the completer; this is to allow instant completions from cache (this is discussed upstream in LSP repo and I outlined changes we need upstream in JupyterLab in https://github.com/jupyterlab/jupyterlab/issues/9763#issuecomment-1001619638). The initial hotfix for the typescript situation is in #735 - it is sufficient for now because we do not use textEdit just yet, but it is not the ultimate solution.

krassowski commented 2 years ago

It does not preclude filtering messages - just not useful here because we want to have all completion items cached on the frontend.