-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ELENA-LANG/develop
Develop
- Loading branch information
Showing
13 changed files
with
322 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,6 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
node_modules | ||
*.vsix | ||
.vscode/ipch | ||
*.code-workspace | ||
dist/ | ||
*.exe | ||
*.out | ||
*.app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Change Log | ||
|
||
All notable changes to the "l" extension will be documented in this file. | ||
|
||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. | ||
|
||
## [Unreleased] | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
# vscode-elena-lang | ||
ELENA Language support for Visual Studio Code | ||
# ELENA language support for Visual Studio Code | ||
|
||
Provides [ELENA language](https://elena-lang.github.io) support for Visual Studio Code. | ||
|
||
## Commands | ||
|
||
- `ELENA: Compile a current file` | ||
- `ELENA: Compile a current project` | ||
|
||
You can access all of the above commands from the command palette (`Cmd+Shift+P`). | ||
|
||
## License | ||
|
||
[MIT](./LICENSE) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"comments": { | ||
// symbol used for single line comment. Remove this entry if your language does not support line comments | ||
"lineComment": "//", | ||
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments | ||
"blockComment": [ "/*", "*/" ] | ||
}, | ||
// symbols used as brackets | ||
"brackets": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"] | ||
], | ||
// symbols that are auto closed when typing | ||
"autoClosingPairs": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"], | ||
["\"", "\""] | ||
], | ||
// symbols that can be used to surround a selection | ||
"surroundingPairs": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"], | ||
["\"", "\""] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"name": "vscode-elena-lang", | ||
"displayName": "ELENA", | ||
"description": "ELENA Language support for Visual Studio Code", | ||
"icon": "icons/icon.png", | ||
"version": "0.0.1", | ||
"engines": { | ||
"vscode": "^1.89.0" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/ELENA-LANG/vscode-elena-lang/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ELENA-LANG/vscode-elena-lang" | ||
}, | ||
"keywords": [ | ||
"elena-lang", | ||
"ELENA" | ||
], | ||
"categories": [ | ||
"Programming Languages" | ||
], | ||
"l10n": "./l10n", | ||
"contributes": { | ||
"languages": [ | ||
{ | ||
"id": "elena", | ||
"aliases": [ | ||
"ELENA", | ||
"elena" | ||
], | ||
"extensions": [ | ||
"l", | ||
"prj" | ||
], | ||
"configuration": "./language-configuration.json" | ||
} | ||
], | ||
"grammars": [ | ||
{ | ||
"language": "elena", | ||
"scopeName": "source.elena-lang", | ||
"path": "./syntaxes/elena.tmLanguage.json" | ||
} | ||
], | ||
"configuration": { | ||
"title": "ELENA", | ||
"properties": { | ||
"elena.executablePath": { | ||
"scope": "resource", | ||
"type": "string", | ||
"description": "Custom path to ELENA compiler executable (`elena-cli`)." | ||
} | ||
} | ||
}, | ||
"commands": [ | ||
{ | ||
"command": "elena.compileSingleFile", | ||
"title": "Compile the current file", | ||
"category": "ELENA" | ||
}, | ||
{ | ||
"command": "elena.compileProject", | ||
"title": "Compile the current project", | ||
"category": "ELENA" | ||
} | ||
], | ||
"menus": { | ||
"commandPalette": [ | ||
{ | ||
"command": "elena.compileSingleFile", | ||
"when": "editorLangId == elena" | ||
}, | ||
{ | ||
"command": "elena.compileProject", | ||
"when": "editorLangId == elena" | ||
} | ||
] | ||
} | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "npm run compile", | ||
"compile": "tsc -p ./", | ||
"watch": "tsc -watch -p ./" | ||
}, | ||
"activationEvents": [ | ||
"workspaceContains:**/*.l", | ||
"onLanguage:elena", | ||
"onCommand:elena.compileSingleFile", | ||
"onCommand:elena.compileProject" | ||
], | ||
"main": "./dist/main.js", | ||
"devDependencies": { | ||
"@vscode/l10n-dev": "^0.0.18", | ||
"typescript": "^5.4.2", | ||
"vscode": "^1.1.37" | ||
}, | ||
"dependencies": { | ||
"@vscode/l10n": "^0.0.10" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extension.sayHello.title": "Hello" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as vscode from 'vscode'; | ||
import { window } from 'vscode'; | ||
import { compileInTerminal } from './exec'; | ||
import { getProjectFile } from './utils'; | ||
|
||
export async function compileSingleFile(): Promise<void> { | ||
const document : vscode.TextDocument | undefined = window?.activeTextEditor?.document; | ||
if (document) { | ||
await document.save(); | ||
const filePath = `"${document.fileName}"`; | ||
|
||
compileInTerminal([filePath]); | ||
} | ||
} | ||
|
||
export async function compileProject(): Promise<void> { | ||
const projectFile : vscode.Uri | undefined = await getProjectFile(); | ||
if (projectFile) { | ||
const filePath = `"${projectFile.fsPath}"`; | ||
|
||
compileInTerminal([filePath]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { window, Terminal } from 'vscode'; | ||
import { getExecCommand } from './utils'; | ||
|
||
let terminalWindow: Terminal | undefined = undefined; | ||
|
||
export function compileInTerminal(args: string[]): void { | ||
const execFile = getExecCommand(); | ||
const cmd = `${execFile} ${args.join(' ')}`; | ||
|
||
if (!terminalWindow) terminalWindow = window.createTerminal('ELENA'); | ||
|
||
terminalWindow.show(); | ||
terminalWindow.sendText(cmd); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as vscode from 'vscode'; | ||
import * as commands from './commands'; | ||
|
||
const cmds : Array<[string, () => void]> = [ | ||
[ 'elena.compileSingleFile', commands.compileSingleFile ], | ||
[ 'elena.compileProject', commands.compileProject ] | ||
]; | ||
|
||
/** | ||
* This method is called when the extension is activated. | ||
* @param context The extension context | ||
*/ | ||
export function activate(context: vscode.ExtensionContext): void { | ||
let output = vscode.window.createOutputChannel("elena"); | ||
output.appendLine("Starting ELENA vscode extension.."); | ||
|
||
for (var cmd of cmds) { | ||
const disposable = vscode.commands.registerCommand(cmd[0], cmd[1]); | ||
context.subscriptions.push(disposable); | ||
} | ||
} | ||
|
||
export function deactivate(): void { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
workspace, | ||
WorkspaceConfiguration, | ||
window, | ||
Uri, | ||
WorkspaceFolder, | ||
RelativePattern | ||
} from 'vscode'; | ||
|
||
const defaultCommand = 'elena-cli'; | ||
|
||
export function getWorkspaceFolder(uri?: Uri): WorkspaceFolder | undefined { | ||
if (uri) { | ||
return workspace.getWorkspaceFolder(uri); | ||
} else if (window.activeTextEditor && window.activeTextEditor.document) { | ||
return workspace.getWorkspaceFolder(window.activeTextEditor.document.uri); | ||
} else if (workspace.workspaceFolders) { | ||
return workspace.workspaceFolders[0]; | ||
} | ||
return undefined; | ||
} | ||
|
||
export function getWorkspaceConfig(): WorkspaceConfiguration | undefined { | ||
const currentWorkspaceFolder = getWorkspaceFolder(); | ||
if (currentWorkspaceFolder) { | ||
return workspace.getConfiguration('elena', currentWorkspaceFolder.uri); | ||
} | ||
return undefined; | ||
} | ||
|
||
export function getExecCommand(): string | undefined { | ||
const config: WorkspaceConfiguration | undefined = getWorkspaceConfig(); | ||
return config?.get('elena.executablePath', defaultCommand); | ||
} | ||
|
||
export async function getProjectFile(): Promise<Uri | undefined> { | ||
const currentWorkspaceFolder = getWorkspaceFolder(); | ||
if (currentWorkspaceFolder == null) { | ||
return undefined; | ||
} | ||
|
||
const pattern = new RelativePattern(currentWorkspaceFolder.uri.path, '*.prj'); | ||
const files = await workspace.findFiles(pattern); | ||
if (files && files.length > 0) { | ||
return files[0]; | ||
}; | ||
|
||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", | ||
"name": "ELENA", | ||
"patterns": [ | ||
{ | ||
"include": "#keywords" | ||
}, | ||
{ | ||
"include": "#strings" | ||
} | ||
], | ||
"repository": { | ||
"keywords": { | ||
"patterns": [{ | ||
"name": "keyword.control.elena", | ||
"match": "\\b(if|while|for|return)\\b" | ||
}] | ||
}, | ||
"strings": { | ||
"name": "string.quoted.double.elena", | ||
"begin": "\"", | ||
"end": "\"", | ||
"patterns": [ | ||
{ | ||
"name": "constant.character.escape.elena", | ||
"match": "\\\\." | ||
} | ||
] | ||
} | ||
}, | ||
"scopeName": "source.elena-lang" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "ES2022", | ||
"outDir": "dist", | ||
"lib": [ | ||
"ES2022", | ||
"dom" | ||
], | ||
"rootDir": "src", | ||
"strict": true, | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules/**" | ||
] | ||
} |