Misc update
This commit is contained in:
parent
0a42421055
commit
a1ac8eb8b9
|
@ -1,5 +1,4 @@
|
||||||
.vscode/
|
.vscode/
|
||||||
node_modules
|
out/
|
||||||
out
|
node_modules/
|
||||||
.vscode-test/
|
|
||||||
*.vsix
|
*.vsix
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
dist: bionic
|
dist: bionic
|
||||||
|
|
||||||
language: node_js
|
language: node_js
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
.vscode/**
|
.vscode/**
|
||||||
.vscode-test/**
|
|
||||||
out/test/**
|
|
||||||
src/**
|
src/**
|
||||||
|
scripts/**
|
||||||
.gitignore
|
.gitignore
|
||||||
.yarnrc
|
.gitattributes
|
||||||
.travis.yml
|
.travis.yml
|
||||||
**/tsconfig.json
|
**/tsconfig.json
|
||||||
**/*.map
|
**/*.map
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
"brackets": [
|
"brackets": [
|
||||||
["{", "}"],
|
["{", "}"],
|
||||||
["[", "]"],
|
["[", "]"],
|
||||||
["(", ")"],
|
["(", ")"]
|
||||||
["``", "''"]
|
|
||||||
],
|
],
|
||||||
"autoClosingPairs": [
|
"autoClosingPairs": [
|
||||||
["{", "}"],
|
["{", "}"],
|
||||||
|
|
|
@ -74,9 +74,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "14.11.8",
|
"version": "14.11.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.8.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.10.tgz",
|
||||||
"integrity": "sha512-KPcKqKm5UKDkaYPTuXSx8wEP7vE9GnuaXIZKijwRYcePpZFDVuy2a57LarFKiORbHOuTOOwYzxVxcUzsh2P2Pw==",
|
"integrity": "sha512-yV1nWZPlMFpoXyoknm4S56y2nlTAuFYaJuQtYRAOU7xA/FJ9RY0Xm7QOkaYMMmr8ESdHIuUb6oQgR/0+2NqlyA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/vscode": {
|
"@types/vscode": {
|
||||||
|
|
23
package.json
23
package.json
|
@ -15,7 +15,7 @@
|
||||||
},
|
},
|
||||||
"icon": "assets/texinfo.png",
|
"icon": "assets/texinfo.png",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^14.11.8",
|
"@types/node": "^14.11.10",
|
||||||
"@types/vscode": "^1.50.0",
|
"@types/vscode": "^1.50.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.8.0",
|
"@typescript-eslint/eslint-plugin": "^3.8.0",
|
||||||
"@typescript-eslint/parser": "^3.8.0",
|
"@typescript-eslint/parser": "^3.8.0",
|
||||||
|
@ -110,42 +110,45 @@
|
||||||
"texinfo.makeinfo": {
|
"texinfo.makeinfo": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "makeinfo",
|
"default": "makeinfo",
|
||||||
"markdownDescription": "Path to the `makeinfo` command."
|
"markdownDescription": "Path to the `makeinfo` (or `texi2any`) command. If not located in `$PATH`, an absolute path should be specified.\n\nThe value should not contain any command-line arguments, just the filename."
|
||||||
},
|
},
|
||||||
"texinfo.preview.noHeaders": {
|
"texinfo.preview.noHeaders": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"markdownDescription": "Suppress node separators in preview. See `makeinfo --help` for details."
|
"markdownDescription": "Suppress node separators in preview.\n\nThis corresponds to the `--no-headers` option of `makeinfo`."
|
||||||
},
|
},
|
||||||
"texinfo.preview.maxSize": {
|
"texinfo.preview.maxSize": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"default": "2",
|
"default": "2",
|
||||||
|
"minimum": 1,
|
||||||
|
"maximum": 16,
|
||||||
"markdownDescription": "Max allowed size (in MiB) for the preview document."
|
"markdownDescription": "Max allowed size (in MiB) for the preview document."
|
||||||
},
|
},
|
||||||
"texinfo.preview.errorLimit": {
|
"texinfo.preview.errorLimit": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"default": 100,
|
"default": 100,
|
||||||
"markdownDescription": "Max tolerated number of errors when trying to display preview."
|
"minimum": 0,
|
||||||
|
"markdownDescription": "Max tolerated number of errors when trying to display preview.\n\nThis corresponds to the `--error-limit=NUM` option of `makeinfo`."
|
||||||
},
|
},
|
||||||
"texinfo.preview.force": {
|
"texinfo.preview.force": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"markdownDescription": "Preserve preview even if errors."
|
"markdownDescription": "Preserve preview even if errors.\n\nThis corresponds to the `--force` option of `makeinfo`."
|
||||||
},
|
},
|
||||||
"texinfo.preview.noValidate": {
|
"texinfo.preview.noValidation": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"markdownDescription": "Supress node cross-reference validation."
|
"markdownDescription": "Supress node cross-reference validation.\n\nThis corresponds to the `--no-validate` option of `makeinfo`."
|
||||||
},
|
},
|
||||||
"texinfo.preview.noWarn": {
|
"texinfo.preview.noWarnings": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"markdownDescription": "Suppress warnings."
|
"markdownDescription": "Suppress warnings.\n\nThis corresponds to the `--no-warn` option of `makeinfo`."
|
||||||
},
|
},
|
||||||
"texinfo.preview.displayImage": {
|
"texinfo.preview.displayImage": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"markdownDescription": "Whether to display images in in the preview."
|
"markdownDescription": "Whether to display images in in the preview.\n\nIf image display is not needed, turn off this option to improve preview performance."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
mkdir -p ./out/grammars
|
SRC_PATH=./node_modules/language-texinfo
|
||||||
|
DEST_PATH=./out/grammars
|
||||||
# Convert TextMate grammar from CSON to JSON (VSCode cannot recognize CSON ones).
|
mkdir -p $DEST_PATH
|
||||||
TMGRAMMAR_CSON=./node_modules/language-texinfo/grammars/texinfo.cson
|
cp $SRC_PATH/LICENSE.md $DEST_PATH
|
||||||
TMGRAMMAR_JSON=./out/grammars/texinfo.json
|
# Convert TextMate grammar from CSON to JSON, as VSCode cannot recognize CSON ones.
|
||||||
cson2json $TMGRAMMAR_CSON > $TMGRAMMAR_JSON
|
cson2json $SRC_PATH/grammars/texinfo.cson > $DEST_PATH/texinfo.json
|
||||||
|
|
|
@ -31,8 +31,8 @@ export default class Converter {
|
||||||
private constructor() {
|
private constructor() {
|
||||||
Options.noHeaders && this.options.push('--no-headers');
|
Options.noHeaders && this.options.push('--no-headers');
|
||||||
Options.force && this.options.push('--force');
|
Options.force && this.options.push('--force');
|
||||||
Options.noValidate && this.options.push('--no-validate');
|
Options.noValidation && this.options.push('--no-validate');
|
||||||
Options.noWarn && this.options.push('--no-warn');
|
Options.noWarnings && this.options.push('--no-warn');
|
||||||
this.options.push(`--error-limit=${Options.errorLimit}`);
|
this.options.push(`--error-limit=${Options.errorLimit}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* extension.ts - Texinfo extension entry
|
* extension.ts - extension entry
|
||||||
*
|
*
|
||||||
* @author CismonX <admin@cismon.net>
|
* @author CismonX <admin@cismon.net>
|
||||||
* @license MIT
|
* @license MIT
|
||||||
|
@ -27,7 +27,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deactivate() {
|
export function deactivate() {
|
||||||
Preview.destroyAll();
|
Preview.clear();
|
||||||
Options.clear();
|
Options.clear();
|
||||||
FoldingRangeContext.clear();
|
FoldingRangeContext.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import * as vscode from 'vscode';
|
||||||
export class FoldingRangeProvider implements vscode.FoldingRangeProvider {
|
export class FoldingRangeProvider implements vscode.FoldingRangeProvider {
|
||||||
|
|
||||||
provideFoldingRanges(document: vscode.TextDocument) {
|
provideFoldingRanges(document: vscode.TextDocument) {
|
||||||
return FoldingRangeContext.get(document).foldingRanges;
|
return FoldingRangeContext.get(document).values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +30,7 @@ export class FoldingRangeContext {
|
||||||
* @param document
|
* @param document
|
||||||
*/
|
*/
|
||||||
static open(document: vscode.TextDocument) {
|
static open(document: vscode.TextDocument) {
|
||||||
if (document.languageId === 'texinfo') {
|
document.languageId === 'texinfo' && FoldingRangeContext.get(document);
|
||||||
FoldingRangeContext.get(document);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,10 +48,9 @@ export class FoldingRangeContext {
|
||||||
* @param event Change event of a document.
|
* @param event Change event of a document.
|
||||||
*/
|
*/
|
||||||
static update(event: vscode.TextDocumentChangeEvent) {
|
static update(event: vscode.TextDocumentChangeEvent) {
|
||||||
if (event.document.languageId !== 'texinfo') {
|
if (event.document.languageId === 'texinfo') {
|
||||||
return;
|
FoldingRangeContext.get(event.document).update(event.contentChanges);
|
||||||
}
|
}
|
||||||
FoldingRangeContext.get(event.document).update(event.contentChanges);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,14 +72,11 @@ export class FoldingRangeContext {
|
||||||
/**
|
/**
|
||||||
* Get VSCode folding ranges from the context.
|
* Get VSCode folding ranges from the context.
|
||||||
*/
|
*/
|
||||||
get foldingRanges() {
|
get values() {
|
||||||
if (this.bufferedFoldingRanges === undefined) {
|
return this.foldingRanges ?? (this.foldingRanges = this.calculateFoldingRanges());
|
||||||
this.calculateFoldingRanges();
|
|
||||||
}
|
|
||||||
return this.bufferedFoldingRanges;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bufferedFoldingRanges?: vscode.FoldingRange[];
|
private foldingRanges?: vscode.FoldingRange[];
|
||||||
|
|
||||||
private commentRange?: { start: number, end: number };
|
private commentRange?: { start: number, end: number };
|
||||||
|
|
||||||
|
@ -128,6 +122,7 @@ export class FoldingRangeContext {
|
||||||
this.insertRange(this.commentRange.start, this.commentRange.end, vscode.FoldingRangeKind.Comment);
|
this.insertRange(this.commentRange.start, this.commentRange.end, vscode.FoldingRangeKind.Comment);
|
||||||
}
|
}
|
||||||
this.commentRange = undefined;
|
this.commentRange = undefined;
|
||||||
|
return this.foldingRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
private processComment(lineText: string, lineNum: number) {
|
private processComment(lineText: string, lineNum: number) {
|
||||||
|
@ -159,10 +154,7 @@ export class FoldingRangeContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
private insertRange(start: number, end: number, kind?: vscode.FoldingRangeKind) {
|
private insertRange(start: number, end: number, kind?: vscode.FoldingRangeKind) {
|
||||||
if (this.bufferedFoldingRanges === undefined) {
|
(this.foldingRanges ?? (this.foldingRanges = [])).push(new vscode.FoldingRange(start, end, kind));
|
||||||
this.bufferedFoldingRanges = [];
|
|
||||||
}
|
|
||||||
this.bufferedFoldingRanges.push(new vscode.FoldingRange(start, end, kind));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,12 +163,14 @@ export class FoldingRangeContext {
|
||||||
* @param events Events describing the changes in the document.
|
* @param events Events describing the changes in the document.
|
||||||
*/
|
*/
|
||||||
private update(events: readonly vscode.TextDocumentContentChangeEvent[]) {
|
private update(events: readonly vscode.TextDocumentContentChangeEvent[]) {
|
||||||
|
if (this.foldingRanges === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
const range = event.range;
|
|
||||||
const updatedLines = event.text.split(this.document.eol === vscode.EndOfLine.LF ? '\n' : '\r\n').length;
|
const updatedLines = event.text.split(this.document.eol === vscode.EndOfLine.LF ? '\n' : '\r\n').length;
|
||||||
// Clear range buffer when line number changes.
|
// Clear folding range buffer when line count changes.
|
||||||
if (updatedLines !== 1 || range.start.line !== range.end.line) {
|
if (updatedLines !== 1 || event.range.start.line !== event.range.end.line) {
|
||||||
this.bufferedFoldingRanges = undefined;
|
this.foldingRanges = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,12 @@ export default class Options {
|
||||||
return Options.instance.getBoolean('preview.force');
|
return Options.instance.getBoolean('preview.force');
|
||||||
}
|
}
|
||||||
|
|
||||||
static get noValidate() {
|
static get noValidation() {
|
||||||
return Options.instance.getBoolean('preview.noValidate');
|
return Options.instance.getBoolean('preview.noValidation');
|
||||||
}
|
}
|
||||||
|
|
||||||
static get noWarn() {
|
static get noWarnings() {
|
||||||
return Options.instance.getBoolean('preview.noWarn');
|
return Options.instance.getBoolean('preview.noWarnings');
|
||||||
}
|
}
|
||||||
|
|
||||||
static get displayImage() {
|
static get displayImage() {
|
||||||
|
@ -62,15 +62,15 @@ export default class Options {
|
||||||
this.configuration = vscode.workspace.getConfiguration(section);
|
this.configuration = vscode.workspace.getConfiguration(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getString(section: string) {
|
private getString(section: string): string {
|
||||||
return this.configuration.get<string>(section) ?? '';
|
return this.configuration.get(section) ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
private getBoolean(section: string) {
|
private getBoolean(section: string): boolean {
|
||||||
return this.configuration.get<boolean>(section) ?? false;
|
return this.configuration.get(section) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getNumber(section: string) {
|
private getNumber(section: string): number {
|
||||||
return this.configuration.get<number>(section) ?? 0;
|
return this.configuration.get(section) ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ export default class Preview {
|
||||||
Preview.getByDocument(document)?.destroy();
|
Preview.getByDocument(document)?.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
static destroyAll() {
|
static clear() {
|
||||||
Preview.map.forEach((preview) => preview.destroy());
|
Preview.map.forEach((preview) => preview.destroy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* utils.ts - Helper functions
|
* utils.ts
|
||||||
*
|
*
|
||||||
* @author CismonX <admin@cismon.net>
|
* @author CismonX <admin@cismon.net>
|
||||||
* @license MIT
|
* @license MIT
|
||||||
|
|
Loading…
Reference in New Issue