JSPM

  • Created
  • Published
  • Downloads 328
  • Score
    100M100P100Q67010F
  • License BSD-3-Clause

Language Server Protocol integration for JupyterLab

Package Exports

  • @krassowski/jupyterlab-lsp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@krassowski/jupyterlab-lsp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Language Server Protocol integration for JupyterLab

Binder

Features overview:

Working:
  • hover over any piece of code; if an underline appears, you can press Control to get a tooltip with function/class signature, module documentation or any other piece of information that the language server provides
  • linting: critical errors have red underline, warnings are orange, etc. Hover over the underlined code to see the linter's message
  • go to definition: use context menu entries to jump to definition (currently only in the file editor)
  • highlight usages: just place your cursor on a variable, function ect and all the usages will be highlighted (only file editor or a single cell as well)
  • advanced autocompletion - even when the kernel is off!
In progress:
  • auto invocation of completer on certain characters (e.g. '.' (dot) in Python)
  • completer: merge suggestions from LSP, kernel and tokens (currently LSP and tokens only)
  • better go-to-definition functionality, including notebook
Planned:
  • "rename" action
May be included:
  • Gutter with linter results

This extension is highly experimental!

git clone https://github.com/krassowski/jupyterlab-lsp.git
cd jupyterlab-lsp
# dev-dependencies may be needed as well
npm install .
jupyter labextension install .

Install servers for languages of your choice. Below are examples for Python (with pyls) and R (with languageserver):

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

create file called servers.yml:

langservers:
  python:
    - pyls
  R:
    - R
    - --slave
    - -e
    - languageserver::run()

For the full list of language servers see the Microsoft's list; it may also be good to visit the repository of each server as many provide some additional configuration options.

Then run (TODO: could this be started by the extension?):

node node_modules/jsonrpc-ws-proxy/dist/server.js --port 3000 --languageServers servers.yml

To enable opening files outside of the root directory (the place where you start JupyterLab), create .lsp_symlink and symlink your home, usr, or any other location which include the files that you wish to make possible to open in there:

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

If your user does not have sufficient permissions to traverse the entire path, you will not be able to open the file.

Under the hood

This would not be possible if not the fantastic work of https://github.com/wylieconlon/lsp-editor-adapter.

Prerequisites

  • JupyterLab

Installation

jupyter labextension install @krassowski/jupyterlab_lsp@next

To update already installed extension:

jupyter labextension update @krassowski/jupyterlab_lsp

Development

For a development install (requires npm version 4 or later), do the following in the repository directory:

npm install
npm run build
jupyter labextension link .

To rebuild the package and the JupyterLab app:

npm run build
jupyter lab build

To run tests suite:

npm test