-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d5bd26b
Showing
8 changed files
with
137 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.vscode-test/ | ||
*.vsix |
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 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
test/** | ||
.gitignore | ||
.yarnrc | ||
vsc-extension-quickstart.md | ||
**/jsconfig.json | ||
**/*.map | ||
**/.eslintrc.json |
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,13 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Asuka Minato <not important> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
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,7 @@ | ||
# MmaFmt | ||
|
||
Format mma code. | ||
|
||
Very slow, but works. | ||
|
||
Need to have <https://github.com/WolframResearch/codeformatter> installed first. |
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,47 @@ | ||
// The module 'vscode' contains the VS Code extensibility API | ||
// Import the module and reference it with the alias vscode in your code below | ||
const vscode = require("vscode"); | ||
const { spawnSync } = require("child_process"); | ||
|
||
// This method is called when your extension is activated | ||
// Your extension is activated the very first time the command is executed | ||
/** | ||
* @param {vscode.ExtensionContext} context | ||
*/ | ||
function activate(context) { | ||
context.subscriptions.push( | ||
vscode.languages.registerDocumentFormattingEditProvider("wolfram", { | ||
provideDocumentFormattingEdits(document) { | ||
const cellContent = []; | ||
for (let i = 0; i < document.lineCount; i++) { | ||
cellContent.push(document.lineAt(i).text); | ||
} | ||
const cellContentString = cellContent.join("\n"); | ||
|
||
return [ | ||
vscode.TextEdit.replace( | ||
new vscode.Range( | ||
new vscode.Position(0, 0), | ||
new vscode.Position( | ||
document.lineCount - 1, | ||
document.lineAt(document.lineCount - 1).text.length | ||
) | ||
), | ||
|
||
spawnSync(`wolframscript`, ["-f", "./fmt.wls", cellContentString], { | ||
timeout: 30000, | ||
stdio: "pipe", | ||
}).stdout.toString() | ||
), | ||
]; | ||
}, | ||
}) | ||
); | ||
} | ||
// This method is called when your extension is deactivated | ||
function deactivate() {} | ||
|
||
module.exports = { | ||
activate, | ||
deactivate, | ||
}; |
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,6 @@ | ||
Needs["CodeFormatter`"]; | ||
|
||
$ScriptCommandLine // | ||
Last // | ||
CodeFormatter`CodeFormat // | ||
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,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "ES2020", | ||
"checkJs": true, /* Typecheck .js files. */ | ||
"lib": [ | ||
"ES2020" | ||
] | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
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,39 @@ | ||
{ | ||
"name": "mmafmt", | ||
"displayName": "mmafmt", | ||
"description": "fmt code", | ||
"version": "0.0.1", | ||
"repository": { | ||
"url": "whatever" | ||
}, | ||
"activationEvents": [ | ||
"onLanguage:wolfram" | ||
], | ||
"engines": { | ||
"vscode": "^1.75.0" | ||
}, | ||
"categories": [ | ||
"Programming Languages", | ||
"Keymaps" | ||
], | ||
"main": "./extension.js", | ||
"contributes": { | ||
"configuration": { | ||
"title": "MmaFmt" | ||
}, | ||
"languages": [ | ||
{ | ||
"id": "wolfram", | ||
"aliases": [ | ||
"Wolfram Language" | ||
], | ||
"extensions": [ | ||
".wls", | ||
".wlnb", | ||
".wl", | ||
".nb" | ||
] | ||
} | ||
] | ||
} | ||
} |