Skip to content

Commit 4995eb2

Browse files
committed
Update to version 0.3.1
added syntax highlighting
1 parent 35b18ef commit 4995eb2

File tree

5 files changed

+110
-42
lines changed

5 files changed

+110
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
5454
- Added support for saving the collapsed status of the TOC view in the settings of the extension. When navigating to different ORCA output files, the TOC view status for each file will be restored.
5555
- Added support for automatically showing TOC view when opening an ORCA output file. (bug fix)
5656
- Added instruction screenshots to this README.
57+
58+
## [0.3.1] - 2023-12-03
59+
60+
- Added grammar syntax highlighting for the ORCA output file (syntax definition is saved in [`orca.tmLanguage.json`](syntaxes/orca.tmLanguage.json))

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ N/A
2727

2828
## Extension Settings
2929

30-
The current version (0.3.0) enables changing the default status of the toggleable TOC view. The default collapsed status of the TOC view can be changed in the settings of the extension. The default value is `true`, which means that the TOC view is collapsed by default. The TOC view can be expanded by clicking on the `ORCA FILE OUTLINE` icon in the sidebar.
30+
The current version (0.3.1) enables changing the default status of the toggleable TOC view. The default collapsed status of the TOC view can be changed in the settings of the extension. The default value is `true`, which means that the TOC view is collapsed by default. The TOC view can be expanded by clicking on the `ORCA FILE OUTLINE` icon in the sidebar.
31+
32+
The current version (0.3.1) also provide syntax highlighting for the ORCA output file, including the headings, separation lines, numbers, and keywords, etc. The syntax highlighting is enabled by default. The disablling of the syntax highlighting will be added in a future release. The display of the syntax highlighting varies with different themes. Dark themes are recommended for better display of the syntax highlighting.
3133

3234
![Setting: Collapse TOC view by default](images/setting_collapse_status.png)
3335

@@ -49,19 +51,17 @@ The current version (0.3.0) enables changing the default status of the toggleabl
4951

5052
For detailed release notes, please see [CHANGELOG.md](CHANGELOG.md).
5153

52-
### 0.3.0
54+
### 0.3.1
5355

54-
- Added support for saving the collapsed status of the TOC view in the settings of the extension. When navigating to different ORCA output files, the TOC view status for each file will be restored.
55-
- Added support for automatically showing TOC view when opening an ORCA output file. (bug fix)
56-
- Added instruction screenshots to this README.
56+
- Added grammar syntax highlighting for the ORCA output file (syntax definition is saved in [`orca.tmLanguage.json`](syntaxes/orca.tmLanguage.json))
5757

5858
## TODO
5959

6060
- [ ] Highlight the corresponding TOC entry when the user is navigating through the ORCA output file based on the current line number.
6161
- [ ] Foldings feature for the ORCA output file based on the TOC entries.
6262
- [ ] Add support for the `ORCA FILE OUTLINE` view to automatically scroll to the current line in the ORCA output file.
63-
- [ ] Formatter for the ORCA output file based on the TOC entries.
64-
63+
- [x] Syntax highliting for the ORCA output file based on the TOC entries.
64+
- [ ] Add settings for enabling/disabling the syntax highlighting for the ORCA output file.
6565

6666
## Roadmap
6767

@@ -80,6 +80,10 @@ Please submit a pull request if you would like to add a new regular expression t
8080

8181
A list of keywords that are used to format the headings in the TOC view is saved in `keywords.json` file. The matched strings will be formatted using the corresponding keywords. This list is currently not complete and will be updated in a future release.
8282

83+
The syntax definition for the ORCA output file is saved in [`orca.tmLanguage.json`](syntaxes/orca.tmLanguage.json). The syntax definition is based on the [TextMate grammar](https://macromates.com/manual/en/language_grammars) and [VS Code TextMate grammars](https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#textmate-grammars). The syntax definition is currently not complete and will be updated in a future release.
84+
85+
Please submit a pull request if you would like to add/modify syntax definitions to the ORCA output file.
86+
8387
## For more information
8488

8589
[ORCA forum](https://orcaforum.kofo.mpg.de/)

extension.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,25 @@ let orcaOutlineProvider = new OrcaOutlineProvider([]);
185185

186186
async function showOrcaOutline() { // Make the function asynchronous
187187
const activeEditor = vscode.window.activeTextEditor;
188-
189-
if (!activeEditor) {
190-
// Check if there's a file with .out extension in the workspace
191-
if (vscode.workspace.textDocuments.some(doc => doc.uri.scheme === 'file' && doc.fileName.endsWith('.out'))) {
192-
vscode.window.showErrorMessage("The file might be too large to open! VS Code is unable to operate with files larger than 50MB in active editor. Please consider breaking the file into smaller chunks.");
193-
} else {
194-
// If there's no file with .out extension in the workspace, show an error message, and Open File button to open the Open File dialog
195-
vscode.window.showErrorMessage("No active document found. Please open a file first.", "Open File").then((value) => {
196-
if (value === "Open File") {
197-
vscode.commands.executeCommand("workbench.action.files.openFile");
198-
}
199-
});
200-
}
188+
if (!activeEditor || !activeEditor.document) {
201189
return;
202190
}
191+
192+
// if there's no active editor, check if there's a file with .out extension in the workspace
193+
// if (!activeEditor) {
194+
// // Check if there's a file with .out extension in the workspace
195+
// if (vscode.workspace.textDocuments.some(doc => doc.uri.scheme === 'file' && doc.fileName.endsWith('.out'))) {
196+
// vscode.window.showErrorMessage("The file might be too large to open! VS Code is unable to operate with files larger than 50MB in active editor. Please consider breaking the file into smaller chunks.");
197+
// } else {
198+
// // If there's no file with .out extension in the workspace, show an error message, and Open File button to open the Open File dialog
199+
// vscode.window.showErrorMessage("No active document found. Please open a file first.", "Open File").then((value) => {
200+
// if (value === "Open File") {
201+
// vscode.commands.executeCommand("workbench.action.files.openFile");
202+
// }
203+
// });
204+
// }
205+
// return;
206+
// }
203207

204208
const document = activeEditor.document;
205209
try {
@@ -340,8 +344,8 @@ function deactivate() { }
340344
function activate(context) {
341345
const orcaProvider = new OrcaFileSystemProvider();
342346
context.subscriptions.push(vscode.workspace.registerFileSystemProvider('orca', orcaProvider, { isReadonly: true }));
343-
context.subscriptions.push(vscode.commands.registerCommand('extension.showOrcaOutlineExternal', (...args) => showOrcaOutlineExternal(context, ...args)));
344347
context.subscriptions.push(vscode.commands.registerCommand('extension.showOrcaOutline', showOrcaOutline));
348+
context.subscriptions.push(vscode.commands.registerCommand('extension.showOrcaOutlineExternal', (...args) => showOrcaOutlineExternal(context, ...args)));
345349
// Register the global instance
346350
vscode.window.registerTreeDataProvider('orcaFileOutline', orcaOutlineProvider);
347351
// Listen to changes in the active editor
@@ -356,6 +360,13 @@ function activate(context) {
356360
showOrcaOutline();
357361
}
358362

363+
// Automatically show outline if a .out file is opened
364+
vscode.workspace.onDidOpenTextDocument(document => {
365+
if (document.languageId === 'orcaOut' && document.fileName.endsWith('.out') && !vscode.window.activeTextEditor) {
366+
showOrcaOutline();
367+
}
368+
});
369+
359370
const treeView = vscode.window.createTreeView('orcaFileOutline', { treeDataProvider: orcaOutlineProvider });
360371

361372
treeView.onDidExpandElement(event => {
@@ -366,12 +377,6 @@ function activate(context) {
366377
orcaOutlineProvider.setExpandedState(event.element, false);
367378
});
368379

369-
370-
vscode.workspace.onDidOpenTextDocument(document => {
371-
if (document.languageId === 'orcaOut' && document.fileName.endsWith('.out') && !vscode.window.activeTextEditor) {
372-
showOrcaOutline();
373-
}
374-
});
375380
// listen to changes in the configuration
376381
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(e => {
377382
if (e.affectsConfiguration('orcatoc.defaultCollapsed')) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "orcatoc",
33
"displayName": "orca_toc",
44
"description": "Provides an outline for ORCA files in the VS Code sidebar.",
5-
"version": "0.3.0",
5+
"version": "0.3.1",
66
"engines": {
77
"vscode": "^1.82.0"
88
},

syntaxes/orca.tmLanguage.json

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,81 @@
44
"patterns": [
55
{
66
"name": "constant.numeric.orca",
7-
"match": "\\b\\d+\\.?\\d*\\b"
7+
"match": "\\b-?\\d+(\\.\\d+)?([eE][-+]?\\d+)?\\b"
8+
},
9+
{
10+
"name": "entity.name.heading.orca",
11+
"begin": "^\\s+\\*{5,}\\w*\\*{5,}\\s*$",
12+
"beginCaptures": {
13+
"0": { "name": "markup.heading.orca" }
14+
},
15+
"end": "^\\s+\\*{10,}\\s*$",
16+
"endCaptures": {
17+
"0": { "name": "markup.heading.orca" }
18+
},
19+
"patterns": [
20+
{
21+
"name": "markup.heading.orca",
22+
"match": "^\\s+\\*.+\\*\\s*$"
23+
}
24+
]
825
},
926
{
10-
"name":"markup.heading.1.orca",
11-
"match":" +\\*{10,}\\s*\\r?\\n"
27+
"name": "string.quoted.other.dashline.orca",
28+
"match": "^\\s*\\-{5,}\\s*$"
1229
},
1330
{
14-
"name":"markup.quote.orca",
15-
"match": "\\|\\s+\\d{1,5}> [^\\r?\\n]+"
31+
"name": "string.quoted.other.equaline.orca",
32+
"match": "^\\s*={5,}\\s*$"
1633
},
1734
{
18-
"name": "entity.name.section",
19-
"begin": "^={80}\\s*$",
20-
"end": "^={80}\\s*$",
21-
"patterns": [
22-
{
23-
"name": "keyword.other.title",
24-
"match": "\\b(?:INPUT FILE|WARNINGS)\\b"
25-
}
26-
]
35+
"name": "entity.name.section.orca",
36+
"match": "^\\s*[A-Z][A-Z -/():]+$"
37+
},
38+
{
39+
"name": "constant.other.element.orca",
40+
"match": "(?<=\\s)(\\d+)?(H|He|Li|Be|B|C|N|O|F|Ne|Na|Mg|Al|Si|P|S|Cl|Ar|K|Ca|Sc|Ti|V|Cr|Mn|Fe|Co|Ni|Cu|Zn|Ga|Ge|As|Se|Br|Kr|Rb|Sr|Y|Zr|Nb|Mo|Tc|Ru|Rh|Pd|Ag|Cd|In|Sn|Sb|Te|I|Xe|Cs|Ba|La|Ce|Pr|Nd|Pm|Sm|Eu|Gd|Tb|Dy|Ho|Er|Tm|Yb|Lu|Hf|Ta|W|Re|Os|Ir|Pt|Au|Hg|Tl|Pb|Bi|Po|At|Rn|Fr|Ra|Ac|Th|Pa|U|Np|Pu|Am|Cm|Bk|Cf|Es|Fm|Md|No|Lr)(?=\\s)"
41+
},
42+
{
43+
"name": "storage.type.orbital.orca",
44+
"match": "(?<=\\s)(\\d+)?(?:s {4}|px {3}|py {3}|pz {3}|dz2 {2}|dx2y2|dxy {2}|dxz {2}|dyz {2}|f0 {3}|f\\+1 {2}|f-1 {2}|f\\+2 {2}|f-2 {2}|f\\+3 {2}|f-3 {2})(?=\\s)"
45+
},
46+
{
47+
"name": "keyword.control.orca",
48+
"match": "\\b(done|true|false|yes|no|on|off|ON|OFF|YES|NO|NOT USED|NOT available|AVAILABLE|ok|auto)\\b"
49+
},
50+
{
51+
"name": "comment.block.orca",
52+
"match": "^\\s*\\*{3,}\\s*[^*]+\\s*\\*{3,}\\s*$"
53+
},
54+
{
55+
"name": "string.quoted.orca",
56+
"match": "^\\|\\s*\\d+>.*$"
57+
},
58+
{
59+
"name": "storage.type.arrow.orca",
60+
"match": "\\-+>|\\=+>"
61+
},
62+
63+
{
64+
"name": "variable.language.orca",
65+
"match": "^.*?(?=\\.\\.\\.)"
66+
},
67+
{
68+
"name": "variable.parameter.orca",
69+
"match": "^.*?(?=\\:)"
70+
},
71+
{
72+
"name": "variable.other.constant.orca",
73+
"match": "^.*?(?=\\=)"
74+
},
75+
{
76+
"name": "keyword.other.orca",
77+
"match": "\\b(DKH|SCF|ORCA|UHF|GTO|CIS|DFT|TRAH|HOMO|LUMO|PBE|NewAuxJGTO|NewGTO|OCC|SOC|XES|XAS)\\b"
78+
},
79+
{
80+
"name": "storage.type.unit.orca",
81+
"match": "(?<=\\s|\\()((days|min|hours|sec|MB|%|eV|cm-1|Eh|Eh\\/bohr|bohr|minutes|seconds|msec|au|nm|cgs)(?=\\s|\\)))"
2782
}
2883
]
2984
}

0 commit comments

Comments
 (0)