lean4monaco 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/vscode-lean4/vscode-lean4/src/utils/depInstaller.d.ts +81 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/depInstaller.js +372 -0
- package/package.json +1 -1
- package/dist/JuliaMono-Regular.ttf +0 -0
- package/dist/lean4-infoview/codicon.ttf +0 -0
- package/dist/lean4-infoview/esm-shims/react-dom.d.ts +0 -5
- package/dist/lean4-infoview/esm-shims/react-jsx-runtime.d.ts +0 -5
- package/dist/lean4-infoview/esm-shims/react.d.ts +0 -5
- package/dist/lean4-infoview/index.css +0 -4161
- package/dist/lean4-infoview/index.d.ts +0 -16
- package/dist/lean4-infoview/index.development.js +0 -37312
- package/dist/lean4-infoview/index.production.min.js +0 -1528
- package/dist/lean4-infoview/infoview/collapsing.d.ts +0 -12
- package/dist/lean4-infoview/infoview/contexts.d.ts +0 -10
- package/dist/lean4-infoview/infoview/editorConnection.d.ts +0 -22
- package/dist/lean4-infoview/infoview/errors.d.ts +0 -14
- package/dist/lean4-infoview/infoview/event.d.ts +0 -33
- package/dist/lean4-infoview/infoview/goalLocation.d.ts +0 -61
- package/dist/lean4-infoview/infoview/goals.d.ts +0 -46
- package/dist/lean4-infoview/infoview/info.d.ts +0 -18
- package/dist/lean4-infoview/infoview/infos.d.ts +0 -2
- package/dist/lean4-infoview/infoview/interactiveCode.d.ts +0 -19
- package/dist/lean4-infoview/infoview/main.d.ts +0 -13
- package/dist/lean4-infoview/infoview/messages.d.ts +0 -19
- package/dist/lean4-infoview/infoview/rpcSessions.d.ts +0 -11
- package/dist/lean4-infoview/infoview/serverVersion.d.ts +0 -10
- package/dist/lean4-infoview/infoview/tooltips.d.ts +0 -32
- package/dist/lean4-infoview/infoview/traceExplorer.d.ts +0 -11
- package/dist/lean4-infoview/infoview/userWidget.d.ts +0 -39
- package/dist/lean4-infoview/infoview/util.d.ts +0 -144
- package/dist/lean4-infoview/loader.d.ts +0 -20
- package/dist/lean4-infoview/loader.development.js +0 -1006
- package/dist/lean4-infoview/loader.production.min.js +0 -1
- package/dist/lean4-infoview/react-dom.development.js +0 -30537
- package/dist/lean4-infoview/react-dom.production.min.js +0 -21
- package/dist/lean4-infoview/react-jsx-runtime.development.js +0 -1362
- package/dist/lean4-infoview/react-jsx-runtime.production.min.js +0 -1
- package/dist/lean4-infoview/react.development.js +0 -2823
- package/dist/lean4-infoview/react.production.min.js +0 -1
- package/dist/monaco-lean4/vscode-lean4/package.json +0 -944
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.d.ts +0 -9
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.js +0 -20
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.d.ts +0 -12
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.js +0 -40
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.d.ts +0 -20
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.js +0 -79
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.d.ts +0 -13
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.js +0 -29
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.d.ts +0 -28
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.js +0 -124
- package/dist/monaco-lean4/vscode-lean4/src/config.d.ts +0 -33
- package/dist/monaco-lean4/vscode-lean4/src/config.js +0 -119
- package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.d.ts +0 -27
- package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.js +0 -133
- package/dist/monaco-lean4/vscode-lean4/src/infoview.d.ts +0 -69
- package/dist/monaco-lean4/vscode-lean4/src/infoview.js +0 -711
- package/dist/monaco-lean4/vscode-lean4/src/leanclient.d.ts +0 -67
- package/dist/monaco-lean4/vscode-lean4/src/leanclient.js +0 -443
- package/dist/monaco-lean4/vscode-lean4/src/rpc.d.ts +0 -16
- package/dist/monaco-lean4/vscode-lean4/src/rpc.js +0 -102
- package/dist/monaco-lean4/vscode-lean4/src/taskgutter.d.ts +0 -11
- package/dist/monaco-lean4/vscode-lean4/src/taskgutter.js +0 -130
- package/dist/monaco-lean4/vscode-lean4/src/utils/batch.d.ts +0 -37
- package/dist/monaco-lean4/vscode-lean4/src/utils/batch.js +0 -203
- package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.d.ts +0 -41
- package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.js +0 -205
- package/dist/monaco-lean4/vscode-lean4/src/utils/converters.d.ts +0 -16
- package/dist/monaco-lean4/vscode-lean4/src/utils/converters.js +0 -129
- package/dist/monaco-lean4/vscode-lean4/src/utils/elan.d.ts +0 -3
- package/dist/monaco-lean4/vscode-lean4/src/utils/elan.js +0 -4
- package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.d.ts +0 -21
- package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.js +0 -53
- package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.d.ts +0 -35
- package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.js +0 -136
- package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.d.ts +0 -17
- package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.js +0 -36
- package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.d.ts +0 -37
- package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.js +0 -210
- package/dist/monaco-lean4/vscode-lean4/src/utils/logger.d.ts +0 -7
- package/dist/monaco-lean4/vscode-lean4/src/utils/logger.js +0 -20
- package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.d.ts +0 -24
- package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.js +0 -110
- package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.d.ts +0 -9
- package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.js +0 -125
- package/dist/useragent.d.ts +0 -1
- package/dist/useragent.js +0 -31
- package/dist/vscode.css +0 -7
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AbbreviationProvider } from '@leanprover/unicode-input';
|
|
2
|
-
import { OutputChannel } from 'vscode';
|
|
3
|
-
import { SelectionMoveMode } from '@leanprover/unicode-input';
|
|
4
|
-
export declare class AbbreviationFeature {
|
|
5
|
-
private readonly disposables;
|
|
6
|
-
readonly abbreviations: AbbreviationProvider;
|
|
7
|
-
constructor(outputChannel: OutputChannel, selectionMoveMove?: SelectionMoveMode);
|
|
8
|
-
dispose(): void;
|
|
9
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AbbreviationProvider } from '@leanprover/unicode-input';
|
|
2
|
-
import { languages } from 'vscode';
|
|
3
|
-
import { AbbreviationHoverProvider } from './AbbreviationHoverProvider';
|
|
4
|
-
import { AbbreviationRewriterFeature } from './AbbreviationRewriterFeature';
|
|
5
|
-
import { VSCodeAbbreviationConfig } from './VSCodeAbbreviationConfig';
|
|
6
|
-
export class AbbreviationFeature {
|
|
7
|
-
disposables = new Array();
|
|
8
|
-
abbreviations;
|
|
9
|
-
constructor(outputChannel, selectionMoveMove) {
|
|
10
|
-
const config = new VSCodeAbbreviationConfig();
|
|
11
|
-
this.disposables.push(config);
|
|
12
|
-
this.abbreviations = new AbbreviationProvider(config);
|
|
13
|
-
this.disposables.push(languages.registerHoverProvider(config.languages, new AbbreviationHoverProvider(config, this.abbreviations)), new AbbreviationRewriterFeature(config, this.abbreviations, outputChannel, selectionMoveMove));
|
|
14
|
-
}
|
|
15
|
-
dispose() {
|
|
16
|
-
for (const d of this.disposables) {
|
|
17
|
-
d.dispose();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AbbreviationConfig, AbbreviationProvider } from '@leanprover/unicode-input';
|
|
2
|
-
import { Hover, HoverProvider, Position, TextDocument } from 'vscode';
|
|
3
|
-
/**
|
|
4
|
-
* Adds hover behaviour for getting translations of unicode characters.
|
|
5
|
-
* Eg: "Type ⊓ using \glb or \sqcap"
|
|
6
|
-
*/
|
|
7
|
-
export declare class AbbreviationHoverProvider implements HoverProvider {
|
|
8
|
-
private readonly config;
|
|
9
|
-
private readonly abbreviations;
|
|
10
|
-
constructor(config: AbbreviationConfig, abbreviations: AbbreviationProvider);
|
|
11
|
-
provideHover(document: TextDocument, pos: Position): Hover | undefined;
|
|
12
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Hover, Range } from 'vscode';
|
|
2
|
-
/**
|
|
3
|
-
* Adds hover behaviour for getting translations of unicode characters.
|
|
4
|
-
* Eg: "Type ⊓ using \glb or \sqcap"
|
|
5
|
-
*/
|
|
6
|
-
export class AbbreviationHoverProvider {
|
|
7
|
-
config;
|
|
8
|
-
abbreviations;
|
|
9
|
-
constructor(config, abbreviations) {
|
|
10
|
-
this.config = config;
|
|
11
|
-
this.abbreviations = abbreviations;
|
|
12
|
-
}
|
|
13
|
-
provideHover(document, pos) {
|
|
14
|
-
const context = document.lineAt(pos.line).text.substr(pos.character);
|
|
15
|
-
const symbolsAtCursor = this.abbreviations.findSymbolsIn(context);
|
|
16
|
-
const allAbbrevs = symbolsAtCursor.map(symbol => ({
|
|
17
|
-
symbol,
|
|
18
|
-
abbrevs: this.abbreviations.collectAllAbbreviations(symbol),
|
|
19
|
-
}));
|
|
20
|
-
if (allAbbrevs.length === 0 || allAbbrevs.every(a => a.abbrevs.length === 0)) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
const leader = this.config.abbreviationCharacter;
|
|
24
|
-
const hoverMarkdown = allAbbrevs
|
|
25
|
-
.map(({ symbol, abbrevs }) => {
|
|
26
|
-
const abbrevInfo = `Type ${symbol} using ${abbrevs.map(a => '`' + leader + a + '`').join(' or ')}`;
|
|
27
|
-
const autoClosingAbbrevs = this.abbreviations.findAutoClosingAbbreviations(symbol);
|
|
28
|
-
const autoClosingInfo = autoClosingAbbrevs.length === 0
|
|
29
|
-
? ''
|
|
30
|
-
: `. ${symbol} can be auto-closed with ${autoClosingAbbrevs
|
|
31
|
-
.map(([a, closingSym]) => `${closingSym} using \`${leader}${a}\``)
|
|
32
|
-
.join(' or ')}.`;
|
|
33
|
-
return abbrevInfo + autoClosingInfo;
|
|
34
|
-
})
|
|
35
|
-
.join('\n\n');
|
|
36
|
-
const maxSymbolLength = Math.max(...allAbbrevs.map(a => a.symbol.length));
|
|
37
|
-
const hoverRange = new Range(pos, pos.translate(0, maxSymbolLength));
|
|
38
|
-
return new Hover(hoverMarkdown, hoverRange);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AbbreviationProvider, SelectionMoveMode } from '@leanprover/unicode-input';
|
|
2
|
-
import { OutputChannel } from 'vscode';
|
|
3
|
-
import { VSCodeAbbreviationConfig } from './VSCodeAbbreviationConfig';
|
|
4
|
-
/**
|
|
5
|
-
* Sets up everything required for the abbreviation rewriter feature.
|
|
6
|
-
* Creates an `AbbreviationRewriter` for the active editor.
|
|
7
|
-
*/
|
|
8
|
-
export declare class AbbreviationRewriterFeature {
|
|
9
|
-
private readonly config;
|
|
10
|
-
private readonly abbreviationProvider;
|
|
11
|
-
private readonly outputChannel;
|
|
12
|
-
private readonly selectionMoveMove?;
|
|
13
|
-
private readonly disposables;
|
|
14
|
-
private activeAbbreviationRewriter;
|
|
15
|
-
constructor(config: VSCodeAbbreviationConfig, abbreviationProvider: AbbreviationProvider, outputChannel: OutputChannel, selectionMoveMove?: SelectionMoveMode | undefined);
|
|
16
|
-
private disposeActiveAbbreviationRewriter;
|
|
17
|
-
private changedActiveTextEditor;
|
|
18
|
-
private shouldEnableRewriterForEditor;
|
|
19
|
-
dispose(): void;
|
|
20
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { commands, languages, window, workspace } from 'vscode';
|
|
2
|
-
import { extUriEquals, toExtUri } from '../utils/exturi';
|
|
3
|
-
import { VSCodeAbbreviationRewriter } from './VSCodeAbbreviationRewriter';
|
|
4
|
-
/**
|
|
5
|
-
* Sets up everything required for the abbreviation rewriter feature.
|
|
6
|
-
* Creates an `AbbreviationRewriter` for the active editor.
|
|
7
|
-
*/
|
|
8
|
-
export class AbbreviationRewriterFeature {
|
|
9
|
-
config;
|
|
10
|
-
abbreviationProvider;
|
|
11
|
-
outputChannel;
|
|
12
|
-
selectionMoveMove;
|
|
13
|
-
disposables = new Array();
|
|
14
|
-
activeAbbreviationRewriter;
|
|
15
|
-
constructor(config, abbreviationProvider, outputChannel, selectionMoveMove) {
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.abbreviationProvider = abbreviationProvider;
|
|
18
|
-
this.outputChannel = outputChannel;
|
|
19
|
-
this.selectionMoveMove = selectionMoveMove;
|
|
20
|
-
void this.changedActiveTextEditor(window.activeTextEditor);
|
|
21
|
-
this.disposables.push(commands.registerTextEditorCommand('lean4.input.convert', async () => {
|
|
22
|
-
if (this.activeAbbreviationRewriter === undefined) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
await this.activeAbbreviationRewriter.replaceAllTrackedAbbreviations();
|
|
26
|
-
}), window.onDidChangeActiveTextEditor(editor => this.changedActiveTextEditor(editor)), workspace.onDidOpenTextDocument(async (doc) => {
|
|
27
|
-
// Ensure that we create/remove abbreviation rewriters when the language ID changes
|
|
28
|
-
if (window.activeTextEditor === undefined) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const editorUri = toExtUri(window.activeTextEditor.document.uri);
|
|
32
|
-
const docUri = toExtUri(doc.uri);
|
|
33
|
-
if (editorUri === undefined || docUri === undefined || !extUriEquals(editorUri, docUri)) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (this.activeAbbreviationRewriter === undefined &&
|
|
37
|
-
this.shouldEnableRewriterForEditor(window.activeTextEditor)) {
|
|
38
|
-
this.activeAbbreviationRewriter = new VSCodeAbbreviationRewriter(config, abbreviationProvider, outputChannel, window.activeTextEditor, this.selectionMoveMove);
|
|
39
|
-
}
|
|
40
|
-
else if (this.activeAbbreviationRewriter !== undefined &&
|
|
41
|
-
!this.shouldEnableRewriterForEditor(window.activeTextEditor)) {
|
|
42
|
-
await this.disposeActiveAbbreviationRewriter();
|
|
43
|
-
}
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
async disposeActiveAbbreviationRewriter() {
|
|
47
|
-
if (this.activeAbbreviationRewriter === undefined) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
await this.activeAbbreviationRewriter.replaceAllTrackedAbbreviations();
|
|
51
|
-
this.activeAbbreviationRewriter.dispose();
|
|
52
|
-
this.activeAbbreviationRewriter = undefined;
|
|
53
|
-
}
|
|
54
|
-
async changedActiveTextEditor(activeTextEditor) {
|
|
55
|
-
await this.disposeActiveAbbreviationRewriter();
|
|
56
|
-
if (activeTextEditor === undefined) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (!this.shouldEnableRewriterForEditor(activeTextEditor)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
this.activeAbbreviationRewriter = new VSCodeAbbreviationRewriter(this.config, this.abbreviationProvider, this.outputChannel, activeTextEditor, this.selectionMoveMove);
|
|
63
|
-
}
|
|
64
|
-
shouldEnableRewriterForEditor(editor) {
|
|
65
|
-
if (!this.config.inputModeEnabled) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
if (!languages.match(this.config.languages, editor.document)) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
dispose() {
|
|
74
|
-
for (const d of this.disposables) {
|
|
75
|
-
d.dispose();
|
|
76
|
-
}
|
|
77
|
-
this.activeAbbreviationRewriter?.dispose();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AbbreviationConfig, SymbolsByAbbreviation } from '@leanprover/unicode-input';
|
|
2
|
-
import { Disposable } from 'vscode';
|
|
3
|
-
export declare class VSCodeAbbreviationConfig implements AbbreviationConfig, Disposable {
|
|
4
|
-
abbreviationCharacter: string;
|
|
5
|
-
customTranslations: SymbolsByAbbreviation;
|
|
6
|
-
eagerReplacementEnabled: boolean;
|
|
7
|
-
inputModeEnabled: boolean;
|
|
8
|
-
languages: string[];
|
|
9
|
-
private subscriptions;
|
|
10
|
-
constructor();
|
|
11
|
-
private reloadConfig;
|
|
12
|
-
dispose(): void;
|
|
13
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { workspace } from 'vscode';
|
|
2
|
-
export class VSCodeAbbreviationConfig {
|
|
3
|
-
abbreviationCharacter;
|
|
4
|
-
customTranslations;
|
|
5
|
-
eagerReplacementEnabled;
|
|
6
|
-
inputModeEnabled;
|
|
7
|
-
languages;
|
|
8
|
-
subscriptions = [];
|
|
9
|
-
constructor() {
|
|
10
|
-
this.reloadConfig();
|
|
11
|
-
this.subscriptions.push(workspace.onDidChangeConfiguration(e => {
|
|
12
|
-
if (e.affectsConfiguration('lean4.input')) {
|
|
13
|
-
this.reloadConfig();
|
|
14
|
-
}
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
reloadConfig() {
|
|
18
|
-
this.inputModeEnabled = workspace.getConfiguration('lean4.input').get('enabled', true);
|
|
19
|
-
this.abbreviationCharacter = workspace.getConfiguration('lean4.input').get('leader', '\\');
|
|
20
|
-
this.languages = workspace.getConfiguration('lean4.input').get('languages', ['lean4']);
|
|
21
|
-
this.customTranslations = workspace.getConfiguration('lean4.input').get('customTranslations', {});
|
|
22
|
-
this.eagerReplacementEnabled = workspace.getConfiguration('lean4.input').get('eagerReplacementEnabled', true);
|
|
23
|
-
}
|
|
24
|
-
dispose() {
|
|
25
|
-
for (const s of this.subscriptions) {
|
|
26
|
-
s.dispose();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { AbbreviationConfig, AbbreviationProvider, AbbreviationTextSource, Change, Range, SelectionMoveMode } from '@leanprover/unicode-input';
|
|
2
|
-
import { OutputChannel, TextEditor } from 'vscode';
|
|
3
|
-
/**
|
|
4
|
-
* Tracks abbreviations in a given text editor and replaces them when dynamically.
|
|
5
|
-
*/
|
|
6
|
-
export declare class VSCodeAbbreviationRewriter implements AbbreviationTextSource {
|
|
7
|
-
readonly config: AbbreviationConfig;
|
|
8
|
-
readonly abbreviationProvider: AbbreviationProvider;
|
|
9
|
-
private readonly outputChannel;
|
|
10
|
-
private readonly textEditor;
|
|
11
|
-
private selectionMoveMoveOverride?;
|
|
12
|
-
private readonly disposables;
|
|
13
|
-
private readonly rewriter;
|
|
14
|
-
private readonly decorationType;
|
|
15
|
-
private firstOutput;
|
|
16
|
-
private isVimExtensionInstalled;
|
|
17
|
-
private checkIsVimExtensionInstalled;
|
|
18
|
-
constructor(config: AbbreviationConfig, abbreviationProvider: AbbreviationProvider, outputChannel: OutputChannel, textEditor: TextEditor, selectionMoveMoveOverride?: SelectionMoveMode | undefined);
|
|
19
|
-
private writeError;
|
|
20
|
-
selectionMoveMode(): SelectionMoveMode;
|
|
21
|
-
collectSelections(): Range[];
|
|
22
|
-
setSelections(selections: Range[]): void;
|
|
23
|
-
replaceAbbreviations(changes: Change[]): Promise<boolean>;
|
|
24
|
-
replaceAllTrackedAbbreviations(): Promise<void>;
|
|
25
|
-
private updateState;
|
|
26
|
-
private setInputActive;
|
|
27
|
-
dispose(): void;
|
|
28
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { AbbreviationRewriter, Range, } from '@leanprover/unicode-input';
|
|
2
|
-
import { Range as LineColRange, Selection, commands, extensions, window, workspace, } from 'vscode';
|
|
3
|
-
/**
|
|
4
|
-
* Tracks abbreviations in a given text editor and replaces them when dynamically.
|
|
5
|
-
*/
|
|
6
|
-
export class VSCodeAbbreviationRewriter {
|
|
7
|
-
config;
|
|
8
|
-
abbreviationProvider;
|
|
9
|
-
outputChannel;
|
|
10
|
-
textEditor;
|
|
11
|
-
selectionMoveMoveOverride;
|
|
12
|
-
disposables = new Array();
|
|
13
|
-
rewriter;
|
|
14
|
-
decorationType = window.createTextEditorDecorationType({
|
|
15
|
-
textDecoration: 'underline',
|
|
16
|
-
});
|
|
17
|
-
firstOutput = true;
|
|
18
|
-
isVimExtensionInstalled = false;
|
|
19
|
-
checkIsVimExtensionInstalled() {
|
|
20
|
-
this.isVimExtensionInstalled = extensions.getExtension('vscodevim.vim') !== undefined;
|
|
21
|
-
}
|
|
22
|
-
constructor(config, abbreviationProvider, outputChannel, textEditor, selectionMoveMoveOverride) {
|
|
23
|
-
this.config = config;
|
|
24
|
-
this.abbreviationProvider = abbreviationProvider;
|
|
25
|
-
this.outputChannel = outputChannel;
|
|
26
|
-
this.textEditor = textEditor;
|
|
27
|
-
this.selectionMoveMoveOverride = selectionMoveMoveOverride;
|
|
28
|
-
this.rewriter = new AbbreviationRewriter(config, abbreviationProvider, this);
|
|
29
|
-
this.disposables.push(this.decorationType);
|
|
30
|
-
this.disposables.push(workspace.onDidChangeTextDocument(async (e) => {
|
|
31
|
-
if (e.document !== this.textEditor.document) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const changes = e.contentChanges.map(changeEvent => ({
|
|
35
|
-
range: new Range(changeEvent.rangeOffset, changeEvent.rangeLength),
|
|
36
|
-
newText: changeEvent.text,
|
|
37
|
-
}));
|
|
38
|
-
this.rewriter.changeInput(changes);
|
|
39
|
-
await this.rewriter.triggerAbbreviationReplacement();
|
|
40
|
-
this.updateState();
|
|
41
|
-
}));
|
|
42
|
-
this.disposables.push(window.onDidChangeTextEditorSelection(async (e) => {
|
|
43
|
-
if (e.textEditor.document !== this.textEditor.document) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const selections = e.selections.map(s => fromVsCodeRange(s, e.textEditor.document));
|
|
47
|
-
await this.rewriter.changeSelections(selections);
|
|
48
|
-
this.updateState();
|
|
49
|
-
}));
|
|
50
|
-
this.checkIsVimExtensionInstalled();
|
|
51
|
-
this.disposables.push(extensions.onDidChange(_ => this.checkIsVimExtensionInstalled()));
|
|
52
|
-
}
|
|
53
|
-
writeError(e) {
|
|
54
|
-
this.outputChannel.appendLine(e);
|
|
55
|
-
if (this.firstOutput) {
|
|
56
|
-
this.outputChannel.show(true);
|
|
57
|
-
this.firstOutput = false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
selectionMoveMode() {
|
|
61
|
-
return this.selectionMoveMoveOverride ?? { kind: 'OnlyMoveCursorSelections', updateUnchangedSelections: this.isVimExtensionInstalled };
|
|
62
|
-
}
|
|
63
|
-
collectSelections() {
|
|
64
|
-
return this.textEditor.selections.map(s => fromVsCodeRange(s, this.textEditor.document));
|
|
65
|
-
}
|
|
66
|
-
setSelections(selections) {
|
|
67
|
-
this.textEditor.selections = selections.map(s => {
|
|
68
|
-
const vr = toVsCodeRange(s, this.textEditor.document);
|
|
69
|
-
return new Selection(vr.start, vr.end);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
async replaceAbbreviations(changes) {
|
|
73
|
-
let ok = false;
|
|
74
|
-
let retries = 0;
|
|
75
|
-
try {
|
|
76
|
-
// The user may have changed the text document in-between `this.textEditor` being updated
|
|
77
|
-
// (when the call to the extension was started) and `this.textEditor.edit()` being executed.
|
|
78
|
-
// In this case, since the state of the editor that the extension sees and the state that
|
|
79
|
-
// the user sees are different, VS Code will reject the edit.
|
|
80
|
-
// This occurs especially often in setups with increased latency until the extension is triggered,
|
|
81
|
-
// e.g. an SSH setup. Since VS Code does not appear to support an atomic read -> write operation,
|
|
82
|
-
// unfortunately the only thing we can do here is to retry.
|
|
83
|
-
while (!ok && retries < 10) {
|
|
84
|
-
ok = await this.textEditor.edit(builder => {
|
|
85
|
-
for (const c of changes) {
|
|
86
|
-
builder.replace(toVsCodeRange(c.range, this.textEditor.document), c.newText);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
retries++;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
this.writeError('Error while replacing abbreviation: ' + e);
|
|
94
|
-
}
|
|
95
|
-
return ok;
|
|
96
|
-
}
|
|
97
|
-
async replaceAllTrackedAbbreviations() {
|
|
98
|
-
await this.rewriter.replaceAllTrackedAbbreviations();
|
|
99
|
-
this.updateState();
|
|
100
|
-
}
|
|
101
|
-
updateState() {
|
|
102
|
-
const trackedAbbreviations = this.rewriter.getTrackedAbbreviations();
|
|
103
|
-
this.textEditor.setDecorations(this.decorationType, [...trackedAbbreviations].map(a => toVsCodeRange(a.range, this.textEditor.document)));
|
|
104
|
-
void this.setInputActive(trackedAbbreviations.size > 0);
|
|
105
|
-
}
|
|
106
|
-
async setInputActive(isActive) {
|
|
107
|
-
await commands.executeCommand('setContext', 'lean4.input.isActive', isActive);
|
|
108
|
-
}
|
|
109
|
-
dispose() {
|
|
110
|
-
for (const d of this.disposables) {
|
|
111
|
-
d.dispose();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function fromVsCodeRange(range, doc) {
|
|
116
|
-
const start = doc.offsetAt(range.start);
|
|
117
|
-
const end = doc.offsetAt(range.end);
|
|
118
|
-
return new Range(start, end - start);
|
|
119
|
-
}
|
|
120
|
-
function toVsCodeRange(range, doc) {
|
|
121
|
-
const start = doc.positionAt(range.offset);
|
|
122
|
-
const end = doc.positionAt(range.offsetEnd + 1);
|
|
123
|
-
return new LineColRange(start, end);
|
|
124
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { PATH } from './utils/envPath';
|
|
2
|
-
export declare function getPowerShellPath(): string;
|
|
3
|
-
export declare function automaticallyBuildDependencies(): boolean;
|
|
4
|
-
export declare function envPathExtensions(): PATH;
|
|
5
|
-
export declare function serverArgs(): string[];
|
|
6
|
-
export declare function serverLoggingEnabled(): boolean;
|
|
7
|
-
export declare function serverLoggingPath(): string;
|
|
8
|
-
export declare function shouldAutofocusOutput(): boolean;
|
|
9
|
-
export declare function getInfoViewStyle(): string;
|
|
10
|
-
export declare function getInfoViewAutoOpen(): boolean;
|
|
11
|
-
export declare function getInfoViewAutoOpenShowsGoal(): boolean;
|
|
12
|
-
export declare function getInfoViewAllErrorsOnLine(): boolean;
|
|
13
|
-
export declare function getInfoViewDebounceTime(): number;
|
|
14
|
-
export declare function getInfoViewShowExpectedType(): boolean;
|
|
15
|
-
export declare function getInfoViewShowGoalNames(): boolean;
|
|
16
|
-
export declare function getInfoViewEmphasizeFirstGoal(): boolean;
|
|
17
|
-
export declare function getInfoViewReverseTacticState(): boolean;
|
|
18
|
-
export declare function getInfoViewShowTooltipOnHover(): boolean;
|
|
19
|
-
export declare function getElaborationDelay(): number;
|
|
20
|
-
export declare function shouldShowSetupWarnings(): boolean;
|
|
21
|
-
export declare function getFallBackToStringOccurrenceHighlighting(): boolean;
|
|
22
|
-
export declare function isRunningTest(): boolean;
|
|
23
|
-
export declare function getTestFolder(): string;
|
|
24
|
-
export declare function getDefaultLeanVersion(): string;
|
|
25
|
-
/** The editor line height, in pixels. */
|
|
26
|
-
export declare function getEditorLineHeight(): number;
|
|
27
|
-
/**
|
|
28
|
-
* The literal 'production' or 'development', depending on the build.
|
|
29
|
-
* Should be turned into a string literal by build tools.
|
|
30
|
-
*/
|
|
31
|
-
export declare const prodOrDev: string;
|
|
32
|
-
/** The literal '.min' or empty, depending on the build. See {@link prodOrDev}. */
|
|
33
|
-
export declare const minIfProd: string;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { workspace } from 'vscode';
|
|
2
|
-
import { PATH } from './utils/envPath';
|
|
3
|
-
// TODO: does currently not contain config options for `./abbreviation`
|
|
4
|
-
// so that it is easy to keep it in sync with vscode-lean.
|
|
5
|
-
export function getPowerShellPath() {
|
|
6
|
-
const windir = process.env.windir;
|
|
7
|
-
return `${windir}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
8
|
-
}
|
|
9
|
-
export function automaticallyBuildDependencies() {
|
|
10
|
-
return workspace.getConfiguration('lean4').get('automaticallyBuildDependencies', false);
|
|
11
|
-
}
|
|
12
|
-
export function envPathExtensions() {
|
|
13
|
-
return new PATH(workspace.getConfiguration('lean4').get('envPathExtensions', []));
|
|
14
|
-
}
|
|
15
|
-
export function serverArgs() {
|
|
16
|
-
return workspace.getConfiguration('lean4').get('serverArgs', []);
|
|
17
|
-
}
|
|
18
|
-
export function serverLoggingEnabled() {
|
|
19
|
-
return workspace.getConfiguration('lean4.serverLogging').get('enabled', false);
|
|
20
|
-
}
|
|
21
|
-
export function serverLoggingPath() {
|
|
22
|
-
return workspace.getConfiguration('lean4.serverLogging').get('path', '.');
|
|
23
|
-
}
|
|
24
|
-
export function shouldAutofocusOutput() {
|
|
25
|
-
return workspace.getConfiguration('lean4').get('autofocusOutput', false);
|
|
26
|
-
}
|
|
27
|
-
export function getInfoViewStyle() {
|
|
28
|
-
const val = workspace.getConfiguration('lean4.infoview').get('style');
|
|
29
|
-
if (val !== undefined)
|
|
30
|
-
return val;
|
|
31
|
-
// Try deprecated name of the same setting if not found
|
|
32
|
-
return workspace.getConfiguration('lean4').get('infoViewStyle', '');
|
|
33
|
-
}
|
|
34
|
-
export function getInfoViewAutoOpen() {
|
|
35
|
-
const val = workspace.getConfiguration('lean4.infoview').get('autoOpen');
|
|
36
|
-
if (val !== undefined)
|
|
37
|
-
return val;
|
|
38
|
-
return workspace.getConfiguration('lean4').get('infoViewAutoOpen', true);
|
|
39
|
-
}
|
|
40
|
-
export function getInfoViewAutoOpenShowsGoal() {
|
|
41
|
-
const val = workspace.getConfiguration('lean4.infoview').get('autoOpenShowsGoal');
|
|
42
|
-
if (val !== undefined)
|
|
43
|
-
return val;
|
|
44
|
-
return workspace.getConfiguration('lean4').get('infoViewAutoOpenShowGoal', true);
|
|
45
|
-
}
|
|
46
|
-
export function getInfoViewAllErrorsOnLine() {
|
|
47
|
-
const val = workspace.getConfiguration('lean4.infoview').get('allErrorsOnLine');
|
|
48
|
-
if (val !== undefined)
|
|
49
|
-
return val;
|
|
50
|
-
return workspace.getConfiguration('lean4').get('infoViewAllErrorsOnLine', true);
|
|
51
|
-
}
|
|
52
|
-
export function getInfoViewDebounceTime() {
|
|
53
|
-
return workspace.getConfiguration('lean4.infoview').get('debounceTime', 50);
|
|
54
|
-
}
|
|
55
|
-
export function getInfoViewShowExpectedType() {
|
|
56
|
-
return workspace.getConfiguration('lean4.infoview').get('showExpectedType', true);
|
|
57
|
-
}
|
|
58
|
-
export function getInfoViewShowGoalNames() {
|
|
59
|
-
return workspace.getConfiguration('lean4.infoview').get('showGoalNames', true);
|
|
60
|
-
}
|
|
61
|
-
export function getInfoViewEmphasizeFirstGoal() {
|
|
62
|
-
return workspace.getConfiguration('lean4.infoview').get('emphasizeFirstGoal', false);
|
|
63
|
-
}
|
|
64
|
-
export function getInfoViewReverseTacticState() {
|
|
65
|
-
return workspace.getConfiguration('lean4.infoview').get('reverseTacticState', false);
|
|
66
|
-
}
|
|
67
|
-
export function getInfoViewShowTooltipOnHover() {
|
|
68
|
-
return workspace.getConfiguration('lean4.infoview').get('showTooltipOnHover', true);
|
|
69
|
-
}
|
|
70
|
-
export function getElaborationDelay() {
|
|
71
|
-
return workspace.getConfiguration('lean4').get('elaborationDelay', 200);
|
|
72
|
-
}
|
|
73
|
-
export function shouldShowSetupWarnings() {
|
|
74
|
-
return workspace.getConfiguration('lean4').get('showSetupWarnings', true);
|
|
75
|
-
}
|
|
76
|
-
export function getFallBackToStringOccurrenceHighlighting() {
|
|
77
|
-
return workspace.getConfiguration('lean4').get('fallBackToStringOccurrenceHighlighting', false);
|
|
78
|
-
}
|
|
79
|
-
export function isRunningTest() {
|
|
80
|
-
return typeof process.env.LEAN4_TEST_FOLDER === 'string';
|
|
81
|
-
}
|
|
82
|
-
export function getTestFolder() {
|
|
83
|
-
return typeof process.env.LEAN4_TEST_FOLDER === 'string' ? process.env.LEAN4_TEST_FOLDER : '';
|
|
84
|
-
}
|
|
85
|
-
export function getDefaultLeanVersion() {
|
|
86
|
-
return typeof process.env.DEFAULT_LEAN_TOOLCHAIN === 'string'
|
|
87
|
-
? process.env.DEFAULT_LEAN_TOOLCHAIN
|
|
88
|
-
: 'leanprover/lean4:stable';
|
|
89
|
-
}
|
|
90
|
-
/** The editor line height, in pixels. */
|
|
91
|
-
export function getEditorLineHeight() {
|
|
92
|
-
// The implementation
|
|
93
|
-
// (recommended by Microsoft: https://github.com/microsoft/vscode/issues/125341#issuecomment-854812591)
|
|
94
|
-
// is absolutely cursed. It's just to copy whatever VSCode does internally.
|
|
95
|
-
const fontSize = workspace.getConfiguration('editor').get('fontSize') ?? 0;
|
|
96
|
-
let lineHeight = workspace.getConfiguration('editor').get('lineHeight') ?? 0;
|
|
97
|
-
const GOLDEN_LINE_HEIGHT_RATIO = process.platform === 'darwin' ? 1.5 : 1.35;
|
|
98
|
-
const MINIMUM_LINE_HEIGHT = 8;
|
|
99
|
-
if (lineHeight === 0) {
|
|
100
|
-
lineHeight = GOLDEN_LINE_HEIGHT_RATIO * fontSize;
|
|
101
|
-
}
|
|
102
|
-
else if (lineHeight < MINIMUM_LINE_HEIGHT) {
|
|
103
|
-
// Values too small to be line heights in pixels are in ems.
|
|
104
|
-
lineHeight = lineHeight * fontSize;
|
|
105
|
-
}
|
|
106
|
-
// Enforce integer, minimum constraints
|
|
107
|
-
lineHeight = Math.round(lineHeight);
|
|
108
|
-
if (lineHeight < MINIMUM_LINE_HEIGHT) {
|
|
109
|
-
lineHeight = MINIMUM_LINE_HEIGHT;
|
|
110
|
-
}
|
|
111
|
-
return lineHeight;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* The literal 'production' or 'development', depending on the build.
|
|
115
|
-
* Should be turned into a string literal by build tools.
|
|
116
|
-
*/
|
|
117
|
-
export const prodOrDev = process.env.NODE_ENV && process.env.NODE_ENV === 'production' ? 'production' : 'development';
|
|
118
|
-
/** The literal '.min' or empty, depending on the build. See {@link prodOrDev}. */
|
|
119
|
-
export const minIfProd = process.env.NODE_ENV && process.env.NODE_ENV === 'production' ? '.min' : '';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { SemVer } from 'semver';
|
|
2
|
-
import { LeanInstaller } from '../utils/leanInstaller';
|
|
3
|
-
export type PreconditionCheckResult = 'Fulfilled' | 'Warning' | 'Fatal';
|
|
4
|
-
export declare function preconditionCheckResultToSeverity(result: PreconditionCheckResult): 0 | 1 | 2;
|
|
5
|
-
export declare function severityToPreconditionCheckResult(severity: 0 | 1 | 2): PreconditionCheckResult;
|
|
6
|
-
export declare function worstPreconditionViolation(...results: PreconditionCheckResult[]): PreconditionCheckResult;
|
|
7
|
-
export type SetupWarningOptions = {
|
|
8
|
-
modal: true;
|
|
9
|
-
} | {
|
|
10
|
-
modal: false;
|
|
11
|
-
finalizer?: (() => void) | undefined;
|
|
12
|
-
};
|
|
13
|
-
export declare function displaySetupError(message: string, finalizer?: (() => void) | undefined): PreconditionCheckResult;
|
|
14
|
-
export declare function displaySetupErrorWithInput<T extends string>(message: string, ...items: T[]): Promise<T | undefined>;
|
|
15
|
-
export declare function displaySetupErrorWithOptionalInput<T extends string>(message: string, input: T, action: () => void, finalizer?: (() => void) | undefined): PreconditionCheckResult;
|
|
16
|
-
export declare function displaySetupErrorWithOutput(message: string, finalizer?: (() => void) | undefined): PreconditionCheckResult;
|
|
17
|
-
export declare function displaySetupErrorWithSetupGuide(message: string, finalizer?: (() => void) | undefined): PreconditionCheckResult;
|
|
18
|
-
export declare function displayDependencySetupError(missingDeps: string[]): PreconditionCheckResult;
|
|
19
|
-
export declare function displayElanSetupError(installer: LeanInstaller, reason: string): Promise<PreconditionCheckResult>;
|
|
20
|
-
export declare function displayElanOutdatedSetupError(installer: LeanInstaller, currentVersion: SemVer, recommendedVersion: SemVer): Promise<PreconditionCheckResult>;
|
|
21
|
-
export declare function displaySetupWarning(message: string, options?: SetupWarningOptions): Promise<PreconditionCheckResult>;
|
|
22
|
-
export declare function displaySetupWarningWithInput<T extends string>(message: string, ...items: T[]): Promise<T | undefined>;
|
|
23
|
-
export declare function displaySetupWarningWithOptionalInput<T extends string>(message: string, input: T, action: () => void, finalizer?: (() => void) | undefined): PreconditionCheckResult;
|
|
24
|
-
export declare function displaySetupWarningWithOutput(message: string, options?: SetupWarningOptions): Promise<PreconditionCheckResult>;
|
|
25
|
-
export declare function displaySetupWarningWithSetupGuide(message: string, options?: SetupWarningOptions): Promise<PreconditionCheckResult>;
|
|
26
|
-
export declare function displayElanSetupWarning(installer: LeanInstaller, reason: string): Promise<PreconditionCheckResult>;
|
|
27
|
-
export declare function displayElanOutdatedSetupWarning(installer: LeanInstaller, currentVersion: SemVer, recommendedVersion: SemVer): Promise<PreconditionCheckResult>;
|