Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Oct 8, 2019
2 parents 808866a + b7f14c8 commit 91af0ae
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Calva: Clojure & Clojurescript Interactive Programming",
"description": "Integrated REPL, formatter, Paredit, and more. Powered by nREPL.",
"icon": "assets/calva.png",
"version": "2.0.45",
"version": "2.0.46",
"publisher": "betterthantomorrow",
"author": {
"name": "Better Than Tomorrow",
Expand Down
2 changes: 1 addition & 1 deletion src/calva-fmt/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as vscode from 'vscode';
function readConfiguration() {
let workspaceConfig = vscode.workspace.getConfiguration("calva.fmt");
return {
"format-as-you-type": workspaceConfig.get("formatAsYouType"),
"format-as-you-type": workspaceConfig.get("formatAsYouType") as boolean,
"indentation?": workspaceConfig.get("indentation"),
"remove-surrounding-whitespace?": workspaceConfig.get("removeSurroundingWhitespace"),
"remove-trailing-whitespace?": workspaceConfig.get("removeTrailingWhitespace"),
Expand Down
35 changes: 21 additions & 14 deletions src/calva-fmt/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ import { RangeEditProvider } from './providers/range_formatter';
import * as formatter from './format';
import * as inferer from './infer';
import * as docmirror from "./docmirror"
import * as config from './config'

const ClojureLanguageConfiguration: vscode.LanguageConfiguration = {
wordPattern: /[^\s,#()[\]{};"\\]+/,
onEnterRules: [
// This is madness, but the only way to stop vscode from indenting new lines
{
beforeText: /.*/,
action: {
indentAction: vscode.IndentAction.Outdent,
removeText: Number.MAX_VALUE
}
},
]
function getLanguageConfiguration(autoIndentOn: boolean): vscode.LanguageConfiguration {
return {
wordPattern: /[^\s,#()[\]{};"\\]+/,
onEnterRules: autoIndentOn ? [
// This is madness, but the only way to stop vscode from indenting new lines
{
beforeText: /.*/,
action: {
indentAction: vscode.IndentAction.Outdent,
removeText: Number.MAX_VALUE
}
},
] : []
}
}



export function activate(context: vscode.ExtensionContext) {
docmirror.activate();
vscode.languages.setLanguageConfiguration("clojure", ClojureLanguageConfiguration);
vscode.languages.setLanguageConfiguration("clojure", getLanguageConfiguration(config.getConfig()["format-as-you-type"]));
// this doesn't actually grow anything yet, but just jumps to the start of the enclosing expression.
// context.subscriptions.push(vscode.commands.registerTextEditorCommand('calva-fmt.forwardSexp', docmirror.forwardSexp))
// context.subscriptions.push(vscode.commands.registerTextEditorCommand('calva-fmt.backwardSexp', docmirror.backwardSexp))
Expand All @@ -41,4 +43,9 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.languages.registerOnTypeFormattingEditProvider("clojure", new FormatOnTypeEditProvider, "\r", "\n"));
context.subscriptions.push(vscode.languages.registerDocumentRangeFormattingEditProvider("clojure", new RangeEditProvider));
vscode.window.onDidChangeActiveTextEditor(inferer.updateState);
vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration("calva.fmt.formatAsYouType")) {
vscode.languages.setLanguageConfiguration("clojure", getLanguageConfiguration(config.getConfig()["format-as-you-type"]));
}
})
}

0 comments on commit 91af0ae

Please sign in to comment.