diff --git a/package.json b/package.json index 7317512..aa1eae2 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,28 @@ "onLanguage:markdown" ], "main": "./out/src/extension", + "contributes": { + "configuration":{ + "type": "object", + "title": "write-good", + "properties": { + "write-good.languages": { + "default": [ + "markdown" + ], + "type": [ + "string", + "array" + ], + "items": { + "type": "string" + }, + "description": "Languages to lint with the write-good linter. '*' to enable on all languages.", + "scope": "resource" + } + } + } + }, "scripts": { "vscode:prepublish": "node ./node_modules/vscode/bin/compile", "compile": "node ./node_modules/vscode/bin/compile -watch -p ./", diff --git a/src/extension.ts b/src/extension.ts index bdfd209..79fda0e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -8,15 +8,28 @@ export function activate(context: ExtensionContext) { console.log("Write-Good Linter active..."); + function isWriteGoodLanguage(languageId) { + let wgLanguages: string = workspace.getConfiguration('write-good').get('languages'); + return (wgLanguages.indexOf(languageId) > -1 || wgLanguages === '*'); + } + context.subscriptions.push(workspace.onDidChangeTextDocument(event => { - doLint(event.document); + if (isWriteGoodLanguage(event.document.languageId)) { + doLint(event.document); + } })); context.subscriptions.push(workspace.onDidOpenTextDocument(event => { - doLint(event); + if (isWriteGoodLanguage(event.languageId)) { + doLint(event); + } })); } +export function deactivate() { + console.log("Write-Good Linter deactivating...") +} + interface Suggestion { index: number, offset: number,