Skip to content

Commit

Permalink
Update grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
jroesch committed Jan 9, 2017
1 parent 90fa8e4 commit 526799a
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 250 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ We currently support:

## Requirements

If you have any requirements or dependencies, add a section describing those and how to install and configure them.
This extension requires an installation of Lean. It is possible
to customize the Lean executable path.

## Extension Settings

Expand All @@ -24,26 +25,30 @@ This extension contributes the following settings:

## Known Issues

* We currently don't support Unicode input.
* Completion still behaves weirdly with hierarchial names

## Release Notes

### 0.6.0

Bug fixes, stability, and a handful of feature improvements
TBD

### 0.4.0

Implement most features of the EMACS mode. We now support:
Implement many features implemented by the EMACS mode. We now support:

- Hovering over definitions for type information
- Go-to-definition & peeking for top-level constants
- Hovering over names for type information
- Go-to-definition & peeking for constants
- Goal support, with the ability to display the
goal at the current position in an output buffer.
- Basic completion support
goal at the current position.
- Basic auto-completion support
- Diagnostics support, dispalying errors, information
& warnings.

### 0.3.0

Added basic integration with the Lean server.
Add basic integration with the Lean server.

### 0.1.0

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{
"language": "lean",
"scopeName": "source.lean",
"path": "./syntaxes/lean.tmLanguage"
"path": "./syntaxes/lean.tmLanguage.json"
}
],
"keybindings": [
Expand Down
18 changes: 8 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function isChangeEvent(e : SyncEvent) : e is vscode.TextDocumentChangeEvent {
return (e as vscode.TextDocumentChangeEvent).document !== undefined;
}


// Seeing .olean files in the source tree is annoying, we should
// just globally hide them.
function configExcludeOLean() {
Expand All @@ -63,19 +62,10 @@ function configExcludeOLean() {
files.update('exclude', exclude, true);
}

function configInputAssistLean() {
let inputAssist = vscode.workspace.getConfiguration('input-assist');
let languages = inputAssist.get('languages') as Array<string>;
languages = languages || [];
languages.push("lean");
inputAssist.update('languages', languages, true);
}

let server : Server;

export function activate(context: vscode.ExtensionContext) {
configExcludeOLean();
configInputAssistLean();

let working_directory = vscode.workspace.rootPath;
let config = vscode.workspace.getConfiguration('lean')
Expand Down Expand Up @@ -169,4 +159,12 @@ export function activate(context: vscode.ExtensionContext) {

// Sync files that are already open.
vscode.workspace.textDocuments.forEach(syncLeanFile);

// Add item to the status bar.
let statusBar = vscode.window.createStatusBarItem();

statusBar.text = "Lean is Running";
statusBar.show();
// Remember to dispose of the status bar.
context.subscriptions.push(statusBar);
}
5 changes: 5 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Server {
tasks : Array<Message>;
senders : SequenceMap;
onMessageCallback : (a : any) => any;
onTaskCallback : (a : any) => any;

constructor(executablePath : string, projectRoot : string) {
this.executablePath = executablePath || "lean";
Expand Down Expand Up @@ -182,6 +183,10 @@ class Server {
this.onMessageCallback = callback;
}

onTask(callback) {
this.onTaskCallback = callback;
}

restart(projectRoot : string) {
this.process.kill();
this.process = child.spawn(
Expand Down
144 changes: 144 additions & 0 deletions syntaxes/lean.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"fileTypes": [
"lean",
"hlean"
],
"name": "Lean",
"patterns": [
{
"include": "#dashComment"
},
{
"include": "#blockComment"
},
{
"begin": "^\\s*(import)\\b",
"beginCaptures": {
"1": {
"name": "keyword.other.lean"
}
},
"end": "$",
"name": "meta.import.lean",
"patterns": []
},
{
"begin": "\\b(inductive|structure|record|theorem|proposition|axiom|axioms|lemma|hypothesis|definition|def|instance|class|constant)\\b[ \\t\\n\\r({\\[]+([^ \\t\\n\\r{(\\[]*)",
"beginCaptures": {
"1": {
"name": "keyword.other.lean"
},
"2": {
"name": "variable.language.lean"
}
},
"end": "[ \\t\\n\\r{(\\[]",
"name": "meta.names.lean",
"pattern": []
},
{
"begin": "\"",
"end": "\"",
"name": "string.quoted.double.lean",
"patterns": [
{
"match": "\\\\.",
"name": "constant.character.escape.lean"
}
]
},
{
"match": "\\b(Prop|Type[\\'₊₀-₉]?)",
"name": "storage.type.lean"
},
{
"match": "@\\[[^\\]]*\\]",
"name": "storage.modifier.lean"
},
{
"match": "attribute\\s*\\[[^\\]]*\\]",
"name": "storage.modifier.lean"
},
{
"match": "\\b(import|prelude|theory|protected|private|noncomputable|mutual|meta|definition|def|instance|renaming|hiding|exposing|parameter|parameters|begin|conjecture|constant|constants|hypothesis|lemma|corollary|variable|variables|premise|premises|print|theorem|example|abbreviation|context|open|as|export|axiom|inductive|with|structure|record|universe|universes|alias|help|override|precedence|reserve|postfix|prefix|infix|infixl|infixr|notation|vm_eval|eval|check|exit|end|using|namespace|section|local|set_option|extends|include|omit|class|classes|instances|metaclasses|raw|run_command)\\b",
"name": "keyword.other.lean"
},
{
"match": "\\b(calc|have|assert|suppose|this|match|obtains|do|suffices|show|by|in|at|let|forall|fun|exists|if|then|else|assume|take|obtain|from)\\b",
"name": "keyword.other.lean"
},
{
"match": "(->|==|:=|<->|\\\\/|/\\\\|<=|>=|⁻¹)",
"name": "constant.language.lua"
},
{
"match": "[#@∼↔/=∧∨≠<>≤≥¬⬝▸+*-]",
"name": "constant.language.lua"
},
{
"match": "(?<=\\s)[=→λ∀?]",
"name": "keyword.operator.lean"
},
{
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.lean"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.lean"
}
},
"name": "string.quoted.double.lean",
"patterns": [
{
"match": "\\\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\\"'\\&])",
"name": "constant.character.escape.lean"
},
{
"match": "\\\\o[0-7]+|\\\\x[0-9A-Fa-f]+|\\\\[0-9]+",
"name": "constant.character.escape.octal.lean"
},
{
"match": "\\^[A-Z@\\[\\]\\\\\\^_]",
"name": "constant.character.escape.control.lean"
}
]
},
{
"match": "\\b([0-9]+|0([xX][0-9a-fA-F]+))\\b",
"name": "constant.numeric.lean"
}
],
"repository": {
"blockComment": {
"begin": "/-",
"captures": {
"0": {
"name": "punctuation.definition.comment.lean"
}
},
"end": "-/",
"name": "comment.block.lean"
},
"dashComment": {
"begin": "(--)",
"beginCaptures": {
"0": {
"name": "punctuation.definition.comment.lean"
}
},
"end": "$",
"name": "comment.line.double-dash.lean"
},
"identifier": {
"comment": "not so much here to be used as to be a reference",
"match": "\\b[^\\(\\)\\{\\}[:space:]=→λ∀?][^\\(\\)\\{\\}[:space:]]*",
"name": "entity.name.function.lean"
}
},
"scopeName": "source.lean"
}
Loading

0 comments on commit 526799a

Please sign in to comment.