cbacon is a Rust-based tool that reads a bacon file containing line references and opens the first reference location in Visual Studio Code (VSCode). It emulates a Python script by automatically opening your project workspace in VSCode, parsing warning/error messages from a file, and navigating directly to the relevant file location using VSCode's --goto and --wait flags.
bacon is a background code checker. It's designed for minimal interaction so that you can just let it run, alongside your editor, and be notified of warnings.
I've been using a simple python script to provide an experience much like nvim-bacon but for vscode. Run bacon, run cbacon. I decided to make it into a rust program too.
Combined with bacon, cbacon navigates between errors and warnings without leaving your editor, just hitting a key. (close the current editor/workspace)
I would like to see something like this integrated into bacon itself, but in the meantime, here is how I use bacon sometimes.
-
Workspace Integration: Opens the current directory as a VSCode workspace so that Rust Analyzer and other extensions process the project.
-
Warning File Parsing: Reads a bacon file (default: .bacon-locations) containing warning messages formatted as:
warning <file_path>::
-
File Navigation: Opens the first warning location in VSCode and waits until you close the file before re-checking for updates.
-
Continuous Monitoring: Automatically re-reads the bacon file for any updates after the warning file is closed.
-
File Watcher Support: Optionally uses a file system watcher (via the notify crate) to monitor for modifications in the bacon file.
Ensure you have Rust installed. Then, clone the repository and build the project:
git clone <repository-url>
cd cbacon
cargo build --release
Replace with the actual URL of the repository.
Run cbacon with an optional path to the bacon file. If no path is specified, it defaults to .bacon-locations in the current directory:
cargo run -- <path_to_bacon_file>
For example:
cargo run -- .bacon-locations
Note: Make sure the "code" command (VSCode) is available in your system's PATH. Verify with:
code --version
The project includes a suite of tests to ensure proper functionality. Run the tests with:
cargo test
The tests cover:
- Parsing of warning messages from the bacon file.
- Correct handling of file paths and line numbers.
- Integration with the VSCode command.
- File watcher behavior when using the uses_notify feature.
cbacon is licensed under the MIT License. See the LICENSE file for more details.
David Horner
March 15, 2025