-
Notifications
You must be signed in to change notification settings - Fork 303
Improved syntastic linting #76
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @chris-morgan (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
let makeprg = self.makeprgBuild({ 'args': '-Zparse-only' }) | ||
let compiler_params = g:rustc_syntax_only ? '-Zparse-only' : '-Zno-trans' | ||
let cwd = '.' " Don't change cwd as default | ||
let cargo_toml_path = findfile('Cargo.toml', '.;') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this search in parent directories or only in current dir and subdirs? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the current and parent directories until it finds the file.
See :help findfile()
I have been using this for a while and it seems to be working fine. 👍 |
Can I rebase this to the latest master, or should I wait for more feedback? |
@somini ah, sorry about this! It can be tough to know with the vim repo sometimes. I think this looks good to me; if you rebase it, i think we can land it. |
There's actually no conflicts, so it's OK to merge this. |
@somini FYI. I turned debugging on for syntastic, because you're branch was not working for me. I get a status code 101 from rustc but no errors from syntastic:
I checked the output of
EDIT:
|
I installed the nightly version and can confirm @ernestrc report. It works on 1.9. I can "fix" it by adding the I really don't know enough Rust to really understand what's going on here, so any help is appreciated. |
The default is the fast lint, maintain the current defaults.
Rebased this to the latest master, it was starting to diverge too much. Still can't fix the breakage that occured on rust v1.11. |
Still interested in landing this, someone was just asking on IRC. What was that breakage, exactly? Sorry for being out of the loop. |
Thanks for keeping this alive. The problem is that cargo can't pass extra arguments to rustc unless we specify a binary or the lib option. This was introduced between 1.9 and 1.11. |
According to rust-lang/cargo#2702 it seems like the right thing to do here is either default to |
@euclio led me to this. |
Recent versions of vim (7.4.1154+ renamed in 7.4.1304) have |
Any updates on this? It would be a really useful feature. I've been using @somini's fork for quite some time and now I almost can't code without it. :) |
I'm not quite sure if anyone had updated their rustc to version 1.13.0, but using the -Z flags will now give a warning. Hopefully there would be a variable to set for the plugin to indicate if using nightly version.
|
I decided to put mention my fork ( https://github.com/mckinnsb/rust.vim ) here, because I figured that it might be of use to anyone who needs more than just parsing checks using rustc. I used @jFransham's fork(https://github.com/jFransham/rust.vim) as a template, and then modified his cargo checker to use the same error format as the updated rustc checker in rust.vim. It basically runs "cargo rustc" in the directory of the file you are editing. I'm not sure if I should make a PR with this or not, but I did make the changes on master and syntax checking with external crates is now working, although it is probably slower than simple parsing. You enable it by setting the syntastic checker:
|
Oh hey, this is a nice surprise |
What I'm currently using: patch1 and patch2 - tested But I should probably be using #147 which seems to be the same as the above #76 (comment) - not tested EDIT: my .vimrc |
As far as I understand it, using cargo-check should solve this. |
\ 'args': 'rustc ' . compiler_params, | ||
\ 'fname': '' }) | ||
" Change cwd to the root of the crate | ||
let cwd = fnamemodify( cargo_toml_path, ':p:h') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line currently doesn't work inside a workspace, for it needs to find workspace's Cargo.toml (which is ../ relative to what it currently finds), so reported filenames in the errors are like:
--> recompile_self/build.rs:32:3
but cwd is
/home/xftroxgpx/build/2nonpkgs/rust.stuff/rustlearnage/recompile_self
when it should be
/home/xftroxgpx/build/2nonpkgs/rust.stuff/rustlearnage
for vim/syntastic to actually show the errors upon save.
I don't know of a way to detect if we're inside a workspace now...
EDIT: I opted to patch cargo
to pass absolute path names to rustc
so that they will show up as such in the error messages, and thus not need any cwd
changes!
This PR builds on PR #72 .
There's a new option to choose between fast lint (parse-only) or comprehensive (no-trans). You can change this at runtime too.
Possible improvements include a buffer-local variable so that you can have different projects with different linting levels.