import sys
from markdown import markdown
sys.path.insert(0, "..")
from versions import (
JUPYTER_LSP_VERSION,
JUPYTERLAB_LSP_VERSION,
JUPYTERLAB_NEXT_MAJOR_VERSION,
JUPYTERLAB_VERSION,
REQUIRED_JUPYTERLAB,
)
%%markdown
### Please Read This First
Delivering LSP features to your JupyterLab **requires** three pieces:
#### `jupyter-lsp`
- runs in your `notebook` web application on your server to handle requests from
the browser to _language servers_
- to run, you need:
- `python >=3.5`
- `notebook >=4.3`
#### `jupyterlab-lsp`
- runs in your browser, as an extension to JupyterLab
- to install it, you need:
- `nodejs >8`
- `jupyterlab {REQUIRED_JUPYTERLAB}`
#### Language Servers
- run on your server
- probably in another language runtime than python
- some can be automatically [detected](./Language%20Servers.ipynb) if installed
- others also need to be [configured](./Configuring.ipynb#language_servers)
Here are two approches based on Jupyter documentation. If these do not meet your needs, try The Harder Way.
%%markdown
#### conda (minimal python)
```bash
conda create -c conda-forge -n lsp 'python >=3.7,<3.8' 'jupyterlab={JUPYTERLAB_VERSION}' 'nodejs>10' python-language-server
# Also consider: r-languageserver [*]
source activate lsp
python -m pip install 'jupyter-lsp={JUPYTER_LSP_VERSION}' --no-deps
jupyter labextension install '@krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}'
```
Then run
```bash
jupyter lab
```
Your browser should open to your local server.
This approach is based roughly on the Jupyter docker-stacks documentation, which should be consulted for more about connecting volumes, passwords, and other advanced features:
%%markdown
##### `Dockerfile`
```dockerfile
# This already contains the python, r, julia, latex, and nodejs runtimes
FROM jupyter/datascience-notebook@sha256:73a577b006b496e1a1c02f5be432f4aab969c456881c4789e0df77c89a0a60c2
RUN conda install --quiet --yes --freeze-installed -c conda-forge \
'python-language-server' \
'jupyterlab={JUPYTERLAB_VERSION}' \
'r-languageserver' \
'texlab' \
'chktex' \
&& python3 -m pip install --no-cache-dir --no-deps \
'jupyter-lsp={JUPYTER_LSP_VERSION}' \
&& jupyter labextension install --no-build \
'@krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}' \
&& jupyter lab build --dev-build=False --minimize=True \
&& conda clean --all -f -y \
&& rm -rf \
$CONDA_DIR/share/jupyter/lab/staging \
/home/$NB_USER/.cache/yarn \
&& fix-permissions $CONDA_DIR \
&& fix-permissions /home/$NB_USER
```
docker-compose.yml
¶version: '2'
services:
lsp-lab:
build: .
ports:
- '18888:8888'
docker-compose up
You should now be able to access http://localhost:18888/lab
, using the token
provided in the log.
Refer to the official JupyterLab Installation Documentation for your installation approach.
pip | conda | pipenv | poetry | * |
---|---|---|---|---|
lab | lab | * |
* |
* |
*
PRs welcome!
Verify your lab works:
jupyter lab --version
jupyter lab
The JupyterLab Development Environment Documentation shows some approaches for getting NodeJS.
conda | * |
---|---|
nodejs | * |
Verify your node works and is findable from python.
jlpm versions
%%markdown
#### Install Jupyter[Lab] LSP
```bash
pip install jupyter-lsp={JUPYTER_LSP_VERSION}
jupyter labextension install @krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}
```
Now that you have jupyterlab-lsp
, jupyter-lsp
and all of their dependencies,
you'll need some language servers. See:
jupyter-lsp
for more control over which
servers to load