Skip to content

Commit acf17ab

Browse files
authored
Merge pull request #288 from bollwyvl/add-texlab-spec
Add texlab for LaTeX
2 parents 419ec72 + f2a7b1a commit acf17ab

28 files changed

+350
-51
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
## CHANGELOG
22

3+
### `jupyter-lsp 0.9.x` (unreleased)
4+
5+
- autodetects the `texlab` language server for `.tex` files ([#288][])
6+
- diagnostics _should_ be provided by `chktex` on save, but don't yet appear,
7+
but can be configured through the Advanced Settings Editor to appear on save or change
8+
9+
[#288]: https://github.com/krassowski/jupyterlab-lsp/issues/288
10+
311
### `@krassowski/jupyterlab-lsp 1.1.0` (2020-07-20)
412

513
- features

atest/01_Editor.robot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ JSX
2828
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'hello')])[last()]
2929
Editor Shows Features for Language JSX example.jsx Diagnostics=Expression expected Jump to Definition=${def} Rename=${def}
3030

31+
LaTeX
32+
[Tags] language:latex
33+
${def} = Set Variable xpath:(//span[contains(@class, 'cm-atom')][contains(text(), 'foo')])[last()]
34+
Editor Shows Features for Language LaTeX example.tex Jump to Definition=${def} Rename=${def}
35+
3136
Less
3237
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), '@width')])[last()]
3338
Editor Shows Features for Language Less example.less Diagnostics=Do not use empty rulesets Jump to Definition=${def}
@@ -62,6 +67,7 @@ YAML
6267
Editor Shows Features for Language
6368
[Arguments] ${Language} ${file} &{features}
6469
Prepare File for Editing ${Language} editor ${file}
70+
Wait Until Fully Initialized
6571
FOR ${f} IN @{features}
6672
Run Keyword If "${f}" == "Diagnostics" Editor Should Show Diagnostics ${features["${f}"]}
6773
... ELSE IF "${f}" == "Jump to Definition" Editor Should Jump To Definition ${features["${f}"]}

atest/03_Notebook.robot

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ Resource Keywords.robot
55

66
*** Test Cases ***
77
Python
8-
Setup Notebook Python Python.ipynb
9-
Capture Page Screenshot 01-python.png
8+
[Setup] Setup Notebook Python Python.ipynb
109
${diagnostic} = Set Variable W291 trailing whitespace (pycodestyle)
1110
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title="${diagnostic}"] timeout=35s
12-
Capture Page Screenshot 02-python.png
13-
Clean Up After Working With File Python.ipynb
11+
Capture Page Screenshot 01-python.png
12+
[Teardown] Clean Up After Working With File Python.ipynb
1413

15-
Foregin Extractors
16-
Setup Notebook Python Foreign extractors.ipynb
17-
# if mypy and pyflakes will fight over `(N|n)ame 'valid'`, just hope for the best
18-
@{diagnostics} = Create List Failed to parse expression ame 'valid' Trailing whitespace is superfluous.
14+
Foreign Extractors
15+
${file} = Set Variable Foreign extractors.ipynb
16+
Configure JupyterLab Plugin
17+
... {"language_servers": {"texlab": {"serverSettings": {"latex.lint.onChange": true}}}}
18+
Capture Page Screenshot 10-configured.png
19+
Reset Application State
20+
Setup Notebook Python ${file}
21+
@{diagnostics} = Create List
22+
... Failed to parse expression # bash
23+
... ame 'valid' # python, mypy and pyflakes will fight over `(N|n)ame 'valid'`, just hope for the best
24+
... Trailing whitespace is superfluous. # r
25+
... `frob` is misspelt # markdown
26+
... Command terminated with space # latex
1927
FOR ${diagnostic} IN @{diagnostics}
2028
Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*\="${diagnostic}"] timeout=35s
21-
Capture Page Screenshot 0x-${diagnostic}.png
2229
END
23-
Clean Up After Working With File Foreign Extractors.ipynb
30+
Capture Page Screenshot 11-extracted.png
31+
[Teardown] Clean Up After Working with File and Settings ${file}

atest/07_Configuration.robot

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Python
1414

1515
YAML
1616
[Documentation] EXPECT FAIL Composer YAML files don't allow a "greetings" key
17+
[Tags] expect:fail
1718
Settings Should Change Editor Diagnostics YAML example.yaml yaml-language-server
1819
... {"yaml.schemas": {"http://json.schemastore.org/composer": "*"}}
1920
... duplicate key
@@ -26,37 +27,55 @@ Markdown
2627
... `Color` is misspelt
2728
... `Colour` is misspelt
2829

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
30+
LaTeX
31+
[Documentation] diagnostics only appear if configured
32+
[Tags] language:latex
33+
${needs reload} = Set Variable "${OS}" == "Windows"
34+
Settings Should Change Editor Diagnostics LaTeX example.tex texlab
35+
... {"latex.lint.onChange": true}
36+
... ${EMPTY}
37+
... Command terminated with space. (chktex)
38+
... Save File
39+
... ${needs reload}
3440

41+
*** Keywords ***
3542
Settings Should Change Editor Diagnostics
36-
[Arguments] ${language} ${file} ${server} ${settings} ${before} ${after}
43+
[Arguments] ${language} ${file} ${server} ${settings} ${before} ${after} ${save command}=${EMPTY} ${needs reload}=${False}
3744
${before diagnostic} = Set Variable ${CSS DIAGNOSTIC}\[title^="${before}"]
3845
${after diagnostic} = Set Variable ${CSS DIAGNOSTIC}\[title^="${after}"]
3946
${tab} = Set Variable ${JLAB XP DOCK TAB}\[contains(., '${file}')]
4047
${close icon} = Set Variable *[contains(@class, 'm-TabBar-tabCloseIcon')]
48+
${save command} = Set Variable If "${save command}" ${save command} Save ${language} File
4149
Prepare File for Editing ${language} config ${file}
4250
Open in Advanced Settings ${LSP PLUGIN ID}
4351
Drag and Drop By Offset ${tab} 0 100
4452
Wait Until Fully Initialized
4553
Open Diagnostics Panel
4654
Drag and Drop By Offset ${JLAB XP DOCK TAB}\[contains(., 'Diagnostics Panel')] 600 -200
4755
Click Element ${JLAB XP DOCK TAB}\[contains(., 'Launcher')]/${close icon}
48-
Wait Until Page Contains Element ${before diagnostic} timeout=30s
56+
Run Keyword If "${before}" Wait Until Page Contains Element ${before diagnostic} timeout=30s
4957
Page Should Not Contain ${after diagnostic}
5058
Capture Page Screenshot 01-default-diagnostics-and-settings.png
5159
Set Editor Content {"language_servers": {"${server}": {"serverSettings": ${settings}}}} ${CSS USER SETTINGS}
5260
Wait Until Page Contains No errors found
53-
Capture Page Screenshot 01-default-diagnostics-and-settings.png
61+
Capture Page Screenshot 02-default-diagnostics-and-unsaved-settings.png
5462
Click Element css:button[title\='Save User Settings']
55-
Click Element ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/${close icon}
63+
Click Element ${JLAB XP CLOSE SETTINGS}
5664
Drag and Drop By Offset ${tab} 0 100
57-
Lab Command Save ${language} File
65+
Lab Command ${save command}
5866
Ensure Sidebar Is Closed
59-
Capture Page Screenshot 02-settings-changed.png
67+
Capture Page Screenshot 03-settings-changed.png
68+
Run Keyword If ${needs reload} Reload After Configuration ${language} ${file}
6069
Wait Until Page Contains Element ${after diagnostic} timeout=30s
61-
Capture Page Screenshot 03-configured-diagnostic-found.png
70+
Capture Page Screenshot 04-configured-diagnostic-found.png
6271
[Teardown] Clean Up After Working with File and Settings ${file}
72+
73+
Reload After Configuration
74+
[Arguments] ${language} ${file}
75+
Reload Page
76+
Wait Until Keyword Succeeds 3x 5s Wait For Splash
77+
Reset Application State
78+
Prepare File for Editing ${language} config ${file}
79+
Wait Until Fully Initialized
80+
Open Diagnostics Panel
81+
Ensure Sidebar Is Closed

atest/Keywords.robot

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,16 @@ Get Editor Content
286286
[Arguments] ${css}=${EMPTY}
287287
${content} = Execute JavaScript return document.querySelector('${css} .CodeMirror').CodeMirror.getValue()
288288
[Return] ${content}
289+
290+
Configure JupyterLab Plugin
291+
[Arguments] ${settings json} ${plugin id}=${LSP PLUGIN ID}
292+
Open in Advanced Settings ${plugin id}
293+
Set Editor Content ${settings json} ${CSS USER SETTINGS}
294+
Wait Until Page Contains No errors found
295+
Click Element css:button[title\='Save User Settings']
296+
Click Element ${JLAB XP CLOSE SETTINGS}
297+
298+
Clean Up After Working with File and Settings
299+
[Arguments] ${file}
300+
Clean Up After Working With File ${file}
301+
Reset Plugin Settings

atest/Variables.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ${CM CURSORS} css:.CodeMirror-cursors:not([style='visibility: hidden'])
3535
${LSP PLUGIN ID} @krassowski/jupyterlab-lsp:plugin
3636
${LSP PLUGIN SETTINGS FILE} @krassowski${/}jupyterlab-lsp${/}plugin.jupyterlab-settings
3737
${CSS USER SETTINGS} .jp-SettingsRawEditor-user
38+
${JLAB XP CLOSE SETTINGS} ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/*[contains(@class, 'm-TabBar-tabCloseIcon')]
3839
# diagnostics
3940
${CSS DIAGNOSTIC} css:.cm-lsp-diagnostic
4041
# log messages

atest/examples/Foreign extractors.ipynb

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,41 @@
6666
"%%bash\n",
6767
"echo $"
6868
]
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"metadata": {},
73+
"source": [
74+
"### $\\LaTeX$"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": null,
80+
"metadata": {},
81+
"outputs": [],
82+
"source": [
83+
"%%latex\n",
84+
"\n",
85+
"\\foo bar"
86+
]
87+
},
88+
{
89+
"cell_type": "markdown",
90+
"metadata": {},
91+
"source": [
92+
"### Markdown"
93+
]
94+
},
95+
{
96+
"cell_type": "code",
97+
"execution_count": null,
98+
"metadata": {},
99+
"outputs": [],
100+
"source": [
101+
"%%markdown\n",
102+
"frob"
103+
]
69104
}
70105
],
71106
"metadata": {
@@ -84,7 +119,7 @@
84119
"name": "python",
85120
"nbconvert_exporter": "python",
86121
"pygments_lexer": "ipython3",
87-
"version": "3.8.0"
122+
"version": "3.7.6"
88123
}
89124
},
90125
"nbformat": 4,

atest/examples/example.tex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
\documentclass{article}
2+
3+
\begin{document}
4+
\foo this is an error
5+
\label{foo}
6+
\ref{foo}
7+
\end{document}

binder/environment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ dependencies:
3333
- r-irkernel
3434
- r-languageserver
3535
- rpy2
36+
# for tex
37+
- tectonic
38+
- texlab
39+
- chktex

ci/env-test.yml.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ dependencies:
2121
- r-languageserver
2222
- r-stringi >=1.4.6
2323
- rpy2
24+
# tex
25+
- tectonic
26+
- texlab
27+
- chktex
2428
# test tools
2529
- pytest-asyncio
2630
- pytest-azurepipelines

0 commit comments

Comments
 (0)