Canop / bacon

background rust code check
https://dystroy.org/bacon
GNU Affero General Public License v3.0
1.68k stars 58 forks source link

Using `bacon` with `rust-analyzer` in VS Code #158

Open bzm3r opened 1 year ago

bzm3r commented 1 year ago

I'm interested in using bacon with rust-analyzer.

rust-analyzer allows for compiler feedback from external tools.

In VS Code, we must define a build task, I think something like this under the project's .vscode/tasks.json:

{
    "label": "Watch",
    "group": "build",
    "type": "shell",
    "command": "bacon",
    "problemMatcher": "$rustc-watch",
    "isBackground": false
}

However, the part I am uncertain about is how to set up my bacon.toml so that the cargo check/clippy command emits errors out in json to stderr using the flag --error-format=json.

If I set up a command like this:

[jobs.clippy]
command = [
    "cargo",
    "clippy",
    "--all-targets",
    "--color",
    "always",
    "--",
    "--error-format=json"
]
need_stdout = false

Then I get a build error stating that I provided the error-format argument twice.

Is this due to a clash with the -e option of bacon? I have disabled this in prefs.toml both by trying enabled = false and simply commenting out the entire block, with no success.

Any ideas on what I can try next? Is there a way for me to pass the default .bacon-locations (perhaps I have to rename the output file) to rust-analyzer? Not entirely sure, so all ideas would be appreciated!

Canop commented 1 year ago

This isn't clear to me. You'd like bacon to not display the errors itself but to send to vscode the raw JSON output of cargo ?

bzm3r commented 1 year ago

@Canop No, not quite. Let me clarify:

Canop commented 1 year ago

Right now bacon uses stdout for its output, so a solution could be to send to stderr what it receives, assuming vscode accepts it. But there's no such feature in bacon, it would need to be added. Or maybe use a tee as job.

bzm3r commented 1 year ago

@Canop makes sense! I'll look into seeing if I can make a PR, but I might just stick with my current setup. Regardless, the clarification was super helpful!

Niraj-Kamdar commented 3 months ago

@bzm3r I am interested in your current setup, Rust-Analyzer is too slow for our gigantic repo, I would prefer if I can just use RA for code navigation and code hinting while use slow running background checks for errors and lazily see those

bzm3r commented 2 weeks ago

@Niraj-Kamdar No, I moved away entirely from bacon. rust-analyzer allows me to get my work done :shrug: