-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(refactor): Improve documentation on the Move prettier plugin usage
- Loading branch information
Showing
1 changed file
with
31 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,52 +20,54 @@ using Prettier's VSCode | |
[extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). When the | ||
plugin is complete, we will make it available directly from Move's VSCode extension. | ||
|
||
## Installation | ||
## Usage (with Npm) | ||
|
||
The plugin can be installed via npm: | ||
1. To use the plugin, you can install it as a development dependency in your Move package: | ||
|
||
``` | ||
npm i @mysten/prettier-plugin-move | ||
> This will install both the prettier formatter and the plugin in the `./node_modules` directory. | ||
```sh | ||
npm install -D prettier @mysten/prettier-plugin-move | ||
``` | ||
|
||
## Usage | ||
1. Create a `.prettierrc` file containing the following configuration: | ||
|
||
Go to the root directory of the Move package whose files you'd like to format (i.e., the directory | ||
containing the Move.toml manifest file for this package) and run the following command: | ||
```json | ||
{ | ||
"plugins": ["@mysten/prettier-plugin-move"] | ||
} | ||
``` | ||
|
||
3. Add a script in your `package.json` file to format Move files: | ||
|
||
```bash | ||
npm install [email protected] "$SUI"/external-crates/move/crates/move-analyzer/prettier-plugin | ||
```json | ||
"scripts": { | ||
"prettier": "prettier --write ." | ||
} | ||
``` | ||
|
||
This will install both the prettier formatter and the plugin in the `./node_modules` directory. | ||
Now you can format all Move files in your package by running: | ||
|
||
# Command-line Usage | ||
```sh | ||
npm run prettier | ||
``` | ||
|
||
## Usage (with Npx) | ||
|
||
You can format Move files in the package where you completed the installation [step](#installation) by running the | ||
following command: | ||
This will require having the prettier-move plugin built (`tsc`) locally in the SUI repository. | ||
|
||
```bash | ||
./node_modules/.bin/prettier --plugin=prettier-plugin-move "$PATH_TO_MOVE_FILE" | ||
```sh | ||
npx --yes [email protected] --plugin "$SUI/external-crates/move/tooling/prettier-move/out/index.js" --write "path/to/move/folder/**/*.move" | ||
``` | ||
|
||
# VSCode integration | ||
|
||
In order to use the plugin in VSCode you first need to install Prettier's VSCode | ||
[extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). | ||
In order to use the plugin in VSCode you first need to install | ||
|
||
Then, in the root directory of the package where you completed the installation [step](#installation) you need to place the `.prettierrc` file containing the following configuration: | ||
|
||
``` | ||
{ | ||
"plugins": [ | ||
"prettier-plugin-move" | ||
] | ||
} | ||
``` | ||
- Prettier's VSCode [extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). | ||
- Move's formatter [extension](https://marketplace.visualstudio.com/items?itemName=mysten.prettier-move). | ||
|
||
After completing these steps, if you open the root directory of the package where you completed the | ||
installation [step](#installation) and choose any of the Move source files in this package, you will | ||
be able to format them by choosing `Format Code` command from VSCode's command palette. | ||
After completing these steps, you will be able to format move files by choosing `Format Code` command from VSCode's command palette. | ||
|
||
## Contribute | ||
|
||
|