on master help sign in
.gitignorenew file+2
since splitsnapshots
unifiedsplit
@@ -0,0 +1,2 @@
1+node_modules
2+out
.vscode/extensions.jsonnew file+7
@@ -0,0 +1,7 @@
1+{
2+ // See http://go.microsoft.com/fwlink/?LinkId=827846
3+ // for the documentation about the extensions.json format
4+ "recommendations": [
5+ "ms-vscode.vscode-typescript-tslint-plugin"
6+ ]
7+}
.vscode/launch.jsonnew file+36
@@ -0,0 +1,36 @@
1+// A launch configuration that compiles the extension and then opens it inside a new window
2+// Use IntelliSense to learn about possible attributes.
3+// Hover to view descriptions of existing attributes.
4+// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+{
6+ "version": "0.2.0",
7+ "configurations": [
8+ {
9+ "name": "Run Extension",
10+ "type": "extensionHost",
11+ "request": "launch",
12+ "runtimeExecutable": "${execPath}",
13+ "args": [
14+ "--extensionDevelopmentPath=${workspaceFolder}"
15+ ],
16+ "outFiles": [
17+ "${workspaceFolder}/out/**/*.js"
18+ ],
19+ "preLaunchTask": "npm: watch"
20+ },
21+ {
22+ "name": "Extension Tests",
23+ "type": "extensionHost",
24+ "request": "launch",
25+ "runtimeExecutable": "${execPath}",
26+ "args": [
27+ "--extensionDevelopmentPath=${workspaceFolder}",
28+ "--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
29+ ],
30+ "outFiles": [
31+ "${workspaceFolder}/out/test/**/*.js"
32+ ],
33+ "preLaunchTask": "npm: watch"
34+ }
35+ ]
36+}
.vscode/settings.jsonnew file+11
@@ -0,0 +1,11 @@
1+// Place your settings in this file to overwrite default and user settings.
2+{
3+ "files.exclude": {
4+ "out": false // set this to true to hide the "out" folder with the compiled JS files
5+ },
6+ "search.exclude": {
7+ "out": true // set this to false to include "out" folder in search results
8+ },
9+ // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10+ "typescript.tsc.autoDetect": "off"
11+}
.vscode/tasks.jsonnew file+20
@@ -0,0 +1,20 @@
1+// See https://go.microsoft.com/fwlink/?LinkId=733558
2+// for the documentation about the tasks.json format
3+{
4+ "version": "2.0.0",
5+ "tasks": [
6+ {
7+ "type": "npm",
8+ "script": "watch",
9+ "problemMatcher": "$tsc-watch",
10+ "isBackground": true,
11+ "presentation": {
12+ "reveal": "never"
13+ },
14+ "group": {
15+ "kind": "build",
16+ "isDefault": true
17+ }
18+ }
19+ ]
20+}
.vscodeignorenew file+10
@@ -0,0 +1,10 @@
1+.vscode/**
2+.vscode-test/**
3+out/test/**
4+src/**
5+.gitignore
6+vsc-extension-quickstart.md
7+**/tsconfig.json
8+**/tslint.json
9+**/*.map
10+**/*.ts
CHANGELOG.mdnew file+51
@@ -0,0 +1,51 @@
1+# Change Log
2+
3+### 0.0.12
4+
5+Fixed a bug where executable paths outside of `$PATH` would fail. (@lzszt)
6+
7+### 0.0.11
8+
9+Added the ability to specify the path to the executable.
10+
11+### 0.0.10
12+
13+Fixed off-by-one range bug.
14+
15+### 0.0.9
16+
17+Fixed range values.
18+
19+### 0.0.8
20+
21+Fixed bug.
22+
23+### 0.0.7
24+
25+Fixed bug.
26+
27+### 0.0.6
28+
29+Added proper range support.
30+
31+### 0.0.5
32+
33+Fixed bugs.
34+
35+### 0.0.4
36+
37+Fixed bugs.
38+
39+### 0.0.3
40+
41+Added logo.
42+
43+### 0.0.2
44+
45+Added configurations.
46+
47+Changed error to warning.
48+
49+### 0.0.1
50+
51+Initial release of Ormolu
README.mdnew file+35
@@ -0,0 +1,35 @@
1+# Ormolu
2+
3+Most ormolu options are exposed in configuration.
4+
5+## Requirements
6+
7+You have to have ormolu installed.
8+
9+Go to [github.com/tweag/ormolu](https://github.com/tweag/ormolu#building) for more info.
10+
11+## Extension Settings
12+
13+## Release Notes
14+
15+### 0.0.1
16+
17+Initial release of Ormolu
18+
19+### 0.0.2
20+
21+Added configurations.
22+
23+Changed error to warning.
24+
25+### 0.0.3
26+
27+Added logo.
28+
29+### 0.0.4
30+
31+Fixed bugs.
32+
33+### 0.0.5
34+
35+Fixed bugs.
logo.pngnew file

Binary file not shown.

package.jsonnew file+163
@@ -0,0 +1,163 @@
1+{
2+ "name": "ormolu",
3+ "displayName": "Ormolu",
4+ "publisher": "ilyakooo0",
5+ "description": "Haskell code formatter with ormolu",
6+ "version": "0.0.12",
7+ "repository": {
8+ "type": "git",
9+ "url": "https://github.com/ilyakooo0/vs-code-ormolu"
10+ },
11+ "icon": "logo.png",
12+ "engines": {
13+ "vscode": "^1.39.0"
14+ },
15+ "categories": [
16+ "Formatters"
17+ ],
18+ "main": "./out/extension.js",
19+ "contributes": {
20+ "languages": [{
21+ "id": "haskell",
22+ "aliases": [
23+ "Haskell"
24+ ]
25+ }],
26+ "configuration": {
27+ "title": "Ormolu",
28+ "properties": {
29+ "ormolu.extensions.AlternativeLayoutRule": {
30+ "type": "boolean",
31+ "default": false,
32+ "description": "Enable the AlternativeLayoutRule extension."
33+ },
34+ "ormolu.extensions.AlternativeLayoutRuleTransitional": {
35+ "type": "boolean",
36+ "default": false,
37+ "description": "Enable the AlternativeLayoutRuleTransitional extension."
38+ },
39+ "ormolu.extensions.Arrows": {
40+ "type": "boolean",
41+ "default": false,
42+ "description": "Enable the Arrows extension."
43+ },
44+ "ormolu.extensions.BangPatterns": {
45+ "type": "boolean",
46+ "default": false,
47+ "description": "Enable the BangPatterns extension."
48+ },
49+ "ormolu.extensions.Cpp": {
50+ "type": "boolean",
51+ "default": false,
52+ "description": "Enable the Cpp extension."
53+ },
54+ "ormolu.extensions.MagicHash": {
55+ "type": "boolean",
56+ "default": false,
57+ "description": "Enable the MagicHash extension."
58+ },
59+ "ormolu.extensions.MonadComprehensions": {
60+ "type": "boolean",
61+ "default": false,
62+ "description": "Enable the MonadComprehensions extension."
63+ },
64+ "ormolu.extensions.PatternSynonyms": {
65+ "type": "boolean",
66+ "default": false,
67+ "description": "Enable the PatternSynonyms extension."
68+ },
69+ "ormolu.extensions.RecursiveDo": {
70+ "type": "boolean",
71+ "default": false,
72+ "description": "Enable the RecursiveDo extension."
73+ },
74+ "ormolu.extensions.StaticPointers": {
75+ "type": "boolean",
76+ "default": false,
77+ "description": "Enable the StaticPointers extension."
78+ },
79+ "ormolu.extensions.TemplateHaskellQuotes": {
80+ "type": "boolean",
81+ "default": false,
82+ "description": "Enable the TemplateHaskellQuotes extension."
83+ },
84+ "ormolu.extensions.TransformListComp": {
85+ "type": "boolean",
86+ "default": false,
87+ "description": "Enable the TransformListComp extension."
88+ },
89+ "ormolu.extensions.TypeApplications": {
90+ "type": "boolean",
91+ "default": false,
92+ "description": "Enable the TypeApplications extension."
93+ },
94+ "ormolu.extensions.UnboxedSums": {
95+ "type": "boolean",
96+ "default": false,
97+ "description": "Enable the UnboxedSums extension."
98+ },
99+ "ormolu.extensions.UnboxedTuples": {
100+ "type": "boolean",
101+ "default": false,
102+ "description": "Enable the UnboxedTuples extension."
103+ },
104+ "ormolu.extensions.UnicodeSyntax": {
105+ "type": "boolean",
106+ "default": false,
107+ "description": "Enable the UnicodeSyntax extension."
108+ },
109+ "ormolu.tolerateCpp": {
110+ "type": "boolean",
111+ "default": false,
112+ "description": "Do not fail if CPP pragma is present."
113+ },
114+ "ormolu.unsafe": {
115+ "type": "boolean",
116+ "default": false,
117+ "description": "Run in \"unsafe\" mode. Do formatting faster but without automatic detection of defects."
118+ },
119+ "ormolu.checkIdempotency": {
120+ "type": "boolean",
121+ "default": false,
122+ "description": "Fail if formatting is not idempotent."
123+ },
124+ "ormolu.customArguments": {
125+ "type": [
126+ "string",
127+ "null"
128+ ],
129+ "default": null,
130+ "description": "Custom arguments to pass to ormolu."
131+ },
132+ "ormolu.executablePath": {
133+ "type": [
134+ "string"
135+ ],
136+ "default": "ormolu",
137+ "description": "The path to the ormolu executable to use."
138+ }
139+ }
140+ }
141+ },
142+ "activationEvents": [
143+ "onLanguage:haskell"
144+ ],
145+ "scripts": {
146+ "vscode:prepublish": "yarn run compile",
147+ "compile": "tsc -p ./",
148+ "watch": "tsc -watch -p ./",
149+ "pretest": "yarn run compile",
150+ "test": "node ./out/test/runTest.js"
151+ },
152+ "devDependencies": {
153+ "@types/glob": "^7.1.1",
154+ "@types/mocha": "^5.2.6",
155+ "@types/node": "^10.12.21",
156+ "@types/vscode": "^1.39.0",
157+ "glob": "^7.1.4",
158+ "mocha": "^6.1.4",
159+ "typescript": "^3.3.1",
160+ "tslint": "^5.12.1",
161+ "vscode-test": "^1.2.0"
162+ }
163+}
src/extension.tsnew file+73
@@ -0,0 +1,73 @@
1+// The module 'vscode' contains the VS Code extensibility API
2+// Import the module and reference it with the alias vscode in your code below
3+import * as vscode from 'vscode';
4+import * as proc from 'child_process';
5+import { Range } from 'vscode';
6+
7+// this method is called when your extension is activated
8+// your extension is activated the very first time the command is executed
9+const haskellLangId = 'haskell';
10+export function activate(context: vscode.ExtensionContext) {
11+ vscode.languages.registerDocumentRangeFormattingEditProvider(haskellLangId, {
12+ provideDocumentRangeFormattingEdits(document, range, options, token) {
13+ const showErrorMessage = (friendlyText: string, error: { stderr: { toString: () => void; }; }) => {
14+ vscode.window.showWarningMessage(`${friendlyText}\n${error.stderr.toString()}`);
15+ return [];
16+ };
17+
18+ const cfg = vscode.workspace.getConfiguration("ormolu");
19+
20+ try {
21+ proc.execSync(cfg.executablePath + ' --help');
22+ } catch (e) {
23+ return showErrorMessage("Ormolu is not installed", e);
24+ }
25+
26+ let command = cfg.executablePath;
27+
28+ command += ` --start-line ${range.start.line + 1} --end-line ${range.end.line + (range.end.character == 0 ? 0 : 1)}`
29+ command += ` --stdin-input-file ${document.fileName}`
30+
31+ for (let [key, value] of Object.entries(cfg.extensions)) {
32+ if (value) {
33+ command += " -o -X" + key;
34+ }
35+ }
36+
37+ if (cfg.customArguments !== null) {
38+ command += " " + cfg.customArguments;
39+ }
40+
41+ if (cfg.tolerateCpp) {
42+ command += " -p";
43+ }
44+
45+ if (cfg.unsafe) {
46+ command += " -u";
47+ }
48+
49+ if (cfg.checkIdempotency) {
50+ command += " -c";
51+ }
52+
53+ const text = document.getText();
54+ let formattedText;
55+ try {
56+ formattedText = proc.execSync(command, { input: text }).toString();
57+ } catch (e) {
58+ return showErrorMessage('Ormolu failed to format the code', e);
59+ }
60+
61+ const fullDocumentRange =
62+ new Range
63+ (document.lineAt(0).range.start
64+ , document.lineAt(document.lineCount - 1).range.end
65+ );
66+
67+ return [vscode.TextEdit.replace(fullDocumentRange, formattedText)];
68+ }
69+ });
70+}
71+
72+// this method is called when your extension is deactivated
73+export function deactivate() { }
src/test/runTest.tsnew file+23
@@ -0,0 +1,23 @@
1+import * as path from 'path';
2+
3+import { runTests } from 'vscode-test';
4+
5+async function main() {
6+ try {
7+ // The folder containing the Extension Manifest package.json
8+ // Passed to `--extensionDevelopmentPath`
9+ const extensionDevelopmentPath = path.resolve(__dirname, '../../');
10+
11+ // The path to test runner
12+ // Passed to --extensionTestsPath
13+ const extensionTestsPath = path.resolve(__dirname, './suite/index');
14+
15+ // Download VS Code, unzip it and run the integration test
16+ await runTests({ extensionDevelopmentPath, extensionTestsPath });
17+ } catch (err) {
18+ console.error('Failed to run tests');
19+ process.exit(1);
20+ }
21+}
22+
23+main();
src/test/suite/extension.test.tsnew file+15
@@ -0,0 +1,15 @@
1+import * as assert from 'assert';
2+
3+// You can import and use all API from the 'vscode' module
4+// as well as import your extension to test it
5+import * as vscode from 'vscode';
6+// import * as myExtension from '../extension';
7+
8+suite('Extension Test Suite', () => {
9+ vscode.window.showInformationMessage('Start all tests.');
10+
11+ test('Sample test', () => {
12+ assert.equal(-1, [1, 2, 3].indexOf(5));
13+ assert.equal(-1, [1, 2, 3].indexOf(0));
14+ });
15+});
src/test/suite/index.tsnew file+37
@@ -0,0 +1,37 @@
1+import * as path from 'path';
2+import * as Mocha from 'mocha';
3+import * as glob from 'glob';
4+
5+export function run(): Promise<void> {
6+ // Create the mocha test
7+ const mocha = new Mocha({
8+ ui: 'tdd',
9+ });
10+ mocha.useColors(true);
11+
12+ const testsRoot = path.resolve(__dirname, '..');
13+
14+ return new Promise((c, e) => {
15+ glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
16+ if (err) {
17+ return e(err);
18+ }
19+
20+ // Add files to the test suite
21+ files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
22+
23+ try {
24+ // Run the mocha test
25+ mocha.run(failures => {
26+ if (failures > 0) {
27+ e(new Error(`${failures} tests failed.`));
28+ } else {
29+ c();
30+ }
31+ });
32+ } catch (err) {
33+ e(err);
34+ }
35+ });
36+ });
37+}
tsconfig.jsonnew file+21
@@ -0,0 +1,21 @@
1+{
2+ "compilerOptions": {
3+ "module": "commonjs",
4+ "target": "es6",
5+ "outDir": "out",
6+ "lib": [
7+ "es6"
8+ ],
9+ "sourceMap": true,
10+ "rootDir": "src",
11+ "strict": true /* enable all strict type-checking options */
12+ /* Additional Checks */
13+ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
14+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
15+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
16+ },
17+ "exclude": [
18+ "node_modules",
19+ ".vscode-test"
20+ ]
21+}
tslint.jsonnew file+15
@@ -0,0 +1,15 @@
1+{
2+ "rules": {
3+ "no-string-throw": true,
4+ "no-unused-expression": true,
5+ "no-duplicate-variable": true,
6+ "curly": true,
7+ "class-name": true,
8+ "semicolon": [
9+ true,
10+ "always"
11+ ],
12+ "triple-equals": true
13+ },
14+ "defaultSeverity": "warning"
15+}
vsc-extension-quickstart.mdnew file+42
@@ -0,0 +1,42 @@
1+# Welcome to your VS Code Extension
2+
3+## What's in the folder
4+
5+* This folder contains all of the files necessary for your extension.
6+* `package.json` - this is the manifest file in which you declare your extension and command.
7+ * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
8+* `src/extension.ts` - this is the main file where you will provide the implementation of your command.
9+ * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
10+ * We pass the function containing the implementation of the command as the second parameter to `registerCommand`.
11+
12+## Get up and running straight away
13+
14+* Press `F5` to open a new window with your extension loaded.
15+* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
16+* Set breakpoints in your code inside `src/extension.ts` to debug your extension.
17+* Find output from your extension in the debug console.
18+
19+## Make changes
20+
21+* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`.
22+* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
23+
24+
25+## Explore the API
26+
27+* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`.
28+
29+## Run tests
30+
31+* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`.
32+* Press `F5` to run the tests in a new window with your extension loaded.
33+* See the output of the test result in the debug console.
34+* Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder.
35+ * The provided test runner will only consider files matching the name pattern `**.test.ts`.
36+ * You can create folders inside the `test` folder to structure your tests any way you want.
37+
38+## Go further
39+
40+ * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension).
41+ * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace.
42+ * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).