Skip to content

Commit 27c371b

Browse files
authored
Giving a more detailed step by step description on using VSCode (#561)
* Giving a more detailed step by step description on using VSCode * Typo
1 parent d96a09e commit 27c371b

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,21 @@ code --install-extension JuanBlanco.solidity
258258

259259
This extension provides basic integration with Prettier for most cases no further action is needed.
260260

261+
Make sure your editor has format on save set to true.
262+
When you save VSCode will ask you what formatter would you like to use for the solidity language, you can choose `JuanBlanco.solidity`.
263+
264+
At this point VSCode's `settings.json` should have a configuration similar to this:
265+
266+
```JSON
267+
{
268+
"editor.formatOnSave": true,
269+
"solidity.formatter": "prettier", // This is the default so it might be missing.
270+
"[solidity]": {
271+
"editor.defaultFormatter": "JuanBlanco.solidity"
272+
}
273+
}
274+
```
275+
261276
If you want more control over other details, you should proceed to install [`prettier-vscode`](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode).
262277

263278
```Bash
@@ -270,10 +285,28 @@ To interact with 3rd party plugins, `prettier-vscode` will look in the project's
270285
npm install --save-dev prettier prettier-plugin-solidity
271286
```
272287

273-
This will allow you to specify the version of the plugin in case you need to freeze the formatting since new versions of this plugin will implement tweaks on the possible formats.
288+
This will allow you to specify the version of the plugin in case you want to use the latest version of the plugin or need to freeze the formatting since new versions of this plugin will implement tweaks on the possible formats.
274289

275290
You'll have to let VSCode what formatter you prefer.
276-
As a final check, make sure that VSCode is configured to format files on save.
291+
This can be done by opening the command palette and executing:
292+
293+
```
294+
>Preferences: Configure Language Specific Settings...
295+
296+
# Select Language
297+
solidity
298+
```
299+
300+
Now VSCode's `settings.json` should have this:
301+
302+
```JSON
303+
{
304+
"editor.formatOnSave": true,
305+
"[solidity]": {
306+
"editor.defaultFormatter": "esbenp.prettier-vscode"
307+
}
308+
}
309+
```
277310

278311
Note: By design, Prettier prioritizes a local over a global configuration. If you have a `.prettierrc` file in your porject, your VSCode's default settings or rules in `settings.json` are ignored ([prettier/prettier-vscode#1079](https://github.com/prettier/prettier-vscode/issues/1079)).
279312

0 commit comments

Comments
 (0)