Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,12 @@
"default": false,
"markdownDescription": "Enable the knowledge-base *tools* in the MCP server in addition to the knowledge-base *resources*. The two tools tlaplus_mcp_knowledge_list and tlaplus_mcp_knowledge_get allow you to search and read TLA+ knowledge-base articles as MCP tools. Restart VSCode to apply the changes. You’ll rarely need to enable this option, since both VSCode and Cursor already support MCP resources."
},
"tlaplus.unicode.autocomplete": {
"type": "boolean",
"scope": "window",
"default": false,
"markdownDescription": "Enable Unicode autocomplete in the editor. Requires reload to update."
},
"tlaplus.pdf.convertCommand": {
"default": "pdflatex",
"type": "string",
Expand Down
63 changes: 60 additions & 3 deletions src/completions/tlaCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,64 @@
import { getPrevText } from './completions';

export const TLA_OPERATORS = [
'E', 'A', 'X', 'lnot', 'land', 'lor', 'cdot', 'equiv', 'subseteq', 'in', 'notin', 'intersect',
'union', 'leq', 'geq', 'cup', 'cap'
'land', 'lor', 'implies',

Check warning on line 6 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''implies''

Check warning on line 6 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''lor''

Check warning on line 6 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''implies''

Check warning on line 6 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''lor''

Check warning on line 6 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''implies''

Check warning on line 6 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''lor''
'lnot', 'equiv', 'equiv',

Check warning on line 7 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''equiv''

Check warning on line 7 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''equiv''

Check warning on line 7 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''equiv''

Check warning on line 7 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''equiv''

Check warning on line 7 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''equiv''

Check warning on line 7 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''equiv''
'in', 'notin', 'ne',

Check warning on line 8 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''ne''

Check warning on line 8 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''notin''

Check warning on line 8 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''ne''

Check warning on line 8 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''notin''

Check warning on line 8 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''ne''

Check warning on line 8 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''notin''
'll', 'gg', '[]',

Check warning on line 9 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''[]''

Check warning on line 9 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''gg''

Check warning on line 9 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''[]''

Check warning on line 9 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''gg''

Check warning on line 9 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''[]''

Check warning on line 9 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''gg''
'leq', 'geq', '<>',

Check warning on line 10 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''<>''

Check warning on line 10 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Multiple spaces found before ''geq''

Check warning on line 10 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''<>''

Check warning on line 10 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Multiple spaces found before ''geq''

Check warning on line 10 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''<>''

Check warning on line 10 in src/completions/tlaCompletions.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Multiple spaces found before ''geq''
'll', 'gg', '~>',
'prec', 'succ', '-+->',
'preceq', 'succeq', 'div',
'subseteq', 'supseteq', 'cdot',
'subset', 'supset', 'o',
'sqsubset', 'sqsupset', 'bullet',
'sqsubseteq', 'sqsupseteq', 'star',
'vdash', 'dashv', 'bigcirc',
'models', 'vDash', 'sim',
'maps', 'leftarrow', 'simeq',
'cap', 'cup', 'asymp',
'sqcap', 'sqcup', 'approx',
'oplus', 'uplus', 'cong',
'ominus', 'X', 'doteq',
'odot', 'wr',
'otimes', 'propto',
'oslash', 's',
'E', 'A',
'EE', 'AA'
];

const enableUnicodeAutocomplete = vscode.workspace.getConfiguration()
.get<boolean>('tlaplus.unicode.autocomplete', false);

const TLA_UNICODE_OPERATORS: Map<string, string> = new Map([
['land', '∧'], ['lor', '∨'], ['implies', '⇒'],
['lnot', '¬'], ['equiv', '≡'], ['triangleq', '≜'],
['in', '∈'], ['notin', '∉'], ['ne', '≠'],
['ll', '≪'], ['gg', '≫'], ['[]', '□'],
['leq', '≤'], ['geq', '≥'], ['<>', '◊'],
['ll', '≪'], ['gg', '≫'], ['~>', '↝'],
['prec', '≺'], ['succ', '≻'], ['-+->', '⇸'],
['preceq', '⪯'], ['succeq', '⪰'], ['div', '÷'],
['subseteq', '⊆'], ['supseteq', '⊇'], ['cdot', '·'],
['subset', '⊂'], ['supset', '⊃'], ['o', '○'],
['sqsubset', '⊏'], ['sqsupset', '⊐'], ['bullet', '•'],
['sqsubseteq', '⊑'], ['sqsupseteq', '⊒'], ['star', '⋆'],
['vdash', '⊢'], ['dashv', '⊣'], ['bigcirc', '◯'],
['models', '⊨'], ['vDash', '=|'], ['sim', '∼'],
['maps', '→'], ['leftarrow', '←'], ['simeq', '≃'],
['cap', '∩'], ['cup', '∪'], ['asymp', '≍'],
['sqcap', '⊓'], ['sqcup', '⊔'], ['approx', '≈'],
['oplus', '⊕'], ['uplus', '⊎'], ['cong', '≅'],
['ominus', '⊖'], ['X', '×'], ['doteq', '≐'],
['odot', '⊙'], ['wr', '≀'],
['otimes', '⊗'], ['propto', '∝'],
['oslash', '⊘'],
['E', '∃'], ['A', '∀'],
['EE', '∃'], ['AA', '∀'],
// Repeats
['times', '×'], ['circ', '∘'], ['intersect', '∩'], ['union', '∪'],
]);

export const TLA_STARTING_KEYWORDS = [ // These keywords start blocks, and should not be in the middle of an expression
'EXTENDS', 'VARIABLE', 'VARIABLES', 'CONSTANT', 'CONSTANTS', 'ASSUME', 'ASSUMPTION', 'AXIOM', 'THEOREM',
'PROOF', 'LEMMA', 'PROPOSITION', 'COROLLARY', 'RECURSIVE'
Expand Down Expand Up @@ -95,7 +150,9 @@
item.insertText = item.label + ' ';
break;
case vscode.CompletionItemKind.Operator:
item.insertText = item.label.toString().substring(1) + ' ';
item.insertText = enableUnicodeAutocomplete ?
TLA_UNICODE_OPERATORS.get(item.label.toString().substring(1)) + ' ' :
item.label.toString().substring(1) + ' ';
break;
}
return item;
Expand Down
Loading