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
Examples show Python code, but most features also work in R, bash, typescript, and many other languages.
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
Critical errors have red underline, warnings are orange, etc. Hover over the underlined code to see a more detailed message
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
Place your cursor on a variable, function, etc and all the usages will be highlighted
- Certain characters, for example '.' (dot) in Python, will automatically trigger completion.
- You can choose to receive the completion suggestions as you type by enabling
continuousHinting
setting.
Function signatures will automatically be displayed
Advanced static-analysis autocompletion without a running kernel
When a kernel is available the suggestions from the kernel (such as keys of a dict and columns of a DataFrame) are merged with the suggestions from 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
section
of Advanced Settings. Alternatively if you only want kernel completions you can add "LSP"
to the same
setting; Or add both if you like to code in hardcore mode and get no completions, or if another provider has been added.
Rename variables, functions and more, in both: notebooks and the file editor. Use the context menu option or the F2 shortcut to invoke.
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.
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.
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.
-
install python 3
conda install -c conda-forge python=3
-
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-python
orjupyter-lsp-r
to install both the server extension and the language server. -
install LSP servers for languages of your choice; for example, for Python (pylsp) and R (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 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 1: it is worth visiting the repository of each server you install as many 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 should not be used in production yet, but will likely benefit individual users You can check it out with:pip install git+https://github.com/krassowski/python-language-server.git@main
Please report any regressions here.
-
(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-server as described in the Note 2 (above). -
(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.
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 withpyslp
{
"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
}
}
}
}
}
}
}
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.
This would not be possible without the fantastic initial work at wylieconlon/lsp-editor-adapter.