Skip to content

Commit a5653a5

Browse files
committed
Merge branch 'master' into krassowski-update-docs-versions
2 parents 6880340 + bcf0ede commit a5653a5

Some content is hidden

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

57 files changed

+1261
-379
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ envs
2424
examples/app/build
2525
examples/app/schemas
2626
examples/app/themes
27+
htmlcov
2728
jupyterlab/geckodriver
2829
jupyterlab/schemas
2930
jupyterlab/staging/index.js

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
- fixes currently-highlighted token in dark editor themes against light lab theme
88
(and vice versa) ([#195][])
99
- restores sorting order-indicating caret icons in diagnostics panel table ([#261][])
10+
- handles document open and change operation ordering more predictably ([#284][])
1011

1112
[#195]: https://github.com/krassowski/jupyterlab-lsp/issues/195
1213
[#261]: https://github.com/krassowski/jupyterlab-lsp/issues/261
14+
[#284]: https://github.com/krassowski/jupyterlab-lsp/pull/284
1315

1416
### `@krassowski/jupyterlab-lsp 1.0.0` (2020-03-14)
1517

README.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,57 @@ jupyter labextension install @krassowski/[email protected]
194194

195195
### Configuring the servers
196196

197-
We plan to provide a configuration GUI at some time ([#25](https://github.com/krassowski/jupyterlab-lsp/issues/25)), but in the meantime, you can use the instructions for the specific servers as described on their websites (see the [table of language servers][language-servers] for links).
197+
Server configurations can be edited using the Advanced Settings editor in JupyterLab (_Settings > Advanced Settings Editor_). For settings specific to each server, please see the [table of language servers][language-servers]. Example settings might include:
198+
199+
```json
200+
{
201+
"language_servers": {
202+
"pyls": {
203+
"serverSettings": {
204+
"pyls.plugins.pydocstyle.enabled": true,
205+
"pyls.plugins.pyflakes.enabled": false,
206+
"pyls.plugins.flake8.enabled": true
207+
}
208+
},
209+
"r-languageserver": {
210+
"serverSettings": {
211+
"r.lsp.debug": false,
212+
"r.lsp.diagnostics": false
213+
}
214+
}
215+
}
216+
}
217+
```
218+
219+
The `serverSettings` key specifies the configurations sent to the language servers. These can be written using stringified dot accessors like above (in the VSCode style), or as nested JSON objects, e.g.:
220+
221+
```json
222+
{
223+
"language_servers": {
224+
"pyls": {
225+
"serverSettings": {
226+
"pyls": {
227+
"plugins": {
228+
"pydocstyle": {
229+
"enabled": true
230+
},
231+
"pyflakes": {
232+
"enabled": false
233+
},
234+
"flake8": {
235+
"enabled": true
236+
}
237+
}
238+
}
239+
}
240+
}
241+
}
242+
}
243+
```
198244

199-
#### I want to hide specific diagnostics/inspections/warnings
245+
#### Other configuration methods
200246

201-
For example, the Python server that we support by default ([pyls](https://github.com/palantir/python-language-server)) has a [configuration section](https://github.com/palantir/python-language-server#configuration) in their documentation which refers to the providers of specific features, including `pycodestyle` for inspections/diagnostics.
247+
Some language servers, such as `pyls`, provide other configuration methods _in addition_ to language-server configuration messages (accessed using the Advanced Settings Editor). For example, `pyls` allows users to configure the server using a local configuration file. You can change the inspection/diagnostics for server plugins like `pycodestyle` there.
202248

203249
The exact configuration details will vary between operating systems (please see the [configuration section of pycodestyle documentation](https://pycodestyle.readthedocs.io/en/latest/intro.html#configuration)), but as an example, on Linux you would simply need to create a file called `~/.config/pycodestyle`, which may look like that:
204250

atest/01_Editor.robot

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Less
3232
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), '@width')])[last()]
3333
Editor Shows Features for Language Less example.less Diagnostics=Do not use empty rulesets Jump to Definition=${def}
3434

35+
Markdown
36+
Editor Shows Features for Language Markdown example.md Diagnostics=`Color` is misspelt
37+
3538
Python
3639
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
3740
Editor Shows Features for Language Python example.py Diagnostics=multiple spaces after keyword Jump to Definition=${def} Rename=${def}
@@ -58,12 +61,7 @@ YAML
5861
*** Keywords ***
5962
Editor Shows Features for Language
6063
[Arguments] ${Language} ${file} &{features}
61-
Set Tags language:${Language.lower()}
62-
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots${/}editor${/}${Language.lower()}
63-
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
64-
Try to Close All Tabs
65-
Open ${file} in ${MENU EDITOR}
66-
Capture Page Screenshot 00-opened.png
64+
Prepare File for Editing ${Language} editor ${file}
6765
FOR ${f} IN @{features}
6866
Run Keyword If "${f}" == "Diagnostics" Editor Should Show Diagnostics ${features["${f}"]}
6967
... ELSE IF "${f}" == "Jump to Definition" Editor Should Jump To Definition ${features["${f}"]}
@@ -106,10 +104,6 @@ Measure Cursor Position
106104
${position} = Wait Until Keyword Succeeds 20 x 0.05s Get Vertical Position ${CM CURSOR}
107105
[Return] ${position}
108106

109-
Get Editor Content
110-
${content} Execute JavaScript return document.querySelector('.CodeMirror').CodeMirror.getValue()
111-
[Return] ${content}
112-
113107
Editor Content Changed
114108
[Arguments] ${old_content}
115109
${new_content} Get Editor Content

atest/02_Settings.robot

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,5 @@ Resource Keywords.robot
44

55
*** Test Cases ***
66
Settings
7-
[Setup] Reset Application State
8-
Lab Command Advanced Settings Editor
9-
Capture Page Screenshot 01-settings-all.png
10-
${sel} = Set Variable css:[data-id="@krassowski/jupyterlab-lsp:plugin"]
11-
Wait Until Page Contains Element ${sel}
12-
Click Element ${sel}
13-
Wait Until Page Contains System Defaults
14-
Capture Page Screenshot 02-settings-lsp.png
7+
Open in Advanced Settings ${LSP PLUGIN ID}
8+
Capture Page Screenshot 01-settings-lsp.png

atest/04_Interface/DiagnosticsPanel.robot

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Settings ***
22
Suite Setup Setup Suite For Screenshots diagnostics_panel
33
Resource ../Keywords.robot
4+
Test Setup Gently Reset Workspace
45

56
*** Variables ***
67
${EXPECTED_COUNT} 1
@@ -11,15 +12,13 @@ ${MENU COLUMN MESSAGE} xpath://div[contains(@class, 'p-Menu-itemLabel')][cont
1112

1213
*** Test Cases ***
1314
Diagnostics Panel Opens
14-
[Setup] Gently Reset Workspace
1515
Open Notebook And Panel Panel.ipynb
1616
Capture Page Screenshot 03-panel-opens.png
1717
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count
1818
[Teardown] Clean Up After Working With File Panel.ipynb
1919

2020
Diagnostics Panel Works After Rename
2121
[Documentation] Test for #141 bug (diagnostics were not cleared after rename)
22-
[Setup] Gently Reset Workspace
2322
Open Notebook And Panel Panel.ipynb
2423
Rename Jupyter File Panel.ipynb PanelRenamed.ipynb
2524
Close Diagnostics Panel
@@ -32,15 +31,13 @@ Diagnostics Panel Works After Rename
3231
[Teardown] Clean Up After Working With File Panel.ipynb
3332

3433
Diagnostics Panel Can Be Restored
35-
[Setup] Gently Reset Workspace
3634
Open Notebook And Panel Panel.ipynb
3735
Close Diagnostics Panel
3836
Open Diagnostics Panel
3937
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count
4038
[Teardown] Clean Up After Working With File Panel.ipynb
4139

4240
Columns Can Be Hidden
43-
[Setup] Gently Reset Workspace
4441
Open Notebook And Panel Panel.ipynb
4542
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
4643
Open Context Menu Over css:.lsp-diagnostics-listing th

atest/05_Features/Completion.robot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*** Settings ***
22
Suite Setup Setup Suite For Screenshots completion
3-
Test Setup Setup Notebook Python Completion.ipynb
3+
Test Setup Setup Completion Test
44
Test Teardown Clean Up After Working With File Completion.ipynb
55
Force Tags feature:completion
66
Resource ../Keywords.robot
@@ -92,6 +92,9 @@ Triggers Completer On Dot
9292
Completer Should Suggest append
9393

9494
*** Keywords ***
95+
Setup Completion Test
96+
Setup Notebook Python Completion.ipynb
97+
9598
Get Cell Editor Content
9699
[Arguments] ${cell_nr}
97100
${content} Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.getValue()

atest/07_Configuration.robot

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
*** Settings ***
2+
Documentation Configuration of language servers
3+
Suite Setup Setup Suite For Screenshots config
4+
Force Tags feature:config
5+
Resource ./Keywords.robot
6+
7+
*** Test Cases ***
8+
Python
9+
[Documentation] pyflakes is enabled by default, but flake8 is not
10+
Settings Should Change Editor Diagnostics Python style.py pyls
11+
... {"pyls": {"plugins": {"flake8": {"enabled": true},"pyflakes": {"enabled": false}}}}
12+
... undefined name 'foo' (pyflakes)
13+
... undefined name 'foo' (flake8)
14+
15+
YAML
16+
[Documentation] EXPECT FAIL Composer YAML files don't allow a "greetings" key
17+
Settings Should Change Editor Diagnostics YAML example.yaml yaml-language-server
18+
... {"yaml.schemas": {"http://json.schemastore.org/composer": "*"}}
19+
... duplicate key
20+
... Property greetings is not allowed.
21+
22+
Markdown
23+
[Documentation] different englishes spell colou?r differently
24+
Settings Should Change Editor Diagnostics Markdown example.md unified-language-server
25+
... {"unified-language-server":{"remark-parse":{"plugins":[["#remark-retext","#parse-latin"],["#retext-spell","#dictionary-en"]]}}}
26+
... `Color` is misspelt
27+
... `Colour` is misspelt
28+
29+
*** Keywords ***
30+
Clean Up After Working with File and Settings
31+
[Arguments] ${file}
32+
Clean Up After Working With File ${file}
33+
Reset Plugin Settings
34+
35+
Settings Should Change Editor Diagnostics
36+
[Arguments] ${language} ${file} ${server} ${settings} ${before} ${after}
37+
${before diagnostic} = Set Variable ${CSS DIAGNOSTIC}\[title^="${before}"]
38+
${after diagnostic} = Set Variable ${CSS DIAGNOSTIC}\[title^="${after}"]
39+
${tab} = Set Variable ${JLAB XP DOCK TAB}\[contains(., '${file}')]
40+
${close icon} = Set Variable *[contains(@class, 'm-TabBar-tabCloseIcon')]
41+
Prepare File for Editing ${language} config ${file}
42+
Open in Advanced Settings ${LSP PLUGIN ID}
43+
Drag and Drop By Offset ${tab} 0 100
44+
Wait Until Fully Initialized
45+
Open Diagnostics Panel
46+
Drag and Drop By Offset ${JLAB XP DOCK TAB}\[contains(., 'Diagnostics Panel')] 600 -200
47+
Click Element ${JLAB XP DOCK TAB}\[contains(., 'Launcher')]/${close icon}
48+
Wait Until Page Contains Element ${before diagnostic} timeout=30s
49+
Page Should Not Contain ${after diagnostic}
50+
Capture Page Screenshot 01-default-diagnostics-and-settings.png
51+
Set Editor Content {"language_servers": {"${server}": {"serverSettings": ${settings}}}} ${CSS USER SETTINGS}
52+
Wait Until Page Contains No errors found
53+
Capture Page Screenshot 01-default-diagnostics-and-settings.png
54+
Click Element css:button[title\='Save User Settings']
55+
Click Element ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/${close icon}
56+
Drag and Drop By Offset ${tab} 0 100
57+
Lab Command Save ${language} File
58+
Ensure Sidebar Is Closed
59+
Capture Page Screenshot 02-settings-changed.png
60+
Wait Until Page Contains Element ${after diagnostic} timeout=30s
61+
Capture Page Screenshot 03-configured-diagnostic-found.png
62+
[Teardown] Clean Up After Working with File and Settings ${file}

atest/Keywords.robot

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Setup Server and Browser
2222
Initialize User Settings
2323
${cmd} = Create Lab Launch Command ${root}
2424
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots
25-
${server} = Start Process ${cmd} shell=yes env:HOME=${home} cwd=${home} stdout=${OUTPUT DIR}${/}lab.log
25+
Set Global Variable ${LAB LOG} ${OUTPUT DIR}${/}lab.log
26+
Set Global Variable ${PREVIOUS LAB LOG LENGTH} 0
27+
${server} = Start Process ${cmd} shell=yes env:HOME=${home} cwd=${home} stdout=${LAB LOG}
2628
... stderr=STDOUT
2729
Set Global Variable ${SERVER} ${server}
2830
Open JupyterLab
@@ -55,26 +57,37 @@ Initialize User Settings
5557
Set Suite Variable ${SETTINGS DIR} ${OUTPUT DIR}${/}user-settings children=${True}
5658
Create File ${SETTINGS DIR}${/}@jupyterlab${/}codemirror-extension${/}commands.jupyterlab-settings {"styleActiveLine": true}
5759

60+
Reset Plugin Settings
61+
Create File ${SETTINGS DIR}${/}${LSP PLUGIN SETTINGS FILE} {}
62+
5863
Tear Down Everything
5964
Close All Browsers
6065
Evaluate __import__("urllib.request").request.urlopen("${URL}api/shutdown?token=${TOKEN}", data=[])
6166
Wait For Process ${SERVER} timeout=30s
6267
Terminate All Processes
6368
Terminate All Processes kill=${True}
6469

70+
Lab Log Should Not Contain Known Error Messages
71+
${log} = Get File ${LAB LOG}
72+
${test log} = Set Variable ${log[${PREVIOUS LAB LOG LENGTH}:]}
73+
${length} = Get Length ${log}
74+
Set Global Variable ${PREVIOUS LAB LOG LENGTH} ${length}
75+
Run Keyword If ("${OS}", "${PY}") !\= ("Windows", "36")
76+
... Should Not Contain Any ${test log} @{KNOWN BAD ERRORS}
77+
6578
Wait For Splash
66-
Wait Until Page Contains Element ${SPLASH} timeout=180s
67-
Wait Until Page Does Not Contain Element ${SPLASH} timeout=180s
79+
Go To ${URL}lab?reset&token=${TOKEN}
80+
Set Window Size 1024 768
81+
Wait Until Page Contains Element ${SPLASH} timeout=30s
82+
Wait Until Page Does Not Contain Element ${SPLASH} timeout=10s
6883
Execute Javascript window.onbeforeunload \= function (){}
6984

7085
Open JupyterLab
7186
Set Environment Variable MOZ_HEADLESS ${HEADLESS}
7287
${firefox} = Which firefox
7388
${geckodriver} = Which geckodriver
7489
Create WebDriver Firefox executable_path=${geckodriver} firefox_binary=${firefox} service_log_path=${OUTPUT DIR}${/}geckodriver.log
75-
Wait Until Keyword Succeeds 20x 3s Go To ${URL}lab?reset&token=${TOKEN}
76-
Set Window Size 1024 768
77-
Wait For Splash
90+
Wait Until Keyword Succeeds 3x 5s Wait For Splash
7891

7992
Close JupyterLab
8093
Close All Browsers
@@ -92,7 +105,7 @@ Reset Application State
92105
Accept Default Dialog Option
93106
Ensure All Kernels Are Shut Down
94107
Lab Command Reset Application State
95-
Wait For Splash
108+
Wait Until Keyword Succeeds 3x 5s Wait For Splash
96109

97110
Accept Default Dialog Option
98111
[Documentation] Accept a dialog, if it exists
@@ -198,6 +211,7 @@ Clean Up After Working With File
198211
[Arguments] ${file}
199212
Remove File ${OUTPUT DIR}${/}home${/}${file}
200213
Reset Application State
214+
Lab Log Should Not Contain Known Error Messages
201215

202216
Setup Notebook
203217
[Arguments] ${Language} ${file} ${isolated}=${True}
@@ -246,3 +260,29 @@ Open Context Menu Over
246260
Wait Until Keyword Succeeds 10 x 0.1 s Mouse Over ${sel}
247261
Wait Until Keyword Succeeds 10 x 0.1 s Click Element ${sel}
248262
Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel}
263+
264+
Prepare File for Editing
265+
[Arguments] ${Language} ${Screenshots} ${file}
266+
Set Tags language:${Language.lower()}
267+
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots${/}${Screenshots}${/}${Language.lower()}
268+
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
269+
Try to Close All Tabs
270+
Open ${file} in ${MENU EDITOR}
271+
Capture Page Screenshot 00-opened.png
272+
273+
Open in Advanced Settings
274+
[Arguments] ${plugin id}
275+
Lab Command Advanced Settings Editor
276+
${sel} = Set Variable css:[data-id="${plugin id}"]
277+
Wait Until Page Contains Element ${sel}
278+
Click Element ${sel}
279+
Wait Until Page Contains System Defaults
280+
281+
Set Editor Content
282+
[Arguments] ${text} ${css}=${EMPTY}
283+
Execute JavaScript return document.querySelector('${css} .CodeMirror').CodeMirror.setValue(`${text}`)
284+
285+
Get Editor Content
286+
[Arguments] ${css}=${EMPTY}
287+
${content} = Execute JavaScript return document.querySelector('${css} .CodeMirror').CodeMirror.getValue()
288+
[Return] ${content}

atest/Variables.robot

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@ ${MENU SETTINGS} xpath://div[contains(@class, 'lm-MenuBar-itemLabel')][contai
3131
${MENU EDITOR THEME} xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "Text Editor Theme")]
3232
${CM CURSOR} css:.CodeMirror-cursor
3333
${CM CURSORS} css:.CodeMirror-cursors:not([style='visibility: hidden'])
34+
# settings
35+
${LSP PLUGIN ID} @krassowski/jupyterlab-lsp:plugin
36+
${LSP PLUGIN SETTINGS FILE} @krassowski${/}jupyterlab-lsp${/}plugin.jupyterlab-settings
37+
${CSS USER SETTINGS} .jp-SettingsRawEditor-user
38+
# diagnostics
39+
${CSS DIAGNOSTIC} css:.cm-lsp-diagnostic
40+
# log messages
41+
@{KNOWN BAD ERRORS}
42+
... pyls_jsonrpc.endpoint - Failed to handle notification
43+
... pyls_jsonrpc.endpoint - Failed to handle request

0 commit comments

Comments
 (0)