-
Notifications
You must be signed in to change notification settings - Fork 164
rustfmt.toml not respected? #132
Comments
Does your rustfmt.toml work with the latest rustfmt-nightly? We do explicitly look for a rustfmt.toml, so this should work, you may have hit a bug though. |
Certainly seems so, running |
the rust version is not linked to the rustfmt version. Try running |
Ah, yup, my bad. That was exactly it. I must've somehow had an old version. It also seemed if I had a directory override set to apply it didn't apply to running rustfmt bare, it complained about missing dlls after I updated it. Running it with "rustup run nightly" worked fine though. My original problem doesn't exist though, both ways are consistent. Thanks! |
Actually, I'm gonna flip-flop. They do seem divergent. This code is preserved by the vscode plugin as-is: let mut get_siz = || {
sizer.ind_sample(&mut rng).abs().max(scaler / 30.0).min(scaler / 2.0) as f32
}; The long line is > 80 cols. But this:
Results in: let mut get_siz = || {
sizer
.ind_sample(&mut rng)
.abs()
.max(scaler / 30.0)
.min(scaler / 2.0) as f32
}; With this config:
Actually after typing all that I just put in some random whitespace, and seems it's jut not formatting at all, which I don't think was happening earlier, so I've got no clue now why it's gone wrong. There aren't any errors in the problems tab. Sorry for the awful bug report. |
I'm having this problem.
When I run When I save in VS Code, it seems to be ignoring the |
I'm also having this problem. I'm on macOS 10.12.6
|
I also have the same problem, rustfmt ignores rustfmt.toml |
I am seeing the same thing here, vscode does not seem to respect the Version:
|
@dvdplm You are using the old version of |
@jonasbb thank you, I missed that. However, even with |
I am seeing a similar problem in Eclipse Rust corrosion plugin. If it helps, in my case It does seem to be caused by |
This should be fixed on VSCode side of things, since we always spawn RLS in the workspace side of things, however RLS itself might need to take the rootUri into account instead of the cwd. Opened rust-lang/rls#1418 to track. |
I still seem to be having this issue (I'm using |
for what its worth I am seeing this still as well I have tried a
rls-vscode: 0.7.0 I am not entirely sure what exactly is happening but would love some guidance on how to fix this particular issue. |
My current workaround is to edit "rust.rustfmt_path": "~/.cargo/bin/rustfmt" It might help to replace |
FWIW, I spend a day working with this problem and have learned some things:
For example: cd /full/path/to/rust
cat /full/path/to/rust/file.rs | rustfmt
# formatted rust that uses rustfmt.toml
cd /
cat /full/path/to/rust/file.rs | rustfmt
# default formatted rust I've been playing around with this extension and adding the project directory to function getFormattedString(doc: vscode.TextDocument): string {
+ const documentUri = vscode.Uri.parse(doc.fileName);
+ const workspaceDir = vscode.workspace.getWorkspaceFolder(documentUri);
return child_process.execSync("rustfmt", {
encoding: 'utf-8',
input: doc.getText(),
+ cwd: workspaceDir.uri.fsPath,
}).toString();
} I realize this is for an entirely different project but this is what comes up in search result so perhaps it will help someone. |
I am still seeing this in 3/21. |
FYI: I implemented the fix from @edwardloveall and it seems to be working fine. I also published a .vsix package. You can alctually build it yourself with the NOTE: I am not planning take over the maintenance of the upstream repo :) an I hope the original author will update. And if not, you now have a plan B. |
Hello
Loving the plugin. Did notice something I'm fairly sure is a bug:
I've got a rustfmt.toml with
In it, and when I run rustfmt on the command line that appears to work, but when running from VS Code it'll use the default "Tall" behavior. This is version 0.2.2 of the plugin.
The text was updated successfully, but these errors were encountered: