├── .gitignore ├── icon.png ├── typings ├── node.d.ts └── vscode-typings.d.ts ├── gitimage.png ├── .vscodeignore ├── tsconfig.json ├── .vscode ├── settings.json ├── launch.json └── tasks.json ├── README.md ├── test ├── extension.test.ts └── index.ts ├── package.json ├── vsc-extension-quickstart.md └── src └── extension.ts /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepehr500/vscode-discourage/HEAD/icon.png -------------------------------------------------------------------------------- /typings/node.d.ts: -------------------------------------------------------------------------------- 1 | /// -------------------------------------------------------------------------------- /gitimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepehr500/vscode-discourage/HEAD/gitimage.png -------------------------------------------------------------------------------- /typings/vscode-typings.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | typings/** 3 | out/test/** 4 | test/** 5 | src/** 6 | **/*.map 7 | .gitignore 8 | tsconfig.json 9 | vsc-extension-quickstart.md 10 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "outDir": "out", 6 | "noLib": true, 7 | "sourceMap": true, 8 | "rootDir": "." 9 | }, 10 | "exclude": [ 11 | "node_modules" 12 | ] 13 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 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 | "typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discourage 2 | 3 | Ever feel like there is a bit too much encouragement in your office? Isn't too much of anything bad? Discourage is meant to bring your life into balance by offering a little discouragement to counter all the encourgement inflating your ego. 4 | 5 | Discourage Package for Visual Studio Code, inspired by [@rebornix](https://github.com/rebornix)'s [vscode-encourage](https://github.com/rebornix/vscode-encourage). 6 | 7 | ![example image](./gitimage.png "Title") 8 | 9 | A Visual Studio Code extension that discourages you while you work. It will be triggered automatically when the active document is saved or manually by command `Toggle Discourage`. 10 | 11 | ## Credit 12 | 13 | All kudos to [@rebornix](https://github.com/rebornix) 14 | -------------------------------------------------------------------------------- /test/extension.test.ts: -------------------------------------------------------------------------------- 1 | // 2 | // Note: This example test is leveraging the Mocha test framework. 3 | // Please refer to their documentation on https://mochajs.org/ for help. 4 | // 5 | 6 | // The module 'assert' provides assertion methods from node 7 | import * as assert from 'assert'; 8 | 9 | // You can import and use all API from the 'vscode' module 10 | // as well as import your extension to test it 11 | import * as vscode from 'vscode'; 12 | import * as myExtension from '../src/extension'; 13 | 14 | // Defines a Mocha test suite to group tests of similar kind together 15 | suite("Extension Tests", () => { 16 | 17 | // Defines a Mocha unit test 18 | test("Something 1", () => { 19 | assert.equal(-1, [1, 2, 3].indexOf(5)); 20 | assert.equal(-1, [1, 2, 3].indexOf(0)); 21 | }); 22 | }); -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}"], 11 | "stopOnEntry": false, 12 | "sourceMaps": true, 13 | "outDir": "${workspaceRoot}/out/src" 14 | }, 15 | { 16 | "name": "Launch Tests", 17 | "type": "extensionHost", 18 | "request": "launch", 19 | "runtimeExecutable": "${execPath}", 20 | "args": [ 21 | "--extensionDevelopmentPath=${workspaceRoot}", 22 | "--extensionTestsPath=${workspaceRoot}/out/test" 23 | ], 24 | "stopOnEntry": false, 25 | "sourceMaps": true, 26 | "outDir": "${workspaceRoot}/out/test" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discourage", 3 | "displayName": "Discourage", 4 | "description": "Visual Studio Code extension that adds little discouragement while you work", 5 | "version": "0.0.5", 6 | "publisher": "sepehr500", 7 | "repository": { 8 | "url": "https://github.com/sepehr500/vscode-discourage" 9 | }, 10 | "engines": { 11 | "vscode": "^1.0.0" 12 | }, 13 | "author": { 14 | "name": "Sepehr Sobhani" 15 | }, 16 | "categories": [ 17 | "Other" 18 | ], 19 | "icon": "icon.png", 20 | "activationEvents": [ 21 | "*" 22 | ], 23 | "main": "./out/src/extension", 24 | "contributes": { 25 | "commands": [ 26 | { 27 | "command": "discourage.toggle", 28 | "title": "Toggle Discourage" 29 | } 30 | ] 31 | }, 32 | "scripts": { 33 | "vscode:prepublish": "npm run compile", 34 | "compile": "tsc -p ./", 35 | "watch": "tsc -watch -p ./", 36 | "postinstall": "node ./node_modules/vscode/bin/install" 37 | }, 38 | "devDependencies": { 39 | "typescript": "^1.8.5", 40 | "vscode": "^0.11.0" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/index.ts: -------------------------------------------------------------------------------- 1 | // 2 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING 3 | // 4 | // This file is providing the test runner to use when running extension tests. 5 | // By default the test runner in use is Mocha based. 6 | // 7 | // You can provide your own test runner if you want to override it by exporting 8 | // a function run(testRoot: string, clb: (error:Error) => void) that the extension 9 | // host can call to run the tests. The test runner is expected to use console.log 10 | // to report the results back to the caller. When the tests are finished, return 11 | // a possible error to the callback or null if none. 12 | 13 | var testRunner = require('vscode/lib/testrunner'); 14 | 15 | // You can directly control Mocha options by uncommenting the following lines 16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info 17 | testRunner.configure({ 18 | ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.) 19 | useColors: true // colored output from test results 20 | }); 21 | 22 | module.exports = testRunner; -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls a custom npm script that compiles the extension. 10 | { 11 | "version": "0.1.0", 12 | 13 | // we want to run npm 14 | "command": "npm", 15 | 16 | // the command is a shell script 17 | "isShellCommand": true, 18 | 19 | // show the output window only if unrecognized errors occur. 20 | "showOutput": "silent", 21 | 22 | // we run the custom script "compile" as defined in package.json 23 | "args": ["run", "compile", "--loglevel", "silent"], 24 | 25 | // The tsc compiler is started in watching mode 26 | "isWatching": true, 27 | 28 | // use the standard tsc in watch mode problem matcher to find compile problems in the output. 29 | "problemMatcher": "$tsc-watch" 30 | } -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your first VS Code Extension 2 | 3 | ## What's in the folder 4 | * This folder contains all of the files necessary for your extension 5 | * `package.json` - this is the manifest file in which you declare your extension and command. 6 | The sample plugin registers a command and defines its title and command name. With this information 7 | 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 10 | activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 11 | We pass the function containing the implementation of the command as the second parameter to 12 | `registerCommand`. 13 | 14 | ## Get up and running straight away 15 | * press `F5` to open a new window with your extension loaded 16 | * run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World` 17 | * set breakpoints in your code inside `src/extension.ts` to debug your extension 18 | * find output from your extension in the debug console 19 | 20 | ## Make changes 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 | ## Explore the API 25 | * you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts` 26 | 27 | ## Run tests 28 | * open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests` 29 | * press `F5` to run the tests in a new window with your extension loaded 30 | * see the output of the test result in the debug console 31 | * make changes to `test/extension.test.ts` or create new test files inside the `test` folder 32 | * by convention, the test runner will only consider files matching the name pattern `**.test.ts` 33 | * you can create folders inside the `test` folder to structure your tests any way you want -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // the module 'vscode' contains the VS Code extensibility API 3 | // import the necessary extensibility types to use in your code below 4 | import { 5 | window, 6 | commands, 7 | workspace, 8 | Disposable, 9 | ExtensionContext, 10 | StatusBarAlignment, 11 | StatusBarItem, 12 | TextDocument 13 | } from "vscode"; 14 | 15 | export function activate(context: ExtensionContext) { 16 | let discourager = new Discourager(); 17 | 18 | let disposable = commands.registerCommand("discourage.toggle", () => { 19 | discourager.updateDiscourageMessage(); 20 | }); 21 | 22 | workspace.onDidSaveTextDocument(e => { 23 | discourager.updateDiscourageMessage(); 24 | }); 25 | 26 | // add to a list of disposables which are disposed when this extension is deactivated. 27 | context.subscriptions.push(discourager); 28 | context.subscriptions.push(disposable); 29 | } 30 | 31 | export function deactivate() {} 32 | 33 | class Discourager { 34 | private _statusBarItem: StatusBarItem; 35 | private _discouragements = [ 36 | "That was pretty meh...", 37 | "Uh... are you ok?", 38 | "Not sure about what you just did there...", 39 | "Do you want me to be nice... or honest?", 40 | "Maybe you should take the rest of the day off...", 41 | "I'm not going to say you made a mistake... but...", 42 | "Was that a typo, or...", 43 | "Yikes..." 44 | ]; 45 | 46 | private _timer: any; 47 | private statusBarAutoDismiss(millisecBeforeDismiss: any) { 48 | if (!this._statusBarItem) { 49 | return; 50 | } 51 | 52 | clearTimeout(this._timer); 53 | let that = this; 54 | this._timer = setTimeout(function() { 55 | that._statusBarItem.hide(); 56 | }, millisecBeforeDismiss); 57 | } 58 | 59 | private getRandomDiscouragement() { 60 | return this._discouragements[ 61 | Math.floor(Math.random() * this._discouragements.length) 62 | ]; 63 | } 64 | 65 | public updateDiscourageMessage() { 66 | // create as needed 67 | if (!this._statusBarItem) { 68 | this._statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left); 69 | } 70 | 71 | // get the current text editor 72 | let editor = window.activeTextEditor; 73 | if (!editor) { 74 | this._statusBarItem.hide(); 75 | return; 76 | } 77 | 78 | this._statusBarItem.text = this.getRandomDiscouragement(); 79 | this._statusBarItem.show(); 80 | this.statusBarAutoDismiss(5000); 81 | } 82 | 83 | dispose() { 84 | this._statusBarItem.dispose(); 85 | } 86 | } 87 | --------------------------------------------------------------------------------