You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,7 @@ This plugin executes CLI commands to format code via stdin (recommended) or via
49
49
General config:
50
50
51
51
-`cacheKey` - Optional value used to bust dprint's incremental cache (ex. provide `"1"`). This is useful if you want to force formatting to occur because the underlying command's code has changed.
52
+
- If you want to automatically calculate the cache key, consider using `command.cacheKeyFiles`.
52
53
-`timeout` - Number of seconds to allow an executable format to occur before a timeout error occurs (default: `30`).
53
54
-`cwd` - Recommend setting this to `${configDir}` to force it to use the cwd of the current config file.
54
55
@@ -61,6 +62,7 @@ Command config:
61
62
- You may have associations match multiple binaries in order to format a file with multiple binaries instead of just one. The order in the config file will dictate the order the formatting occurs in.
62
63
-`stdin` - If the text should be provided via stdin (default: `true`)
63
64
-`cwd` - Current working directory to use when launching this command (default: dprint's cwd or the root `cwd` setting if set)
65
+
-`cacheKeyFiles` - A list of paths (relative to `cwd`) to files used to automatically compute a `cacheKey`. This allows automatic invalidation of dprint's incremental cache when any of these files are changed.
64
66
65
67
Command templates (ex. see the prettier example above):
66
68
@@ -118,7 +120,12 @@ Use the `rustfmt` binary so you can format stdin.
118
120
"cwd":"${configDir}",
119
121
"commands": [{
120
122
"command":"rustfmt --edition 2021",
121
-
"exts": ["rs"]
123
+
"exts": ["rs"],
124
+
// add the config files for automatic cache invalidation when the rust version or rustfmt config changes
125
+
"cacheKeyFiles": [
126
+
"rustfmt.toml",
127
+
"rust-toolchain.toml"
128
+
]
122
129
}]
123
130
},
124
131
"plugins": [
@@ -139,7 +146,11 @@ Consider using [dprint-plugin-prettier](https://dprint.dev/plugins/prettier/) in
0 commit comments