on 2fbb1e5 help sign in
10 files changed+93−344
since splitsnapshots
unifiedsplit
.vscode/extensions.json−7 .vscode/launch.json−36 .vscode/settings.json−11 .vscode/tasks.json−20 .vscodeignore−10 CHANGELOG.md+4−46 README.md+46−16 logo.png package.json+37−155 src/extension.ts+6−43
.vscode/extensions.jsondeleted−7
@@ -1,7 +0,0 @@
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.jsondeleted−36
@@ -1,36 +0,0 @@
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.jsondeleted−11
@@ -1,11 +0,0 @@
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.jsondeleted−20
@@ -1,20 +0,0 @@
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−}
.vscodeignoredeleted−10
@@ -1,10 +0,0 @@
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.md+4−46
@@ -1,51 +1,9 @@
11# Change Log
22
3−### 0.0.12
3+All notable changes to the "ormolu" extension will be documented in this file.
44
5−Fixed a bug where executable paths outside of `$PATH` would fail. (@lzszt)
5+Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66
7−### 0.0.11
7+## [Unreleased]
88
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
9+- Initial release
README.md+46−16
@@ -1,35 +1,65 @@
1−# Ormolu
1+# ormolu README
22
3−Most ormolu options are exposed in configuration.
3+This is the README for your extension "ormolu". After writing up a brief description, we recommend including the following sections.
44
5−## Requirements
5+## Features
6+
7+Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
8+
9+For example if there is an image subfolder under your extension project workspace:
10+
11+\!\[feature X\]\(images/feature-x.png\)
612
7−You have to have ormolu installed.
13+> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
814
9−Go to [github.com/tweag/ormolu](https://github.com/tweag/ormolu#building) for more info.
15+## Requirements
16+
17+If you have any requirements or dependencies, add a section describing those and how to install and configure them.
1018
1119## Extension Settings
1220
21+Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
22+
23+For example:
24+
25+This extension contributes the following settings:
26+
27+* `myExtension.enable`: enable/disable this extension
28+* `myExtension.thing`: set to `blah` to do something
29+
30+## Known Issues
31+
32+Calling out known issues can help limit users opening duplicate issues against your extension.
33+
1334## Release Notes
1435
15−### 0.0.1
36+Users appreciate release notes as you update your extension.
37+
38+### 1.0.0
39+
40+Initial release of ...
41+
42+### 1.0.1
1643
17−Initial release of Ormolu
44+Fixed issue #.
1845
19−### 0.0.2
46+### 1.1.0
2047
21−Added configurations.
48+Added features X, Y, and Z.
2249
23−Changed error to warning.
50+-----------------------------------------------------------------------------------------------------------
2451
25−### 0.0.3
52+## Working with Markdown
2653
27−Added logo.
54+**Note:** You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
2855
29−### 0.0.4
56+* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux)
57+* Toggle preview (`Shift+CMD+V` on macOS or `Shift+Ctrl+V` on Windows and Linux)
58+* Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (macOS) to see a list of Markdown snippets
3059
31−Fixed bugs.
60+### For more information
3261
33−### 0.0.5
62+* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
63+* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
3464
35−Fixed bugs.
65+**Enjoy!**
logo.pngdeleted

Binary file not shown.

package.json+37−155
@@ -1,163 +1,45 @@
11{
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",
2+ "name": "ormolu",
3+ "displayName": "Ormolu",
4+ "publisher": "ilyakooo0",
5+ "description": "Haskell code formatter with ormolu",
6+ "version": "0.0.1",
7+ "engines": {
8+ "vscode": "^1.39.0"
9+ },
10+ "categories": [
11+ "Formatters"
12+ ],
13+ "main": "./out/extension.js",
1914 "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− }
15+ "languages": [
16+ {
17+ "id": "haskell",
18+ "aliases": [
19+ "Haskell"
20+ ]
13921 }
140− }
22+ ]
14123 },
14224 "activationEvents": [
14325 "onLanguage:haskell"
14426 ],
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− }
27+ "scripts": {
28+ "vscode:prepublish": "yarn run compile",
29+ "compile": "tsc -p ./",
30+ "watch": "tsc -watch -p ./",
31+ "pretest": "yarn run compile",
32+ "test": "node ./out/test/runTest.js"
33+ },
34+ "devDependencies": {
35+ "@types/glob": "^7.1.1",
36+ "@types/mocha": "^5.2.6",
37+ "@types/node": "^10.12.21",
38+ "@types/vscode": "^1.39.0",
39+ "glob": "^7.1.4",
40+ "mocha": "^6.1.4",
41+ "typescript": "^3.3.1",
42+ "tslint": "^5.12.1",
43+ "vscode-test": "^1.2.0"
44+ }
16345}
src/extension.ts+6−43
@@ -2,7 +2,6 @@
22// Import the module and reference it with the alias vscode in your code below
33import * as vscode from 'vscode';
44import * as proc from 'child_process';
5−import { Range } from 'vscode';
65
76// this method is called when your extension is activated
87// your extension is activated the very first time the command is executed
@@ -11,63 +10,27 @@ export function activate(context: vscode.ExtensionContext) {
1110 vscode.languages.registerDocumentRangeFormattingEditProvider(haskellLangId, {
1211 provideDocumentRangeFormattingEdits(document, range, options, token) {
1312 const showErrorMessage = (friendlyText: string, error: { stderr: { toString: () => void; }; }) => {
14− vscode.window.showWarningMessage(`${friendlyText}\n${error.stderr.toString()}`);
13+ vscode.window.showErrorMessage(`${friendlyText}\n${error.stderr.toString()}`);
1514 return [];
1615 };
1716
18− const cfg = vscode.workspace.getConfiguration("ormolu");
19−
2017 try {
21− proc.execSync(cfg.executablePath + ' --help');
18+ proc.execSync('ormolu --help');
2219 } catch (e) {
2320 return showErrorMessage("Ormolu is not installed", e);
2421 }
2522
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();
23+ const text = document.getText(range);
5424 let formattedText;
5525 try {
56− formattedText = proc.execSync(command, { input: text }).toString();
26+ formattedText = proc.execSync('ormolu', {input: text}).toString();
5727 } catch (e) {
5828 return showErrorMessage('Ormolu failed to format the code', e);
5929 }
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)];
30+ return [vscode.TextEdit.replace(range, formattedText)];
6831 }
6932 });
7033}
7134
7235// this method is called when your extension is deactivated
73−export function deactivate() { }
36+export function deactivate() {}