当前位置: 首页 > 软件库 > 神经网络/人工智能 > >

jupyterlab-lsp

授权协议 BSD-3-Clause License
开发语言 Python
所属分类 神经网络/人工智能
软件类型 开源软件
地区 不详
投 递 者 马奇略
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Language Server Protocol integration for Jupyter(Lab)

tests

This project is still maturing, but you are welcome to check it out, leave feedback and/or a PR

Quick Links: Installation | Configuring | Changelog | Roadmap | Contributing | Extending

Features

Examples show Python code, but most features also work in R, bash, typescript, and many other languages.

Hover

Hover over any piece of code; if an underline appears, you can press Ctrlto get a tooltip with function/class signature, module documentation or any otherpiece of information that the language server provides

hover

Diagnostics

Critical errors have red underline, warnings are orange, etc. Hoverover the underlined code to see a more detailed message

inspections

Jump to Definition

Use the context menu entry, or Alt + ��️ to jump to definitions (you can change it to Ctrl/ in settings); use Alt + o to jump back

jump

Highlight References

Place your cursor on a variable, function, etc and all the usages will be highlighted

Automatic Completion and Continuous Hinting

  • Certain characters, for example '.' (dot) in Python, will automatically triggercompletion.
  • You can choose to receive the completion suggestions as you type by enabling continuousHinting setting.

invoke

Automatic Signature Suggestions

Function signatures will automatically be displayed

signature

Kernel-less Autocompletion

Advanced static-analysis autocompletion without a running kernel

autocompletion

The runtime kernel suggestions are still there

When a kernel is available the suggestions from the kernel (such as keys of adict and columns of a DataFrame) are merged with the suggestionsfrom the Language Server (in notebook).

If the kernel is too slow to respond promptly only the Language Server suggestions will be shown (default threshold: 0.6s).You can configure the completer to not attempt to fetch the kernel completions if the kernel is busy (skipping the 0.6s timeout).

You can deactivate the kernel suggestions by adding "Kernel" to the disableCompletionsFrom in the completion sectionof Advanced Settings. Alternatively if you only want kernel completions you can add "LSP" to the samesetting; Or add both if you like to code in hardcore mode and get no completions, or if another provider has been added.

Rename

Rename variables, functions and more, in both: notebooks and the file editor.Use the context menu option or the F2 shortcut to invoke.

rename

Diagnostics panel

Sort and jump between the diagnostics using the diagnostics panel.Open it searching for "Show diagnostics panel" in JupyterLab commands palette or from the context menu.Use context menu on rows in the panel to filter out diagnostics or copy their message.

panel

Prerequisites

You will need to have both of the following installed:

  • JupyterLab >=3.0.0,<4.0.0a0
  • Python 3.6+

In addition, if you wish to use javascript, html, markdown or any other NodeJS-based language server you will need to have appropriate NodeJS version installed.

Note: Installation for JupyterLab 2.x requires a different procedure, please consult the documentation for the extension version 2.x.

Installation

For more extensive installation instructions, see the documentation.

For the current stable version, the following steps are recommended.Use of a python virtualenv or a conda env is also recommended.

  1. install python 3

    conda install -c conda-forge python=3
  2. install JupyterLab and the extensions

    conda install -c conda-forge 'jupyterlab>=3.0.0,<4.0.0a0' jupyterlab-lsp
    # or
    pip install 'jupyterlab>=3.0.0,<4.0.0a0' jupyterlab-lsp

    Note: jupyterlab-lsp provides both the server extension and the lab extension.

    Note: With conda, you could take advantage of the bundles: jupyter-lsp-pythonor jupyter-lsp-r to install both the server extension and the language server.

  3. install LSP servers for languages of your choice; for example, for Python(pylsp) andR (languageserver) servers:

    # note: you may want to use our fork of python-language-server instead (see below)
    pip install 'python-lsp-server[all]'
    R -e 'install.packages("languageserver")'

    or from conda-forge

    conda install -c conda-forge python-lsp-server r-languageserver

    Please see our full list ofsupported language serverswhich includes installation hints for the common package managers (npm/pip/conda).In general, any LSP server from theMicrosoft listshould work after some additional configuration.

    Note 1: it is worth visiting the repository of each server you install asmany provide additional configuration options.

    Note 2: we are developing an improved (faster autocompletion, added features)version of the python-language-server. It is experimental and shouldnot be used in production yet, but will likely benefit individual usersYou can check it out with:

    pip install git+https://github.com/krassowski/python-language-server.git@main

    Please report any regressions here.

  4. (Optional, IPython users only) to improve the performance of autocompletion,disable Jedi in IPython (the LSP servers for Python use Jedi too).You can do that temporarily with:

    %config Completer.use_jedi = False
    

    or permanently by setting c.Completer.use_jedi = False in youripython_config.py file.You will also benefit from using experimental version of python-language-serveras described in the Note 2 (above).

  5. (Optional, Linux/OSX-only) to enable opening files outside of the rootdirectory (the place where you start JupyterLab), create .lsp_symlink andsymlink your /home, or any other location which includes the files that youwish to make possible to open in there:

    mkdir .lsp_symlink
    cd .lsp_symlink
    ln -s /home home

    If your user does not have sufficient permissions to traverse the entire path,you will not be able to open the file. A more detailed guide on symlinking(written for a related jupyterlab-go-to-definition extension) is availablehere.

Configuring the servers

Server configurations can be edited using the Advanced Settings editor in JupyterLab (Settings > Advanced Settings Editor). For settings specific to each server, please see the table of language servers. Example settings might include:

Note: for the new (currently recommended) python-lsp-server replace pyls occurrences with pylsp

{
  "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
      }
    }
  }
}

The serverSettings key specifies the configurations sent to the language servers. These can be written using stringified dot accessors like above (in the VSCode style), or as nested JSON objects, e.g.:

{
  "language_servers": {
    "pyls": {
      "serverSettings": {
        "pyls": {
          "plugins": {
            "pydocstyle": {
              "enabled": true
            },
            "pyflakes": {
              "enabled": false
            },
            "flake8": {
              "enabled": true
            }
          }
        }
      }
    }
  }
}

Other configuration methods

Some language servers, such as pyls, provide other configuration methods in addition to language-server configuration messages (accessed using the Advanced Settings Editor). For example, pyls allows users to configure the server using a local configuration file. You can change the inspection/diagnostics for server plugins like pycodestyle there.

The exact configuration details will vary between operating systems (please see the configuration section of pycodestyle documentation), but as an example, on Linux you would simply need to create a file called ~/.config/pycodestyle, which may look like that:

[pycodestyle]
ignore = E402, E703
max-line-length = 120

In the example above:

  • ignoring E402 allows imports which are not on the very top of the file,
  • ignoring E703 allows terminating semicolon (useful for matplotlib plots),
  • the maximal allowed line length is increased to 120.

After changing the configuration you may need to restart the JupyterLab, and please be advised that the errors in configuration may prevent the servers from functioning properly.

Again, please do check the pycodestyle documentation for specific error codes, and check the configuration of other feature providers and language servers as needed.

Acknowledgements

This would not be possible without the fantastic initial work atwylieconlon/lsp-editor-adapter.

  • JupyterLab 远程访问配置 安装 pip install jupyterlab 1.初始化并生成配置文件 jupyter lab --generate-config 系统会生成/root/.jupyter/jupyter_lab_config.py文件。 2.生成密码 ipython from jupyter_server.auth import passwd passwd() 输入

  • 推测为网络问题,更换language-server为 jedi-language-server,可能解决 anaconda prompt在对应环境下执行如下命令 conda install -c conda-forge jedi-language-server

 相关资料
  • JupyterLab LaTeX build stable latest An extension for JupyterLab which allows for live-editing of LaTeX documents. Usage To use, right-click on an open .tex document within JupyterLab, and select Show

  • JupyterLab Desktop A desktop application for JupyterLab, based on Electron. Download Before installing please read the Python Environment Customization Guide if you plan to customize the Python enviro

  • 大家好,堆栈溢出。今天,我想问一些非常不同的问题。 我目前是一名数据科学家,我在JupyterLab/笔记本上做了很多工作。我的几个同事用笔记本电脑代替了JupyterLab。看起来这两者之间并没有太大区别(我真的很喜欢JupyterLab以不同的颜色呈现代码的方式)。我在网上搜索过,上面写着 "JupyterLab是下一代的Jupyter笔记本" 然而,一些特写,如情节人物,在JupyterLa

  • 问题内容: 我正在使用Jupyter笔记本中的Jupyterlab。在我以前使用的笔记本中: 用于交互式地块。现在给我(在jupyterlab中): 我还尝试了魔术(安装了jupyter-matplotlib): 但这只是返回: 内联图 工作正常,但我想要交互式地块。 问题答案: 完成步骤 1. 安装nodejs,例如。 2. 安装ipympl,例如。 3. [可选,但推荐;更新JupyterLa

  • 我似乎找不到是什么引起的:/

  • 我是Jupyter笔记本电脑的新手,Jupyter笔记本电脑和JupyterLab的主要区别是什么,建议我选择最好的,以后应该使用。