Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Rust #358

Closed
fabianmeyer opened this issue May 22, 2015 · 15 comments
Closed

Support for Rust #358

fabianmeyer opened this issue May 22, 2015 · 15 comments

Comments

@fabianmeyer
Copy link

Please add support for the Rust language. Rust 1.0 was released on 05-15-2015 and the syntax is stable now.

@nicokoch
Copy link

nicokoch commented Jun 4, 2015

https://github.com/nrc/rustfmt might be helpful

@Glavin001
Copy link
Owner

Excellent, @nicokoch! That looks great.

For those interested in making this happen, you can submit a Pull Request. I am still working on complete documentation however I have documented most of the steps required to add a new Language and a new Beautifier: #300 (comment)

@Glavin001 Glavin001 added this to the v0.29.0 milestone Jun 4, 2015
@Glavin001 Glavin001 self-assigned this Jun 6, 2015
@Glavin001
Copy link
Owner

I have started development on the Rustfmt beautifier support however I have not tested it and it likely is not in a working state, yet. Feel free to fork Atom Beautify, and try it out for yourself and submit a Pull Request when it's completely working. Thanks.

Update: I've published my current progress to v0.27.11

@Glavin001 Glavin001 modified the milestones: v0.28.0, v0.29.0 Jun 8, 2015
@Glavin001
Copy link
Owner

I will be maintaining this documentation on adding languages and beautifiers: https://github.com/Glavin001/atom-beautify/blob/master/docs/add-languages-and-beautifiers.md

@mattmaslin
Copy link

Rustfmt works correctly. The only extra step I had to do was copy the default.toml file from the Rustfmt project into my home directory.

@LaylBongers
Copy link

It seems there's a problem with the way rustfmt is used by Beautify. When trying to do a format, I get the following error.

C:\Users\Layl\AppData\Local\Temp\tmp1151030-5452-fkq6dy:5:5: 5:13 error: file not found for module `frontend`
C:\Users\Layl\AppData\Local\Temp\tmp1151030-5452-fkq6dy:5 mod frontend;
                                                              ^~~~~~~~
C:\Users\Layl\AppData\Local\Temp\tmp1151030-5452-fkq6dy:5:5: 5:13 help: name the file either frontend.rs or frontend/mod.rs inside the directory "C:\\Users\\Layl\\AppData\\Local\\Temp"
thread '<main>' panicked at 'Box<Any>', C:\Users\Layl\.cargo\git\checkouts\syntex-b2c5d63b3d829888\master\syntex_syntax\src\parse/mod.rs:76

It seems that rustfmt is expecting the entire cargo project to be in the location it wants to format it.

@Drakulix
Copy link

There is another problem. rustfmt supports having a config file next to the source file or further up the directory tree. Because atom-beautify copies the source file to /tmp/ (at least on my system - Arch Linux), rustfmt does not find the config file and just applies the default config. The only "workaround" is moving my config to system root, which applies it globally. Not exactly optimal.

@Glavin001
Copy link
Owner

Please feel free to submit a Pull request for rustfmt support in Atom Beautify.
Applicable beautifier code here: https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/rustfmt.coffee
I do not believe the beautifier was tested and is likely incomplete.

@lhecker
Copy link
Contributor

lhecker commented Dec 23, 2015

https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/clang-format.coffee could probably be seen as a reference model how rustfmt needs to be invoked like. I tried to modify the code myself, but gave up after a while since I failed to understand how this project works. Maybe someone with more experience could copy over and integrate the code. 😊

Otherwise the file content could just be piped into a rustfmt instance to replace the editor contents with it's ouputs before saving and thus circumvent any kind of slow disk access.

@sidred
Copy link
Contributor

sidred commented Jan 29, 2016

I have working version of Beautifier support for rustfmt.toml at https://github.com/sidred/atom-beautify/tree/rustfmt-update. Waiting for rust-lang/rustfmt#780 to be merged before submititng a PR.

@Glavin001 Glavin001 modified the milestones: v0.30.0, v0.29.0 Mar 30, 2016
@xavier83
Copy link

xavier83 commented May 1, 2016

@sidred looks like it has been merged. any update?

@sidred
Copy link
Contributor

sidred commented May 1, 2016

Merged via #790. Beautifier should read the rustfmt.toml in the file path.

@Glavin001 Glavin001 modified the milestones: v0.30.0, v0.31.0 Jun 22, 2017
@Glavin001 Glavin001 removed this from the v0.30.0 milestone Jun 22, 2017
@imp
Copy link
Contributor

imp commented Jul 15, 2017

rustfmt development recently has been moved to rustfmt-nightly branch, which original rustfmt being frozen. As a side effect of that change, the version numbering has been reset back to 0.1.x. However, atom-beautify check for the version being higher than 0.5. Naturally, it comes to the wrong conclusion with rustfmt-nightly as not being good enough. Fortunately, it is easy to distinguish between the two branches - as nightly clearly says so in its --version output:

$ /usr/local/bin/rustfmt --version
0.1.9-nightly ( )

It would be great to add extra check for running newer branch of rustfmt and clear it for using inside atom-beautify

@Glavin001
Copy link
Owner

Pull Requests welcome! See https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/rustfmt.coffee for applicable code.

I am not a Rust user/developer, so it is unlikely I would write the Pull Request. However, I will be happy to review and merge any changes. Thanks in advance!

@stevenzeck
Copy link
Contributor

Published to v0.30.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests