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

SageMath uses python lsp, and reports a lot of errors #910

Open anstadnik opened 1 year ago

anstadnik commented 1 year ago

Description

image Here, it complains about the undefined name "matrix"

Reproduce

  1. Install SageMath
  2. Install jupyterlab-lsp
  3. Write SageMath code
  4. Observe the errors

Expected behavior

LSP should be turned off by default.

Context

Required: installed server extensions

```
    jupyter_lsp enabled
    - Validating jupyter_lsp...
      jupyter_lsp 1.5.1 OK
    jupyter_server_mathjax enabled
    - Validating jupyter_server_mathjax...
      jupyter_server_mathjax  OK
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 3.4.3 OK
    jupyterlab_code_formatter enabled
    - Validating jupyterlab_code_formatter...
      jupyterlab_code_formatter 1.4.10 OK
    jupytext enabled
    - Validating jupytext...
      jupytext 1.11.5 OK
    nbclassic enabled
    - Validating nbclassic...
      nbclassic  OK
    nbdime enabled
    - Validating nbdime...
      nbdime 3.1.1 OK

Config dir: /usr/local/etc/jupyter
```
Required: installed lab extensions

```
        jupyterlab-plotly v5.5.0 enabled OK
        nbdime-jupyterlab v2.1.1 enabled OK
        jupyterlab-jupytext v1.3.4 enabled OK (python, jupytext)
        @jupyter-widgets/jupyterlab-manager v3.0.1 enabled OK (python, jupyterlab_widgets)
        @ryantam626/jupyterlab_code_formatter v1.4.10 enabled OK (python, jupyterlab-code-formatter)
        @krassowski/jupyterlab-lsp v3.10.1 enabled OK (python, jupyterlab-lsp)
```
Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
Command Line Output
Paste the output from your command line running `jupyter lab` here, use `--debug` if possible.
Browser Output (recommended for all interface issues)
Paste the output from your browser JavaScript console replacing the text in here.

To learn how to open the developer tools in your browser:
https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools#How_to_open_the_devtools_in_your_browser
If too many messages accumulated after many hours of working in JupyterLab,
consider refreshing the window and then reproducing the bug to reduce the noise in the logs.

krassowski commented 1 year ago

Is SageMath shipping a custom kernel which defines these variables? If so, it probably should not advertise that it uses Python language as standard Python does not have matrix built-in.

krassowski commented 1 year ago

It looks that SageMath does not populate language_info the way one would expect (it always populates it with Python as name of language). In jupytext, https://github.com/mwouts/jupytext/pull/732 workarounds this by using language from kernel specs instead, which could be used in jupyterlab-lsp too.