GithubHelp home page GithubHelp logo

tchigher / jupyterlab-lsp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jupyter-lsp/jupyterlab-lsp

0.0 0.0 0.0 2.35 MB

Language Server Protocol integration for JupyterLab (code navigation + hover suggestions + linters + autocompletion + rename)

License: BSD 3-Clause "New" or "Revised" License

JavaScript 0.58% Shell 0.20% TypeScript 75.80% CSS 1.47% Python 14.63% R 0.05% RobotFramework 5.94% Dockerfile 0.01% Jupyter Notebook 1.32%

jupyterlab-lsp's Introduction

Language Server Protocol integration for Jupyter(Lab)

Build Status Build Status Documentation Status Binder

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

Quick Links: Installation | Configuring | Updating | 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 Ctrl to get a tooltip with function/class signature, module documentation or any other piece of information that the language server provides

hover

Diagnostics

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

inspections

Jump to Definition

Use the context menu entries to jump to definitions

jump

Highlight References

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

Automatic Completion

Certain characters, for example '.' (dot) in Python, will automatically trigger completion

invoke

Automatic Signature Suggestions

Function signatures will automatically be displayed

signature

Kernel-less Autocompletion

Advanced static-analysis autocompletion without a running kernel

autocompletion

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

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.

panel

Prerequisites

Either:

  • JupyterLab >=2,<3.0.0a0

And:

  • Python 3.5+
  • nodejs 10+

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

    conda install -c conda-forge 'jupyterlab>=2,<2.1.0a0'
    # or
    pip install 'jupyterlab>=2,<2.1.0a0'
  3. install the server extension:

    pip install jupyter-lsp
  4. install nodejs

    conda install -c conda-forge nodejs
    # or one of the following, as an administrator
    choco install nodejs            # Windows with Chocolatey
    sudo apt-get install nodejs     # Debian/Ubuntu
    sudo brew install nodejs        # MacOS with Homebrew
    sudo dnf install nodejs         # Fedora
    sudo yum install nodejs         # RHEL/CentOS
  5. install the frontend extension:

    jupyter labextension install @krassowski/jupyterlab-lsp           # for JupyterLab 2.x
    # jupyter labextension install @krassowski/[email protected]   # for JupyterLab 1.x
  6. install LSP servers for languages of your choice; for example, for Python (pyls) and R (languageserver) servers:

    pip install python-language-server[all]
    R -e 'install.packages("languageserver")'

    or from conda-forge

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

    Please see our full list of supported language servers which includes installation hints for the common package managers (npm/pip/conda). In general, any LSP server from the Microsoft list should work after some additional configuration.

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

    Note on pyls (python-language-server) issues: pyls is known to require specific versions of some dependencies such as ujson <= 1.35, jedi == 0.15.2 and parso == 0.5.2. If you experience any issues with LSP functions in Python, please check if you have the right version using pip freeze command.

  7. (Optional, Linux/OSX-only) to enable opening files outside of the root directory (the place where you start JupyterLab), create .lsp_symlink and symlink your /home, or any other location which includes the files that you wish 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 available here.

Updating

To update previously installed extensions:

pip install -U jupyter-lsp
jupyter labextension update @krassowski/jupyterlab-lsp

Getting the latest alpha/beta/RC version

Use install command (update does not seem to work) appending @<0.x.y.rc-z> to the extension name, like this:

jupyter labextension install @krassowski/[email protected]

Configuring the servers

We plan to provide a configuration GUI at some time (#25), but in the meantime, you can use the instructions for the specific servers as described on their websites (see the table of language servers for links).

I want to hide specific diagnostics/inspections/warnings

For example, the Python server that we support by default (pyls) has a configuration section in their documentation which refers to the providers of specific features, including pycodestyle for inspections/diagnostics.

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 at wylieconlon/lsp-editor-adapter.

jupyterlab-lsp's People

Contributors

andaag avatar bollwyvl avatar dependabot[bot] avatar fcollonval avatar krassowski avatar yunair avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.