jupyterlab-lsp icon indicating copy to clipboard operation
jupyterlab-lsp copied to clipboard

Several inconsistencies found, trying to configure pylsp

Open michaelaye opened this issue 1 year ago • 16 comments

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.:

  • language_servers is now languageServers
  • and pyls(p).serverSettings is now pyls(p).configuration

(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

michaelaye avatar Feb 06 '24 12:02 michaelaye

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 avatar Feb 06 '24 12:02 krassowski

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 avatar Feb 06 '24 12:02 krassowski

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

krassowski avatar Feb 06 '24 12:02 krassowski

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 avatar Feb 06 '24 12:02 michaelaye

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

michaelaye avatar Feb 06 '24 12:02 michaelaye

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.

michaelaye avatar Feb 06 '24 12:02 michaelaye

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?

krassowski avatar Feb 06 '24 12:02 krassowski

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 avatar Feb 06 '24 14:02 michaelaye

possibly more important context before that:

image

michaelaye avatar Feb 06 '24 15:02 michaelaye

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 avatar Feb 06 '24 15:02 krassowski

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

krassowski avatar Feb 06 '24 15:02 krassowski

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

michaelaye avatar Feb 06 '24 15:02 michaelaye

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

krassowski avatar Feb 06 '24 15:02 krassowski

What about editing the file on disk?

krassowski avatar Feb 06 '24 15:02 krassowski

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

michaelaye avatar Feb 06 '24 15:02 michaelaye

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...

michaelaye avatar Feb 06 '24 15:02 michaelaye