Skip to content

Commit 6e56292

Browse files
committed
merge master, apply linters
2 parents bda0f67 + 494b711 commit 6e56292

22 files changed

+2942
-2054
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

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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,5 @@ Resource Keywords.robot
55
*** Test Cases ***
66
Settings
77
[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
8+
Open in Advanced Settings ${LSP PLUGIN ID}
9+
Capture Page Screenshot 01-settings-lsp.png

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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Initialize User Settings
5555
Set Suite Variable ${SETTINGS DIR} ${OUTPUT DIR}${/}user-settings children=${True}
5656
Create File ${SETTINGS DIR}${/}@jupyterlab${/}codemirror-extension${/}commands.jupyterlab-settings {"styleActiveLine": true}
5757

58+
Reset Plugin Settings
59+
Create File ${SETTINGS DIR}${/}${LSP PLUGIN SETTINGS FILE} {}
60+
5861
Tear Down Everything
5962
Close All Browsers
6063
Evaluate __import__("urllib.request").request.urlopen("${URL}api/shutdown?token=${TOKEN}", data=[])
@@ -246,3 +249,29 @@ Open Context Menu Over
246249
Wait Until Keyword Succeeds 10 x 0.1 s Mouse Over ${sel}
247250
Wait Until Keyword Succeeds 10 x 0.1 s Click Element ${sel}
248251
Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel}
252+
253+
Prepare File for Editing
254+
[Arguments] ${Language} ${Screenshots} ${file}
255+
Set Tags language:${Language.lower()}
256+
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots${/}${Screenshots}${/}${Language.lower()}
257+
Copy File examples${/}${file} ${OUTPUT DIR}${/}home${/}${file}
258+
Try to Close All Tabs
259+
Open ${file} in ${MENU EDITOR}
260+
Capture Page Screenshot 00-opened.png
261+
262+
Open in Advanced Settings
263+
[Arguments] ${plugin id}
264+
Lab Command Advanced Settings Editor
265+
${sel} = Set Variable css:[data-id="${plugin id}"]
266+
Wait Until Page Contains Element ${sel}
267+
Click Element ${sel}
268+
Wait Until Page Contains System Defaults
269+
270+
Set Editor Content
271+
[Arguments] ${text} ${css}=${EMPTY}
272+
Execute JavaScript return document.querySelector('${css} .CodeMirror').CodeMirror.setValue(`${text}`)
273+
274+
Get Editor Content
275+
[Arguments] ${css}=${EMPTY}
276+
${content} = Execute JavaScript return document.querySelector('${css} .CodeMirror').CodeMirror.getValue()
277+
[Return] ${content}

atest/Variables.robot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ ${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

atest/examples/composer-schema.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: 0
2+
foo:
3+
bar:
4+
bar:

atest/examples/example.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Colour
2+
3+
Color [link][] ![link][]
4+
5+
- list item
6+
7+
[link]: http://example.com

atest/examples/example.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
greetings:
22
hello:
3-
hello:
3+
hello:
4+
well:

0 commit comments

Comments
 (0)