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.82k stars 148 forks source link

Several inconsistencies found, trying to configure pylsp #1048

Open michaelaye opened 10 months ago

michaelaye commented 10 months ago

This project's main README describes installing an example server like so, using the Advanced Settings Editor:

{
  "language_servers": {
    "pyls": {
      "serverSettings": {
        "pyls.plugins.pydocstyle.enabled": true,
        "pyls.plugins.pyflakes.enabled": false,
        "pyls.plugins.flake8.enabled": true
      }
    },
    "r-languageserver": {
      "serverSettings": {
        "r.lsp.debug": false,
        "r.lsp.diagnostics": false
      }
    }
  }
}

But when trying to use the settings for Language Servers, since recently called "Language Servers (Experimental)", it seems one first needs to create a new language server with the right server name and manually activate it with a switch:

image

and then opening the JSON Settings Editor, some of the JSON keywords seem to not match above given instructions:

image

i.e.:

(indicating the recommended replacement of pyls with pylsp).

Note, that this is just an observation of inconsistencies, while I tried to find out how to get a python lsp server running, which I haven't been able to do so far. Something has changed as I was able to do to so before, even wrote a medium post about it...

Another observation: Anytime I added a property using the GUI, the terminal log said:

2024-02-06 13:18:26,728 CET - WARNING - pylsp_jsonrpc.endpoint - Ignoring notification for unknown method $/setTrace
krassowski commented 10 months ago

Language Servers (Experimental)

You do not have this extension installed (or enabled, or both). This is coming from JupyteLab 4.0+ and is non functional without this extension (or another one). This extension replaces Language Servers (Experimental) with Language Servers

krassowski commented 10 months ago

Personally I am not happy that upstream includes Language Servers (Experimental) but no LSP features (which are in this extension) - if it has no features, I would prefer it to not show that settings page at all, but was told that I can just replace it downstream here so here we are. Also there is so much I can do convincing other to embrace LSP features upstream. It really comes down to users voice (and funding).

krassowski commented 10 months ago

Feel welcome to submit PR replacing pyls with pylsp in readme :)

michaelaye commented 10 months ago

Ugh, that one escaped me, I had jupyter-lsp, and jupyter-lsp-python, but not that one. Ironically, I wrote it correct in my old blog post, but STILL overlooked it now. :( Will send a PR.

michaelaye commented 10 months ago

Hm, now i don't have ANY language server settings shown anymore.. because I filled something into the experimental settings?

michaelaye commented 10 months ago

still have some stuff disabled, don't understand difference between @jupyterlab/lsp-extension (disabled) and @jupyter-lsp/jupyterlab-lsp (enabled). still no settings there, hmpf.

krassowski commented 10 months ago

Can you try choosing and reopening settings tab? There is a known issue with some settings categories not showing up when loading for the first time with Settings editor open.

If it suits not help, is there anything in the browser console?

michaelaye commented 10 months ago

created new clean env and only installed jupyterlab-lsp and jupyter-lsp-python.

Settings still do not appear, but pylsp is being loaded. This is in the console:

image

michaelaye commented 10 months ago

possibly more important context before that:

image

krassowski commented 10 months ago

Yes, this one suggests that you may have an invalid setting in pylsp.configurationSources. It should be either pyflakes of pyflakes:

https://github.com/jupyter-lsp/jupyterlab-lsp/blob/5afe3b406e6f5d19952c0a70ba859e7f8b0f3d61/python_packages/jupyter_lsp/jupyter_lsp/specs/config/pylsp.schema.json#L5-L14

Can you check/clear your settings? These are stored on disk in a path indicated by jupyter lab path under @jupyter-lsp/jupyterlab-lsp/plugin.jupyterlab-settings.

krassowski commented 10 months ago

Wait, you should not need to edit files on disk. You should be able to access the panel in the JSON Settings Editor

michaelaye commented 10 months ago

Sorry, i don't know how to get to the pylsp settings with the JSON Settings Editor when they don't appear in the list:

image

krassowski commented 10 months ago

Thank you, this is a bug. It should be there even if validation fails.

krassowski commented 10 months ago

What about editing the file on disk?

michaelaye commented 10 months ago

yes, i removed my settings folder for jupyterlab-lsp and now the entry appears in the settings UI, thanks!

michaelaye commented 10 months ago

Maybe i should open another DOCS issue about this, but I can't find on how to activate notebook formatting (for example isort or yapf) using pylsp in the notebook? I only find advice on how to run pylsp in the terminal...