Neovim + Rust setup: which guide to follow?

I'm running Arch Linux.

I've tried helix and got it running with rust quite easily, but I've found out that there's currently no easy way (aside from a hack that involves compiling a program from source) to get the program to open up with the cursor at its last position. I need this feature, so it's a non-starter for me. As far as I could tell, this is a bug that they still haven't solved.

I got vim working only to find that neovim is supposedly newer and better, so I'd like to get neovim running with rust. There are so many tutorials out there with different routes to take that's it's overwhelming to decide which is best for me.

Currently I'm just working on a small side-scrolling game (which was made by AI and I've been adding onto it, learning as I go).

So I'm looking not just for what to install but a guide that will show me exactly how to install everything and get the configs working.

I've been using AstroNvim with great success for some time.

1 Like

Neovim has a version 1.0 planned which is supposed to make this easier (tree sitter, language server) - I think is 6 months away (April 1st - hope it is not a joke).

Both vim and neovim are active projects - but neovim is the one to use for the newer features.

1 Like

this comes preconfigured with plugins, one being a plugin installer aka lazy.nvim. I found it great.

The process involves cloning a repo, using it as a starting point, then adding what you need.

2 Likes

Thanks for this. I've got many things to work perfectly.

However, I've been at it for about an hour trying to get this program to run a command with a shortcut, and it's not working for me. Tried about half a dozen AI methods. Tried a bunch of other methods suggested by people in posts.

This was so easy to setup in vim.

...

Found a solution!

Edit: .config/nvim/init.lua and add:

vim.keymap.set("n", "<leader>rr", ":!run-rust.sh %<CR>", { desc = "Cargo run + push to git" })

This is then activated by pressing the space bar and then 'r' and then 'r' again. It will then run the command 'run-rust.sh' with the current opened file ('%').

Another way is to edit the .config/nvim/init.lua file and add:

vim.api.nvim_create_user_command("Run", function()
  vim.cmd("!run-rust.sh " .. vim.fn.expand "%")
end, {})

The shortcut is activated by entering:
':' + 'Run'

1 Like

Thanks. I'll keep this in mind!

Thanks. I'll give this a try later and let you know how it goes.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.