Skip to content

Commit eaa4ca3

Browse files
authored
Merge pull request #1 from bollwyvl/server-config
Add markdown config atest
2 parents 630920b + 2347b28 commit eaa4ca3

File tree

17 files changed

+301
-143
lines changed

17 files changed

+301
-143
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
- fixes currently-highlighted token in dark editor themes against light lab theme
88
(and vice versa) ([#195][])
9+
- restores sorting order-indicating caret icons in diagnostics panel table ([#261][])
910

1011
[#195]: https://github.com/krassowski/jupyterlab-lsp/issues/195
12+
[#261]: https://github.com/krassowski/jupyterlab-lsp/issues/261
1113

1214
### `@krassowski/jupyterlab-lsp 1.0.0` (2020-03-14)
1315

atest/01_Editor.robot

Lines changed: 3 additions & 0 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}

atest/07_Configuration.robot

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,59 @@ Suite Setup Setup Suite For Screenshots config
44
Force Tags feature:config
55
Resource ./Keywords.robot
66

7-
*** Variables ***
8-
${CONFIG PYLS} {"language_servers": {"pyls": {"serverSettings": {"pyls": {"plugins": {"flake8": {"enabled": true},"pyflakes": {"enabled": false}}}}}}}
9-
# pyflakes is enabled by default, but flake8 is not
10-
${PYFLAKES DIAGNOSTIC} ${CSS DIAGNOSTIC}-Error[title="undefined name 'foo' (pyflakes)"]
11-
${FLAKE8 DIAGNOSTIC} ${CSS DIAGNOSTIC}-Warning[title="undefined name 'foo' (flake8)"]
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)
1214

13-
# Sets expectation that all YAML files (wildcard *) adhere to Composer spec
14-
${CONFIG YAML SCHEMA} {"language_servers": {"yaml-language-server": {"serverSettings": {"yaml.schemas": {"http://json.schemastore.org/composer": "*"}}}}}
15-
# Composer YAML files don't allow a "greetings" key
16-
${SCHEMA DIAGNOSTIC} ${CSS DIAGNOSTIC}-Error[title="Property greetings is not allowed."]
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.
1721

18-
*** Test Cases ***
19-
Pyls Configuration
20-
${file} = Set Variable style.py
21-
${tab} = Set Variable ${JLAB XP DOCK TAB}\[contains(., '${file}')]
22-
Prepare File for Editing PYTHON config ${file}
23-
Open in Advanced Settings ${LSP PLUGIN ID}
24-
Drag and Drop By Offset ${tab} 0 100
25-
Wait Until Fully Initialized
26-
Open Diagnostics Panel
27-
Drag and Drop By Offset ${JLAB XP DOCK TAB}\[contains(., 'Diagnostics Panel')] 600 -200
28-
Ensure Sidebar Is Closed
29-
Capture Page Screenshot 01-diagnostics-and-settings.png
30-
# Diagnostic panel should show pyflakes diagnostics, but no flake8
31-
Wait Until Page Contains Element ${PYFLAKES DIAGNOSTIC} timeout=60s
32-
Page Should Not Contain ${FLAKE8 DIAGNOSTIC}
33-
Set Editor Content ${CONFIG PYLS} ${CSS USER SETTINGS}
34-
Click Element css:button[title\='Save User Settings']
35-
Drag and Drop By Offset ${tab} 0 100
36-
Lab Command Save Python File
37-
Capture Page Screenshot 02-settings-changed.png
38-
# After updating settings, we should see flake8 but no pyflakes
39-
Wait Until Page Contains Element ${FLAKE8 DIAGNOSTIC} timeout=60s
40-
Page Should Not Contain ${PYFLAKES DIAGNOSTIC}
41-
Capture Page Screenshot 03-flake8-diagnostic-found.png
42-
[Teardown] Clean Up After Working with File and Settings ${file}
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
4328

44-
YAML Schema
45-
${file} = Set Variable example.yaml
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}"]
4639
${tab} = Set Variable ${JLAB XP DOCK TAB}\[contains(., '${file}')]
47-
Prepare File for Editing YAML config ${file}
40+
${close icon} = Set Variable *[contains(@class, 'm-TabBar-tabCloseIcon')]
41+
Prepare File for Editing ${language} config ${file}
4842
Open in Advanced Settings ${LSP PLUGIN ID}
4943
Drag and Drop By Offset ${tab} 0 100
5044
Wait Until Fully Initialized
5145
Open Diagnostics Panel
5246
Drag and Drop By Offset ${JLAB XP DOCK TAB}\[contains(., 'Diagnostics Panel')] 600 -200
53-
Capture Page Screenshot 01-diagnostics-and-settings.png
54-
# Diagnostic panel shouldn't show "Property ... is not allowed"
55-
Page Should Not Contain ${SCHEMA DIAGNOSTIC}
56-
Set Editor Content ${CONFIG YAML SCHEMA} ${CSS USER SETTINGS}
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
5754
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
5859
Capture Page Screenshot 02-settings-changed.png
59-
# Now show the Composer YAML error
60-
Wait Until Page Contains Element ${SCHEMA DIAGNOSTIC} timeout=60s
61-
Capture Page Screenshot 03-schema-diagnostic-found.png
60+
Wait Until Page Contains Element ${after diagnostic} timeout=30s
61+
Capture Page Screenshot 03-configured-diagnostic-found.png
6262
[Teardown] Clean Up After Working with File and Settings ${file}
63-
64-
*** Keywords ***
65-
Clean Up After Working with File and Settings
66-
[Arguments] ${file}
67-
Clean Up After Working With File ${file}
68-
Reset Plugin Settings

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

docs/_static/css/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ body div.nboutput.container div[class*='highlight'] pre {
3434
.wy-nav-content {
3535
max-width: 100%;
3636
}
37+
38+
.nbinput .prompt,
39+
.nboutput .prompt {
40+
display: none;
41+
}

docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"""{% block input -%}""" """{% if not cell.metadata.get("hide_input", False) -%}""",
1717
).replace("""{% endblock input %}""", """{%- endif -%}{%- endblock input %}""")
1818

19-
nbsphinx_prompt_width = "0"
2019

2120
sys.path.insert(
2221
0, str((pathlib.Path.cwd().parent / "py_src" / "jupyter_lsp").resolve())
@@ -27,7 +26,7 @@
2726
author = "Jupyter[Lab] Language Server Contributors"
2827

2928
version = "0.7.0"
30-
release = "0"
29+
release = ""
3130

3231
extensions = [
3332
"recommonmark",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"dependencies": {},
33
"devDependencies": {
44
"bash-language-server": "^1.6.1",
5+
"dictionary-en": "^3.0.0",
56
"dockerfile-language-server-nodejs": "^0.0.22",
67
"eslint": "^5.16.0",
78
"eslint-config-prettier": "^4.1.0",
@@ -20,7 +21,7 @@
2021
"vscode-css-languageserver-bin": "^1.4.0",
2122
"vscode-html-languageserver-bin": "^1.4.0",
2223
"vscode-json-languageserver-bin": "^1.0.1",
23-
"yaml-language-server": "^0.8.0"
24+
"yaml-language-server": "~0.4.0"
2425
},
2526
"husky": {
2627
"hooks": {

packages/jupyterlab-lsp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"license": "BSD-3-Clause",
2020
"author": "Michał Krassowski",
2121
"files": [
22-
"{lib,style,schema,src}/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf,css,json,ts,tsx}"
22+
"{lib,style,schema,src}/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf,css,json,ts,tsx,txt,md}"
2323
],
2424
"main": "lib/index.js",
2525
"types": "lib/index.d.ts",

packages/jupyterlab-lsp/src/adapters/codemirror/features/diagnostics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
DIAGNOSTICS_LISTING_CLASS,
1212
DiagnosticsDatabase,
1313
DiagnosticsListing,
14-
IEditorDiagnostic
14+
IEditorDiagnostic,
15+
diagnosticsIcon
1516
} from './diagnostics_listing';
1617
import { VirtualDocument } from '../../../virtual/document';
1718
import { VirtualEditor } from '../../../virtual/editor';
@@ -46,6 +47,7 @@ class DiagnosticsPanel {
4647
widget.id = 'lsp-diagnostics-panel';
4748
widget.title.label = 'Diagnostics Panel';
4849
widget.title.closable = true;
50+
widget.title.icon = diagnosticsIcon;
4951
return widget;
5052
}
5153

packages/jupyterlab-lsp/src/adapters/codemirror/features/diagnostics_listing.tsx

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { ReactElement } from 'react';
22
import { VDomModel, VDomRenderer } from '@jupyterlab/apputils';
3+
import { caretDownIcon, caretUpIcon, LabIcon } from '@jupyterlab/ui-components';
34
import * as lsProtocol from 'vscode-languageserver-protocol';
45
import * as CodeMirror from 'codemirror';
56
import { IEditorPosition } from '../../../positioning';
@@ -12,6 +13,13 @@ import { Cell } from '@jupyterlab/cells';
1213
import { diagnosticSeverityNames } from '../../../lsp';
1314
import { message_without_code } from './diagnostics';
1415

16+
import diagnosticsSvg from '../../../../style/icons/diagnostics.svg';
17+
18+
export const diagnosticsIcon = new LabIcon({
19+
name: 'lsp:diagnostics',
20+
svgstr: diagnosticsSvg
21+
});
22+
1523
/**
1624
* Diagnostic which is localized at a specific editor (cell) within a notebook
1725
* (if used in the context of a FileEditor, then there is just a single editor)
@@ -161,19 +169,20 @@ class Column {
161169

162170
function SortableTH(props: { name: string; listing: DiagnosticsListing }): any {
163171
const is_sort_key = props.name === props.listing.sort_key;
172+
const sortIcon =
173+
!is_sort_key || props.listing.sort_direction === 1
174+
? caretUpIcon
175+
: caretDownIcon;
164176
return (
165177
<th
166178
key={props.name}
167179
onClick={() => props.listing.sort(props.name)}
168-
className={
169-
is_sort_key
170-
? 'lsp-sorted ' +
171-
(props.listing.sort_direction === 1 ? 'lsp-descending' : '')
172-
: ''
173-
}
180+
className={is_sort_key ? 'lsp-sorted-header' : null}
174181
>
175-
{props.name}
176-
{is_sort_key ? <span className={'lsp-caret'} /> : null}
182+
<div>
183+
<label>{props.name}</label>
184+
<sortIcon.react tag="span" className="lsp-sort-icon" />
185+
</div>
177186
</th>
178187
);
179188
}
@@ -230,19 +239,29 @@ export class DiagnosticsListing extends VDomRenderer<DiagnosticsListing.Model> {
230239
new Column({
231240
name: 'Cell',
232241
render_cell: row => <td key={5}>{row.cell_number}</td>,
233-
sort: (a, b) => (a.cell_number > b.cell_number ? 1 : -1),
242+
sort: (a, b) =>
243+
a.cell_number > b.cell_number
244+
? 1
245+
: a.data.range.start.line > b.data.range.start.line
246+
? 1
247+
: a.data.range.start.ch > b.data.range.start.ch
248+
? 1
249+
: -1,
234250
is_available: context => context.editor.has_cells
235251
}),
236252
new Column({
237-
name: 'Line',
238-
render_cell: row => <td key={6}>{row.data.range.start.line}</td>,
253+
name: 'Line:Ch',
254+
render_cell: row => (
255+
<td key={6}>
256+
{row.data.range.start.line}:{row.data.range.start.ch}
257+
</td>
258+
),
239259
sort: (a, b) =>
240-
a.data.range.start.line > b.data.range.start.line ? 1 : -1
241-
}),
242-
new Column({
243-
name: 'Ch',
244-
render_cell: row => <td key={7}>{row.data.range.start.line}</td>,
245-
sort: (a, b) => (a.data.range.start.ch > b.data.range.start.ch ? 1 : -1)
260+
a.data.range.start.line > b.data.range.start.line
261+
? 1
262+
: a.data.range.start.ch > b.data.range.start.ch
263+
? 1
264+
: -1
246265
})
247266
];
248267

0 commit comments

Comments
 (0)