Skip to content

Commit

Permalink
Add jupyterlab-lsp 3.0.0 integration (elyra-ai#1176)
Browse files Browse the repository at this point in the history
The Language Server Protocol provides high-level support
for multiple programming languages, the integration with
jupyterlab brings editor features such as autocompletion,
code navigation, hover suggestions, linters, and rename.
  • Loading branch information
karlaspuldaro authored Jan 11, 2021
1 parent 5c450cb commit 72353b1
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
SHELL:=/bin/bash

GIT_VERSION:=0.23.1
LSP_VERSION:=3.0.0
TOC_VERSION:=4.0.0

TAG:=dev
Expand Down Expand Up @@ -60,6 +61,10 @@ uninstall:
$(call UNINSTALL_LAB_EXTENSION,@elyra/python-editor-extension)
$(call UNINSTALL_LAB_EXTENSION,@jupyterlab/toc)
pip uninstall -y jupyterlab-git
pip uninstall -y jupyter-lsp
- jupyter labextension uninstall @krassowski/jupyterlab-lsp
pip uninstall -y jupyterlab-lsp
pip uninstall -y python-language-server
pip uninstall -y elyra
- jupyter lab clean

Expand Down Expand Up @@ -103,6 +108,8 @@ install-ui: build-ui

install-external-extensions:
# pip install --upgrade jupyterlab-git==$(GIT_VERSION)
pip install jupyterlab-lsp==$(LSP_VERSION)
pip install python-language-server[all]

install: install-server install-ui install-external-extensions ## Build and install
jupyter lab build
Expand Down Expand Up @@ -143,6 +150,7 @@ dist-ui: build-ui
$(call PACKAGE_LAB_EXTENSION,pipeline-editor)
$(call PACKAGE_LAB_EXTENSION,python-editor)
# cd dist && curl -o jupyterlab-git-$(GIT_VERSION).tgz $$(npm view @jupyterlab/git@$(GIT_VERSION) dist.tarball) && cd -
# cd dist && curl -o jupyterlab-lsp-$(LSP_VERSION).tgz $$(npm view @jupyterlab/git@$(LSP_VERSION) dist.tarball) && cd -

release: dist-ui build-server ## Build wheel file for release

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Elyra currently includes the following functionality:
- [Python script editor with local/remote execution capabilities](https://elyra.readthedocs.io/en/latest/getting_started/overview.html#python-script-execution-support)
- [Python script navigation using auto-generated Table of Contents](https://elyra.readthedocs.io/en/latest/getting_started/overview.html#python-script-execution-support)
- [Notebook navigation using auto-generated outlines using Table of Contents](https://elyra.readthedocs.io/en/latest/getting_started/overview.html#notebook-navigation-using-auto-generated-table-of-contents)
- [Version control using Git integration](https://elyra.readthedocs.io/en/latest/getting_started/overview.html#python-script-execution-support)
- [Version control using Git integration](https://elyra.readthedocs.io/en/latest/getting_started/overview.html#version-control-using-git-integration)
- [Language Server Protocol integration](https://elyra.readthedocs.io/en/latest/getting_started/overview.html#language-server-protocol-integration)

![Elyra](docs/source/images/elyra-main-page.png)

Expand Down
21 changes: 20 additions & 1 deletion docs/source/getting_started/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The main features include:
* [Python script execution support](#python-script-execution-support)
* [Version control using git integration](#version-control-using-git-integration)
* [Notebook navigation using auto-generated Table of Contents](#notebook-navigation-using-auto-generated-table-of-contents)
* [Language Server Protocol integration](#language-server-protocol-integration)

You can try out some of these features using the getting started tour [on Binder](https://github.com/elyra-ai/elyra#using-binder) without having to install anything.

Expand Down Expand Up @@ -103,4 +104,22 @@ a Table of Contents providing enhanced navigation capabilities.

To access the Table of Contents, open a notebook and select the _Table of Contents_ tab from the sidebar.

![Notebook Table of Contents](../images/notebook-toc.png)
![Notebook Table of Contents](../images/notebook-toc.png)

#### Language Server Protocol integration

The integration with Language Server Protocol (LSP) provides a high level support for programming languages in JupyterLab. It enhances the development experience, bringing features common in IDEs such as autocopletion, code navigation, hover suggestions, linters and rename. It works for notebooks and file editors without a running kernel.

![LSP Integration](../images/lsp.gif)

By default, Elyra provides access to the python server package, levaraging the tools in the Python Editor extension.
User can also expand the support to other programming languages of their choice to boost their File Editor.

To manually install other LSP servers (eg. R server - first make sure you have R language installed in your system or environment, then) :
``` bash
R -e 'install.packages("languageserver")'
```

Refer to the [jupyterlab-lsp documentation](https://jupyterlab-lsp.readthedocs.io/en/latest/Language%20Servers.html) for a full list of other language servers supported by the extension and how to install them.

To learn more about the extension and its features check out the [jupyterlab-lsp repository](https://github.com/krassowski/jupyterlab-lsp).
Binary file added docs/source/images/lsp.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
'jupyter_server>=1.2.0',
'jupyterlab>=3.0.0',
# 'jupyterlab-git==0.21.1',
'jupyterlab-lsp>==3.0.0',
'kfp-notebook>=0.17.0,<0.18.0',
'kfp==1.1.2',
'minio>=5.0.7,<7.0.0',
Expand All @@ -65,6 +66,7 @@
# 'nbdime>=2.0.0',
'nbresuse>=0.3.6',
'papermill>=2.1.3',
'python-language-server[all]',
'requests>=2.9.1,<3.0',
'rfc3986-validator>=0.1.1',
'traitlets>=4.3.2',
Expand Down
48 changes: 48 additions & 0 deletions tests/integration/lsp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2018-2020 Elyra Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

describe('LSP', () => {
before(() => {
// read python file used for testing
cy.readFile('tests/assets/helloworld.py').then((file: any) => {
cy.writeFile('build/cypress-tests/helloworld.py', file);
});

cy.openJupyterLab();
});

after(() => {
// delete python file used for testing
cy.exec('find build/cypress-tests/ -name helloworld.py -delete', {
failOnNonZeroExit: false
});
});

it('LSP extension is initialized', () => {
// open python editor
cy.getFileByType('python').dblclick();

cy.wait(1000);

//check for lsp item on status bar
cy.get('.lsp-statusbar-item ').find(
'[title="Fully connected & initialized (1 virtual document)"]'
);

// close tab
cy.closeCurrentTab();
});
});
2 changes: 1 addition & 1 deletion tests/integration/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('Pipeline Editor tests', () => {
cy.get('[data-command="pipeline-editor:add-node"]').click();
// Open notebook with double-click
cy.get('.d3-node-label').dblclick();
cy.wait(100);
cy.wait(500);
cy.get(
'#jp-main-dock-panel > .lm-TabBar > .lm-TabBar-content > .lm-TabBar-tab > .lm-TabBar-tabLabel'
)
Expand Down

0 comments on commit 72353b1

Please sign in to comment.