From 530902128c542e50cd8d9bd3cf322af888743535 Mon Sep 17 00:00:00 2001 From: CismonX Date: Thu, 4 Apr 2024 04:02:25 +0800 Subject: [PATCH] feat: support GNU Texinfo 7.1 * update version indicator * add completion for several @-commands --- src/indicator.ts | 25 ++++++++++++++----------- src/providers/completion_item.ts | 28 ++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/indicator.ts b/src/indicator.ts index 98ce9ec..13e30ec 100644 --- a/src/indicator.ts +++ b/src/indicator.ts @@ -1,7 +1,7 @@ /** * indicator.ts * - * Copyright (C) 2020,2021 CismonX + * Copyright (C) 2020,2021,2024 CismonX * * This file is part of vscode-texinfo. * @@ -85,16 +85,19 @@ export default class Indicator implements vscode.Disposable 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.8) { - icon = '$(warning)'; - tooltip = `GNU Texinfo (${options.makeinfo}) ` + - `is outdated (${version} < 6.8).`; - } else { - // Unrecognizable version. Assume it is okay. - icon = '$(check)'; + const version = result?.[1] ?? ''; + let tooltip = '', icon: string; + if (version) { + icon = '$(check)'; + const verArr = version.split('.'); + if (version.length >= 2) { + const verMajor = parseInt(verArr[0], 10); + const verMinor = parseInt(verArr[1], 10); + if (verMajor < 7 || verMinor < 1) { + icon = '$(warning)'; + tooltip = `GNU Texinfo (${options.makeinfo}) ` + + `is outdated (${version} < 7.1).`; + } } this._canDisplayPreview = true; } else { diff --git a/src/providers/completion_item.ts b/src/providers/completion_item.ts index c2d4c28..cd808ef 100644 --- a/src/providers/completion_item.ts +++ b/src/providers/completion_item.ts @@ -37,7 +37,7 @@ export default class CompletionItemProvider * 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 50-1117 of + * independent work", which means that GFDL applies to lines 50-1141 of * this file, while the remainder is under GPL like other source code files * of the project. * @@ -230,6 +230,9 @@ export default class CompletionItemProvider 'Define a new index, print entries in an @code font', 'index-name', ), + ...blockCommand('defblock', + 'Start a block containing definitions', + ), ...lineCommandX('defcv', 'Format a description for a variable associated with a class', 'category', 'class', 'name', @@ -245,7 +248,11 @@ export default class CompletionItemProvider ...lineCommandX('defivar', 'Format a description for an instance variable ' + 'in object-oriented programming', - 'class', 'instance-variable-name' + 'class', 'instance-variable-name', + ), + ...lineCommandX('defline', + 'Give the heading prototype line for a symbol being defined', + 'category', 'name', 'arguments', ), ...lineCommandX('defmac', 'Format a description for a macro', @@ -297,6 +304,11 @@ export default class CompletionItemProvider 'object-oriented programming', 'class', 'data-type', 'variable-name', ), + ...lineCommandX('deftypeline', + 'Give the heading prototype line for a symbol being ' + + 'defined, with data types', + 'category', 'data-type', 'name', 'arguments', + ), ...lineCommandX('deftypemethod', 'Format a description for a typed method in ' + 'object-oriented programming', @@ -346,6 +358,9 @@ export default class CompletionItemProvider ...blockCommand('display', 'Begin a kind of example', ), + ...blockCommand('displaymath', + 'Format a block of math in "display" format', + ), ...braceCommand('dmn', 'Format a unit of measure, as in 12pt', 1, 'dimension', @@ -552,6 +567,9 @@ export default class CompletionItemProvider ...blockCommand('ifinfo', 'Begin text that will appear only in Info format', ), + ...blockCommand('iflatex', + 'Begin text that will appear only in LaTeX format', + ), ...blockCommand('ifplaintext', 'Begin text that will appear only in plain text format', ), @@ -574,6 +592,9 @@ export default class CompletionItemProvider ...blockCommand('ifnotinfo', 'Begin text to be ignored in Info format', ), + ...blockCommand('ifnotlatex', + 'Begin text to be ignored in LaTeX format', + ), ...blockCommand('ifnotplaintext', 'Begin text to be ignored in plain text format', ), @@ -657,6 +678,9 @@ export default class CompletionItemProvider 'Add entry to the index of keys', 'entry', ), + ...blockCommand('latex', + 'Enter LaTeX completely', + ), command('LaTeX', 'Generate the LaTeX logo', { hasEmptyBrace: true },