├── CODEOWNERS ├── .gitignore ├── img ├── command.gif ├── status_bar_none.png ├── status_bar_one.png ├── status_bar_three.png ├── status_bar_two.png └── syntax_highlighting.png ├── .gitattributes ├── language-configuration.json ├── .prettierrc ├── .vscode ├── settings.json └── launch.json ├── .vscodeignore ├── jsconfig.json ├── CHANGELOG.md ├── README.md ├── syntaxes └── codeowners.tmLanguage.json ├── LICENSE.txt ├── package.json └── extension.js /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * jasonnutter 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode-test/ 3 | *.vsix 4 | -------------------------------------------------------------------------------- /img/command.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonnutter/vscode-codeowners/HEAD/img/command.gif -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behavior to automatically normalize line endings. 2 | * text=auto 3 | 4 | -------------------------------------------------------------------------------- /language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "#" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /img/status_bar_none.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonnutter/vscode-codeowners/HEAD/img/status_bar_none.png -------------------------------------------------------------------------------- /img/status_bar_one.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonnutter/vscode-codeowners/HEAD/img/status_bar_one.png -------------------------------------------------------------------------------- /img/status_bar_three.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonnutter/vscode-codeowners/HEAD/img/status_bar_three.png -------------------------------------------------------------------------------- /img/status_bar_two.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonnutter/vscode-codeowners/HEAD/img/status_bar_two.png -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "singleQuote": true, 4 | "tabWidth": 4, 5 | "printWidth": 120 6 | } 7 | -------------------------------------------------------------------------------- /img/syntax_highlighting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonnutter/vscode-codeowners/HEAD/img/syntax_highlighting.png -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "editor.formatOnSave": true 4 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | test/** 4 | .gitignore 5 | vsc-extension-quickstart.md 6 | **/jsconfig.json 7 | **/*.map 8 | **/.eslintrc.json 9 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "checkJs": false, /* Typecheck .js files. */ 6 | "lib": [ 7 | "es6" 8 | ] 9 | }, 10 | "exclude": [ 11 | "node_modules" 12 | ] 13 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## v1.1.1 4 | 5 | Thanks to [@bmalehorn](https://github.com/bmalehorn) for these bug fixes! 6 | 7 | - Fixed: Hide status bar item when no CODEOWNERS file ([#3](https://github.com/jasonnutter/vscode-codeowners/pull/3)). 8 | - Fixed: Fix /root paths ([#4](https://github.com/jasonnutter/vscode-codeowners/pull/4)). 9 | 10 | ## v1.1.0 11 | 12 | - Added: Syntax highlighting for `CODEOWNERS` files. Thanks [@bmalehorn](https://github.com/bmalehorn) for the [contribution](https://github.com/jasonnutter/vscode-codeowners/pull/1)! 13 | 14 | ## v1.0.0 15 | 16 | - Initial release 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vscode-codeowners 2 | 3 | VS Code extension to display the code owners for the current file, as defined in the [CODEOWNERS](https://help.github.com/articles/about-codeowners/) file. 4 | 5 | ## Features 6 | 7 | ### Syntax highlighting 8 | 9 | ![](./img/syntax_highlighting.png) 10 | 11 | ### Status bar 12 | 13 | ![](./img/status_bar_none.png) 14 | ![](./img/status_bar_one.png) 15 | ![](./img/status_bar_two.png) 16 | ![](./img/status_bar_three.png) 17 | 18 | The first code owners for an open file will be displayed in the right side of the status bar. Clicking the status bar item will open a menu displaying all of the code owners. 19 | 20 | ### Command 21 | 22 | ![](./img/command.gif) 23 | 24 | Use the command palette to run the `CODEOWNERS: Show owners of current file` command, which will display all code owners for the current file. 25 | -------------------------------------------------------------------------------- /syntaxes/codeowners.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "codeowners", 3 | "patterns": [ 4 | { 5 | "include": "#comment" 6 | }, 7 | { 8 | "include": "#pattern" 9 | }, 10 | { 11 | "include": "#owner" 12 | } 13 | ], 14 | "repository": { 15 | "comment": { 16 | "patterns": [ 17 | { 18 | "begin": "^\\s*#", 19 | "captures": { 20 | "0": { 21 | "name": "punctuation.definition.comment.codeowners" 22 | } 23 | }, 24 | "end": "$", 25 | "name": "comment.line.codeowners" 26 | } 27 | ] 28 | }, 29 | "pattern": { 30 | "match": "^\\s*(\\S+)", 31 | "name": "variable.other.codeowners" 32 | }, 33 | "owner": { 34 | "match": "\\S*@\\S+", 35 | "name": "storage.type.function.codeowners" 36 | } 37 | }, 38 | "scopeName": "text.codeowners" 39 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension 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": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}" 15 | ] 16 | }, 17 | { 18 | "name": "Extension Tests", 19 | "type": "extensionHost", 20 | "request": "launch", 21 | "runtimeExecutable": "${execPath}", 22 | "args": [ 23 | "--extensionDevelopmentPath=${workspaceFolder}", 24 | "--extensionTestsPath=${workspaceFolder}/test" 25 | ] 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jason Nutter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-codeowners", 3 | "displayName": "CODEOWNERS", 4 | "description": "VS Code extension for CODEOWNERS file", 5 | "publisher": "jasonnutter", 6 | "repository": { 7 | "url": "https://github.com/jasonnutter/vscode-codeowners" 8 | }, 9 | "license": "MIT", 10 | "version": "1.1.1", 11 | "engines": { 12 | "vscode": "^1.29.0" 13 | }, 14 | "categories": [ 15 | "Other" 16 | ], 17 | "activationEvents": [ 18 | "workspaceContains:**/CODEOWNERS" 19 | ], 20 | "main": "./extension", 21 | "contributes": { 22 | "commands": [ 23 | { 24 | "command": "vscode-codeowners.show-owners", 25 | "title": "CODEOWNERS: Show owners of current file" 26 | } 27 | ], 28 | "languages": [ 29 | { 30 | "id": "codeowners", 31 | "aliases": [ 32 | "CODEOWNERS", 33 | "codeowners" 34 | ], 35 | "filenames": [ 36 | "CODEOWNERS" 37 | ], 38 | "configuration": "./language-configuration.json" 39 | } 40 | ], 41 | "grammars": [ 42 | { 43 | "language": "codeowners", 44 | "scopeName": "text.codeowners", 45 | "path": "./syntaxes/codeowners.tmLanguage.json" 46 | } 47 | ] 48 | }, 49 | "scripts": { 50 | "postinstall": "node ./node_modules/vscode/bin/install", 51 | "test": "node ./node_modules/vscode/bin/test" 52 | }, 53 | "devDependencies": { 54 | "@types/mocha": "^2.2.42", 55 | "@types/node": "^8.10.25", 56 | "prettier": "1.15.3", 57 | "typescript": "^3.1.4", 58 | "vscode": "^1.1.36" 59 | }, 60 | "dependencies": { 61 | "codeowners": "^4.1.1" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | const vscode = require('vscode'); 2 | const Codeowners = require('codeowners'); 3 | const path = require('path'); 4 | 5 | const COMMAND_ID = 'vscode-codeowners.show-owners'; 6 | const STATUS_BAR_PRIORITY = 100; 7 | 8 | const getOwners = () => { 9 | if (!vscode.window.activeTextEditor) { 10 | return []; 11 | } 12 | 13 | const { fileName, uri } = vscode.window.activeTextEditor.document; 14 | 15 | const { 16 | uri: { fsPath: workspacePath } 17 | } = vscode.workspace.getWorkspaceFolder(uri); 18 | 19 | let folder; 20 | try { 21 | folder = new Codeowners(workspacePath); 22 | } catch { 23 | // no CODEOWNERS file 24 | return null; 25 | } 26 | 27 | const file = fileName.split(`${workspacePath}${path.sep}`)[1]; 28 | 29 | return folder.getOwner(file); 30 | }; 31 | 32 | const activate = context => { 33 | console.log('CODEOWNERS: activated'); 34 | 35 | const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, STATUS_BAR_PRIORITY); 36 | 37 | statusBarItem.command = COMMAND_ID; 38 | context.subscriptions.push(statusBarItem); 39 | 40 | context.subscriptions.push( 41 | vscode.commands.registerCommand(COMMAND_ID, () => { 42 | vscode.window.showQuickPick(getOwners()); 43 | }) 44 | ); 45 | 46 | context.subscriptions.push( 47 | vscode.window.onDidChangeActiveTextEditor(() => { 48 | const owners = getOwners(); 49 | 50 | if (!owners) { 51 | statusBarItem.hide(); 52 | return; 53 | } 54 | 55 | if (owners.length > 2) { 56 | statusBarItem.text = `CODEOWNERS: ${owners[0]} & ${owners.length - 1} others`; 57 | } else if (owners.length === 2) { 58 | statusBarItem.text = `CODEOWNERS: ${owners[0]} & 1 other`; 59 | } else if (owners.length === 1) { 60 | statusBarItem.text = `CODEOWNERS: ${owners[0]}`; 61 | } else { 62 | statusBarItem.text = 'CODEOWNERS: None'; 63 | } 64 | 65 | statusBarItem.tooltip = 'Show CODEOWNERS'; 66 | statusBarItem.show(); 67 | }) 68 | ); 69 | }; 70 | 71 | exports.activate = activate; 72 | 73 | const deactivate = () => {}; 74 | exports.deactivate = deactivate; 75 | --------------------------------------------------------------------------------