Cargo Info in Neovim, or How Simple Features Go a Long Way

TL;DR Open cargo info in Vim or neovim for the package under the cursor using these 4 lines of Lua. Cargo info Rust 1.82 was released a couple of days ago. It’s packed with improvements, but one in particular caught my eye. Cargo now has a info sub-command. It displays details about a package in the registry from the comfort of your terminal. Here is an example: $ cargo info lazy_static lazy_static #macro #lazy #static A macro for declaring lazily evaluated statics in Rust. version: 1.5.0 license: MIT OR Apache-2.0 rust-version: unknown documentation: https://docs.rs/lazy_static repository: https://github.com/rust-lang-nursery/lazy-static.rs crates.io: https://crates.io/crates/lazy_static/1.5.0 features: spin = [dep:spin] spin_no_std = [spin] note: to see how you depend on lazy_static, run `cargo tree --invert --package [email protected]` Vim and neovim generally composes well with other terminal tools. So how can we easily integrate cargo info and neovim? ...

October 21, 2024 · 4 min · Clément Joly

Quick Git Commit Amend

Sometimes when your pull request is reviewed, it turns out that you have to make a small change. For instance, you have to remove a white space. Here is a really quick way to fix it, that will not even fire your editor to change the commit message. Make sure you are on the branch of the pull request (for instance, by reading the output of git status) Edit and save your file, removing the white space. Then in your terminal, use: git commit --amend -a -v -C HEAD This edits (--amend) your last commit, adding all the changes made to files (-a) and reusing the last commit message (-C HEAD). Once this is done, a summary is printed (-v). You can now push your changes with: git push --force-with-lease We need --force-with-lease to “confirm to the server that we really want to edit the last commit”. Caution Two words of caution with this technique: ...

November 21, 2021 · 2 min · Clément Joly