├── .gitignore ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── README.md ├── images ├── icon.png └── verilog-format.gif ├── package-lock.json ├── package.json ├── src ├── extension.ts └── test │ ├── extension.test.ts │ └── index.ts ├── tsconfig.json ├── tslint.json └── vsc-extension-quickstart.md /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | .vscode-test/ 4 | *.vsix 5 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 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.json: -------------------------------------------------------------------------------- 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 | "name": "Run Extension", 9 | "type": "extensionHost", 10 | "request": "launch", 11 | "runtimeExecutable": "${execPath}", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ], 15 | "outFiles": [ 16 | "${workspaceFolder}/out/**/*.js" 17 | ], 18 | "preLaunchTask": "npm: watch" 19 | }, 20 | { 21 | "name": "Extension Tests", 22 | "type": "extensionHost", 23 | "request": "launch", 24 | "runtimeExecutable": "${execPath}", 25 | "args": [ 26 | "--extensionDevelopmentPath=${workspaceFolder}", 27 | "--extensionTestsPath=${workspaceFolder}/out/test" 28 | ], 29 | "outFiles": [ 30 | "${workspaceFolder}/out/test/**/*.js" 31 | ], 32 | "preLaunchTask": "npm: watch" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /.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 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts 10 | "typescript.tsc.autoDetect": "off" 11 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 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 | } 21 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 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: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to the "verilogformat" extension will be documented in this file. 3 | 4 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 5 | 6 | ## [Unreleased] 7 | - Initial release -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vscode VerilogFormat 2 | 3 | VerilogFormat Extension is a tool for formatter verilog files. This extension use the console aplication verilog-format. 4 | 5 | ![sample](images/verilog-format.gif) 6 | 7 | ## Requirements 8 | 9 | 1. IMPORTANTE, verilog-format executable. 10 | 11 | [Install verilog-format](https://github.com/ericsonj/verilog-format) 12 | 13 | ## Extension Settings 14 | 15 | 1. File > Preferences > Settings > Verilog Format > Path 16 | 17 | Path of executable verilof-format. 18 | 19 | * LINUX: `/verilog-format` 20 | * WIN: `/verilog-format.exe` 21 | 22 | 2. File > Preferences > Settings > Verilog Format > Settings 23 | 24 | Path of file `.verilog-format.properties` (global settings). Example: `~/.verilog-format.properties` 25 | 26 | ```properties 27 | IndentWidth=4 28 | IndentType=tab 29 | ``` 30 | 31 | **Important**: If project folder don't have the file `.verilog-format.properties` (local settings) the global settings is used. If no files exist the internal settings is used. 32 | 33 | 34 | ## Verilog-Format Style Options 35 | 36 | This options are setting in `.verilog-format.properties` file. 37 | 38 | ### Example 39 | 40 | ```properties 41 | ## File .verilog-format.properties 42 | IndentWidth=4 43 | IndentType=space 44 | SpacesBeforeTrailingComments=0 45 | SpacesAfterTrailingComments=0 46 | AlignLineComments=true 47 | AlignNoBlockingAssignments=true 48 | AlignBlockingAssignments=true 49 | SpacesInParentheses=false 50 | SpacesInSquareBrackets=false 51 | ``` 52 | 53 | --- 54 | ### IndentWidth=[number] 55 | 56 | ```verilog 57 | // IndentWidth=4 #(default) 58 | always @(posedge clk) 59 | if (load == 1) 60 | bitc <= 0; 61 | else if (load == 0 && clk_baud == 1) 62 | bitc <= bitc + 1; 63 | 64 | // IndentWidth=1 65 | always @(posedge clk) 66 | if (load == 1) 67 | bitc <= 0; 68 | else if (load == 0 && clk_baud == 1) 69 | bitc <= bitc + 1; 70 | ``` 71 | --- 72 | ### IndentType=[space|tab] 73 | ```verilog 74 | // IndentType=space #(default) 75 | always @(posedge clk) 76 | if (load == 1) 77 | bitc <= 0; 78 | else if (load == 0 && clk_baud == 1) 79 | bitc <= bitc + 1; 80 | 81 | // IndentType=tab # not recommended yet 82 | always @(posedge clk) 83 | if (load == 1) 84 | bitc <= 0; 85 | else if (load == 0 && clk_baud == 1) 86 | bitc <= bitc + 1; 87 | ``` 88 | --- 89 | ### SpacesInParentheses=[true|false] 90 | ```verilog 91 | // SpacesInParentheses=false #(default) 92 | always @(posedge clk) 93 | if (load == 1) 94 | 95 | // SpacesInParentheses=true 96 | always @( posedge clk ) 97 | if ( load == 1 ) 98 | ``` 99 | --- 100 | 101 | ### SpacesInSquareBrackets=[true|false] 102 | ```verilog 103 | // SpacesInSquareBrackets=false #(default) 104 | reg [DW-1:0] rom [0:NPOS-1]; 105 | 106 | always @(posedge clk) begin 107 | data <= rom[addr]; 108 | end 109 | 110 | // SpacesInSquareBrackets=true 111 | reg [ DW-1:0 ] rom [ 0:NPOS-1 ]; 112 | 113 | always @(posedge clk) begin 114 | data <= rom[ addr ]; 115 | ``` 116 | --- 117 | ### AlignBlockingAssignments=[true|false] 118 | ```verilog 119 | // AlignBlockingAssignments=true #(default) 120 | assign load = (state == START) ? 1 : 0; 121 | assign baud_en = (state == IDLE) ? 0 : 1; 122 | 123 | // AlignBlockingAssignments=false 124 | assign load = (state == START) ? 1 : 0; 125 | assign baud_en = (state == IDLE) ? 0 : 1; 126 | 127 | ``` 128 | --- 129 | ### AlignNoBlockingAssignments=[true|false] 130 | ```verilog 131 | // AlignNoBlockingAssignments=true #(default) 132 | state_ts <= IDLE; 133 | state_pad <= IDLE; 134 | state_wait <= IDLE; 135 | 136 | // AlignNoBlockingAssignments=false 137 | state_ts <= IDLE; 138 | state_pad <= IDLE; 139 | state_wait <= IDLE; 140 | ``` 141 | --- 142 | ### AlignLineComments=[true|false] 143 | ```verilog 144 | // AlignLineComments=false #(default) 145 | always @(posedge clk) // always 146 | if (load == 1) // if 147 | bitc <= 0; // 148 | else if (load == 0 && clk_baud == 1) // else if 149 | bitc <= bitc + 1; // 150 | 151 | // AlignLineComments=true 152 | always @(posedge clk) // always 153 | if (load == 1) // if 154 | bitc <= 0; // 155 | else if (load == 0 && clk_baud == 1) // else if 156 | bitc <= bitc + 1; // 157 | ``` 158 | --- 159 | ### SpacesBeforeTrailingComments=[number] 160 | ```verilog 161 | // SpacesBeforeTrailingComments=1 #(default) 162 | localparam IDLE = 0; //IDLE 163 | 164 | // SpacesBeforeTrailingComments=0 165 | localparam IDLE = 0;//IDLE 166 | ``` 167 | --- 168 | ### SpacesAfterTrailingComments=[number] 169 | ```verilog 170 | // SpacesAfterTrailingComments=0 #(default) 171 | localparam IDLE = 0; //IDLE 172 | 173 | // SpacesAfterTrailingComments=3 174 | localparam IDLE = 0; // IDLE 175 | ``` 176 | --- 177 | 178 | ## Known Issues 179 | 180 | ERR: multiple module align in file not work. 181 | 182 | ## Release Notes 183 | 184 | Line indent and align module definition. 185 | 186 | SpacesBeforeTrailingComments 187 | SpacesAfterTrailingComments 188 | AlignLineComments 189 | AlignNoBlockingAssignments 190 | AlignBlockingAssignments 191 | SpacesInParentheses 192 | SpacesInSquareBrackets 193 | 194 | ### 1.0.1 195 | 196 | Add more documentation, new feactures and fix bugs. 197 | 198 | ### 1.0.0 199 | 200 | Initial release of verilog-format vscode extension. -------------------------------------------------------------------------------- /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsonj/vscode-verilogformar/a2c87ebbf14213227771d693028864b9f1f3e63a/images/icon.png -------------------------------------------------------------------------------- /images/verilog-format.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsonj/vscode-verilogformar/a2c87ebbf14213227771d693028864b9f1f3e63a/images/verilog-format.gif -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "verilogformat", 3 | "version": "1.0.1", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@tootallnate/once": { 8 | "version": "1.1.2", 9 | "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", 10 | "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", 11 | "dev": true 12 | }, 13 | "@types/mocha": { 14 | "version": "2.2.48", 15 | "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz", 16 | "integrity": "sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==", 17 | "dev": true 18 | }, 19 | "@types/node": { 20 | "version": "10.12.24", 21 | "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.24.tgz", 22 | "integrity": "sha512-GWWbvt+z9G5otRBW8rssOFgRY87J9N/qbhqfjMZ+gUuL6zoL+Hm6gP/8qQBG4jjimqdaNLCehcVapZ/Fs2WjCQ==" 23 | }, 24 | "@types/temp": { 25 | "version": "0.8.33", 26 | "resolved": "https://registry.npmjs.org/@types/temp/-/temp-0.8.33.tgz", 27 | "integrity": "sha512-lxvpXBglH4QAg9Esk75fUeK8sP7Cz29Bx3wghmjJwDxihO+xN1UN3a3HtPQXIyr4O2mzjOCapbwJ/aF7hXIOMQ==", 28 | "requires": { 29 | "@types/node": "*" 30 | } 31 | }, 32 | "agent-base": { 33 | "version": "6.0.2", 34 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", 35 | "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", 36 | "dev": true, 37 | "requires": { 38 | "debug": "4" 39 | } 40 | }, 41 | "ansi-regex": { 42 | "version": "2.1.1", 43 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", 44 | "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", 45 | "dev": true 46 | }, 47 | "ansi-styles": { 48 | "version": "2.2.1", 49 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", 50 | "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", 51 | "dev": true 52 | }, 53 | "argparse": { 54 | "version": "1.0.10", 55 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 56 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 57 | "dev": true, 58 | "requires": { 59 | "sprintf-js": "~1.0.2" 60 | } 61 | }, 62 | "babel-code-frame": { 63 | "version": "6.26.0", 64 | "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", 65 | "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", 66 | "dev": true, 67 | "requires": { 68 | "chalk": "^1.1.3", 69 | "esutils": "^2.0.2", 70 | "js-tokens": "^3.0.2" 71 | }, 72 | "dependencies": { 73 | "chalk": { 74 | "version": "1.1.3", 75 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", 76 | "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", 77 | "dev": true, 78 | "requires": { 79 | "ansi-styles": "^2.2.1", 80 | "escape-string-regexp": "^1.0.2", 81 | "has-ansi": "^2.0.0", 82 | "strip-ansi": "^3.0.0", 83 | "supports-color": "^2.0.0" 84 | } 85 | } 86 | } 87 | }, 88 | "balanced-match": { 89 | "version": "1.0.0", 90 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 91 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" 92 | }, 93 | "brace-expansion": { 94 | "version": "1.1.11", 95 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 96 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 97 | "requires": { 98 | "balanced-match": "^1.0.0", 99 | "concat-map": "0.0.1" 100 | } 101 | }, 102 | "browser-stdout": { 103 | "version": "1.3.1", 104 | "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", 105 | "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", 106 | "dev": true 107 | }, 108 | "buffer-from": { 109 | "version": "1.1.2", 110 | "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", 111 | "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", 112 | "dev": true 113 | }, 114 | "builtin-modules": { 115 | "version": "1.1.1", 116 | "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", 117 | "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", 118 | "dev": true 119 | }, 120 | "chalk": { 121 | "version": "2.4.2", 122 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", 123 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", 124 | "dev": true, 125 | "requires": { 126 | "ansi-styles": "^3.2.1", 127 | "escape-string-regexp": "^1.0.5", 128 | "supports-color": "^5.3.0" 129 | }, 130 | "dependencies": { 131 | "ansi-styles": { 132 | "version": "3.2.1", 133 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", 134 | "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", 135 | "dev": true, 136 | "requires": { 137 | "color-convert": "^1.9.0" 138 | } 139 | }, 140 | "supports-color": { 141 | "version": "5.5.0", 142 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 143 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 144 | "dev": true, 145 | "requires": { 146 | "has-flag": "^3.0.0" 147 | } 148 | } 149 | } 150 | }, 151 | "color-convert": { 152 | "version": "1.9.3", 153 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", 154 | "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", 155 | "dev": true, 156 | "requires": { 157 | "color-name": "1.1.3" 158 | } 159 | }, 160 | "color-name": { 161 | "version": "1.1.3", 162 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", 163 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", 164 | "dev": true 165 | }, 166 | "commander": { 167 | "version": "2.19.0", 168 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", 169 | "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", 170 | "dev": true 171 | }, 172 | "concat-map": { 173 | "version": "0.0.1", 174 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 175 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" 176 | }, 177 | "debug": { 178 | "version": "4.3.4", 179 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 180 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 181 | "dev": true, 182 | "requires": { 183 | "ms": "2.1.2" 184 | } 185 | }, 186 | "diff": { 187 | "version": "3.5.0", 188 | "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", 189 | "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", 190 | "dev": true 191 | }, 192 | "es6-promise": { 193 | "version": "4.2.8", 194 | "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", 195 | "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", 196 | "dev": true 197 | }, 198 | "es6-promisify": { 199 | "version": "5.0.0", 200 | "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", 201 | "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", 202 | "dev": true, 203 | "requires": { 204 | "es6-promise": "^4.0.3" 205 | } 206 | }, 207 | "escape-string-regexp": { 208 | "version": "1.0.5", 209 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 210 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 211 | "dev": true 212 | }, 213 | "esprima": { 214 | "version": "4.0.1", 215 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 216 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 217 | "dev": true 218 | }, 219 | "esutils": { 220 | "version": "2.0.2", 221 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", 222 | "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", 223 | "dev": true 224 | }, 225 | "fs.realpath": { 226 | "version": "1.0.0", 227 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 228 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" 229 | }, 230 | "glob": { 231 | "version": "7.1.3", 232 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", 233 | "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", 234 | "requires": { 235 | "fs.realpath": "^1.0.0", 236 | "inflight": "^1.0.4", 237 | "inherits": "2", 238 | "minimatch": "^3.0.4", 239 | "once": "^1.3.0", 240 | "path-is-absolute": "^1.0.0" 241 | } 242 | }, 243 | "growl": { 244 | "version": "1.10.5", 245 | "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", 246 | "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", 247 | "dev": true 248 | }, 249 | "has-ansi": { 250 | "version": "2.0.0", 251 | "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", 252 | "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", 253 | "dev": true, 254 | "requires": { 255 | "ansi-regex": "^2.0.0" 256 | } 257 | }, 258 | "has-flag": { 259 | "version": "3.0.0", 260 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 261 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 262 | "dev": true 263 | }, 264 | "he": { 265 | "version": "1.1.1", 266 | "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", 267 | "integrity": "sha512-z/GDPjlRMNOa2XJiB4em8wJpuuBfrFOlYKTZxtpkdr1uPdibHI8rYA3MY0KDObpVyaes0e/aunid/t88ZI2EKA==", 268 | "dev": true 269 | }, 270 | "http-proxy-agent": { 271 | "version": "4.0.1", 272 | "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", 273 | "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", 274 | "dev": true, 275 | "requires": { 276 | "@tootallnate/once": "1", 277 | "agent-base": "6", 278 | "debug": "4" 279 | } 280 | }, 281 | "https-proxy-agent": { 282 | "version": "5.0.1", 283 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", 284 | "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", 285 | "dev": true, 286 | "requires": { 287 | "agent-base": "6", 288 | "debug": "4" 289 | } 290 | }, 291 | "inflight": { 292 | "version": "1.0.6", 293 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 294 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 295 | "requires": { 296 | "once": "^1.3.0", 297 | "wrappy": "1" 298 | } 299 | }, 300 | "inherits": { 301 | "version": "2.0.3", 302 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 303 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 304 | }, 305 | "js-tokens": { 306 | "version": "3.0.2", 307 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", 308 | "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", 309 | "dev": true 310 | }, 311 | "js-yaml": { 312 | "version": "3.13.1", 313 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", 314 | "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", 315 | "dev": true, 316 | "requires": { 317 | "argparse": "^1.0.7", 318 | "esprima": "^4.0.0" 319 | } 320 | }, 321 | "minimatch": { 322 | "version": "3.0.4", 323 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 324 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 325 | "requires": { 326 | "brace-expansion": "^1.1.7" 327 | } 328 | }, 329 | "minimist": { 330 | "version": "0.0.8", 331 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 332 | "integrity": "sha512-miQKw5Hv4NS1Psg2517mV4e4dYNaO3++hjAvLOAzKqZ61rH8NS1SK+vbfBWZ5PY/Me/bEWhUwqMghEW5Fb9T7Q==", 333 | "dev": true 334 | }, 335 | "mkdirp": { 336 | "version": "0.5.1", 337 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 338 | "integrity": "sha512-SknJC52obPfGQPnjIkXbmA6+5H15E+fR+E4iR2oQ3zzCLbd7/ONua69R/Gw7AgkTLsRG+r5fzksYwWe1AgTyWA==", 339 | "dev": true, 340 | "requires": { 341 | "minimist": "0.0.8" 342 | } 343 | }, 344 | "mocha": { 345 | "version": "5.2.0", 346 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", 347 | "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", 348 | "dev": true, 349 | "requires": { 350 | "browser-stdout": "1.3.1", 351 | "commander": "2.15.1", 352 | "debug": "3.1.0", 353 | "diff": "3.5.0", 354 | "escape-string-regexp": "1.0.5", 355 | "glob": "7.1.2", 356 | "growl": "1.10.5", 357 | "he": "1.1.1", 358 | "minimatch": "3.0.4", 359 | "mkdirp": "0.5.1", 360 | "supports-color": "5.4.0" 361 | }, 362 | "dependencies": { 363 | "commander": { 364 | "version": "2.15.1", 365 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", 366 | "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", 367 | "dev": true 368 | }, 369 | "debug": { 370 | "version": "3.1.0", 371 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 372 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 373 | "dev": true, 374 | "requires": { 375 | "ms": "2.0.0" 376 | } 377 | }, 378 | "glob": { 379 | "version": "7.1.2", 380 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", 381 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", 382 | "dev": true, 383 | "requires": { 384 | "fs.realpath": "^1.0.0", 385 | "inflight": "^1.0.4", 386 | "inherits": "2", 387 | "minimatch": "^3.0.4", 388 | "once": "^1.3.0", 389 | "path-is-absolute": "^1.0.0" 390 | } 391 | }, 392 | "ms": { 393 | "version": "2.0.0", 394 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 395 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", 396 | "dev": true 397 | }, 398 | "supports-color": { 399 | "version": "5.4.0", 400 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", 401 | "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", 402 | "dev": true, 403 | "requires": { 404 | "has-flag": "^3.0.0" 405 | } 406 | } 407 | } 408 | }, 409 | "ms": { 410 | "version": "2.1.2", 411 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 412 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 413 | "dev": true 414 | }, 415 | "once": { 416 | "version": "1.4.0", 417 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 418 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 419 | "requires": { 420 | "wrappy": "1" 421 | } 422 | }, 423 | "path-is-absolute": { 424 | "version": "1.0.1", 425 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 426 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" 427 | }, 428 | "path-parse": { 429 | "version": "1.0.7", 430 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", 431 | "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", 432 | "dev": true 433 | }, 434 | "resolve": { 435 | "version": "1.10.0", 436 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", 437 | "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", 438 | "dev": true, 439 | "requires": { 440 | "path-parse": "^1.0.6" 441 | } 442 | }, 443 | "rimraf": { 444 | "version": "2.6.3", 445 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", 446 | "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", 447 | "requires": { 448 | "glob": "^7.1.3" 449 | } 450 | }, 451 | "semver": { 452 | "version": "5.6.0", 453 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", 454 | "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", 455 | "dev": true 456 | }, 457 | "source-map": { 458 | "version": "0.6.1", 459 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 460 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 461 | "dev": true 462 | }, 463 | "source-map-support": { 464 | "version": "0.5.21", 465 | "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", 466 | "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", 467 | "dev": true, 468 | "requires": { 469 | "buffer-from": "^1.0.0", 470 | "source-map": "^0.6.0" 471 | } 472 | }, 473 | "sprintf-js": { 474 | "version": "1.0.3", 475 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 476 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 477 | "dev": true 478 | }, 479 | "strip-ansi": { 480 | "version": "3.0.1", 481 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", 482 | "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", 483 | "dev": true, 484 | "requires": { 485 | "ansi-regex": "^2.0.0" 486 | } 487 | }, 488 | "supports-color": { 489 | "version": "2.0.0", 490 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", 491 | "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", 492 | "dev": true 493 | }, 494 | "temp": { 495 | "version": "0.9.0", 496 | "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.0.tgz", 497 | "integrity": "sha512-YfUhPQCJoNQE5N+FJQcdPz63O3x3sdT4Xju69Gj4iZe0lBKOtnAMi0SLj9xKhGkcGhsxThvTJ/usxtFPo438zQ==", 498 | "requires": { 499 | "rimraf": "~2.6.2" 500 | } 501 | }, 502 | "tslib": { 503 | "version": "1.9.3", 504 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", 505 | "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", 506 | "dev": true 507 | }, 508 | "tslint": { 509 | "version": "5.12.1", 510 | "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.12.1.tgz", 511 | "integrity": "sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw==", 512 | "dev": true, 513 | "requires": { 514 | "babel-code-frame": "^6.22.0", 515 | "builtin-modules": "^1.1.1", 516 | "chalk": "^2.3.0", 517 | "commander": "^2.12.1", 518 | "diff": "^3.2.0", 519 | "glob": "^7.1.1", 520 | "js-yaml": "^3.7.0", 521 | "minimatch": "^3.0.4", 522 | "resolve": "^1.3.2", 523 | "semver": "^5.3.0", 524 | "tslib": "^1.8.0", 525 | "tsutils": "^2.27.2" 526 | } 527 | }, 528 | "tsutils": { 529 | "version": "2.29.0", 530 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", 531 | "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", 532 | "dev": true, 533 | "requires": { 534 | "tslib": "^1.8.1" 535 | } 536 | }, 537 | "typescript": { 538 | "version": "3.3.3", 539 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.3.tgz", 540 | "integrity": "sha512-Y21Xqe54TBVp+VDSNbuDYdGw0BpoR/Q6wo/+35M8PAU0vipahnyduJWirxxdxjsAkS7hue53x2zp8gz7F05u0A==", 541 | "dev": true 542 | }, 543 | "vscode": { 544 | "version": "1.1.37", 545 | "resolved": "https://registry.npmjs.org/vscode/-/vscode-1.1.37.tgz", 546 | "integrity": "sha512-vJNj6IlN7IJPdMavlQa1KoFB3Ihn06q1AiN3ZFI/HfzPNzbKZWPPuiU+XkpNOfGU5k15m4r80nxNPlM7wcc0wg==", 547 | "dev": true, 548 | "requires": { 549 | "glob": "^7.1.2", 550 | "http-proxy-agent": "^4.0.1", 551 | "https-proxy-agent": "^5.0.0", 552 | "mocha": "^5.2.0", 553 | "semver": "^5.4.1", 554 | "source-map-support": "^0.5.0", 555 | "vscode-test": "^0.4.1" 556 | } 557 | }, 558 | "vscode-test": { 559 | "version": "0.4.3", 560 | "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-0.4.3.tgz", 561 | "integrity": "sha512-EkMGqBSefZH2MgW65nY05rdRSko15uvzq4VAPM5jVmwYuFQKE7eikKXNJDRxL+OITXHB6pI+a3XqqD32Y3KC5w==", 562 | "dev": true, 563 | "requires": { 564 | "http-proxy-agent": "^2.1.0", 565 | "https-proxy-agent": "^2.2.1" 566 | }, 567 | "dependencies": { 568 | "agent-base": { 569 | "version": "4.3.0", 570 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", 571 | "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", 572 | "dev": true, 573 | "requires": { 574 | "es6-promisify": "^5.0.0" 575 | } 576 | }, 577 | "debug": { 578 | "version": "3.1.0", 579 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 580 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 581 | "dev": true, 582 | "requires": { 583 | "ms": "2.0.0" 584 | } 585 | }, 586 | "http-proxy-agent": { 587 | "version": "2.1.0", 588 | "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", 589 | "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", 590 | "dev": true, 591 | "requires": { 592 | "agent-base": "4", 593 | "debug": "3.1.0" 594 | } 595 | }, 596 | "https-proxy-agent": { 597 | "version": "2.2.4", 598 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", 599 | "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", 600 | "dev": true, 601 | "requires": { 602 | "agent-base": "^4.3.0", 603 | "debug": "^3.1.0" 604 | } 605 | }, 606 | "ms": { 607 | "version": "2.0.0", 608 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 609 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", 610 | "dev": true 611 | } 612 | } 613 | }, 614 | "wrappy": { 615 | "version": "1.0.2", 616 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 617 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" 618 | } 619 | } 620 | } 621 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "verilogformat", 3 | "displayName": "Verilog Format", 4 | "description": "Console application for apply format to verilog file.", 5 | "version": "1.0.1", 6 | "engines": { 7 | "vscode": "^1.31.0" 8 | }, 9 | "categories": [ 10 | "Formatters" 11 | ], 12 | "icon": "images/icon.png", 13 | "galleryBanner": { 14 | "color": "#232323", 15 | "theme": "dark" 16 | }, 17 | "activationEvents": [ 18 | "onLanguage:verilog" 19 | ], 20 | "main": "./out/extension.js", 21 | "contributes": { 22 | "configuration": { 23 | "title": "Verilog Format", 24 | "properties": { 25 | "verilog-format.path": { 26 | "scope": "window", 27 | "type": "string", 28 | "default": "/opt/verilog-format/verilog-format", 29 | "description": "Path of verilog-format" 30 | }, 31 | "verilog-format.settings": { 32 | "scope": "window", 33 | "type": "string", 34 | "default": "${env:HOME}/.verilog-format.properties", 35 | "description": "Path of global verilog-format settings" 36 | } 37 | } 38 | } 39 | }, 40 | "scripts": { 41 | "vscode:prepublish": "npm run compile", 42 | "compile": "tsc -p ./", 43 | "watch": "tsc -watch -p ./", 44 | "postinstall": "node ./node_modules/vscode/bin/install", 45 | "test": "npm run compile && node ./node_modules/vscode/bin/test" 46 | }, 47 | "devDependencies": { 48 | "typescript": "^3.3.1", 49 | "vscode": "^1.1.37", 50 | "tslint": "^5.12.1", 51 | "@types/node": "^10.12.21", 52 | "@types/mocha": "^2.2.42" 53 | }, 54 | "dependencies": { 55 | "@types/temp": "^0.8.33", 56 | "temp": "^0.9.0" 57 | }, 58 | "publisher": "ericsonj", 59 | "homepage": "https://github.com/ericsonj/vscode-verilogformar", 60 | "repository": { 61 | "type": "git", 62 | "url": "https://github.com/ericsonj/vscode-verilogformar.git" 63 | }, 64 | "bugs": { 65 | "email": "ericsonjoseph@gmail.com", 66 | "url": "https://github.com/ericsonj/vscode-verilogformar/issues" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | // The module 'vscode' contains the VS Code extensibility API 2 | // Import the module and reference it with the alias vscode in your code below 3 | import * as vscode from 'vscode'; 4 | import * as temp from 'temp'; 5 | import * as child from 'child_process'; 6 | import * as fs from 'fs'; 7 | import * as path from 'path'; 8 | 9 | // this method is called when your extension is activated 10 | // your extension is activated the very first time the command is executed 11 | export function activate(context: vscode.ExtensionContext) { 12 | 13 | vscode.languages.registerDocumentFormattingEditProvider({ scheme: "file", language: "verilog" }, { 14 | provideDocumentFormattingEdits(document: vscode.TextDocument): vscode.TextEdit[] { 15 | let result: vscode.TextEdit[] = []; 16 | const verilogformat = vscode.workspace.getConfiguration().get('verilog-format.path'); 17 | const globalSettings = vscode.workspace.getConfiguration().get('verilog-format.settings'); 18 | 19 | if (!validFile(verilogformat)) { 20 | vscode.window.showErrorMessage('Executable ' + verilogformat + ' not found, set Settings verilog-format.path'); 21 | return result; 22 | } 23 | 24 | var args: string[] = ["-f",]; 25 | var tempfile: string = createTempFileOfDocument(document); 26 | args.push(tempfile); 27 | 28 | var hasSettingsFile: boolean = false; 29 | var settingFile: string = ''; 30 | 31 | var localSettings = path.dirname(document.fileName) 32 | + path.sep 33 | + ".verilog-format.properties"; 34 | 35 | if (validFile(localSettings)) { 36 | console.log('Local settings found'); 37 | settingFile = localSettings; 38 | hasSettingsFile = true; 39 | } else if (validFile(globalSettings)) { 40 | console.log('Global settings found'); 41 | settingFile = globalSettings; 42 | hasSettingsFile = true; 43 | } else { 44 | } 45 | 46 | if (hasSettingsFile) { 47 | args.push("-s") 48 | args.push(settingFile); 49 | } 50 | 51 | try { 52 | console.log(`Executing command: "${verilogformat} ${args.join(" ")}"`); 53 | child.execFileSync(verilogformat, args, {}); 54 | result = determineEdits(document, tempfile); 55 | } catch (err) { 56 | console.log(err); 57 | } 58 | 59 | return result; 60 | } 61 | }); 62 | } 63 | 64 | // this method is called when your extension is deactivated 65 | export function deactivate() { } 66 | 67 | 68 | function createTempFileOfDocument(document: vscode.TextDocument): string { 69 | const content = document.getText(); 70 | const tempfile = temp.openSync(); 71 | if (tempfile === undefined) { 72 | throw "Unable to create temporary file"; 73 | } 74 | fs.writeSync(tempfile.fd, content); 75 | fs.closeSync(tempfile.fd); 76 | return tempfile.path; 77 | } 78 | 79 | function determineEdits(document: vscode.TextDocument, tempfile: string): vscode.TextEdit[] { 80 | const origContent = document.getText(); 81 | const wholeFile = new vscode.Range(document.positionAt(0), 82 | document.positionAt(origContent.length)); 83 | const formatted = fs.readFileSync(tempfile, { encoding: "utf8" }); 84 | return [ 85 | vscode.TextEdit.replace(wholeFile, formatted), 86 | ]; 87 | } 88 | 89 | function validFile(file: string): boolean { 90 | 91 | try { 92 | if (file === undefined) { 93 | return false; 94 | } 95 | 96 | if (file.length === 0) { 97 | return false; 98 | } 99 | 100 | if (fs.existsSync(file)) { 101 | return true; 102 | } 103 | } catch (err) { 104 | console.log(err); 105 | } 106 | 107 | return false; 108 | } -------------------------------------------------------------------------------- /src/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 '../extension'; 13 | 14 | // Defines a Mocha test suite to group tests of similar kind together 15 | suite("Extension Tests", function () { 16 | 17 | // Defines a Mocha unit test 18 | test("Something 1", function() { 19 | assert.equal(-1, [1, 2, 3].indexOf(5)); 20 | assert.equal(-1, [1, 2, 3].indexOf(0)); 21 | }); 22 | }); -------------------------------------------------------------------------------- /src/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 | import * as testRunner from 'vscode/lib/testrunner'; 14 | 15 | // You can directly control Mocha options by configuring the test runner below 16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options 17 | // for more info 18 | testRunner.configure({ 19 | ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.) 20 | useColors: true // colored output from test results 21 | }); 22 | 23 | module.exports = testRunner; -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "out", 6 | "lib": [ 7 | "es6" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "strict": true /* enable all strict type-checking options */ 12 | /* Additional Checks */ 13 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 14 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 15 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 16 | }, 17 | "exclude": [ 18 | "node_modules", 19 | ".vscode-test" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-string-throw": true, 4 | "no-unused-expression": true, 5 | "no-duplicate-variable": true, 6 | "curly": true, 7 | "class-name": true, 8 | "semicolon": [ 9 | true, 10 | "always" 11 | ], 12 | "triple-equals": true 13 | }, 14 | "defaultSeverity": "warning" 15 | } 16 | -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | * This folder contains all of the files necessary for your extension. 6 | * `package.json` - this is the manifest file in which you declare your extension and command. 7 | * The sample plugin registers a command and defines its title and command name. With this information 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 activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 10 | * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. 11 | 12 | ## Get up and running straight away 13 | 14 | * Press `F5` to open a new window with your extension loaded. 15 | * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. 16 | * Set breakpoints in your code inside `src/extension.ts` to debug your extension. 17 | * Find output from your extension in the debug console. 18 | 19 | ## Make changes 20 | 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 | 26 | * You can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`. 27 | 28 | ## Run tests 29 | 30 | * Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`. 31 | * Press `F5` to run the tests in a new window with your extension loaded. 32 | * See the output of the test result in the debug console. 33 | * Make changes to `test/extension.test.ts` or create new test files inside the `test` folder. 34 | * By convention, the test runner will only consider files matching the name pattern `**.test.ts`. 35 | * You can create folders inside the `test` folder to structure your tests any way you want. 36 | --------------------------------------------------------------------------------