Skip to content

Commit a65019a

Browse files
authored
Merge pull request #315 from krassowski/configurable-competer
Add completion settings (Hinterland mode, documentation, suppression)
2 parents 574abcc + d400629 commit a65019a

File tree

207 files changed

+8229
-3589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+8229
-3589
lines changed

CHANGELOG.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,47 @@
88

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

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

1313
- features
1414

1515
- support for JupyterLab 2.2 ([#301][])
1616
- completer now displays server-provided documentation,
1717
and a kernel icon for kernel suggestions without type information ([#301][])
18+
- add two icons themes for the completer (material and vscode) ([#322])
19+
- the documentation by the completer can be turned on or off ([#315])
20+
- continuous hinting (Hinterland mode) can be enabled in settings ([#315])
21+
- tokens in which the completer should not be triggered can be changed ([#315])
22+
- configuration for the following features is now exposed in the settings editor ([#318]):
23+
- diagnostics (display, filtering)
24+
- hover (modifier key)
25+
- rename operation status reporting got improved ([#318])
26+
- replaced the generic status icons with code check icon (coloured differently according to the status) ([#318])
27+
- added icons for all the features and their commands ([#318])
28+
- refactored the codebase with a new architecture which allows dynamic feature, document widget adapter, and code editor registration ([#318])
29+
- 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])
30+
- syntax highlighting mode is adjusted to the language with the majority of the code in an editor ([#319])
1831

1932
- bug fixes
2033

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

2342
[#301]: https://github.com/krassowski/jupyterlab-lsp/pull/301
43+
[#315]: https://github.com/krassowski/jupyterlab-lsp/pull/315
44+
[#318]: https://github.com/krassowski/jupyterlab-lsp/pull/318
45+
[#319]: https://github.com/krassowski/jupyterlab-lsp/pull/319
46+
[#322]: https://github.com/krassowski/jupyterlab-lsp/pull/322
47+
[#329]: https://github.com/krassowski/jupyterlab-lsp/pull/329
48+
[00448d0]: https://github.com/krassowski/jupyterlab-lsp/pull/318/commits/00448d0c55e7f9a1e7e0a5322f17610daac47dfe
49+
[bacc006]: https://github.com/krassowski/jupyterlab-lsp/pull/318/commits/bacc0066da0727ff7397574914bf0401e4d8f7cb
50+
[4e5b2ad]: https://github.com/krassowski/jupyterlab-lsp/pull/318/commits/4e5b2adf655120458cc8be4b453fe9a78c98e061
51+
[8798f2d]: https://github.com/krassowski/jupyterlab-lsp/pull/318/commits/8798f2dcfd28da10a2b8d8f648974111caa52307
2452

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

atest/04_Interface/Statusbar.robot

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,20 @@ Statusbar Popup Opens
1818
Element Should Contain ${POPOVER} python
1919
Element Should Contain ${POPOVER} initialized
2020
[Teardown] Clean Up After Working With File Python.ipynb
21+
22+
Status Changes Correctly Between Editors
23+
Prepare File for Editing Python status example.py
24+
Wait Until Fully Initialized
25+
Open File example.plain
26+
Wait Until Element Contains ${STATUSBAR} Initialized (additional servers needed) timeout=60s
27+
Capture Page Screenshot 01-both-open.png
28+
Switch To Tab example.py
29+
Wait Until Fully Initialized
30+
Switch To Tab example.plain
31+
Wait Until Element Contains ${STATUSBAR} Initialized (additional servers needed) timeout=60s
32+
[Teardown] Clean Up After Working With File example.plain
33+
34+
*** Keywords ***
35+
Switch To Tab
36+
[Arguments] ${file}
37+
Click Element ${JLAB XP DOCK TAB}\[contains(., '${file}')]

atest/05_Features/Completion.robot

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ Works When Kernel Is Shut Down
3939
# this comes from kernel:
4040
Completer Should Not Suggest %%timeit
4141

42+
Works In File Editor
43+
Prepare File for Editing Python completion completion.py
44+
Place Cursor In File Editor At 9 2
45+
Capture Page Screenshot 01-editor-ready.png
46+
Trigger Completer
47+
Completer Should Suggest add
48+
[Teardown] Clean Up After Working With File completion.py
49+
4250
Autocompletes If Only One Option
4351
Enter Cell Editor 3 line=1
4452
Press Keys None cle
@@ -113,6 +121,61 @@ Triggers Completer On Dot
113121
Wait Until Page Contains Element ${COMPLETER_BOX} timeout=35s
114122
Completer Should Suggest append
115123

124+
Material Theme Works
125+
Configure JupyterLab Plugin {"theme": "material"} plugin id=${COMPLETION PLUGIN ID}
126+
Capture Page Screenshot 01-configured.png
127+
Enter Cell Editor 1 line=2
128+
Trigger Completer
129+
Capture Page Screenshot 02-completions-shown.png
130+
# TabError is a builtin exception which is a class in Python,
131+
# so we should get lsp:material-class-light icon:
132+
Completer Should Suggest TabError
133+
Completer Should Include Icon lsp:material-class-light
134+
135+
VSCode Theme Works
136+
Configure JupyterLab Plugin {"theme": "vscode"} plugin id=${COMPLETION PLUGIN ID}
137+
Capture Page Screenshot 01-configured.png
138+
Enter Cell Editor 1 line=2
139+
Trigger Completer
140+
Capture Page Screenshot 02-completions-shown.png
141+
Completer Should Suggest TabError
142+
Completer Should Include Icon lsp:vscode-class-light
143+
144+
VSCode Dark Theme Works
145+
${file} = Set Variable Completion.ipynb
146+
Lab Command Use JupyterLab Dark Theme
147+
Wait For Splash
148+
Capture Page Screenshot 00-theme-changed.png
149+
Configure JupyterLab Plugin {"theme": "vscode"} plugin id=${COMPLETION PLUGIN ID}
150+
Capture Page Screenshot 01-configured.png
151+
Open ${file} in ${MENU NOTEBOOK}
152+
Enter Cell Editor 1 line=2
153+
Wait Until Fully Initialized
154+
Trigger Completer
155+
Capture Page Screenshot 02-completions-shown.png
156+
Completer Should Suggest TabError
157+
Completer Should Include Icon lsp:vscode-class-dark
158+
Lab Command Use JupyterLab Light Theme
159+
Wait For Splash
160+
161+
Works Without A Theme
162+
Configure JupyterLab Plugin {"theme": null} plugin id=${COMPLETION PLUGIN ID}
163+
Capture Page Screenshot 01-configured.png
164+
Enter Cell Editor 1 line=2
165+
Trigger Completer
166+
Capture Page Screenshot 02-completions-shown.png
167+
Completer Should Suggest TabError
168+
Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-monogram
169+
170+
Works With Incorrect Theme
171+
Configure JupyterLab Plugin {"theme": "a-non-existing-theme"} plugin id=${COMPLETION PLUGIN ID}
172+
Capture Page Screenshot 01-configured.png
173+
Enter Cell Editor 1 line=2
174+
Trigger Completer
175+
Capture Page Screenshot 02-completions-shown.png
176+
Completer Should Suggest TabError
177+
Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-monogram
178+
116179
*** Keywords ***
117180
Setup Completion Test
118181
Setup Notebook Python Completion.ipynb
@@ -139,6 +202,10 @@ Completer Should Suggest
139202
Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"]
140203
Capture Page Screenshot ${text.replace(' ', '_')}.png
141204

205+
Completer Should Include Icon
206+
[Arguments] ${icon}
207+
Wait Until Page Contains Element ${COMPLETER_BOX} svg[data-icon="${icon}"]
208+
142209
Completer Should Not Suggest
143210
[Arguments] ${text}
144211
Wait Until Page Does Not Contain Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
*** Settings ***
2+
Suite Setup Setup Suite For Screenshots syntax_highlighting
3+
Test Setup Setup Highlighting Test
4+
Test Teardown Clean Up After Working With File Syntax highlighting.ipynb
5+
Force Tags feature:syntax_highlighting
6+
Resource ../Keywords.robot
7+
8+
*** Test Cases ***
9+
Syntax Highlighting Mode Stays Normal In Normal Cells
10+
${mode} = Get Mode Of A Cell 1
11+
should be equal ${mode['name']} ipython
12+
13+
Syntax Highlighting Mode Changes In Cells Dominated By Foreign Documents
14+
${mode} = Get Mode Of A Cell 2
15+
should be equal ${mode['name']} markdown
16+
${mode} = Get Mode Of A Cell 3
17+
should be equal ${mode['name']} xml
18+
${mode} = Get Mode Of A Cell 4
19+
should be equal ${mode['name']} javascript
20+
21+
Highlighing Mode Works For Multiple Documents
22+
${mode} = Get Mode Of A Cell 4
23+
should be equal ${mode['name']} javascript
24+
${mode} = Get Mode Of A Cell 6
25+
should be equal ${mode['name']} javascript
26+
27+
*** Keywords ***
28+
Get Mode Of A Cell
29+
[Arguments] ${cell_nr}
30+
Click Element css:.jp-Cell:nth-child(${cell_nr})
31+
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_nr}) .CodeMirror-focused
32+
${mode} = Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.getMode()
33+
[Return] ${mode}
34+
35+
Setup Highlighting Test
36+
Setup Notebook Python Syntax highlighting.ipynb

atest/Keywords.robot

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ Place Cursor In Cell Editor At
263263
Enter Cell Editor ${cell_nr} ${line}
264264
Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.setCursor({line: ${line} - 1, ch: ${character}})
265265

266+
Enter File Editor
267+
Click Element css:.jp-FileEditor .CodeMirror
268+
Wait Until Page Contains Element css:.jp-FileEditor .CodeMirror-focused
269+
270+
Place Cursor In File Editor At
271+
[Arguments] ${line} ${character}
272+
Enter File Editor
273+
Execute JavaScript return document.querySelector('.jp-FileEditor .CodeMirror').CodeMirror.setCursor({line: ${line} - 1, ch: ${character}})
274+
266275
Wait Until Fully Initialized
267276
Wait Until Element Contains ${STATUSBAR} Fully initialized timeout=60s
268277

@@ -276,8 +285,12 @@ Prepare File for Editing
276285
[Arguments] ${Language} ${Screenshots} ${file}
277286
Set Tags language:${Language.lower()}
278287
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots${/}${Screenshots}${/}${Language.lower()}
279-
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
280288
Try to Close All Tabs
289+
Open File ${file}
290+
291+
Open File
292+
[Arguments] ${file}
293+
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
281294
Open ${file} in ${MENU EDITOR}
282295
Capture Page Screenshot 00-opened.png
283296

atest/Variables.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ${CM CURSOR} css:.CodeMirror-cursor
3333
${CM CURSORS} css:.CodeMirror-cursors:not([style='visibility: hidden'])
3434
# settings
3535
${LSP PLUGIN ID} @krassowski/jupyterlab-lsp:plugin
36+
${COMPLETION PLUGIN ID} @krassowski/jupyterlab-lsp:completion
3637
${LSP PLUGIN SETTINGS FILE} @krassowski${/}jupyterlab-lsp${/}plugin.jupyterlab-settings
3738
${CSS USER SETTINGS} .jp-SettingsRawEditor-user
3839
${JLAB XP CLOSE SETTINGS} ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/*[contains(@class, 'm-TabBar-tabCloseIcon')]
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"variable = 1\n",
10+
"\n",
11+
"def function():\n",
12+
" return\n",
13+
"\n",
14+
"# note print is highlighted in Python but function is not\n",
15+
"print(variable, function)"
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": null,
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"%%markdown\n",
25+
"# header\n",
26+
"**bold**, *italic*\n",
27+
"\n",
28+
"### Heading with wrong level"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": null,
34+
"metadata": {},
35+
"outputs": [],
36+
"source": [
37+
"%%html\n",
38+
"<html style=\"color: green\">\n",
39+
" <!-- this is a comment -->\n",
40+
" <head>\n",
41+
" <title>HTML Example</title>\n",
42+
" </head>\n",
43+
" <body>\n",
44+
" The indentation tries to be <em>somewhat &quot;do what\n",
45+
" I mean&quot;</em>... but might not match your style.\n",
46+
" </body>\n",
47+
"</html>"
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"%%javascript\n",
57+
"// \"print\" is NOT highlighted in javascript, while \"function\" is\n",
58+
"function add_together(a, b) {\n",
59+
" return a + b\n",
60+
"}\n",
61+
"\n",
62+
"print('A')"
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"It should work for the same language of virtual document with multiple occurrences:"
70+
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": null,
75+
"metadata": {},
76+
"outputs": [],
77+
"source": [
78+
"%%javascript \n",
79+
"function add_together(a, b) {\n",
80+
" return a + b\n",
81+
"}\n",
82+
"\n",
83+
"print('A')"
84+
]
85+
}
86+
],
87+
"metadata": {
88+
"kernelspec": {
89+
"display_name": "Python 3",
90+
"language": "python",
91+
"name": "python3"
92+
},
93+
"language_info": {
94+
"codemirror_mode": {
95+
"name": "ipython",
96+
"version": 3
97+
},
98+
"file_extension": ".py",
99+
"mimetype": "text/x-python",
100+
"name": "python",
101+
"nbconvert_exporter": "python",
102+
"pygments_lexer": "ipython3",
103+
"version": "3.7.5"
104+
}
105+
},
106+
"nbformat": 4,
107+
"nbformat_minor": 4
108+
}

atest/examples/completion.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
addition = ''
2+
3+
4+
def add(a: int, b: int):
5+
"""Adds a and b together"""
6+
return a, b
7+
8+
9+
ad

atest/examples/example.plain

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
There is nothing interesting in here.
2+
It is here just to test how the extension works with files for which there is no associated language support.

azure-pipelines.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ trigger:
66
- refs/tags/v*
77

88
pr:
9-
- master
9+
branches:
10+
include:
11+
- '*'
1012

1113
variables:
1214
PYTHONUNBUFFERED: 1
@@ -23,6 +25,9 @@ variables:
2325
LINKED_EXTENSIONS: >-
2426
packages/lsp-ws-connection
2527
packages/jupyterlab-go-to-definition
28+
packages/completion-theme
29+
packages/theme-vscode
30+
packages/theme-material
2631
2732
jobs:
2833
- template: ci/job.lint.yml

0 commit comments

Comments
 (0)