|
1 | 1 | {
|
2 | 2 | "cells": [
|
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "metadata": { |
| 7 | + "hide_input": true |
| 8 | + }, |
| 9 | + "outputs": [], |
| 10 | + "source": [ |
| 11 | + "from sys import path\n", |
| 12 | + "path.insert(0, '../py_src/jupyter_lsp')" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "code", |
| 17 | + "execution_count": null, |
| 18 | + "metadata": { |
| 19 | + "hide_input": true |
| 20 | + }, |
| 21 | + "outputs": [], |
| 22 | + "source": [ |
| 23 | + "import _version\n", |
| 24 | + "JUPYTER_LSP_VERSION = _version.__version__" |
| 25 | + ] |
| 26 | + }, |
| 27 | + { |
| 28 | + "cell_type": "code", |
| 29 | + "execution_count": null, |
| 30 | + "metadata": { |
| 31 | + "hide_input": true |
| 32 | + }, |
| 33 | + "outputs": [], |
| 34 | + "source": [ |
| 35 | + "import json\n", |
| 36 | + "\n", |
| 37 | + "with open('../packages/jupyterlab-lsp/package.json') as f:\n", |
| 38 | + " jupyterlab_lsp_package = json.load(f)\n", |
| 39 | + "\n", |
| 40 | + "JUPYTERLAB_LSP_VERSION = jupyterlab_lsp_package['version']\n", |
| 41 | + "JUPYTERLAB_VERSION = jupyterlab_lsp_package['devDependencies']['@jupyterlab/application'].lstrip('~^')\n", |
| 42 | + "JUPYTERLAB_NEXT_MAJOR_VERSION = int(JUPYTERLAB_VERSION.split('.')[0]) + 1\n", |
| 43 | + "\n", |
| 44 | + "REQUIRED_JUPYTERLAB = f'>={JUPYTERLAB_VERSION},<{JUPYTERLAB_NEXT_MAJOR_VERSION}'" |
| 45 | + ] |
| 46 | + }, |
| 47 | + { |
| 48 | + "cell_type": "code", |
| 49 | + "execution_count": null, |
| 50 | + "metadata": { |
| 51 | + "hide_input": true |
| 52 | + }, |
| 53 | + "outputs": [], |
| 54 | + "source": [ |
| 55 | + "from IPython.display import Markdown\n", |
| 56 | + "from IPython.core.magic import register_cell_magic\n", |
| 57 | + "\n", |
| 58 | + "\n", |
| 59 | + "@register_cell_magic\n", |
| 60 | + "def markdown(line, cell):\n", |
| 61 | + " \"\"\"Cell itnerpreted as Markdown but with variable substitution support.\n", |
| 62 | + "\n", |
| 63 | + " Variables from global environment will be substituted using the standard\n", |
| 64 | + " Python format mechanism which uses single curly braces (e.g. {variable})\n", |
| 65 | + " \"\"\"\n", |
| 66 | + " return Markdown(cell.format(**globals()))" |
| 67 | + ] |
| 68 | + }, |
3 | 69 | {
|
4 | 70 | "cell_type": "markdown",
|
5 | 71 | "metadata": {},
|
|
8 | 74 | ]
|
9 | 75 | },
|
10 | 76 | {
|
11 |
| - "cell_type": "markdown", |
12 |
| - "metadata": {}, |
| 77 | + "cell_type": "code", |
| 78 | + "execution_count": null, |
| 79 | + "metadata": { |
| 80 | + "hide_input": true |
| 81 | + }, |
| 82 | + "outputs": [], |
13 | 83 | "source": [
|
| 84 | + "%%markdown\n", |
14 | 85 | "### Please Read This First\n",
|
15 | 86 | "\n",
|
16 | 87 | "Delivering LSP features to your JupyterLab **requires** three pieces:\n",
|
|
28 | 99 | "- runs in your browser, as an extension to JupyterLab\n",
|
29 | 100 | "- to install it, you need:\n",
|
30 | 101 | " - `nodejs >8`\n",
|
31 |
| - " - `jupyterlab >=2.1,<3`\n", |
| 102 | + " - `jupyterlab {REQUIRED_JUPYTERLAB}`\n", |
32 | 103 | "\n",
|
33 | 104 | "#### Language Servers\n",
|
34 | 105 | "\n",
|
|
49 | 120 | ]
|
50 | 121 | },
|
51 | 122 | {
|
52 |
| - "cell_type": "markdown", |
53 |
| - "metadata": {}, |
| 123 | + "cell_type": "code", |
| 124 | + "execution_count": null, |
| 125 | + "metadata": { |
| 126 | + "hide_input": true |
| 127 | + }, |
| 128 | + "outputs": [], |
54 | 129 | "source": [
|
| 130 | + "%%markdown\n", |
55 | 131 | "#### conda (minimal python)\n",
|
56 | 132 | "\n",
|
57 | 133 | "```bash\n",
|
58 |
| - "conda create -c conda-forge -n lsp 'python >=3.7,<3.8' 'jupyterlab=2.1' 'nodejs>8' python-language-server\n", |
| 134 | + "conda create -c conda-forge -n lsp 'python >=3.7,<3.8' 'jupyterlab={JUPYTERLAB_VERSION}' 'nodejs>8' python-language-server\n", |
59 | 135 | "# Also consider: r-languageserver [*]\n",
|
60 | 136 | "source activate lsp\n",
|
61 |
| - "python -m pip install 'jupyter-lsp=0.8.0' --no-deps\n", |
62 |
| - "jupyter labextension install '@krassowski/jupyterlab-lsp@1.0.0'\n", |
| 137 | + "python -m pip install 'jupyter-lsp={JUPYTER_LSP_VERSION}' --no-deps\n", |
| 138 | + "jupyter labextension install '@krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}'\n", |
63 | 139 | "```\n",
|
64 | 140 | "\n",
|
65 | 141 | "Then run\n",
|
|
84 | 160 | ]
|
85 | 161 | },
|
86 | 162 | {
|
87 |
| - "cell_type": "markdown", |
88 |
| - "metadata": {}, |
| 163 | + "cell_type": "code", |
| 164 | + "execution_count": null, |
| 165 | + "metadata": { |
| 166 | + "hide_input": true |
| 167 | + }, |
| 168 | + "outputs": [], |
89 | 169 | "source": [
|
| 170 | + "%%markdown\n", |
90 | 171 | "##### `Dockerfile`\n",
|
91 | 172 | "\n",
|
92 | 173 | "```dockerfile\n",
|
|
98 | 179 | " 'jupyterlab=2.1' \\\n",
|
99 | 180 | " 'r-languageserver' \\\n",
|
100 | 181 | " && python3 -m pip install --no-cache-dir --no-deps \\\n",
|
101 |
| - " 'jupyter-lsp=0.8.0' \\\n", |
| 182 | + " 'jupyter-lsp={JUPYTER_LSP_VERSION}' \\\n", |
102 | 183 | " && jupyter labextension install --no-build \\\n",
|
103 |
| - " '@krassowski/jupyterlab-lsp@1.0.0' \\\n", |
| 184 | + " '@krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}' \\\n", |
104 | 185 | " && jupyter lab build --dev-build=False --minimize=True \\\n",
|
105 | 186 | " && conda clean --all -f -y \\\n",
|
106 | 187 | " && rm -rf \\\n",
|
|
202 | 283 | ]
|
203 | 284 | },
|
204 | 285 | {
|
205 |
| - "cell_type": "markdown", |
206 |
| - "metadata": {}, |
| 286 | + "cell_type": "code", |
| 287 | + "execution_count": null, |
| 288 | + "metadata": { |
| 289 | + "hide_input": true |
| 290 | + }, |
| 291 | + "outputs": [], |
207 | 292 | "source": [
|
| 293 | + "%%markdown\n", |
208 | 294 | "#### Install Jupyter[Lab] LSP\n",
|
209 | 295 | "\n",
|
210 | 296 | "```bash\n",
|
211 |
| - "pip install jupyter-lsp=0.8.0\n", |
212 |
| - "jupyter labextension install @krassowski/jupyterlab-lsp@1.0.0\n", |
| 297 | + "pip install jupyter-lsp={JUPYTER_LSP_VERSION}\n", |
| 298 | + "jupyter labextension install @krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}\n", |
213 | 299 | "```"
|
214 | 300 | ]
|
215 | 301 | },
|
|
245 | 331 | "name": "python",
|
246 | 332 | "nbconvert_exporter": "python",
|
247 | 333 | "pygments_lexer": "ipython3",
|
248 |
| - "version": "3.7.6" |
| 334 | + "version": "3.7.5" |
249 | 335 | }
|
250 | 336 | },
|
251 | 337 | "nbformat": 4,
|
|
0 commit comments