Semantic code navigation for Rust
A Rust source browser. Explore your Rust project with semantic understanding of the code. Features:
Uses knowledge from the RLS.
This is work-in-progress, pre-release software, expect bugs and plenty of rough edges.
Requires a nightly version of Rust.
To install, run
cargo install cargo-src.
Then, to run:
cargo srcin a directory where you would usually run
cargo build. You can run
cargo src --opento open the output of
cargo srcdirectly in your web browser.
cargo srcwill start a web server and build (
cargo check) and index your code. This may take some time (depending on your crate, up to twice as long as a normal build). You can browse the source in whilst indexing, but you'll be missing all the good stuff like jump-to-def and search.
Create a
rustw.tomlfile in your project's directory. See src/config.rs or run
cargo src -- -hfor the options available and their defaults.
Some features need configuration in the rustw.toml before they can be used.
edit_command = "subl $file:$line"
To be able to open files in your local editor. This example works for sublime text (
subl). Use the
$fileand
$linevariables as appropriate for your editor.
vcs_link = "https://github.com/nrc/rustw-test/blob/master/$file#L$line"
For links to the code in version control, GitHub, in the example.
Requires a nightly version of Rust.
Get the source code from https://github.com/nrc/cargo-src.
npm installor
yarn
npm run buildor
yarn build
cargo build --release
Run
CARGO=cargo //rustw/target/release/cargo-srcin your project's directory (i.e., the directory you would normally use
cargo buildfrom).
Running
cargo srcwill start a web server and display a URL in the console. To terminate the server, use
ctrl + c. If you point your browser at the provided URL, it will list the directories and files from your project, which you can then use to view the code. The terminal is only used to display logging, it can be ignored.
You can use
--opento open the cargo src browser directly in your web browser.
Currently, cargo src has only been tested on Firefox on Linux and MacOS (issue 48).
If you get an error like
error while loading shared librarieswhile starting up cargo src you should try the following:
On Linux:
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH
On MacOS:
export DYLD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$DYLD_LIBRARY_PATH
Cargo src is open source (dual-licensed under the Apache 2.0 and MIT licenses) and contributions are welcome! You can help by testing and reporting issues. Code, tests, and documentation are very welcome, you can browse all issues or easy issues to find something to work on.
If you'd like help or want to talk about cargo, you can find me on the rust-dev-tools irc channel (nrc), email (my irc handle @mozilla.com), or twitter (@nickrcameron).
The cargo src server is written in Rust and uses Hyper. It runs
cargo checkas a separate process and only really deals with output on stdout/stderr.
The cargo src frontend is a single page web app written in HTML and Javascript. It uses React and JQuery.