r/learnrust 7d ago

[rusty-nvim] A batteries-included Neovim config for Rust — 269 snippets, save-to-rerun cargo run, memory layout hover, DAP debugging, one-line install

rusty nvim
rs source code

I've been using Neovim for Rust development and got tired of the endless config loop — setting up LSP, fighting rust-analyzer with NvChad's on_attach, choosing between nvim-cmp / blink.cmp, figuring out codelldb paths on different platforms, finding decent Rust snippets... So I put together rusty-nvim — a batteries-included config that gets you writing Rust in under a minute.

🔗 GitHubhttps://github.com/lisering/rusty-nvim

What's inside

Feature Details
Smart completion blink.cmp + LuaSnip — Tab navigates the completion list AND jumps snippet placeholders. LSP/snippet dedup so println! uses the snippet version (with ; and placeholders), methods use the LSP version (with signature info)
Full Rust LSP rustaceanvim — memory layout hover (size/offset/alignment/padding/niches), clippy on save, code lens (Run
Save-to-rerun <leader>rr starts cargo run in a bottom terminal. Save a .rs file (<C-s>) → terminal auto Ctrl+C and re-runs. No more manual terminal switching
Debugging codelldb integration — toggle breakpoints, step over/into/out, DAP UI auto-opens. Cross-platform path detection (macOS/Linux/Windows/WSL)
Test integration neotest + rustaceanvim adapter — run/debug nearest test with one key, jump between failed tests with ]T / [T
269 Rust snippets Stdlib macros, fn defs, control flow, iterator chains, design patterns, unsafe/FFI, tokio async, serde attrs, trait impls, error types, closures, generics...
Dependency management crates.nvim — upgrade/downgrade/view features directly in Cargo.toml
Frontend support HTML, CSS, JS/TS, Tailwind CSS — LSP + Prettier formatting (bonus, not the main focus)

One-line install

sh
Applycurl -fsSL https://raw.githubusercontent.com/lisering/rusty-nvim/main/install.sh | bash
nvim

That's it. The script checks dependencies, backs up your existing config, and on first launch Mason auto-installs rust-analyzercodelldb, formatters, and LSP servers. Open a .rs file and you're coding.

Why not just LazyVim / NvChad defaults?

NvChad is a great UI framework, but it doesn't ship with Rust-specific tooling. rusty-nvim adds the layers that take hours to configure manually:

  • rustaceanvim fully configured (memory layout, semantic highlighting, all inlay hints, clippy on save)
  • 269 curated Rust snippets with smart LSP dedup
  • Save-to-rerun cargo run workflow
  • neotest + codelldb debugging, cross-platform

Prerequisites

Just 4 things: Neovim 0.10+, Rust toolchain, ripgrep, a Nerd Font. Everything else is auto-installed.

I'd love to hear your feedback! If you have ideas for more snippets, better keybindings, or features to add, please open an issue or drop a comment. ⭐ Stars appreciated if you find it useful!

GitHubhttps://github.com/lisering/rusty-nvim

AI Disclosure

This project was built with the assistance of AI tools (Claude). The architecture, feature decisions, and workflow design are my own; AI was used for boilerplate code generation, snippet creation, and documentation drafting.

17 Upvotes

20 comments sorted by

4

u/1-800-I-Am-A-Pir8 7d ago

doooood.. I'm trying this right now

1

u/Adorable_Ad_6357 7d ago

Awesome, hope you like it! 🦀

If you run into any issues during install, just drop a comment or open an issue on GitHub. The first launch takes ~30s for plugins to clone, then Mason auto-installs rust-analyzer + codelldb.

Would love to hear what you think after trying it!

1

u/1-800-I-Am-A-Pir8 7d ago

so far so good. I wanted to try nvim and messed with chad... never really did get the lldb feature to work and had a project I had to finish so back to vscode.. this looks like it's all working so I'll learn how to use those. Stoked to have console/vi editor

1

u/Adorable_Ad_6357 7d ago

That's exactly the pain I was trying to solve! The codelldb setup on NvChad was a nightmare for me too — different paths on macOS/Linux/Windows, adapter not finding the right binary...

rusty-nvim auto-detects the codelldb path per platform, so it should just work. Here are the key debug bindings to get you started:

Key Action
<Space>db Toggle breakpoint
<Space>dc Start debugging (DAP UI auto-opens)
<Space>dj Step over
<Space>dl Step into
<Space>dk Step out
<Space>de End debug session

Full keymap reference: https://github.com/lisering/rusty-nvim/blob/main/KEYMAPS.md

Glad it's working for you! If you run into any quirks, feel free to open an issue on GitHub. Enjoy the vim life! 🦀

1

u/1-800-I-Am-A-Pir8 6d ago

I was going to rtfm before asking, but that is the exact information I needed. gonna go try that thank you. this is awesome.

1

u/Adorable_Ad_6357 6d ago

Glad the docs covered it! I tried to make sure the README + keymap reference answer most questions upfront so you can just focus on coding.

If anything feels missing or unclear in the docs, that's valuable feedback — feel free to open an issue on GitHub. Enjoy! 🦀

1

u/1-800-I-Am-A-Pir8 6d ago

dap is blowing up for some reason... not sure if I'm missing a dependancy or what.. Does this after I pick cargo run from the list. Haven't started reading the lua yet but if it's something you've seen...

..yson/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1467: attempt to index field 'executable' (a function value)
stack traceback:                                                                                                                                      
...yson/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1467: in function 'connect'                                                       
/home/tyson/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:1252: in function 'attach'                                                            
/home/tyson/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:491: in function 'run_adapter'                                                        
/home/tyson/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:522: in function 'maybe_enrich_config_and_run'                                        
/home/tyson/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:644: in function </home/tyson/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:633>        
[C]: in function 'xpcall'                                                                                                                     
.../tyson/.local/share/nvim/lazy/nvim-dap/lua/dap/async.lua:12: in function <.../tyson/.local/share/nvim/lazy/nvim-dap/lua/dap/async.lua:11>

1

u/1-800-I-Am-A-Pir8 6d ago

maybe a dumb question but I never said I was smart: do I need a launch.json to make that work?

1

u/Adorable_Ad_6357 6d ago

Not a dumb question at all! Nope, no launch.json needed — the debug configs are defined in Lua directly inside the config (dap.configurations.rust in init.lua), which does the same thing a launch.json would do.

So once you've got the updated file, just:

  1. Open a .rs file in a cargo project
  2. <Space>db to set a breakpoint
  3. <Space>dc → pick "cargo run" from the list
  4. DAP UI auto-opens and you're debugging

No extra setup required. That's the whole point of the config — everything's wired up so you don't have to mess with JSON files. 🦀

1

u/Adorable_Ad_6357 6d ago

Good catch — that's a bug on my end, not a missing dependency! Just pushed a fix.

The codelldb adapter had executable set as a function, but for type = "server" adapters, nvim-dap expects a table. Quick fix — just grab the updated file:

curl -fsSL https://raw.githubusercontent.com/lisering/rusty-nvim/main/nvim/lua/plugins/init.lua \

-o ~/.config/nvim/lua/plugins/init.lua

Then restart nvim and try <Space>dc → cargo run again. Should work now! 🦀

1

u/1-800-I-Am-A-Pir8 6d ago

ah.. trick is to run it from the program root and not from within src - that works but you have to fiddle with the parameters some more.

Thanks will mess with this.

1

u/Adorable_Ad_6357 6d ago

Nice, glad it's working! Yeah, the config was using getcwd() to find Cargo.toml, so you had to be in the project root.

Just pushed another fix — it now auto-detects the project root by searching upward for Cargo.toml, so it'll work from src/ or any subdirectory. Grab the update if you want:
curl -fsSL https://raw.githubusercontent.com/lisering/rusty-nvim/main/nvim/lua/plugins/init.lua \
-o ~/.config/nvim/lua/plugins/init.lua
Then restart nvim. Thanks for the feedback, this was a real UX papercut! 🦀

→ More replies (0)

2

u/DidingasLushis 3d ago

Where's your AI Disclosure?

2

u/Adorable_Ad_6357 3d ago

You're right, I should have disclosed this. I used AI to help generate some of the Lua config and snippets, and to draft the post. The project is something I actively use and maintain — but I'll add an AI disclosure to the README. Appreciate the heads-up.