diff --git a/doc/vscode-texinfo.texi b/doc/vscode-texinfo.texi index 95112d9..4fd258b 100644 --- a/doc/vscode-texinfo.texi +++ b/doc/vscode-texinfo.texi @@ -81,10 +81,10 @@ developers. We believe that Texinfo deserves more users, for it is an excellent format for writing software manuals, as well as other technical materials. We chose Visual -Studio Code, one of the most popular code editors as of year 2020, and developed -this very extension, vscode-texinfo, which provides some useful features for -Visual Studio Code regarding the Texinfo format, in the hope that more -developers can benefit from it. +Studio Code, one of the most popular code editors as of year 2020, and +developed this very extension, vscode-texinfo, which provides some useful +features for Visual Studio Code regarding the Texinfo format, in the hope that +more developers can benefit from it. vscode-texinfo is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -100,8 +100,8 @@ version 3 of the License}, or (at your option) any later version. @section Contributing This project is hosted on @url{https://sv.gnu.org/p/vscode-texinfo, Savannah}. -Any kind of contribution is welcome, including bug reports, patches, and general -discussions regarding the usage of vscode-texinfo. +Any kind of contribution is welcome, including bug reports, patches, and +general discussions regarding the usage of vscode-texinfo. Before you submit something, please make sure that you have read this manual, and no one else has posted the same content. @@ -146,13 +146,15 @@ proprietary Visual Studio Marketplace. Before you install a @code{.vsix} file downloaded from a third party, you should check whether the file matches a trusted signature: +@set vsix-name texinfo-@value{VERSION}.vsix + @ifhtml @example wget -O cismonx.gpg.asc "https://sv.gnu.org/people/viewgpg.php?user_id=214244" gpg --import cismonx.gpg.asc -wget https://dl.sv.gnu.org/releases/vscode-texinfo/texinfo-0.2.0.vsix.sig.asc -gpg --verify texinfo-0.2.0.vsix.sig.asc texinfo-0.2.0.vsix +wget https://dl.sv.gnu.org/releases/vscode-texinfo/@value{vsix-name}.sig.asc +gpg --verify @value{vsix-name}.sig.asc @value{vsix-name} @end example @end ifhtml @@ -163,8 +165,8 @@ wget -O cismonx.gpg.asc \ gpg --import cismonx.gpg.asc wget "https://dl.sv.gnu.org/releases/vscode-texinfo/ - texinfo-0.2.0.vsix.sig.asc" -gpg --verify texinfo-0.2.0.vsix.sig.asc texinfo-0.2.0.vsix + @value{vsix-name}.sig.asc" +gpg --verify @value{vsix-name}.sig.asc @value{vsix-name} @end example @end ifnothtml @@ -223,8 +225,8 @@ suffix @code{.texi}, @code{.txi} or @code{.texinfo}, this process should be automatic. If not, find and click the status bar item with ``Select Language Mode'' tooltip, then choose ``Texinfo'' in the menu which just popped up. -If syntax highlighting does not look satisfactory, try another color theme where -keyword/operator colors are distinct. Some good examples are Solarized +If syntax highlighting does not look satisfactory, try another color theme +where keyword/operator colors are distinct. Some good examples are Solarized Light/Dark, Monokai, etc. For details about how to @url{@value{vscode-docs-url} @@ -265,10 +267,10 @@ code snippets is disabled by default. You can re-enable it on by switching off @quotation Note Code completion provided by vscode-texinfo does not recognize much of Texinfo's -semantics, and completion may appear in contexts where it should not exist. This -is a known bug (which cannot be fixed in near future, unless a -@url{https://microsoft.github.io/language-server-protocol/, language server} for -Texinfo is implemented, which is not trivial). +semantics, and completion may appear in contexts where it should not exist. +This is a known bug (which cannot be fixed in near future, unless a +@url{https://microsoft.github.io/language-server-protocol/, language server} +for Texinfo is implemented, which is not trivial). @end quotation @@ -286,14 +288,15 @@ Three types of code blocks can be recognized by vscode-texinfo: @item Consecutive lines of comments @end itemize -While editing a Texinfo document, you can collapse or expand a code block either -by clicking the folding icon to the left of the first line of the block, or by -invoking a corresponding command. See the Visual Studio Code User Guide for -@url{@value{vscode-docs-url}/editor/codebasics#_folding, details}. +While editing a Texinfo document, you can collapse or expand a code block +either by clicking the folding icon to the left of the first line of the block, +or by invoking a corresponding command. See the Visual Studio Code User Guide +for @url{@value{vscode-docs-url}/editor/codebasics#_folding, details}. @quotation Note Due to performance issues, the block hierarchy of a Texinfo document is -re-calculated only when total line count changes, or when the document is saved. +re-calculated only when total line count changes, or when the document is +saved. @end quotation @@ -314,10 +317,10 @@ See the Visual Studio Code User Guide for more information about Some more advanced features of vscode-texinfo is available if GNU Texinfo is correctly installed and configured on your device. -@url{https://www.gnu.org/software/texinfo, GNU Texinfo} is the official (and the -only known) full implementation of Texinfo. On most platforms, it can be easily -installed using a package manager. For example, if you're using a Debian-based -GNU/Linux distribution, you can install GNU Texinfo with: +@url{https://www.gnu.org/software/texinfo, GNU Texinfo} is the official (and +the only known) full implementation of Texinfo. On most platforms, it can be +easily installed using a package manager. For example, if you're using a +Debian-based GNU/Linux distribution, you can install GNU Texinfo with: @example sudo apt-get install texinfo @@ -329,8 +332,8 @@ plain text, etc. To specify the location of @code{makeinfo}, edit the configuration item @code{texinfo.makeinfo}. If it's not located in @code{$PATH}, an absolute path -should be specified. Also note that the path should not contain any command line -arguments. +should be specified. Also note that the path should not contain any command +line arguments. To check whether GNU Texinfo is correctly installed and configured, see @ref{Version Indicator}. @@ -346,20 +349,20 @@ To check whether GNU Texinfo is correctly installed and configured, see @section Version Indicator The version indicator is a status bar item with text ``GNU Texinfo''. It is -located on the right side of the status bar, which is shown when the active text -editor contains a Texinfo document. +located on the right side of the status bar, which is shown when the active +text editor contains a Texinfo document. If you see a @b{check icon} and the version of GNU Texinfo, then congratulations, you're all set. If a @b{cross icon} is displayed, it means that GNU Texinfo is @emph{not} correctly installed and configured. If a @b{warning icon} is displayed, it means that the currently installed GNU -Texinfo is outdated, or has an unrecognizable version number. In that case, some -features may not work as expected. +Texinfo is outdated, or has an unrecognizable version number. In that case, +some features may not work as expected. @quotation Note -The version indicator does not automatically refresh since the activation of the -extension. To manually trigger a refresh, click the status bar item. +The version indicator does not automatically refresh since the activation of +the extension. To manually trigger a refresh, click the status bar item. @end quotation @@ -371,9 +374,9 @@ to see how the document looks like when displayed online. In the active text editor which contains a Texinfo document, click the ``Show Preview'' button on the top right of the editor. A webview will be created in a -split editor (if not already), and the HTML preview will be displayed there. The -``Show Preview'' command is also available in command palette, and has a default -@code{Ctrl+K V} key binding (on GNU/Linux). +split editor (if not already), and the HTML preview will be displayed there. +The ``Show Preview'' command is also available in command palette, and has a +default @code{Ctrl+K V} key binding (on GNU/Linux). The HTML used for preview is generated by @code{makeinfo --html --nosplit}, and Texinfo source is read from disk, instead of taken from a @@ -402,11 +405,12 @@ means that the preview is being updated. You can use a custom CSS to make the HTML preview look prettier. To configure this, edit the configuration option @code{texinfo.preview.customCSS}. The CSS -file can either be an online or a local (starting with @code{file://}) resource. +file can either be an online or a local (starting with @code{file://}) +resource. -A good example is @url{https://www.gnu.org/software/gnulib/manual.css}, which is -popular among manuals of GNU projects. (Note: May require some tinkering when -used with darker editor themes) +A good example is @url{https://www.gnu.org/software/gnulib/manual.css}, which +is popular among manuals of GNU projects. (Note: May require some tinkering +when used with darker editor themes) @node Goto Node diff --git a/package.json b/package.json index 5f5a1d8..e5642ef 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "max-len": [ "warn", { - "code": 120 + "code": 79 } ], "@typescript-eslint/explicit-module-boundary-types": "off", diff --git a/src/context_mapping.ts b/src/context_mapping.ts index e7bf7fc..368708c 100644 --- a/src/context_mapping.ts +++ b/src/context_mapping.ts @@ -25,7 +25,8 @@ import GlobalContext from './global_context'; import { prompt } from './utils/misc'; /** - * Manage mappings between Texinfo documents and corresponding document-specific contexts. + * Manage mappings between Texinfo documents and corresponding + * document-specific contexts. */ export default class ContextMapping implements vscode.Disposable { @@ -38,30 +39,45 @@ export default class ContextMapping implements vscode.Disposable { getDocumentContext(document: vscode.TextDocument) { let documentContext = this._map.get(document); if (documentContext === undefined) { - documentContext = new DocumentContext(this._globalContext, document); + documentContext + = new DocumentContext(this._globalContext, document); this._map.set(document, documentContext); } return documentContext; } dispose() { - this._map.forEach(documentContext => documentContext.getPreview()?.close()); + this._map + .forEach(documentContext => documentContext.getPreview()?.close()); } constructor(private readonly _globalContext: GlobalContext) { _globalContext.subscribe( - vscode.commands.registerTextEditorCommand('texinfo.preview.show', this._showPreview.bind(this)), - vscode.commands.registerCommand('texinfo.preview.goto', this._gotoPreview.bind(this)), - vscode.workspace.onDidChangeTextDocument(this._onDocumentUpdate.bind(this)), - vscode.workspace.onDidCloseTextDocument(this._onDocumentClose.bind(this)), - vscode.workspace.onDidSaveTextDocument(this._onDocumentSave.bind(this)), + vscode.commands.registerTextEditorCommand( + 'texinfo.preview.show', + this._showPreview.bind(this), + ), + vscode.commands.registerCommand( + 'texinfo.preview.goto', + this._gotoPreview.bind(this), + ), + vscode.workspace.onDidChangeTextDocument( + this._onDocumentUpdate.bind(this), + ), + vscode.workspace.onDidCloseTextDocument( + this._onDocumentClose.bind(this), + ), + vscode.workspace.onDidSaveTextDocument( + this._onDocumentSave.bind(this), + ), ); } private readonly _map = new Map(); private _tryGetDocumentContext(document: vscode.TextDocument) { - return document.languageId === 'texinfo' ? this.getDocumentContext(document) : undefined; + return document.languageId === 'texinfo' + ? this.getDocumentContext(document) : undefined; } /** @@ -100,9 +116,12 @@ export default class ContextMapping implements vscode.Disposable { */ private async _showPreview(editor: vscode.TextEditor) { const document = editor.document; - // Only show preview for saved files, as we're not gonna send document content to `makeinfo` via STDIN. + // Only show preview for saved files, as we're not gonna send + // document content to `makeinfo` via STDIN. // Instead, the file will be loaded from disk. - if (document.isUntitled && !await prompt('Save this document to display preview.', 'Save')) { + if (document.isUntitled && + !await prompt('Save this document to display preview.', 'Save') + ) { return; } if (document.isDirty && !await document.save()) { diff --git a/src/contexts/document.ts b/src/contexts/document.ts index c372820..8a6b91a 100644 --- a/src/contexts/document.ts +++ b/src/contexts/document.ts @@ -46,7 +46,10 @@ export default class DocumentContext { this._preview = undefined; } - constructor(readonly globalContext: GlobalContext, readonly document: vscode.TextDocument) {} + constructor( + readonly globalContext: GlobalContext, + readonly document: vscode.TextDocument, + ) {} private _preview?: PreviewContext; } diff --git a/src/contexts/document_symbol.ts b/src/contexts/document_symbol.ts index e04e18f..bd730e2 100644 --- a/src/contexts/document_symbol.ts +++ b/src/contexts/document_symbol.ts @@ -55,15 +55,19 @@ export default class DocumentSymbolContext { } } -function foldingRangeToSymbols(ranges: readonly Optional[], start: number, end: number) { +function foldingRangeToSymbols( + ranges: readonly Optional[], + start: number, + end: number, +) { const symbols = []; for (let idx = start; idx < end; ++idx) { const node = ranges[idx]; if (node === undefined) continue; const range = lineNumToRange(idx, node.end); const selectionRange = lineNumToRange(idx); - const symbol = new vscode.DocumentSymbol('@' + node.name, node.detail, vscode.SymbolKind.String, - range, selectionRange); + const symbol = new vscode.DocumentSymbol('@' + node.name, node.detail, + vscode.SymbolKind.String, range, selectionRange); symbol.children = foldingRangeToSymbols(ranges, idx + 1, node.end); symbols.push(symbol); idx = node.end; diff --git a/src/contexts/folding_range.ts b/src/contexts/folding_range.ts index a8042a3..7da9710 100644 --- a/src/contexts/folding_range.ts +++ b/src/contexts/folding_range.ts @@ -27,8 +27,8 @@ import DocumentContext from './document'; /** * Stores information about folding ranges for a document. * - * Actually, more than folding ranges (e.g. code lens) is handled within this context, so I believe - * we should use another name... + * Actually, more than folding ranges (e.g. code lens) is handled within + * this context, so perhaps we should use another name... */ export default class FoldingRangeContext { @@ -58,7 +58,9 @@ export default class FoldingRangeContext { const eol = this._document.eol === vscode.EndOfLine.LF ? '\n' : '\r\n'; for (const event of events) { // Clear cached folding range when line count changes. - if (event.text.split(eol).length !== 1 || event.range.start.line !== event.range.end.line) { + if (event.text.split(eol).length !== 1 || + event.range.start.line !== event.range.end.line + ) { this._foldingRanges = undefined; this._nodes = []; return true; @@ -80,8 +82,10 @@ export default class FoldingRangeContext { /** * Regex for matching subsection/section/chapter (-like) commands. */ - private static readonly _nodeFormat = RegExp('^@(?:(node)|(subsection|unnumberedsubsec|appendixsubsec|subheading)' + - '|(section|unnumberedsec|appendixsec|heading)|(chapter|unnumbered|appendix|majorheading|chapheading)) (.*)$'); + private static readonly _nodeFormat = RegExp('^@(?:(node)|' + + '(subsection|unnumberedsubsec|appendixsubsec|subheading)|' + + '(section|unnumberedsec|appendixsec|heading)|' + + '(chapter|unnumbered|appendix|majorheading|chapheading)) (.*)$'); private _foldingRanges?: FoldingRange[]; @@ -100,8 +104,14 @@ export default class FoldingRangeContext { detail?: string, kind?: vscode.FoldingRangeKind }) { - (this._foldingRanges ??= []) - .push({ name: extraArgs.name ?? '', detail: extraArgs.detail ?? '', start, end, kind: extraArgs.kind }); + const items = { + name: extraArgs.name ?? '', + detail: extraArgs.detail ?? '', + start, + end, + kind: extraArgs.kind, + }; + (this._foldingRanges ??= []).push(items); } /** @@ -144,16 +154,19 @@ export default class FoldingRangeContext { if (!verbatim && this._processNode(line, idx, lastLine)) continue; const closingBlock = closingBlocks.pop(); if (closingBlock === undefined) continue; - if (line.substring(1, closingBlock.name.length + 2).trim() === closingBlock.name) { - this._addRange(idx, closingBlock.line, { name: closingBlock.name }); - // If `verbatim == true` goes here, this line must be the `@verbatim` line. + const name = closingBlock.name; + if (line.substring(1, name.length + 2).trim() === name) { + this._addRange(idx, closingBlock.line, { name: name }); + // If `verbatim == true` goes here, + // this line must be the `@verbatim` line. verbatim = false; } else { closingBlocks.push(closingBlock); } } if (this._commentRange !== undefined) { - this._addRange(this._commentRange.start, this._commentRange.end, { kind: vscode.FoldingRangeKind.Comment }); + this._addRange(this._commentRange.start, this._commentRange.end, + { kind: vscode.FoldingRangeKind.Comment }); } return this._foldingRanges; } @@ -162,7 +175,8 @@ export default class FoldingRangeContext { this._commentRange = undefined; this._headerStart = undefined; this._nodes = []; - this._closingSubsection = this._closingSection = this._closingChapter = undefined; + this._closingSubsection = this._closingSection = this._closingChapter + = undefined; } private _getLastTextLine(lineNum: number, limit = 3) { @@ -176,7 +190,7 @@ export default class FoldingRangeContext { private _processComment(lineText: string, lineNum: number) { if (!lineText.startsWith('@c')) return false; - if (!lineText.startsWith(' ', 2) && !lineText.startsWith('omment ', 2)) { + if (lineText.charAt(2) != ' ' && !lineText.startsWith('omment ', 2)) { return false; } // Check for opening/closing header. @@ -184,7 +198,8 @@ export default class FoldingRangeContext { if (this._headerStart === undefined) { this._headerStart = lineNum; } else { - this._addRange(lineNum, this._headerStart, { kind: vscode.FoldingRangeKind.Region }); + this._addRange(lineNum, this._headerStart, + { kind: vscode.FoldingRangeKind.Region }); this._headerStart = undefined; } return true; @@ -194,13 +209,18 @@ export default class FoldingRangeContext { } else if (this._commentRange.start - 1 === lineNum) { this._commentRange.start = lineNum; } else { - this._addRange(this._commentRange.start, this._commentRange.end, { kind: vscode.FoldingRangeKind.Comment }); + this._addRange(this._commentRange.start, this._commentRange.end, + { kind: vscode.FoldingRangeKind.Comment }); this._commentRange = undefined; } return true; } - private _processNode(lineText: string, lineNum: number, lastLineNum: number) { + private _processNode( + lineText: string, + lineNum: number, + lastLineNum: number, + ) { const result = lineText.match(FoldingRangeContext._nodeFormat); if (result === null) return false; // Node identifier. @@ -214,20 +234,25 @@ export default class FoldingRangeContext { } // Subsection level node. if (result[2] !== undefined) { - this._addRange(lineNum, this._closingSubsection ?? lastLineNum, { name: result[2], detail: result[5] }); + this._addRange(lineNum, this._closingSubsection ?? lastLineNum, + { name: result[2], detail: result[5] }); this._closingSubsection = this._getLastTextLine(lineNum - 1); return true; } // Section level node. if (result[3] !== undefined) { - this._addRange(lineNum, this._closingSection ?? lastLineNum, { name: result[3], detail: result[5] }); - this._closingSubsection = this._closingSection = this._getLastTextLine(lineNum - 1); + this._addRange(lineNum, this._closingSection ?? lastLineNum, + { name: result[3], detail: result[5] }); + this._closingSubsection = this._closingSection + = this._getLastTextLine(lineNum - 1); return true; } // Chapter level node. if (result[4] !== undefined) { - this._addRange(lineNum, this._closingChapter ?? lastLineNum, { name: result[4], detail: result[5] }); - this._closingSubsection = this._closingSection = this._closingChapter = this._getLastTextLine(lineNum - 1); + this._addRange(lineNum, this._closingChapter ?? lastLineNum, + { name: result[4], detail: result[5] }); + this._closingSubsection = this._closingSection + = this._closingChapter = this._getLastTextLine(lineNum - 1); return true; } return false; diff --git a/src/contexts/preview.ts b/src/contexts/preview.ts index 697c380..4bd2dbb 100644 --- a/src/contexts/preview.ts +++ b/src/contexts/preview.ts @@ -39,7 +39,8 @@ export default class PreviewContext { } goto(nodeName: string) { - this._panel.webview.postMessage({ command: 'goto', value: getNodeHtmlRef(nodeName) }); + const message = { command: 'goto', value: getNodeHtmlRef(nodeName) }; + this._webview.postMessage(message); } show() { @@ -53,11 +54,14 @@ export default class PreviewContext { } this._updating = true; this._pendingUpdate = false; - // Inform the user that the preview is updating if `makeinfo` takes too long. + // Inform the user that the preview is updating, when `makeinfo` + // takes too long. setTimeout(() => this._updating && this._updateTitle(), 500); - const initFile = this._globalContext.extensionPath + '/ext/html-preview.pm'; - const converter = new Converter(this._document.fileName, initFile, this._globalContext.options, this._logger); - const { data, error } = await converter.toHTML(path => this._panel.webview.asWebviewUri(path), this._script); + const initFile = this._globalContext.path + '/ext/html-preview.pm'; + const converter = new Converter(this._document.fileName, initFile, + this._globalContext.options, this._logger); + const { data, error } = await converter + .toHTML(path => this._webview.asWebviewUri(path), this._script); if (error) { this._logger.log(error); this._diagnosis.update(this._document, error); @@ -65,10 +69,11 @@ export default class PreviewContext { this._diagnosis.delete(this._document); } if (data === undefined) { - prompt(`Failed to show preview for ${this._document.fileName}.`, 'Show log', true) + prompt(`Failed to show preview for ${this._document.fileName}.`, + 'Show log', true) .then(result => result && this._logger.show()); } else { - this._panel.webview.html = data; + this._webview.html = data; } this._updating = false; this._updateTitle(); @@ -76,8 +81,14 @@ export default class PreviewContext { } constructor(private readonly _documentContext: DocumentContext) { - this._panel = vscode.window.createWebviewPanel('texinfo.preview', '', vscode.ViewColumn.Beside, - { enableFindWidget: true, retainContextWhenHidden: true, enableScripts: true }); + const options = { + enableFindWidget: true, + retainContextWhenHidden: true, + enableScripts: true, + }; + this._panel = vscode.window.createWebviewPanel('texinfo.preview', '', + vscode.ViewColumn.Beside, options); + this._webview = this._panel.webview; this._disposables.push(this._panel.onDidDispose(() => this.close())); this._updateTitle(); this.updateWebview(); @@ -91,6 +102,7 @@ export default class PreviewContext { private readonly _disposables = []; private readonly _panel: vscode.WebviewPanel; + private readonly _webview: vscode.Webview; /** * Whether a preview update request is pending. @@ -103,7 +115,8 @@ export default class PreviewContext { private _updating = false; /** - * Generate script used for jumping to the corresponding location of preview with code lens. + * Generate script used for jumping to the corresponding location of + * preview with code lens. */ private get _script() { if (!this._globalContext.options.enableCodeLens) return undefined; diff --git a/src/diagnosis.ts b/src/diagnosis.ts index caacead..80b5698 100644 --- a/src/diagnosis.ts +++ b/src/diagnosis.ts @@ -47,7 +47,7 @@ export default class Diagnosis implements vscode.Disposable { const fileName = document.uri.path; const diagnostics = logText.split('\n') .filter(line => line.startsWith(fileName)) - .map(line => logLineToDiagnostic(line.substring(fileName.length + 1))) + .map(line => logToDiagnostic(line.substring(fileName.length + 1))) .filter(isDefined); this._diagnostics.set(document.uri, diagnostics); } @@ -56,7 +56,8 @@ export default class Diagnosis implements vscode.Disposable { this._diagnostics.dispose(); } - private readonly _diagnostics = vscode.languages.createDiagnosticCollection('texinfo'); + private readonly _diagnostics + = vscode.languages.createDiagnosticCollection('texinfo'); } /** @@ -65,11 +66,12 @@ export default class Diagnosis implements vscode.Disposable { * @param lineText * @returns */ -function logLineToDiagnostic(lineText: string) { +function logToDiagnostic(lineText: string) { const lineNum = parseInt(lineText) - 1; // Ignore error that does not correspond a line in document. if (isNaN(lineNum)) return undefined; const message = lineText.substring(lineNum.toString().length + 2); - const severity = message.startsWith('warning:') ? vscode.DiagnosticSeverity.Warning : undefined; + const severity = message.startsWith('warning:') + ? vscode.DiagnosticSeverity.Warning : undefined; return new vscode.Diagnostic(lineNumToRange(lineNum), message, severity); } diff --git a/src/global_context.ts b/src/global_context.ts index 0f03d5f..1228627 100644 --- a/src/global_context.ts +++ b/src/global_context.ts @@ -40,10 +40,12 @@ export default class GlobalContext { readonly indicator = new Indicator(this); readonly logger = new Logger; - readonly extensionPath = this.context.extensionPath; + readonly path = this.context.extensionPath; /** - * Note: `Options`' no singleton. Do not wire directly, always use `globalContext.options` instead. + * Note: `Options`' no singleton. + * + * Do not wire directly, always use `globalContext.options` instead. */ get options() { return this._options ??= new Options; @@ -54,12 +56,18 @@ export default class GlobalContext { } constructor(private readonly context: vscode.ExtensionContext) { - this.subscribe(this.contextMapping, this.diagnosis, this.indicator, this.logger, - vscode.languages.registerCodeLensProvider('texinfo', new CodeLensProvider(this)), - vscode.languages.registerCompletionItemProvider('texinfo', new CompletionItemProvider(this), '@'), - vscode.languages.registerDocumentSymbolProvider('texinfo', new DocumentSymbolProvider(this)), - vscode.languages.registerFoldingRangeProvider('texinfo', new FoldingRangeProvider(this)), - vscode.workspace.onDidChangeConfiguration(() => this._options = undefined), + this.subscribe( + this.contextMapping, this.diagnosis, this.indicator, this.logger, + vscode.languages.registerCodeLensProvider('texinfo', + new CodeLensProvider(this)), + vscode.languages.registerCompletionItemProvider('texinfo', + new CompletionItemProvider(this), '@'), + vscode.languages.registerDocumentSymbolProvider('texinfo', + new DocumentSymbolProvider(this)), + vscode.languages.registerFoldingRangeProvider('texinfo', + new FoldingRangeProvider(this)), + vscode.workspace.onDidChangeConfiguration( + () => this._options = undefined), ); } diff --git a/src/indicator.ts b/src/indicator.ts index 5818d66..ed8ee39 100644 --- a/src/indicator.ts +++ b/src/indicator.ts @@ -38,15 +38,19 @@ export default class Indicator implements vscode.Disposable { constructor(private readonly globalContext: GlobalContext) { globalContext.subscribe( - vscode.commands.registerCommand('texinfo.indicator.click', this._click.bind(this)), - vscode.window.onDidChangeActiveTextEditor(this._refresh.bind(this)), + vscode.commands.registerCommand('texinfo.indicator.click', + this._click.bind(this)), + vscode.window.onDidChangeActiveTextEditor( + this._refresh.bind(this)), ); - this._updateStatus().then(() => this._refresh(vscode.window.activeTextEditor)); + this._updateStatus() + .then(() => this._refresh(vscode.window.activeTextEditor)); } private _canDisplayPreview = false; - private readonly _statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); + private readonly _statusBarItem = vscode.window.createStatusBarItem( + vscode.StatusBarAlignment.Right, 100); /** * Calls when the status bar item is clicked. @@ -70,18 +74,21 @@ export default class Indicator implements vscode.Disposable { } /** - * Update the installation status of GNU Texinfo, by checking `makeinfo --version`. + * Update the installation status of GNU Texinfo, + * by checking `makeinfo --version`. */ private async _updateStatus() { const options = this.globalContext.options; - const output = await exec(options.makeinfo, ['--version'], options.maxSize); + const output = await exec(options.makeinfo, ['--version'], + options.maxSize); const result = output.data?.match(/\(GNU texinfo\) (.*)\n/); let tooltip = '', icon: string, version = ''; if (result && result[1]) { version = result[1]; if (!isNaN(+version) && +version < 6.7) { icon = '$(warning)'; - tooltip = `GNU Texinfo (${options.makeinfo}) is outdated (${version} < 6.7).`; + tooltip = `GNU Texinfo (${options.makeinfo}) ` + + `is outdated (${version} < 6.7).`; } else { // Unrecognizable version. Assume it is okay. icon = '$(check)'; @@ -89,7 +96,8 @@ export default class Indicator implements vscode.Disposable { this._canDisplayPreview = true; } else { icon = '$(close)'; - tooltip = `GNU Texinfo (${options.makeinfo}) is not correctly installed or configured.`; + tooltip = `GNU Texinfo (${options.makeinfo}) ` + + `is not correctly installed or configured.`; this._canDisplayPreview = false; } this._statusBarItem.command = 'texinfo.indicator.click'; diff --git a/src/logger.ts b/src/logger.ts index 7312519..6c43abe 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -27,7 +27,8 @@ import * as vscode from 'vscode'; export default class Logger implements vscode.Disposable { log(message: string) { - const dateTime = new Date().toLocaleString(undefined, { hour12: false }); + const dateTime = new Date() + .toLocaleString(undefined, { hour12: false }); this._outputChannel.appendLine(`[ ${dateTime} ]\n${message}`); } @@ -39,5 +40,6 @@ export default class Logger implements vscode.Disposable { this._outputChannel.dispose(); } - private readonly _outputChannel = vscode.window.createOutputChannel('Texinfo'); + private readonly _outputChannel + = vscode.window.createOutputChannel('Texinfo'); } diff --git a/src/options.ts b/src/options.ts index 9b56a5f..cb181cc 100644 --- a/src/options.ts +++ b/src/options.ts @@ -80,7 +80,8 @@ export default class Options { return this._getArray('preview.variables'); } - private readonly _configuration = vscode.workspace.getConfiguration('texinfo'); + private readonly _configuration + = vscode.workspace.getConfiguration('texinfo'); private _getArray(section: string): readonly string[] { return this._configuration.get(section, []); diff --git a/src/providers/code_lens.ts b/src/providers/code_lens.ts index f25f7c8..bf39c52 100644 --- a/src/providers/code_lens.ts +++ b/src/providers/code_lens.ts @@ -30,7 +30,8 @@ export default class CodeLensProvider implements vscode.CodeLensProvider { provideCodeLenses(document: vscode.TextDocument) { if (!this._globalContext.options.enableCodeLens) return undefined; if (!this._globalContext.indicator.canDisplayPreview) return undefined; - return this._globalContext.contextMapping.getDocumentContext(document).foldingRange.nodeValues; + return this._globalContext.contextMapping.getDocumentContext(document) + .foldingRange.nodeValues; } constructor(private readonly _globalContext: GlobalContext) {} diff --git a/src/providers/completion_item.ts b/src/providers/completion_item.ts index 6fd704c..a4390b7 100644 --- a/src/providers/completion_item.ts +++ b/src/providers/completion_item.ts @@ -26,346 +26,1116 @@ import { CompletionItem } from '../utils/types'; /** * Provide code completion info for Texinfo documents. */ -export default class CompletionItemProvider implements vscode.CompletionItemProvider { - +export default class CompletionItemProvider + implements vscode.CompletionItemProvider +{ /** * Full list of completion items. * - * Note: Descriptions of completion items for @-commands are excerpted from the - * {@link https://www.gnu.org/software/texinfo/manual/texinfo GNU Texinfo manual}, + * Note: Descriptions of completion items for @-commands are excerpted from + * the GNU Texinfo manual + * ({@link https://www.gnu.org/software/texinfo/manual/texinfo }), * which is licensed under the GNU Free Documentation License, version 1.3. * - * According to GFDL, this usage is considered "aggregation with independent work", - * which means that GFDL applies to lines 46-365 of this file, while the remainder - * is under GPL like other source code files of the project. + * According to GFDL, this usage is considered "aggregation with + * independent work", which means that GFDL applies to lines 48-367 of this + * file, while the remainder is under GPL like other source code files of + * the project. */ private _getCompletionItems() { const enableSnippets = this._oldOptions.enableSnippets; const hideSnippetCommands = this._oldOptions.hideSnippetCommands; return this._completionItems ??= [ - command('ampchar', 'Insert an ampersand, "&"', { hasEmptyBrace: true }), - command('atchar', 'Insert an at sign, "@"', { hasEmptyBrace: true }), - command('backslashchar', 'Insert a blackslash, "\\"', { hasEmptyBrace: true }), - command('lbracechar', 'Insert a left brace, "{"', { hasEmptyBrace: true }), - command('rbracechar', 'Insert a right brace, "}"', { hasEmptyBrace: true }), - ...braceCommand('abbr', 'Indicate a general abbreviation', 1, 'abbreviation', 'meaning'), - ...braceCommand('acronym', 'Indicate an acronym in all capital letters', 1, 'acronym', 'meaning'), - snippet('alias', 'alias', 'Defines a new command to be just like an existing one', 0, - '@alias new=existing', 'alias ${1:new}=${2:existing}'), - command('alias', 'Defines a new command to be just like an existing one', { snippet: true }), - ...lineCommandEnum('allowcodebreaks', 'Control breaking at "-" and "_" in TeX', 'true', 'false'), - ...braceCommand('anchor', 'Define current location for use as a cross-reference target', 1, 'name'), - ...lineCommand('appendix', 'Begin an appendix', 'title'), - ...lineCommand('appendixsec', 'Begin an appendix section within an appendix', 'title'), - ...lineCommand('appendixsection', 'Begin an appendix section within an appendix', 'title'), - ...lineCommand('appendixsubsec', 'Begin an appendix subsection', 'title'), - ...lineCommand('appendixsubsubsec', 'Begin an appendix subsubsection', 'title'), - command('arrow', 'Generate a right arrow glyph, "→"', { hasEmptyBrace: true }), - command('asis', 'Print the table’s first column without highlighting'), - ...lineCommand('author', 'Set the names of the author(s)', 'author-name'), - ...braceCommand('b', 'Set text in a bold font', 1, 'text'), - ...blockCommand('copying', 'Declare copying permissions'), - command('bullet', 'Generate a large round dot, "•"', { hasEmptyBrace: true }), - command('bye', 'Stop formatting'), - ...lineCommand('c', 'Begin a line comment', 'comment'), - snippet('header', 'c', 'Declare header block', 2, '@c %**start of header\n\n@c %**end of header', - 'c %**${1:start of header}\n$3\n@c %**${2:end of header}'), - ...braceCommand('caption', 'Define the full caption for a @float', 1, 'definition'), - ...blockCommand('cartouche', 'Highlight by drawing a box with rounded corners around it'), - ...lineCommand('center', 'Center the line of text following the command', 'text-line'), - ...lineCommand('centerchap', 'Like @chapter, but centers the chapter title', 'text-line'), - ...lineCommand('chapheading', 'Print an unnumbered chapter-like heading', 'title'), - ...lineCommand('chapter', 'Begin a numbered chapter', 'title'), - ...lineCommand('cindex', 'Add entry to the index of concepts', 'entry'), - ...braceCommand('cite', 'Highlight the name of a reference', 1, 'reference'), - ...lineCommand('clear', 'Unset flag', 'flag'), - command('click', 'Represent a single "click" in a GUI', { hasEmptyBrace: true }), - ...braceCommand('clicksequence', 'Represent a sequence of clicks in a GUI', 1, 'actions'), - ...lineCommand('clickstyle', 'Execute command on each @click', '@command'), - ...braceCommand('code', 'Indicate text which is a piece of code', 1, 'sample-code'), - ...lineCommandEnum('codequotebacktick', 'Control output of "`" in code examples', 'on', 'off'), - ...lineCommandEnum('codequoteundirected', 'Control output of "\'" in code examples', 'on', 'off'), - command('comma', 'Insert a comma character, ","', { hasEmptyBrace: true }), - ...braceCommand('command', 'Indicate a command name', 1, 'command-name'), - ...lineCommand('comment', 'Begin a line comment', 'comment'), - command('contents', "Print a complete table of contents."), - ...blockCommand('copying', 'Specify copyright holders and copying conditions'), - command('copyright', 'The copyright symbol, "©"', { hasEmptyBrace: true }), - ...lineCommand('defcodeindex', 'Define a new index, print entries in an @code font', 'index-name'), - ...lineCommandX('defcv', 'Format a description for a variable associated with a class', - 'category', 'class', 'name'), - ...lineCommandX('deffn', 'Format a description for a function', 'category', 'name', 'arguments'), - ...lineCommand('defindex', 'Define a new index, print entries in a roman font', 'index-name'), - ...lineCommand('definfoenclose', 'Create a new command for Info that marks text by enclosing it in ' + - 'strings that precede and follow the text.', 'newcmd', 'before', 'after'), - ...lineCommandX('defivar', 'Format a description for an instance variable in object-oriented programming', - 'class', 'instance-variable-name'), - ...lineCommandX('defmac', 'Format a description for a macro', 'macroname', 'arguments'), - ...lineCommandX('defmethod', 'Format a description for a method in object-oriented programming', - 'class', 'method-name', 'arguments'), - ...lineCommandX('defop', 'Format a description for an operation in object-oriented programming', - 'category', 'class', 'name', 'arguments'), - ...lineCommandX('defopt', 'Format a description for a user option', 'option-name'), - ...lineCommandX('defspec', 'Format a description for a special form', 'special-form-name', 'arguments'), - ...lineCommandX('deftp', 'Format a description for a data type', 'category', 'name-of-type', 'attributes'), - ...lineCommandX('deftypecv', 'Format a description for a typed class variable in ' + - 'object-oriented programming', 'category', 'class', 'data-type', 'name'), - ...lineCommandX('deftypefn', 'Format a description for a function or similar entity that may ' + - 'take arguments and that is typed', 'category', 'data-type', 'name', 'arguments'), - ...lineCommandEnum('deftypefnnewline', 'Specifies whether return types for @deftypefn and similar ' + - 'are printed on lines by themselves', 'on', 'off'), - ...lineCommandX('deftypefun', 'Format a description for a function in a typed language', - 'data-type', 'function-name', 'arguments'), - ...lineCommandX('deftypeivar', 'Format a description for a typed instance variable in ' + - 'object-oriented programming', 'class', 'data-type', 'variable-name'), - ...lineCommandX('deftypemethod', 'Format a description for a typed method in object-oriented programming', - 'class', 'data-type', 'method-name', 'arguments'), - ...lineCommandX('deftypeop', 'Format a description for a typed operation in object-oriented programming', - 'category', 'class', 'data-type', 'name', 'arguments'), - ...lineCommandX('deftypevar', 'Format a description for a variable in a typed language', - 'data-type', 'variable-name'), - ...lineCommandX('deftypevr', 'Format a description for something like a variable in a typed language', - 'category', 'data-type', 'name'), - ...lineCommandX('defun', 'Format a description for a function', 'function-name', 'arguments'), - ...lineCommandX('defvar', 'Format a description for a variable', 'variable-name'), - ...lineCommandX('defvr', 'Format a description for any kind of variable', 'category', 'name'), - ...blockCommand('detailmenu', 'Mark the (optional) detailed node listing in a master menu'), - ...braceCommand('dfn', 'Indicate the introductory or defining use of a term', 1, 'term'), - ...lineCommand('dircategory', "Specify a part of the Info directory menu where this file's entry should go", - 'dirpart'), - ...blockCommand('direntry', 'Begin the Info directory menu entry for this file'), - ...blockCommand('display', 'Begin a kind of example'), - ...braceCommand('dmn', 'Format a unit of measure, as in 12pt', 1, 'dimension'), - ...blockCommand('docbook', 'Enter Docbook completely'), - ...blockCommand('documentdescription', 'Set the document description text, included in the HTML output'), - ...lineCommand('documentencoding', 'Declare the input encoding', 'enc'), - ...lineCommand('documentlanguage', 'Declares the current document locale', 'll_CC'), - ...braceCommand('dotaccent', 'Generate a dot accent over the character', 1, 'c'), - command('dots', 'Generate an ellipsis, "…"', { hasEmptyBrace: true }), - ...braceCommand('email', 'Indicate an electronic mail address', 1, 'address', 'displayed-text'), - ...braceCommand('emph', 'Emphasize text', 1, 'text'), - ...lineCommand('end', 'Ends a block command environment', 'environment'), - command('enddots', 'Generate an end-of-sentence ellipsis, "..."', { hasEmptyBrace: true }), - ...blockCommand('enumerate', 'Begin a numbered list, using @item for each entry'), - ...braceCommand('env', 'Indicate an environment variable name', 1, 'environment-variable'), - command('equiv', 'Insert a glyph indicating exact equivalence, "≡"', { hasEmptyBrace: true }), - command('error', 'Indicate that the following text is an error message, "error→"', - { hasEmptyBrace: true }), - ...braceCommand('errormsg', 'Report message as an error to standard error, and exit unsuccessfully', - 1, 'msg'), - command('euro', 'Generate the Euro currency sign, "€"', { hasEmptyBrace: true }), - ...headingFootingCommand('evenfooting', 'Generate page footers that are the same for even-numbered pages'), - ...headingFootingCommand('evenheading', 'Generate page headers that are the same for even-numbered pages'), - ...headingFootingCommand('everyfooting', 'Generate page footers that are the same for every pages'), - ...headingFootingCommand('everyheading', 'Generate page headers that are the same for every pages'), - ...blockCommand('example', 'Indicate an example'), - ...lineCommand('exampleindent', 'Indent example-like environments by number of spaces', 'indent'), - ...lineCommand('exdent', 'Remove any indentation a line might have', 'line-of-text'), - command('expansion', 'Indicate the result of a macro expansion with a glyph, "→"', - { hasEmptyBrace: true }), - ...braceCommand('file', 'Highlight the name of a file', 1, 'filename'), - command('finalout', 'Prevent TeX from printing large black warning rectangles beside over-wide lines'), - ...lineCommand('findex', 'Add entry to the index of functions', 'entry'), - ...lineCommandEnum('firstparagraphindent', 'Control indentation of the first paragraph after ' + - 'section headers', 'none', 'insert'), - ...blockCommand('float', 'Environment to define floating material'), - ...blockCommand('flushleft', 'Left justify every line while leaving the right end ragged'), - ...blockCommand('flushright', 'Right justify every line while leaving the left end ragged'), - ...lineCommandEnum('fonttextsize', 'Change the size of the main body font in the TeX output', '10', '11'), - ...braceCommand('footnote', 'Enter a footnote', 1, 'footnote-text'), - ...lineCommandEnum('footnotestyle', "Specify an Info file's footnote style", 'end', 'separate'), - ...blockCommand('format', 'Begin a kind of example, but do not indent'), - ...lineCommandEnum('frenchspacing', 'Control spacing after punctuation', 'on', 'off'), - ...blockCommand('ftable', 'Begin a two-column table, using @item for each entry', 'formatting-command'), - command('geq', 'Generate a greater-than-or-equal sign, "≥"', { hasEmptyBrace: true }), - ...blockCommand('group', 'Disallow page breaks within following text'), - command('hashchar', 'Insert a hash character, "#"', { hasEmptyBrace: true }), - ...lineCommand('heading', 'Print an unnumbered section-like heading', 'title'), - ...lineCommandEnum('headings', 'Turn page headings on or off, and/or specify single or double-sided ' + - 'page headings for printing', 'on', 'single', 'double', 'singleafter', 'doubleafter', 'off'), - command('headitem', 'Begin a heading row in a multitable'), - ...braceCommand('headitemfont', 'Set text in the font used for multitable heading rows', 1, 'text'), - ...blockCommand('html', 'Enter HTML completely'), - ...braceCommand('hyphenation', 'Tell TeX how to hyphenate words', 1, 'hy-phen-a-ted words'), - ...braceCommand('i', 'Set text in an italic font', 1, 'text'), - ...blockCommand('ifclear', 'If the Texinfo variable is not set, format the following text', 'txivar'), - ...blockCommand('ifcommanddefined', 'If the Texinfo code is defined, format the follow text', 'txicmd'), - ...blockCommand('ifcommandnotdefined', 'If the Texinfo code is not defined, format the follow text', - 'txicmd'), - ...blockCommand('ifdocbook', 'Begin text that will appear only in DocBook format'), - ...blockCommand('ifhtml', 'Begin text that will appear only in HTML format'), - ...blockCommand('ifinfo', 'Begin text that will appear only in Info format'), - ...blockCommand('ifplaintext', 'Begin text that will appear only in plain text format'), - ...blockCommand('ifset', 'If the Texinfo variable is set, format the following text', 'txivar'), - ...blockCommand('iftex', 'Begin text that will appear only in TeX format'), - ...blockCommand('ifxml', 'Begin text that will appear only in XML format'), - ...blockCommand('ifnotdocbook', 'Begin text to be ignored in DocBook format'), - ...blockCommand('ifnothtml', 'Begin text to be ignored in HTML format'), - ...blockCommand('ifnotinfo', 'Begin text to be ignored in Info format'), - ...blockCommand('ifnotplaintext', 'Begin text to be ignored in plain text format'), - ...blockCommand('ifnottex', 'Begin text to be ignored in TeX format'), - ...blockCommand('ifnotxml', 'Begin text to be ignored in XML format'), - ...blockCommand('ignore', 'Begin text that will not appear in any output'), - ...braceCommand('image', 'Insert an image', 1, 'filename', 'width', 'height', 'alt', 'ext'), - ...lineCommand('include', 'Read the contents of Texinfo source file', 'filname'), - command('indent', 'Insert paragraph indentation'), - ...blockCommand('indentedblock', 'Indent a block of arbitary text on the left'), - ...braceCommand('indicateurl', 'Indicate text that is a URL', 1, 'URL'), - ...braceCommand('inforef', 'Make a cross-reference to an Info file', 3, 'node-name', - 'entry-name', 'info-file-name'), - ...braceCommand('inlinefmt', 'Insert text only if the output format is fmt', 2, 'fmt', 'text'), - ...braceCommand('inlinefmtifelse', 'Insert text if the output format is fmt, else else-text', 3, - 'fmt', 'text', 'else-text'), - ...braceCommand('inlineifclear', 'Insert text only if variable var is not set', 2, 'var', 'text'), - ...braceCommand('inlineifset', 'Insert text only if variable var is set', 2, 'var', 'text'), - ...braceCommand('inlineraw', 'Insert text as in a raw conditional, only if the output format is fmt', 2, - 'fmt', 'raw-text'), - command('insertcopying', 'Insert previously defined @copying text'), - command('item', 'Indicate the beginning of a marked paragraph, or the beginning of the text of a ' + - 'first column entry for a table'), - ...blockCommand('itemize', 'Begin an unordered list', 'mark-generating-character-or-command'), - command('itemx', 'Like @item but do not generate extra vertical space above the item text'), - ...braceCommand('kbd', 'Indicate characters of input to be typed by users', 1, 'keyboard-characters'), - ...lineCommandEnum('kbdinputstyle', 'Specify when @kbd should use a font distinct from @code', - 'code', 'distinct', 'example'), - ...braceCommand('key', 'Indicate the name of a key on a keyboard', 1, 'key-name'), - ...lineCommand('kindex', 'Add entry to the index of keys', 'entry'), - command('LaTeX', 'Generate the LaTeX logo', { hasEmptyBrace: true }), - command('leq', 'Generate a less-than-or-equal sign, "≤"', { hasEmptyBrace: true }), - ...blockCommand('lisp', 'Begin an example of Lisp code'), - command('listoffloats', 'Produce a table-of-contents-like listing of floats'), - command('lowersections', 'Change subsequent chapters to sections, sections to subsections'), - ...blockCommand('macro', 'Define a new Texinfo command', 'macroname', 'params'), - ...lineCommand('majorheading', 'Print an unnumbered chapter-like heading', 'title'), - ...braceCommand('math', 'Format a mathematical expression', 1, 'math-expression'), - ...blockCommand('menu', 'Mark the beginning of a menu of nodes'), - command('minus', 'Generate a minus sign, "-"', { hasEmptyBrace: true }), - ...blockCommand('multitable', 'Begin a multi-column table', 'column-width-spec'), - ...lineCommand('need', 'Start a new page if fewer than n mils remain on the current page'), - ...lineCommand('node', 'Begin a new node', 'name'), - command('noindent', 'Prevent text from being indented as if it were a new paragraph'), - command('novalidate', 'Suppress validation of node references'), - ...headingFootingCommand('oddfooting', 'Generate page footers that are the same for odd-numbered pages'), - ...headingFootingCommand('oddheading', 'Generate page headers that are the same for odd-numbered pages'), - ...braceCommand('ogonek', 'Generate an ogonek diacritic under the character', 1, 'c'), - ...braceCommand('option', 'Indicate a command-line option', 1, 'option-name'), - command('page', 'Start a new page in a printed manual'), - snippet('pagesizes', 'pagesizes', 'Change page dimensions', 0, '@pagesizes width, height', - 'pagesizes ${1:height}${2:, ${3:height}}'), - command('pagesizes', 'Change page dimensions', { snippet: true }), - ...lineCommand('paragraphindent', 'Indent paragraphs by spaces', 'indent'), - ...lineCommand('part', 'Begin a group of chapters or appendixes', 'title'), - ...lineCommand('pindex', 'Add entry to the index of programs', 'entry'), - command('point', 'Indicate the position of point in a buffer with "∗"', { hasEmptyBrace: true }), - command('pounds', 'Generate the pounds sterling currency sign, "£"', { hasEmptyBrace: true }), - command('print', 'Indicate printed output to the reader with "-|"', { hasEmptyBrace: true }), - ...lineCommand('printindex', 'Generate the alphabetized index for index name', 'index-name'), - ...braceCommand('pxref', 'Make a reference that starts with a lowercase "see" in a printed manual', 1, - 'node', 'entry', 'node-title', 'info-file', 'manual'), - ...blockCommand('quotation', 'Narrow the margins to indicate text that is quoted from another work'), - command('quotedblleft', 'Produce quotation mark "“"', { hasEmptyBrace: true }), - command('quotedblright', 'Produce quotation mark "”"', { hasEmptyBrace: true }), - command('quoteleft', 'Produce quotation mark "‘"', { hasEmptyBrace: true }), - command('quoteright', 'Produce quotation mark "’"', { hasEmptyBrace: true }), - ...braceCommand('r', 'Set text in the regular roman font', 1, 'text'), - command('raggedright', 'Fill text; left justify every line while leaving the right end ragged'), - command('raisesections', 'Change subsequent sections to chapters, subsections to sections'), - ...braceCommand('ref', 'Make a plain reference that does not start with any special text', 1, - 'node', 'entry', 'node-title', 'info-node', 'manual'), - command('refill', 'Refill and indent the paragraph after all the other processing has been done'), - command('registeredsymbol', 'Generate the legal symbol, "®"', { hasEmptyBrace: true }), - command('result', 'Indicate the result of an expression with "⇒"', { hasEmptyBrace: true }), - ...braceCommand('ringaccent', 'Generate a ring accent over the next character', 1, 'c'), - ...braceCommand('samp', 'Indicate a literal example of a sequence of characters', 1, 'text'), - ...braceCommand('sansserif', 'Set text in a sans serif font if possible', 1, 'text'), - ...braceCommand('sc', 'Set text in a small caps font in printed output, and uppercase in Info', 1, 'text'), - ...lineCommand('section', 'Begin a section within a chapter', 'title'), - ...lineCommand('set', 'Define a Texinfo variable', 'txivar', 'value'), - ...lineCommandEnum('setchapternewpage', 'Specify whether chapters start on new pages', 'on', 'off', 'odd'), - ...lineCommand('setfilename', 'Provide a name for the output files', 'info-file-name'), - ...lineCommand('settitle', 'Specify the title for page headers', 'title'), - command('shortcaption', 'Define the short caption for a @float'), - command('shortcontents', 'Print a short table of contents, with chapter-level entries only'), - ...lineCommand('shorttitlepage', 'Generate a minimal title page', 'title'), - ...braceCommand('slanted', 'Settextin aslantedfont if possible', 1, 'text'), - command('smallbook', 'Cause TeX to produce a printed manual in a 7 by 9.25 inch format'), - command('smalldisplay', 'Like @display, but use a smaller font size'), - command('smallexample', 'Like @example, but use a smaller font size'), - command('smallformat', 'Like @format, but use a smaller font size'), - command('smallindentedblock', 'Like @indentedblock, but use a smaller font size'), - ...blockCommand('smalllisp', 'Begin an example of Lisp code, same as @smallexample'), - command('smallquotation', 'Like @quotation, but use a smaller font size'), - ...braceCommand('sortas', 'Give a string by which the index entry should be sorted', 1, 'key'), - ...lineCommand('sp', 'Skip n lines', 'n'), - ...braceCommand('strong', 'Emphasize text by using boldface where possible', 1, 'text'), - ...braceCommand('sub', 'Set text as a subscript', 1, 'text'), - ...lineCommand('subheading', 'Print an unnumbered subsection-like heading', 'title'), - ...lineCommand('subsection', 'Begin a subsection within a section', 'title'), - ...lineCommand('subsubheading', 'Print an unnumbered subsubsection-like heading', 'title'), - ...lineCommand('subsubsection', 'Begin a subsubsection within a subsection', 'title'), - ...lineCommand('subtitle', 'Set a subtitle in a normal sized font flush to the right-hand side of the page', - 'title'), - command('summarycontents', 'Print a short table of contents'), - ...braceCommand('sup', 'Set text as a superscript', 1, 'text'), - ...lineCommand('syncodeindex', 'Merge the first index into the second, formatting the entries from ' + - 'the first index with @code', 'from-index', 'to-index'), - ...lineCommand('synindex', 'Merge the first index into the second', 'from-index', 'to-index'), - ...braceCommand('t', 'Set text ina fixed-width font', 1, 'text'), - command('tab', 'Separate columns in a row of a multitable'), - ...blockCommand('table', 'Begin a two-column table', 'formatting-command'), - command('TeX', 'Generate the TeX logo', { hasEmptyBrace: true }), - ...blockCommand('tex', 'Enter TeX completely'), - command('textdegree', 'Generate the degree symbol, "◦"', { hasEmptyBrace: true }), - command('thischapter', 'Insert the number and name of the current chapter'), - command('thischaptername', 'Insert the current chapter name'), - command('thischapternum', 'Insert the current chapter number'), - command('thisfile', 'Insert the current file name'), - command('thispage', 'Insert the current page number'), - command('thistitle', 'Insert the title of the current document'), - command('tie', 'Generate a normal interword space at which a line break is not allowed', - { hasEmptyBrace: true }), - ...braceCommand('tieaccent', 'Generate a tie-after accent over the two characters', 1, 'cc'), - ...lineCommand('tindex', 'Add entry to the index of data types', 'entry'), - ...lineCommand('title', 'Set a title flush to the left-hand side of the page', 'title'), - ...braceCommand('titlefont', 'Print text in a larger than normal font', 1, 'text'), - ...blockCommand('titlepage', 'Begin the title page'), - command('today', 'Insert the current date', { hasEmptyBrace: true }), - ...lineCommand('top', 'Mark the topmost @node in the file', 'title'), - ...braceCommand('U', 'Generate a representation of Unicode character', 1, 'hex'), - ...braceCommand('u', 'Generate a breve accent over character', 1, 'c'), - ...braceCommand('ubaraccent', 'Generate a underbar accent under character', 1, 'c'), - ...braceCommand('udotaccent', 'Generate a underdot accent under character', 1, 'c'), - ...lineCommand('unmacro', 'Undefine the macro if it has been defined', 'macroname'), - ...lineCommand('unnumbered', 'Begin a chapter that appears without chapter numbers', 'title'), - ...lineCommand('unnumberedsec', 'Begin a section that appears without section numbers', 'title'), - ...lineCommand('unnumberedsubsec', 'Begin an unnumbered subsection', 'title'), - ...lineCommand('unnumberedsubsubsec', 'Begin an unnumbered subsubsection', 'title'), - ...braceCommand('uref', 'Define a cross-reference to an external URL', 1, - 'url', 'displayed-text', 'replacement'), - ...braceCommand('url', 'Define a cross-reference to an external URL', 1, - 'url', 'displayed-text', 'replacement'), - ...lineCommandEnum('urefbreakstyle', 'Specify how @uref/@url should break at special characters', - 'after', 'before', 'none'), - ...braceCommand('v', 'Generate check accent over the character', 1, 'c'), - ...lineCommandEnum('validatemenus', 'Control whether menus can be automatically generated', 'on', 'off'), - ...braceCommand('value', 'Insert the value of the Texinfo variable', 1, 'txivar'), - ...braceCommand('var', 'Highlight a metasyntactic variable', 1, 'metasyntactic-variable'), - ...braceCommand('verb', 'Output text, delimited by the single character', 1, 'chartextchar'), - ...blockCommand('verbatim', 'Output the text of the environment exactly as is'), - ...lineCommand('verbatiminclude', 'Output the contents of file as is', 'filename'), - ...lineCommand('vindex', 'Add entry to the index of variables', 'entry'), - ...lineCommand('vskip', 'Insert whitespace so as to push text on the remainder of the page ' + - 'towards the bottom', 'amount'), - ...lineCommand('vtable', 'Begin a two-column table', 'formatting-command'), - ...braceCommand('w', 'Disallow line breaks within text', 1, 'text'), - ...blockCommand('xml', 'Enter XML completely'), - ...braceCommand('xref', 'Make a reference that starts with "See" in a printed manual', 1, - 'node', 'entry', 'node-title', 'info-file', 'manual'), - ...lineCommandEnum('xrefautomaticsectiontitle', 'By default, use the section title instead of the ' + - 'node name in cross references', 'on', 'off'), + command('ampchar', + 'Insert an ampersand, "&"', + { hasEmptyBrace: true }, + ), + command('atchar', + 'Insert an at sign, "@"', + { hasEmptyBrace: true }, + ), + command('backslashchar', + 'Insert a blackslash, "\\"', + { hasEmptyBrace: true }, + ), + command( + 'lbracechar', + 'Insert a left brace, "{"', + { hasEmptyBrace: true }, + ), + command('rbracechar', + 'Insert a right brace, "}"', + { hasEmptyBrace: true }, + ), + ...braceCommand('abbr', + 'Indicate a general abbreviation', + 1, 'abbreviation', 'meaning', + ), + ...braceCommand('acronym', + 'Indicate an acronym in all capital letters', + 1, 'acronym', 'meaning', + ), + snippet('alias', 'alias', + 'Defines a new command to be just like an existing one', + 0, + '@alias new=existing', + 'alias ${1:new}=${2:existing}', + ), + command('alias', + 'Defines a new command to be just like an existing one', + { snippet: true }, + ), + ...lineCommandEnum('allowcodebreaks', + 'Control breaking at "-" and "_" in TeX', + 'true', 'false', + ), + ...braceCommand('anchor', + 'Define current location for use as a cross-reference target', + 1, 'name', + ), + ...lineCommand('appendix', + 'Begin an appendix', + 'title', + ), + ...lineCommand('appendixsec', + 'Begin an appendix section within an appendix', + 'title', + ), + ...lineCommand('appendixsection', + 'Begin an appendix section within an appendix', + 'title', + ), + ...lineCommand('appendixsubsec', + 'Begin an appendix subsection', + 'title', + ), + ...lineCommand('appendixsubsubsec', + 'Begin an appendix subsubsection', + 'title', + ), + command('arrow', + 'Generate a right arrow glyph, "→"', + { hasEmptyBrace: true }, + ), + command('asis', + 'Print the table’s first column without highlighting', + ), + ...lineCommand('author', + 'Set the names of the author(s)', + 'author-name', + ), + ...braceCommand('b', + 'Set text in a bold font', + 1, 'text', + ), + ...blockCommand('copying', + 'Declare copying permissions', + ), + command('bullet', + 'Generate a large round dot, "•"', + { hasEmptyBrace: true }, + ), + command('bye', + 'Stop formatting', + ), + ...lineCommand('c', + 'Begin a line comment', + 'comment', + ), + snippet('header', 'c', + 'Declare header block', + 2, + '@c %**start of header\n\n@c %**end of header', + 'c %**${1:start of header}\n$3\n@c %**${2:end of header}', + ), + ...braceCommand('caption', + 'Define the full caption for a @float', + 1, 'definition', + ), + ...blockCommand('cartouche', + 'Highlight by drawing a box with rounded corners around it', + ), + ...lineCommand('center', + 'Center the line of text following the command', + 'text-line', + ), + ...lineCommand('centerchap', + 'Like @chapter, but centers the chapter title', + 'text-line', + ), + ...lineCommand('chapheading', + 'Print an unnumbered chapter-like heading', + 'title', + ), + ...lineCommand('chapter', + 'Begin a numbered chapter', + 'title', + ), + ...lineCommand('cindex', + 'Add entry to the index of concepts', + 'entry', + ), + ...braceCommand('cite', + 'Highlight the name of a reference', + 1, 'reference', + ), + ...lineCommand('clear', + 'Unset flag', + 'flag', + ), + command('click', + 'Represent a single "click" in a GUI', + { hasEmptyBrace: true }, + ), + ...braceCommand('clicksequence', + 'Represent a sequence of clicks in a GUI', + 1, 'actions', + ), + ...lineCommand('clickstyle', + 'Execute command on each @click', + '@command', + ), + ...braceCommand('code', + 'Indicate text which is a piece of code', + 1, 'sample-code', + ), + ...lineCommandEnum('codequotebacktick', + 'Control output of "`" in code examples', + 'on', 'off', + ), + ...lineCommandEnum('codequoteundirected', + 'Control output of "\'" in code examples', + 'on', 'off', + ), + command('comma', + 'Insert a comma character, ","', + { hasEmptyBrace: true }, + ), + ...braceCommand('command', + 'Indicate a command name', + 1, 'command-name', + ), + ...lineCommand('comment', + 'Begin a line comment', + 'comment', + ), + command('contents', + 'Print a complete table of contents.', + ), + ...blockCommand('copying', + 'Specify copyright holders and copying conditions', + ), + command('copyright', + 'The copyright symbol, "©"', + { hasEmptyBrace: true }, + ), + ...lineCommand('defcodeindex', + 'Define a new index, print entries in an @code font', + 'index-name', + ), + ...lineCommandX('defcv', + 'Format a description for a variable associated with a class', + 'category', 'class', 'name', + ), + ...lineCommandX('deffn', + 'Format a description for a function', + 'category', 'name', 'arguments', + ), + ...lineCommand('defindex', + 'Define a new index, print entries in a roman font', + 'index-name', + ), + ...lineCommand('definfoenclose', + 'Create a new command for Info that marks text by enclosing ' + + 'it in strings that precede and follow the text.', + 'newcmd', 'before', 'after', + ), + ...lineCommandX('defivar', + 'Format a description for an instance variable ' + + 'in object-oriented programming', + 'class', 'instance-variable-name' + ), + ...lineCommandX('defmac', + 'Format a description for a macro', + 'macroname', 'arguments', + ), + ...lineCommandX('defmethod', + 'Format a description for a method in ' + + 'object-oriented programming', + 'class', 'method-name', 'arguments', + ), + ...lineCommandX('defop', + 'Format a description for an operation in ' + + 'object-oriented programming', + 'category', 'class', 'name', 'arguments', + ), + ...lineCommandX('defopt', + 'Format a description for a user option', + 'option-name', + ), + ...lineCommandX('defspec', + 'Format a description for a special form', + 'special-form-name', 'arguments', + ), + ...lineCommandX('deftp', + 'Format a description for a data type', + 'category', 'name-of-type', 'attributes', + ), + ...lineCommandX('deftypecv', + 'Format a description for a typed class variable in ' + + 'object-oriented programming', + 'category', 'class', 'data-type', 'name', + ), + ...lineCommandX('deftypefn', + 'Format a description for a function or similar entity ' + + 'that may take arguments and that is typed', + 'category', 'data-type', 'name', 'arguments', + ), + ...lineCommandEnum('deftypefnnewline', + 'Specifies whether return types for @deftypefn and similar ' + + 'are printed on lines by themselves', + 'on', 'off', + ), + ...lineCommandX('deftypefun', + 'Format a description for a function in a typed language', + 'data-type', 'function-name', 'arguments', + ), + ...lineCommandX('deftypeivar', + 'Format a description for a typed instance variable in ' + + 'object-oriented programming', + 'class', 'data-type', 'variable-name', + ), + ...lineCommandX('deftypemethod', + 'Format a description for a typed method in ' + + 'object-oriented programming', + 'class', 'data-type', 'method-name', 'arguments', + ), + ...lineCommandX('deftypeop', + 'Format a description for a typed operation in ' + + 'object-oriented programming', + 'category', 'class', 'data-type', 'name', 'arguments', + ), + ...lineCommandX('deftypevar', + 'Format a description for a variable in a typed language', + 'data-type', 'variable-name', + ), + ...lineCommandX('deftypevr', + 'Format a description for something like a variable ' + + 'in a typed language', + 'category', 'data-type', 'name', + ), + ...lineCommandX('defun', + 'Format a description for a function', + 'function-name', 'arguments', + ), + ...lineCommandX('defvar', + 'Format a description for a variable', + 'variable-name', + ), + ...lineCommandX('defvr', + 'Format a description for any kind of variable', + 'category', 'name', + ), + ...blockCommand('detailmenu', + 'Mark the (optional) detailed node listing in a master menu', + ), + ...braceCommand('dfn', + 'Indicate the introductory or defining use of a term', + 1, 'term', + ), + ...lineCommand('dircategory', + 'Specify a part of the Info directory menu where this ' + + "file's entry should go", + 'dirpart', + ), + ...blockCommand('direntry', + 'Begin the Info directory menu entry for this file', + ), + ...blockCommand('display', + 'Begin a kind of example', + ), + ...braceCommand('dmn', + 'Format a unit of measure, as in 12pt', + 1, 'dimension', + ), + ...blockCommand('docbook', + 'Enter Docbook completely', + ), + ...blockCommand('documentdescription', + 'Set the document description text, included in the ' + + 'HTML output', + ), + ...lineCommand('documentencoding', + 'Declare the input encoding', + 'enc', + ), + ...lineCommand('documentlanguage', + 'Declares the current document locale', + 'll_CC', + ), + ...braceCommand('dotaccent', + 'Generate a dot accent over the character', + 1, 'c', + ), + command('dots', + 'Generate an ellipsis, "…"', + { hasEmptyBrace: true }, + ), + ...braceCommand('email', + 'Indicate an electronic mail address', + 1, 'address', 'displayed-text', + ), + ...braceCommand('emph', + 'Emphasize text', + 1, 'text', + ), + ...lineCommand('end', + 'Ends a block command environment', + 'environment', + ), + command('enddots', + 'Generate an end-of-sentence ellipsis, "..."', + { hasEmptyBrace: true }, + ), + ...blockCommand('enumerate', + 'Begin a numbered list, using @item for each entry', + ), + ...braceCommand('env', + 'Indicate an environment variable name', + 1, + 'environment-variable', + ), + command('equiv', + 'Insert a glyph indicating exact equivalence, "≡"', + { hasEmptyBrace: true }, + ), + command('error', + 'Indicate that the following text is an error message, ' + + '"error→"', + { hasEmptyBrace: true }, + ), + ...braceCommand('errormsg', + 'Report message as an error to standard error, ' + + 'and exit unsuccessfully', + 1, 'msg', + ), + command('euro', + 'Generate the Euro currency sign, "€"', + { hasEmptyBrace: true }, + ), + ...headingFootingCommand('evenfooting', + 'Generate page footers that are the same for ' + + 'even-numbered pages', + ), + ...headingFootingCommand('evenheading', + 'Generate page headers that are the same for ' + + 'even-numbered pages', + ), + ...headingFootingCommand('everyfooting', + 'Generate page footers that are the same for every pages', + ), + ...headingFootingCommand('everyheading', + 'Generate page headers that are the same for every pages', + ), + ...blockCommand('example', + 'Indicate an example', + ), + ...lineCommand('exampleindent', + 'Indent example-like environments by number of spaces', + 'indent', + ), + ...lineCommand('exdent', + 'Remove any indentation a line might have', + 'line-of-text', + ), + command('expansion', + 'Indicate the result of a macro expansion with a glyph, "→"', + { hasEmptyBrace: true }, + ), + ...braceCommand('file', + 'Highlight the name of a file', + 1, 'filename', + ), + command('finalout', + 'Prevent TeX from printing large black warning rectangles ' + + 'beside over-wide lines', + ), + ...lineCommand('findex', + 'Add entry to the index of functions', 'entry', + ), + ...lineCommandEnum('firstparagraphindent', + 'Control indentation of the first paragraph after ' + + 'section headers', + 'none', 'insert', + ), + ...blockCommand('float', + 'Environment to define floating material', + ), + ...blockCommand('flushleft', + 'Left justify every line while leaving the right end ragged', + ), + ...blockCommand('flushright', + 'Right justify every line while leaving the left end ragged', + ), + ...lineCommandEnum('fonttextsize', + 'Change the size of the main body font in the TeX output', + '10', '11', + ), + ...braceCommand('footnote', + 'Enter a footnote', + 1, 'footnote-text', + ), + ...lineCommandEnum('footnotestyle', + "Specify an Info file's footnote style", + 'end', 'separate', + ), + ...blockCommand('format', + 'Begin a kind of example, but do not indent', + ), + ...lineCommandEnum('frenchspacing', + 'Control spacing after punctuation', + 'on', 'off', + ), + ...blockCommand('ftable', + 'Begin a two-column table, using @item for each entry', + 'formatting-command', + ), + command('geq', + 'Generate a greater-than-or-equal sign, "≥"', + { hasEmptyBrace: true }, + ), + ...blockCommand('group', + 'Disallow page breaks within following text', + ), + command('hashchar', + 'Insert a hash character, "#"', + { hasEmptyBrace: true }, + ), + ...lineCommand('heading', + 'Print an unnumbered section-like heading', + 'title', + ), + ...lineCommandEnum('headings', + 'Turn page headings on or off, and/or specify single or ' + + 'double-sided page headings for printing', + 'on', 'single', 'double', 'singleafter', 'doubleafter', 'off', + ), + command('headitem', + 'Begin a heading row in a multitable', + ), + ...braceCommand('headitemfont', + 'Set text in the font used for multitable heading rows', + 1, 'text', + ), + ...blockCommand('html', + 'Enter HTML completely', + ), + ...braceCommand('hyphenation', + 'Tell TeX how to hyphenate words', + 1, 'hy-phen-a-ted words', + ), + ...braceCommand('i', + 'Set text in an italic font', + 1, 'text', + ), + ...blockCommand('ifclear', + 'If the Texinfo variable is not set, format the ' + + 'following text', + 'txivar', + ), + ...blockCommand('ifcommanddefined', + 'If the Texinfo code is defined, format the follow text', + 'txicmd', + ), + ...blockCommand('ifcommandnotdefined', + 'If the Texinfo code is not defined, format the follow text', + 'txicmd', + ), + ...blockCommand('ifdocbook', + 'Begin text that will appear only in DocBook format', + ), + ...blockCommand('ifhtml', + 'Begin text that will appear only in HTML format', + ), + ...blockCommand('ifinfo', + 'Begin text that will appear only in Info format', + ), + ...blockCommand('ifplaintext', + 'Begin text that will appear only in plain text format', + ), + ...blockCommand('ifset', + 'If the Texinfo variable is set, format the following text', + 'txivar', + ), + ...blockCommand('iftex', + 'Begin text that will appear only in TeX format', + ), + ...blockCommand('ifxml', + 'Begin text that will appear only in XML format', + ), + ...blockCommand('ifnotdocbook', + 'Begin text to be ignored in DocBook format', + ), + ...blockCommand('ifnothtml', + 'Begin text to be ignored in HTML format', + ), + ...blockCommand('ifnotinfo', + 'Begin text to be ignored in Info format', + ), + ...blockCommand('ifnotplaintext', + 'Begin text to be ignored in plain text format', + ), + ...blockCommand('ifnottex', + 'Begin text to be ignored in TeX format', + ), + ...blockCommand('ifnotxml', + 'Begin text to be ignored in XML format', + ), + ...blockCommand('ignore', + 'Begin text that will not appear in any output', + ), + ...braceCommand('image', + 'Insert an image', + 1, 'filename', 'width', 'height', 'alt', 'ext', + ), + ...lineCommand('include', + 'Read the contents of Texinfo source file', + 'filename', + ), + command('indent', + 'Insert paragraph indentation', + ), + ...blockCommand('indentedblock', + 'Indent a block of arbitary text on the left', + ), + ...braceCommand('indicateurl', + 'Indicate text that is a URL', + 1, 'URL', + ), + ...braceCommand('inforef', + 'Make a cross-reference to an Info file', + 3, 'node-name', 'entry-name', 'info-file-name', + ), + ...braceCommand('inlinefmt', + 'Insert text only if the output format is fmt', + 2, 'fmt', 'text', + ), + ...braceCommand('inlinefmtifelse', + 'Insert text if the output format is fmt, else else-text', + 3, 'fmt', 'text', 'else-text', + ), + ...braceCommand('inlineifclear', + 'Insert text only if variable var is not set', + 2, 'var', 'text', + ), + ...braceCommand('inlineifset', + 'Insert text only if variable var is set', + 2, 'var', 'text', + ), + ...braceCommand('inlineraw', + 'Insert text as in a raw conditional, only if ' + + 'the output format is fmt', + 2, 'fmt', 'raw-text', + ), + command('insertcopying', + 'Insert previously defined @copying text', + ), + command('item', + 'Indicate the beginning of a marked paragraph, ' + + 'or the beginning of the text of a first column entry ' + + 'for a table', + ), + ...blockCommand('itemize', + 'Begin an unordered list', + 'mark-generating-character-or-command', + ), + command('itemx', + 'Like @item, but do not generate extra vertical space ' + + 'above the item text', + ), + ...braceCommand('kbd', + 'Indicate characters of input to be typed by users', + 1, 'keyboard-characters', + ), + ...lineCommandEnum('kbdinputstyle', + 'Specify when @kbd should use a font distinct from @code', + 'code', 'distinct', 'example', + ), + ...braceCommand('key', + 'Indicate the name of a key on a keyboard', + 1, 'key-name', + ), + ...lineCommand('kindex', + 'Add entry to the index of keys', + 'entry', + ), + command('LaTeX', + 'Generate the LaTeX logo', + { hasEmptyBrace: true }, + ), + command('leq', + 'Generate a less-than-or-equal sign, "≤"', + { hasEmptyBrace: true }, + ), + ...blockCommand('lisp', + 'Begin an example of Lisp code', + ), + command('listoffloats', + 'Produce a table-of-contents-like listing of floats', + ), + command('lowersections', + 'Change subsequent chapters to sections, ' + + 'sections to subsections', + ), + ...blockCommand('macro', + 'Define a new Texinfo command', + 'macroname', 'params', + ), + ...lineCommand('majorheading', + 'Print an unnumbered chapter-like heading', + 'title', + ), + ...braceCommand('math', + 'Format a mathematical expression', + 1, 'math-expression', + ), + ...blockCommand('menu', + 'Mark the beginning of a menu of nodes', + ), + command('minus', + 'Generate a minus sign, "-"', + { hasEmptyBrace: true }, + ), + ...blockCommand('multitable', + 'Begin a multi-column table', + 'column-width-spec', + ), + ...lineCommand('need', + 'Start a new page if fewer than n mils remain ' + + 'on the current page', + ), + ...lineCommand('node', + 'Begin a new node', + 'name', + ), + command('noindent', + 'Prevent text from being indented as if ' + + 'it were a new paragraph', + ), + command('novalidate', + 'Suppress validation of node references', + ), + ...headingFootingCommand('oddfooting', + 'Generate page footers that are the same ' + + 'for odd-numbered pages', + ), + ...headingFootingCommand('oddheading', + 'Generate page headers that are the same ' + + 'for odd-numbered pages', + ), + ...braceCommand('option', + 'Indicate a command-line option', + 1, 'option-name', + ), + command('page', + 'Start a new page in a printed manual', + ), + snippet('pagesizes', 'pagesizes', + 'Change page dimensions', + 0, + '@pagesizes width, height', + 'pagesizes ${1:height}${2:, ${3:height}}', + ), + command('pagesizes', + 'Change page dimensions', + { snippet: true }, + ), + ...lineCommand('paragraphindent', + 'Indent paragraphs by spaces', + 'indent', + ), + ...lineCommand('part', + 'Begin a group of chapters or appendixes', + 'title', + ), + ...lineCommand('pindex', + 'Add entry to the index of programs', + 'entry', + ), + command('point', + 'Indicate the position of point in a buffer with "∗"', + { hasEmptyBrace: true }, + ), + command('pounds', + 'Generate the pounds sterling currency sign, "£"', + { hasEmptyBrace: true }, + ), + command('print', + 'Indicate printed output to the reader with "-|"', + { hasEmptyBrace: true }, + ), + ...lineCommand('printindex', + 'Generate the alphabetized index for index name', + 'index-name', + ), + ...braceCommand('pxref', + 'Make a reference that starts with a lowercase "see" ' + + 'in a printed manual', + 1, 'node', 'entry', 'node-title', 'info-file', 'manual', + ), + ...blockCommand('quotation', + 'Narrow the margins to indicate text that is ' + + 'quoted from another work', + ), + command('quotedblleft', + 'Produce quotation mark "“"', + { hasEmptyBrace: true }, + ), + command('quotedblright', + 'Produce quotation mark "”"', + { hasEmptyBrace: true }, + ), + command('quoteleft', + 'Produce quotation mark "‘"', + { hasEmptyBrace: true }, + ), + command('quoteright', + 'Produce quotation mark "’"', + { hasEmptyBrace: true }, + ), + ...braceCommand('r', + 'Set text in the regular roman font', + 1, 'text', + ), + command('raggedright', + 'Fill text; left justify every line while ' + + 'leaving the right end ragged', + ), + command('raisesections', + 'Change subsequent sections to chapters, ' + + 'subsections to sections', + ), + ...braceCommand('ref', + 'Make a plain reference that does not start with ' + + 'any special text', + 1, 'node', 'entry', 'node-title', 'info-node', 'manual', + ), + command('refill', + 'Refill and indent the paragraph after all the ' + + 'other processing has been done', + ), + command('registeredsymbol', + 'Generate the legal symbol, "®"', + { hasEmptyBrace: true }, + ), + command('result', + 'Indicate the result of an expression with "⇒"', + { hasEmptyBrace: true }, + ), + ...braceCommand('samp', + 'Indicate a literal example of a sequence of characters', + 1, 'text', + ), + ...braceCommand('sansserif', + 'Set text in a sans serif font if possible', + 1, 'text', + ), + ...braceCommand('sc', + 'Set text in a small caps font in printed output, ' + + 'and uppercase in Info', + 1, 'text', + ), + ...lineCommand('section', + 'Begin a section within a chapter', + 'title', + ), + ...lineCommand('set', + 'Define a Texinfo variable', + 'txivar', 'value', + ), + ...lineCommandEnum('setchapternewpage', + 'Specify whether chapters start on new pages', + 'on', 'off', 'odd', + ), + ...lineCommand('setfilename', + 'Provide a name for the output files', + 'info-file-name', + ), + ...lineCommand('settitle', + 'Specify the title for page headers', + 'title', + ), + command('shortcaption', + 'Define the short caption for a @float', + ), + command('shortcontents', + 'Print a short table of contents, with ' + + 'chapter-level entries only', + ), + ...lineCommand('shorttitlepage', + 'Generate a minimal title page', + 'title', + ), + ...braceCommand('slanted', + 'Set text in a slanted font if possible', + 1, 'text', + ), + command('smallbook', + 'Cause TeX to produce a printed manual in a ' + + '7 by 9.25 inch format', + ), + command('smalldisplay', + 'Like @display, but use a smaller font size', + ), + command('smallexample', + 'Like @example, but use a smaller font size', + ), + command('smallformat', + 'Like @format, but use a smaller font size', + ), + command('smallindentedblock', + 'Like @indentedblock, but use a smaller font size', + ), + ...blockCommand('smalllisp', + 'Begin an example of Lisp code, same as @smallexample', + ), + command('smallquotation', + 'Like @quotation, but use a smaller font size', + ), + ...braceCommand('sortas', + 'Give a string by which the index entry should be sorted', + 1, 'key', + ), + ...lineCommand('sp', + 'Skip n lines', + 'n', + ), + ...braceCommand('strong', + 'Emphasize text by using boldface where possible', + 1, 'text', + ), + ...braceCommand('sub', + 'Set text as a subscript', + 1, 'text', + ), + ...lineCommand('subheading', + 'Print an unnumbered subsection-like heading', + 'title', + ), + ...lineCommand('subsection', + 'Begin a subsection within a section', + 'title', + ), + ...lineCommand('subsubheading', + 'Print an unnumbered subsubsection-like heading', + 'title', + ), + ...lineCommand('subsubsection', + 'Begin a subsubsection within a subsection', + 'title', + ), + ...lineCommand('subtitle', + 'Set a subtitle in a normal sized font flush to ' + + 'the right-hand side of the page', + 'title', + ), + command('summarycontents', + 'Print a short table of contents', + ), + ...braceCommand('sup', + 'Set text as a superscript', + 1, 'text', + ), + ...lineCommand('syncodeindex', + 'Merge the first index into the second, formatting ' + + 'the entries from the first index with @code', + 'from-index', 'to-index', + ), + ...lineCommand('synindex', + 'Merge the first index into the second', + 'from-index', 'to-index', + ), + ...braceCommand('t', + 'Set text ina fixed-width font', + 1, 'text', + ), + command('tab', + 'Separate columns in a row of a multitable', + ), + ...blockCommand('table', + 'Begin a two-column table', + 'formatting-command', + ), + command('TeX', + 'Generate the TeX logo', + { hasEmptyBrace: true }, + ), + ...blockCommand('tex', + 'Enter TeX completely', + ), + command('textdegree', + 'Generate the degree symbol, "◦"', + { hasEmptyBrace: true }, + ), + command('thischapter', + 'Insert the number and name of the current chapter', + ), + command('thischaptername', + 'Insert the current chapter name', + ), + command('thischapternum', + 'Insert the current chapter number', + ), + command('thisfile', + 'Insert the current file name', + ), + command('thispage', + 'Insert the current page number', + ), + command('thistitle', + 'Insert the title of the current document', + ), + command('tie', + 'Generate a normal interword space at which a line break ' + + 'is not allowed', + { hasEmptyBrace: true }, + ), + ...braceCommand('tieaccent', + 'Generate a tie-after accent over the two characters', + 1, 'cc', + ), + ...lineCommand('tindex', + 'Add entry to the index of data types', + 'entry', + ), + ...lineCommand('title', + 'Set a title flush to the left-hand side of the page', + 'title', + ), + ...braceCommand('titlefont', + 'Print text in a larger than normal font', + 1, 'text', + ), + ...blockCommand('titlepage', + 'Begin the title page', + ), + command('today', + 'Insert the current date', + { hasEmptyBrace: true }, + ), + ...lineCommand('top', + 'Mark the topmost @node in the file', + 'title', + ), + ...braceCommand('U', + 'Generate a representation of Unicode character', + 1, 'hex', + ), + ...braceCommand('u', + 'Generate a breve accent over character', + 1, 'c', + ), + ...braceCommand('ubaraccent', + 'Generate a underbar accent under character', + 1, 'c', + ), + ...braceCommand('udotaccent', + 'Generate a underdot accent under character', + 1, 'c', + ), + ...lineCommand('unmacro', + 'Undefine the macro if it has been defined', + 'macroname', + ), + ...lineCommand('unnumbered', + 'Begin a chapter that appears without chapter numbers', + 'title', + ), + ...lineCommand('unnumberedsec', + 'Begin a section that appears without section numbers', + 'title', + ), + ...lineCommand('unnumberedsubsec', + 'Begin an unnumbered subsection', + 'title', + ), + ...lineCommand('unnumberedsubsubsec', + 'Begin an unnumbered subsubsection', + 'title', + ), + ...braceCommand('uref', + 'Define a cross-reference to an external URL', + 1, 'url', 'displayed-text', 'replacement', + ), + ...braceCommand('url', + 'Define a cross-reference to an external URL', + 1, 'url', 'displayed-text', 'replacement', + ), + ...lineCommandEnum('urefbreakstyle', + 'Specify how @uref/@url should break at special characters', + 'after', 'before', 'none', + ), + ...braceCommand('v', + 'Generate check accent over the character', + 1, 'c', + ), + ...lineCommandEnum('validatemenus', + 'Control whether menus can be automatically generated', + 'on', 'off', + ), + ...braceCommand('value', + 'Insert the value of the Texinfo variable', + 1, 'txivar', + ), + ...braceCommand('var', + 'Highlight a metasyntactic variable', + 1, 'metasyntactic-variable', + ), + ...braceCommand('verb', + 'Output text, delimited by the single character', + 1, 'chartextchar', + ), + ...blockCommand('verbatim', + 'Output the text of the environment exactly as is', + ), + ...lineCommand('verbatiminclude', + 'Output the contents of file as is', + 'filename', + ), + ...lineCommand('vindex', + 'Add entry to the index of variables', + 'entry', + ), + ...lineCommand('vskip', + 'Insert whitespace so as to push text on the remainder of ' + + 'the page towards the bottom', + 'amount', + ), + ...lineCommand('vtable', + 'Begin a two-column table', + 'formatting-command', + ), + ...braceCommand('w', + 'Disallow line breaks within text', + 1, 'text', + ), + ...blockCommand('xml', + 'Enter XML completely', + ), + ...braceCommand('xref', + 'Make a reference that starts with "See" in a printed manual', + 1, 'node', 'entry', 'node-title', 'info-file', 'manual', + ), + ...lineCommandEnum('xrefautomaticsectiontitle', + 'By default, use the section title instead of the node name ' + + 'in cross references', + 'on', 'off', + ), ].filter(completionItem => { - if (!enableSnippets) return completionItem.kind === vscode.CompletionItemKind.Function; - return !hideSnippetCommands || !completionItem.snippet; + if (enableSnippets) { + return !hideSnippetCommands || !completionItem.snippet; + } + return completionItem.kind === vscode.CompletionItemKind.Function; }); } @@ -377,14 +1147,18 @@ export default class CompletionItemProvider implements vscode.CompletionItemProv ) { const lineText = document.lineAt(position.line).text; // Ignore comment line. - if (lineText.startsWith('@c ') || lineText.startsWith('@comment ')) return undefined; + if (lineText.startsWith('@c ') || lineText.startsWith('@comment ')) { + return undefined; + } // Triggered in the middle of a word. if (context.triggerKind === vscode.CompletionTriggerKind.Invoke) { const wordRange = document.getWordRangeAtPosition(position); if (wordRange === undefined) return undefined; - // Normalize position so that it can be treated as triggered by '@' character. + // Normalize position so that it can be treated as + // triggered by '@' character. position = wordRange.start; - if (document.getText(new vscode.Range(position.translate(0, -1), position)) !== '@') return undefined; + const pos = new vscode.Range(position.translate(0, -1), position); + if (document.getText(pos) !== '@') return undefined; } // Check whether options has changed. const newOptions = this._globalContext.options; @@ -394,7 +1168,9 @@ export default class CompletionItemProvider implements vscode.CompletionItemProv } if (position.character === 1) return this._getCompletionItems(); // Check whether the '@' character is escaped. - if (document.getText(new vscode.Range(position.translate(0, -2), position.translate(0, -1))) === '@') { + const pos = new vscode.Range( + position.translate(0, -2), position.translate(0, -1)); + if (document.getText(pos) === '@') { return undefined; } else { return this._getCompletionItems(); @@ -443,8 +1219,13 @@ function command(name: string, detail: string, extraArgs?: { * @param detail * @param args */ -function blockCommand(name: string, detail: string, ...args: string[]) { - return [blockSnippet(name, detail, ...args), command(name, detail, { snippet: true })]; +function blockCommand( + name: string, + detail: string, + ...args: string[] +) { + return [blockSnippet(name, detail, ...args), + command(name, detail, { snippet: true })]; } /** @@ -454,8 +1235,14 @@ function blockCommand(name: string, detail: string, ...args: string[]) { * @param detail * @param args */ -function braceCommand(name: string, detail: string, numArgsRequired: number, ...args: string[]) { - return [braceCommandSnippet(name, detail, numArgsRequired, ...args), command(name, detail, { snippet: true })]; +function braceCommand( + name: string, + detail: string, + numArgsRequired: number, + ...args: string[] +) { + return [braceCommandSnippet(name, detail, numArgsRequired, ...args), + command(name, detail, { snippet: true })]; } /** @@ -466,18 +1253,21 @@ function braceCommand(name: string, detail: string, numArgsRequired: number, ... * @param args */ function lineCommand(name: string, detail: string, ...args: string[]) { - return [lineCommandSnippet(name, detail, ...args), command(name, detail, { snippet: true })]; + return [lineCommandSnippet(name, detail, ...args), + command(name, detail, { snippet: true })]; } /** - * Build the completion items for a line command with arguments which has an x-form. + * Build the completion items for a line command with arguments + * which has an x-form. * * @param name * @param detail * @param args */ function lineCommandX(name: string, detail: string, ...args: string[]) { - return [...lineCommand(name, detail, ...args), ...lineCommand(name + 'x', detail, ...args)]; + return [...lineCommand(name, detail, ...args), + ...lineCommand(name + 'x', detail, ...args)]; } /** @@ -488,7 +1278,10 @@ function lineCommandX(name: string, detail: string, ...args: string[]) { */ function lineCommandEnum(name: string, detail: string, ...items: string[]) { return [ - snippet(name, name, detail, 0, `@${name} ${items.join('/')}`, `${name} \${1|${items.join(',')}|}`), + snippet(name, name, detail, 0, + `@${name} ${items.join('/')}`, + `${name} \${1|${items.join(',')}|}`, + ), command(name, detail, { snippet: true }), ]; } @@ -515,11 +1308,22 @@ function headingFootingCommand(name: string, detail: string) { * @param numArgsRequired Number of required arguments. * @param args Argument names. */ -function braceCommandSnippet(name: string, detail: string, numArgsRequired: number, ...args: string[]) { - const documentation = `@${name}{${args.map((arg, idx) => idx < numArgsRequired ? arg : '?' + arg).join(', ')}}`; - const optionalArgs = args.splice(numArgsRequired).map((arg, idx) => `\${${numArgsRequired + idx + 2}:${arg}}`); +function braceCommandSnippet( + name: string, + detail: string, + numArgsRequired: number, + ...args: string[] +) { + const argsDoc = args + .map((arg, idx) => idx < numArgsRequired ? arg : '?' + arg) + .join(', '); + const documentation = `@${name}{${argsDoc}}`; + const optionalArgs = args + .splice(numArgsRequired) + .map((arg, idx) => `\${${numArgsRequired + idx + 2}:${arg}}`); const requiredArgs = args.map((arg, idx) => `\${${idx + 1}:${arg}}`); - const optionalText = optionalArgs.length === 0 ? '' : `\${${numArgsRequired + 1}:, ${optionalArgs.join(', ')}}`; + const optionalText = optionalArgs.length === 0 + ? '' : `\${${numArgsRequired + 1}:, ${optionalArgs.join(', ')}}`; const insertText = `${name}{${requiredArgs.join(', ')}${optionalText}}`; return snippet(name, name, detail, 0, documentation, insertText); } @@ -532,8 +1336,13 @@ function braceCommandSnippet(name: string, detail: string, numArgsRequired: numb * @param args Argument names. */ function lineCommandSnippet(name: string, detail: string, ...args: string[]) { - const argsIndexed = args.map((arg, idx) => `\${${idx + 1}:${arg}}`).join(' '); - return snippet(name, name, detail, 0, `@${name} ${args.join(' ')}`, `${name} ${argsIndexed}`); + const argsIndexed = args + .map((arg, idx) => `\${${idx + 1}:${arg}}`) + .join(' '); + return snippet(name, name, detail, 0, + `@${name} ${args.join(' ')}`, + `${name} ${argsIndexed}`, + ); } /** @@ -543,9 +1352,14 @@ function lineCommandSnippet(name: string, detail: string, ...args: string[]) { * @param detail The snippet description. */ function blockSnippet(name: string, detail: string, ...args: string[]) { - const argsIndexed = args.map((arg, idx) => `\${${idx + 1}:${arg}}`).join(' '); - return snippet(name, name, detail, 0, `@${name} ${args.join(' ')}\n\n@end ${name}`, - `${name}${args.length ? ' ' : ''}${argsIndexed}\n$${args.length + 1}\n@end ${name}`); + const argsIndexed = args + .map((arg, idx) => `\${${idx + 1}:${arg}}`) + .join(' '); + return snippet(name, name, detail, 0, + `@${name} ${args.join(' ')}\n\n@end ${name}`, + name + args.length ? ' ' : '' + argsIndexed + + `\n$${args.length + 1}\n@end ${name}` + ); } /** @@ -556,7 +1370,7 @@ function blockSnippet(name: string, detail: string, ...args: string[]) { * @param detail The snippet description. * @param sortOrder Sort order for this completion item when names collide. * @param documentation The Markdown documentation for this snippet. - * @param insertText The text to replace current word when the item is selected. + * @param insertText The text to replace current word when selected. */ function snippet( label: string, diff --git a/src/providers/document_symbol.ts b/src/providers/document_symbol.ts index c1c0fe6..ce94642 100644 --- a/src/providers/document_symbol.ts +++ b/src/providers/document_symbol.ts @@ -25,10 +25,12 @@ import GlobalContext from '../global_context'; /** * Provide document symbol information for Texinfo documents. */ -export default class DocumentSymbolProvider implements vscode.DocumentSymbolProvider { - +export default class DocumentSymbolProvider + implements vscode.DocumentSymbolProvider +{ provideDocumentSymbols(document: vscode.TextDocument) { - return this._globalContext.contextMapping.getDocumentContext(document).documentSymbol.documentSymbols; + return this._globalContext.contextMapping.getDocumentContext(document) + .documentSymbol.documentSymbols; } constructor(private readonly _globalContext: GlobalContext) {} diff --git a/src/providers/folding_range.ts b/src/providers/folding_range.ts index 223a48a..73a80ce 100644 --- a/src/providers/folding_range.ts +++ b/src/providers/folding_range.ts @@ -25,10 +25,12 @@ import GlobalContext from '../global_context'; /** * Provide folding range info for Texinfo documents. */ -export default class FoldingRangeProvider implements vscode.FoldingRangeProvider { - +export default class FoldingRangeProvider + implements vscode.FoldingRangeProvider +{ provideFoldingRanges(document: vscode.TextDocument) { - return this._globalContext.contextMapping.getDocumentContext(document).foldingRange.foldingRanges; + return this._globalContext.contextMapping.getDocumentContext(document) + .foldingRange.foldingRanges; } constructor(private readonly _globalContext: GlobalContext) {} diff --git a/src/utils/converter.ts b/src/utils/converter.ts index 44cb366..88a4caa 100644 --- a/src/utils/converter.ts +++ b/src/utils/converter.ts @@ -32,18 +32,25 @@ import { Operator } from './types'; export default class Converter { async toHTML(imgTransformer: Operator, insertScript?: string) { - const newPath = imgTransformer(vscode.Uri.file(path.dirname(this._path))).toString() + '/'; - const options = ['-o-', '--no-split', '--html', `--error-limit=${this._options.errorLimit}`, - `--init-file=${this._initFile}`, '-D', `__vscode_texinfo_image_uri_base ${newPath}`]; + const pathUri = vscode.Uri.file(path.dirname(this._path)); + const newPath = imgTransformer(pathUri).toString() + '/'; + const options = ['-o-', '--no-split', '--html', + `--error-limit=${this._options.errorLimit}`, + `--init-file=${this._initFile}`, + '-D', `__vscode_texinfo_image_uri_base ${newPath}`, + ]; this._options.noHeaders && options.push('--no-headers'); this._options.noNumberSections && options.push('--no-number-sections'); this._options.noValidation && options.push('--no-validate'); this._options.noWarnings && options.push('--no-warn'); - insertScript !== undefined && options.push('-c', `EXTRA_HEAD `); + if (insertScript !== undefined) { + options.push('-c', `EXTRA_HEAD `); + } this._addIncludePaths(this._options.includePaths, options); this._defineVariables(this._options.variables, options); this._includeCustomCSS(this._options.customCSS, options); - return await exec(this._options.makeinfo, options.concat(this._path), this._options.maxSize); + return await exec(this._options.makeinfo, options.concat(this._path), + this._options.maxSize); } constructor( @@ -78,7 +85,8 @@ export default class Converter { throw URIError; } } catch (e) { - this._logger.log(`Cannot load custom CSS. Invalid URI: '${cssFileURI}'`); + this._logger + .log(`Cannot load custom CSS. Invalid URI: '${cssFileURI}'`); } } } diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 5132c25..7a4ef62 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -32,9 +32,18 @@ import { ExecResult } from './types'; * @returns The output data, or `undefined` if execution fails. */ export function exec(path: string, args: string[], maxBuffer: number) { - return new Promise(resolve => child_process.execFile(path, args, - { env: { ...process.env, LC_MESSAGES: 'en_US' }, maxBuffer: maxBuffer }, (error, stdout, stderr) => - resolve(error ? { error: stderr ? stderr : error.message } : { data: stdout, error: stderr }))); + return new Promise( + resolve => child_process.execFile(path, args, + { + env: { ...process.env, LC_MESSAGES: 'en_US' }, + maxBuffer: maxBuffer, + }, + (error, stdout, stderr) => resolve(error + ? { error: stderr ? stderr : error.message } + : { data: stdout, error: stderr } + ) + ) + ); } /** @@ -46,7 +55,8 @@ export function exec(path: string, args: string[], maxBuffer: number) { * @returns Whether the user clicked the button. */ export async function prompt(message: string, label: string, error = false) { - const func = error ? vscode.window.showErrorMessage : vscode.window.showInformationMessage; + const func = error ? + vscode.window.showErrorMessage : vscode.window.showInformationMessage; return label === await func(message, label); } @@ -68,7 +78,8 @@ export function lineNumToRange(startLine: number, endLine = startLine) { * @param charCode ASCII code of character. */ export function isAlpha(charCode: number) { - return charCode >= 97 && charCode <= 122 || charCode >= 65 && charCode <= 90; + return (charCode >= 97 && charCode <= 122) + || (charCode >= 65 && charCode <= 90); } /** @@ -77,16 +88,17 @@ export function isAlpha(charCode: number) { * @param charCode ASCII code of character. */ export function isAlnum(charCode: number) { - return isAlpha(charCode) || charCode >= 48 && charCode <= 57; + return isAlpha(charCode) || (charCode >= 48 && charCode <= 57); } /** * Get corresponding HTML cross-reference name by node name. * - * See section *HTML Cross-reference Node Name Expansion* in the Texinfo manual. + * See section *HTML Cross-reference Node Name Expansion* in + * the Texinfo manual. * - * TODO: Node name is not displayed verbatim, leading to wrong HTML xref when containing commands. - * Fix this when migrating to LSP. + * TODO: Node name is not displayed verbatim, leading to wrong HTML xref when + * containing commands. Fix this when migrating to LSP. * * @param nodeName */ @@ -100,5 +112,6 @@ export function getNodeHtmlRef(nodeName: string) { .join('')) .join('-'); const firstCharCode = result.charCodeAt(0); - return isAlpha(firstCharCode) ? result : 'g_t_00' + firstCharCode.toString(16) + result.substring(1); + return isAlpha(firstCharCode) ? result : 'g_t_00' + + firstCharCode.toString(16) + result.substring(1); } diff --git a/src/utils/types.ts b/src/utils/types.ts index 626b152..e96ffea 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -21,19 +21,33 @@ import * as vscode from 'vscode'; -export type CompletionItem = vscode.CompletionItem & { snippet?: boolean }; +export type CompletionItem = vscode.CompletionItem & { + snippet?: boolean, +}; -export type ExecResult = { data?: string, error: string }; +export type ExecResult = { + data?: string, + error: string, +}; -export type FoldingRange = vscode.FoldingRange & { name: string, detail: string }; +export type FoldingRange = vscode.FoldingRange & { + name: string, + detail: string, +}; -export type NamedLine = { name: string, line: number }; +export type NamedLine = { + name: string, + line: number, +}; export type Operator = (arg: T) => T; export type Optional = T | undefined; -export type Range = { start: number, end: number }; +export type Range = { + start: number, + end: number, +}; export function isDefined(value: Optional): value is T { return value !== undefined;