Skip to content

Commit

Permalink
Merge pull request #315 from krassowski/configurable-competer
Browse files Browse the repository at this point in the history
Add completion settings (Hinterland mode, documentation, suppression)
  • Loading branch information
krassowski authored Aug 31, 2020
2 parents 574abcc + d400629 commit a65019a
Show file tree
Hide file tree
Showing 207 changed files with 8,229 additions and 3,589 deletions.
30 changes: 29 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,47 @@

[#328]: https://github.com/krassowski/jupyterlab-lsp/pull/328

### `@krassowski/jupyterlab-lsp 1.2.0` (unreleased)
### `@krassowski/jupyterlab-lsp 2.0.0` (unreleased)

- features

- support for JupyterLab 2.2 ([#301][])
- completer now displays server-provided documentation,
and a kernel icon for kernel suggestions without type information ([#301][])
- add two icons themes for the completer (material and vscode) ([#322])
- the documentation by the completer can be turned on or off ([#315])
- continuous hinting (Hinterland mode) can be enabled in settings ([#315])
- tokens in which the completer should not be triggered can be changed ([#315])
- configuration for the following features is now exposed in the settings editor ([#318]):
- diagnostics (display, filtering)
- hover (modifier key)
- rename operation status reporting got improved ([#318])
- replaced the generic status icons with code check icon (coloured differently according to the status) ([#318])
- added icons for all the features and their commands ([#318])
- refactored the codebase with a new architecture which allows dynamic feature, document widget adapter, and code editor registration ([#318])
- the document in the connections list in the statusbar popover are now represented by easy-to-understand DocumentLocator (breadcrumbs) widget rather than an internal id ([bacc006])
- syntax highlighting mode is adjusted to the language with the majority of the code in an editor ([#319])

- bug fixes

- path-autocompletion issues were resolved upstream an this release adopts these changes
- missing caret and document connection icons were restored in the statusbar popover ([#318])
- pressing "Cancel" rename during rename now correctly aborts the rename operation ([#318])
- when a language server for a foreign document is not available an explanation is displayed (rather than the "Connecting..." status as before) ([4e5b2ad])
- when jump target is not found a message is now shown instead of raising an exception ([00448d0])
- fixed status message expiration and replacement ([8798f2d]), ([#329])
- fixed some context command rank issues introduced after an attempt of migration to nulls ([#318])

[#301]: https://github.com/krassowski/jupyterlab-lsp/pull/301
[#315]: https://github.com/krassowski/jupyterlab-lsp/pull/315
[#318]: https://github.com/krassowski/jupyterlab-lsp/pull/318
[#319]: https://github.com/krassowski/jupyterlab-lsp/pull/319
[#322]: https://github.com/krassowski/jupyterlab-lsp/pull/322
[#329]: https://github.com/krassowski/jupyterlab-lsp/pull/329
[00448d0]: https://github.com/krassowski/jupyterlab-lsp/pull/318/commits/00448d0c55e7f9a1e7e0a5322f17610daac47dfe
[bacc006]: https://github.com/krassowski/jupyterlab-lsp/pull/318/commits/bacc0066da0727ff7397574914bf0401e4d8f7cb
[4e5b2ad]: https://github.com/krassowski/jupyterlab-lsp/pull/318/commits/4e5b2adf655120458cc8be4b453fe9a78c98e061
[8798f2d]: https://github.com/krassowski/jupyterlab-lsp/pull/318/commits/8798f2dcfd28da10a2b8d8f648974111caa52307

### `@krassowski/jupyterlab-lsp 1.1.2` (2020-08-05)

Expand Down
17 changes: 17 additions & 0 deletions atest/04_Interface/Statusbar.robot
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,20 @@ Statusbar Popup Opens
Element Should Contain ${POPOVER} python
Element Should Contain ${POPOVER} initialized
[Teardown] Clean Up After Working With File Python.ipynb

Status Changes Correctly Between Editors
Prepare File for Editing Python status example.py
Wait Until Fully Initialized
Open File example.plain
Wait Until Element Contains ${STATUSBAR} Initialized (additional servers needed) timeout=60s
Capture Page Screenshot 01-both-open.png
Switch To Tab example.py
Wait Until Fully Initialized
Switch To Tab example.plain
Wait Until Element Contains ${STATUSBAR} Initialized (additional servers needed) timeout=60s
[Teardown] Clean Up After Working With File example.plain

*** Keywords ***
Switch To Tab
[Arguments] ${file}
Click Element ${JLAB XP DOCK TAB}\[contains(., '${file}')]
67 changes: 67 additions & 0 deletions atest/05_Features/Completion.robot
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ Works When Kernel Is Shut Down
# this comes from kernel:
Completer Should Not Suggest %%timeit

Works In File Editor
Prepare File for Editing Python completion completion.py
Place Cursor In File Editor At 9 2
Capture Page Screenshot 01-editor-ready.png
Trigger Completer
Completer Should Suggest add
[Teardown] Clean Up After Working With File completion.py

Autocompletes If Only One Option
Enter Cell Editor 3 line=1
Press Keys None cle
Expand Down Expand Up @@ -113,6 +121,61 @@ Triggers Completer On Dot
Wait Until Page Contains Element ${COMPLETER_BOX} timeout=35s
Completer Should Suggest append

Material Theme Works
Configure JupyterLab Plugin {"theme": "material"} plugin id=${COMPLETION PLUGIN ID}
Capture Page Screenshot 01-configured.png
Enter Cell Editor 1 line=2
Trigger Completer
Capture Page Screenshot 02-completions-shown.png
# TabError is a builtin exception which is a class in Python,
# so we should get lsp:material-class-light icon:
Completer Should Suggest TabError
Completer Should Include Icon lsp:material-class-light

VSCode Theme Works
Configure JupyterLab Plugin {"theme": "vscode"} plugin id=${COMPLETION PLUGIN ID}
Capture Page Screenshot 01-configured.png
Enter Cell Editor 1 line=2
Trigger Completer
Capture Page Screenshot 02-completions-shown.png
Completer Should Suggest TabError
Completer Should Include Icon lsp:vscode-class-light

VSCode Dark Theme Works
${file} = Set Variable Completion.ipynb
Lab Command Use JupyterLab Dark Theme
Wait For Splash
Capture Page Screenshot 00-theme-changed.png
Configure JupyterLab Plugin {"theme": "vscode"} plugin id=${COMPLETION PLUGIN ID}
Capture Page Screenshot 01-configured.png
Open ${file} in ${MENU NOTEBOOK}
Enter Cell Editor 1 line=2
Wait Until Fully Initialized
Trigger Completer
Capture Page Screenshot 02-completions-shown.png
Completer Should Suggest TabError
Completer Should Include Icon lsp:vscode-class-dark
Lab Command Use JupyterLab Light Theme
Wait For Splash

Works Without A Theme
Configure JupyterLab Plugin {"theme": null} plugin id=${COMPLETION PLUGIN ID}
Capture Page Screenshot 01-configured.png
Enter Cell Editor 1 line=2
Trigger Completer
Capture Page Screenshot 02-completions-shown.png
Completer Should Suggest TabError
Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-monogram

Works With Incorrect Theme
Configure JupyterLab Plugin {"theme": "a-non-existing-theme"} plugin id=${COMPLETION PLUGIN ID}
Capture Page Screenshot 01-configured.png
Enter Cell Editor 1 line=2
Trigger Completer
Capture Page Screenshot 02-completions-shown.png
Completer Should Suggest TabError
Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-monogram

*** Keywords ***
Setup Completion Test
Setup Notebook Python Completion.ipynb
Expand All @@ -139,6 +202,10 @@ Completer Should Suggest
Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"]
Capture Page Screenshot ${text.replace(' ', '_')}.png

Completer Should Include Icon
[Arguments] ${icon}
Wait Until Page Contains Element ${COMPLETER_BOX} svg[data-icon="${icon}"]

Completer Should Not Suggest
[Arguments] ${text}
Wait Until Page Does Not Contain Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"]
Expand Down
36 changes: 36 additions & 0 deletions atest/05_Features/Syntax_highlighting.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots syntax_highlighting
Test Setup Setup Highlighting Test
Test Teardown Clean Up After Working With File Syntax highlighting.ipynb
Force Tags feature:syntax_highlighting
Resource ../Keywords.robot

*** Test Cases ***
Syntax Highlighting Mode Stays Normal In Normal Cells
${mode} = Get Mode Of A Cell 1
should be equal ${mode['name']} ipython

Syntax Highlighting Mode Changes In Cells Dominated By Foreign Documents
${mode} = Get Mode Of A Cell 2
should be equal ${mode['name']} markdown
${mode} = Get Mode Of A Cell 3
should be equal ${mode['name']} xml
${mode} = Get Mode Of A Cell 4
should be equal ${mode['name']} javascript

Highlighing Mode Works For Multiple Documents
${mode} = Get Mode Of A Cell 4
should be equal ${mode['name']} javascript
${mode} = Get Mode Of A Cell 6
should be equal ${mode['name']} javascript

*** Keywords ***
Get Mode Of A Cell
[Arguments] ${cell_nr}
Click Element css:.jp-Cell:nth-child(${cell_nr})
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_nr}) .CodeMirror-focused
${mode} = Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.getMode()
[Return] ${mode}

Setup Highlighting Test
Setup Notebook Python Syntax highlighting.ipynb
15 changes: 14 additions & 1 deletion atest/Keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ Place Cursor In Cell Editor At
Enter Cell Editor ${cell_nr} ${line}
Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.setCursor({line: ${line} - 1, ch: ${character}})

Enter File Editor
Click Element css:.jp-FileEditor .CodeMirror
Wait Until Page Contains Element css:.jp-FileEditor .CodeMirror-focused

Place Cursor In File Editor At
[Arguments] ${line} ${character}
Enter File Editor
Execute JavaScript return document.querySelector('.jp-FileEditor .CodeMirror').CodeMirror.setCursor({line: ${line} - 1, ch: ${character}})

Wait Until Fully Initialized
Wait Until Element Contains ${STATUSBAR} Fully initialized timeout=60s

Expand All @@ -276,8 +285,12 @@ Prepare File for Editing
[Arguments] ${Language} ${Screenshots} ${file}
Set Tags language:${Language.lower()}
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots${/}${Screenshots}${/}${Language.lower()}
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
Try to Close All Tabs
Open File ${file}

Open File
[Arguments] ${file}
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
Open ${file} in ${MENU EDITOR}
Capture Page Screenshot 00-opened.png

Expand Down
1 change: 1 addition & 0 deletions atest/Variables.robot
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ${CM CURSOR} css:.CodeMirror-cursor
${CM CURSORS} css:.CodeMirror-cursors:not([style='visibility: hidden'])
# settings
${LSP PLUGIN ID} @krassowski/jupyterlab-lsp:plugin
${COMPLETION PLUGIN ID} @krassowski/jupyterlab-lsp:completion
${LSP PLUGIN SETTINGS FILE} @krassowski${/}jupyterlab-lsp${/}plugin.jupyterlab-settings
${CSS USER SETTINGS} .jp-SettingsRawEditor-user
${JLAB XP CLOSE SETTINGS} ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/*[contains(@class, 'm-TabBar-tabCloseIcon')]
Expand Down
108 changes: 108 additions & 0 deletions atest/examples/Syntax highlighting.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"variable = 1\n",
"\n",
"def function():\n",
" return\n",
"\n",
"# note print is highlighted in Python but function is not\n",
"print(variable, function)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%markdown\n",
"# header\n",
"**bold**, *italic*\n",
"\n",
"### Heading with wrong level"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%html\n",
"<html style=\"color: green\">\n",
" <!-- this is a comment -->\n",
" <head>\n",
" <title>HTML Example</title>\n",
" </head>\n",
" <body>\n",
" The indentation tries to be <em>somewhat &quot;do what\n",
" I mean&quot;</em>... but might not match your style.\n",
" </body>\n",
"</html>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%javascript\n",
"// \"print\" is NOT highlighted in javascript, while \"function\" is\n",
"function add_together(a, b) {\n",
" return a + b\n",
"}\n",
"\n",
"print('A')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It should work for the same language of virtual document with multiple occurrences:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%javascript \n",
"function add_together(a, b) {\n",
" return a + b\n",
"}\n",
"\n",
"print('A')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
9 changes: 9 additions & 0 deletions atest/examples/completion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
addition = ''


def add(a: int, b: int):
"""Adds a and b together"""
return a, b


ad
2 changes: 2 additions & 0 deletions atest/examples/example.plain
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
There is nothing interesting in here.
It is here just to test how the extension works with files for which there is no associated language support.
7 changes: 6 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ trigger:
- refs/tags/v*

pr:
- master
branches:
include:
- '*'

variables:
PYTHONUNBUFFERED: 1
Expand All @@ -23,6 +25,9 @@ variables:
LINKED_EXTENSIONS: >-
packages/lsp-ws-connection
packages/jupyterlab-go-to-definition
packages/completion-theme
packages/theme-vscode
packages/theme-material
jobs:
- template: ci/job.lint.yml
Expand Down
4 changes: 2 additions & 2 deletions docs/Configuring.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Configuring"
"## Configuring backend"
]
},
{
Expand Down Expand Up @@ -206,7 +206,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.5"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit a65019a

Please sign in to comment.