16 ms·
Rust-Analyzer Architecture
- nindalf 6y agoFor those who don't know, rust-analyzer is an implementation of the Language Server Protocol for the Rust programming language, written in Rust. It assists you while you program, for example finding usages of a piece of code or going to the definition of a function. Basically a Rust IDE that you can plug into any text editor (in theory).
- deleted 6y ago[deleted]
- ibraheemdev 6y agoIt is also worth noting that rust-analyzer is the successor to RLS. If anyone is still using the RLS (most editor plugins can be configured to use either), they should switch to rust-analyzer. It is much much better in almost every possible way, and soon to be made the "official" rust LSP [0]. 0: https://github.com/rust-analyzer/rust-analyzer/issues/4224 https://github.com/rust-analyzer/rust-analyzer/issues/4224
- Fiahil 6y agoI got convinced to use rust-analyzer instead of RLS by a comment like yours on hacker news ! I can't thank you enough ! It's almost like Rust became a different -much pleasant- language after that !
- User23 6y agoHow is the Emacs support for this LSP implementation? Does it actually work comparably well to VS Code, or is it going to be like trying to use Emacs as a Java IDE back in the day: fighting your tooling constantly and getting little help from it.
- saghm 6y agoI use rust-analyzer with Emacs every day for work. There was a small amount of initial setup time (one or two bugs that had to be fixed with line or two in the init file), and since then, I haven't had to do anything; it's just worked fine.
- pimeys 6y agoI use it in Emacs every day since a few years. It mainly works, but I still haven't figured out the best way to set the right feature flag combinations if I work in a crate that uses them a lot. In these cases, if some code requires a feature to be enabled, analyzer does nothing because it compiles with the feature disabled. It's not bothering me that much that I'd find a solution, because I don't need the help of analyzer in crates that I maintain anymore...
- umanwizard 6y agoAnecdote: it worked fine for me in spacemacs. I switched from spacemacs to VSCode because the latter's vi emulation was better, not because r-a didn't work well.
- zxv 6y agoThe emacs support is great. I use emacs 'racer' and 'lsp' packages full time for development. There are two popular emacs packages for rust-analyzer: lsp[0] and eglot[1]. lsp (language server protocol) package is the default for racer. Eglot has far more features and is correspondingly resource hungry. Detailed type information has a super helpful impact on my ability to review Rust code in general. I find reviewing rust code much more productive when I can see what owns a variable, how long it lives, and how it's being used (immutable vs mutable). So yea, lsp or eglot. Super helpful. [0] https://emacs-lsp.github.io/lsp-mode/ https://emacs-lsp.github.io/lsp-mode/ [1] https://github.com/joaotavora/eglot https://github.com/joaotavora/eglot
- pdimitar 6y agoI use it with Spacemacs for 6+ months now and it's only getting better with time. It's 99% reliable.
- stefan_ 6y agoIf you want to use the rust-analyzer LSP, you might want to switch to the rust-analyzer VSCode extension instead of the Rust one. There is a reason the "official" one doesn't use it yet and having a flaky autocomplete is the worst.
- adamnemecek 6y agoRust analyzer is a game changer. Try it today if you haven’t already.
- carlmr 6y agoIt is, with RLS I always felt it was what kept me from really liking programming in Rust. Since I don't program Rust every day it would be looking up everything. Now with rust-analyzer it's fast and exact enough that I can stay in the flow.
- brundolf 6y ago+1 Not only is it infinitely better than the default RLS, it's honestly one of the better IDE experiences I've ever had in any language period. In particular it has novel features like inline labels for inferred types, argument names when calling functions, etc.
- adamnemecek 6y agoI’m also very impressed with the rate of progress. They are moving very fast and I can notice a pretty big improvement regularly.
- brundolf 6y agoYes! I follow them on Twitter to keep up with the updates, it seems like there's a new feature every week Edit: Not sure why you're getting downvoted for making a positive, relevant, and factual statement. Sometimes I just can't figure out what goes on in people's heads when they downvote something.
- Xylakant 6y agoAs one of the managing people at Ferrous Systems, I’d like to mention that the pace of development is very much only possible because of the sponsors of the project, both individuals and corporate and some paid for feature development. This allows us to spend constant engineer hours on the project instead of what’s just left over as well as pay some money to contributors as well. A big Thank You to all of them.
- pbw 6y agoWith dark mode it's hard to read the Bird's Eye View diagram: https://imgur.com/a/pJwZP9v https://imgur.com/a/pJwZP9v I guess a consequence of dark mode is you should not use transparency in your diagrams if you have black lines.
- krut-patel 6y ago"Open image in a new tab" to the rescue! The extension I use (Dark Reader) didn't force dark mode for images, which means I can see the labels just fine in these cases.
- lalaithion 6y agoIt shouldn't be that hard for a dark mode implementation to determine which images are diagrams and which are photos, and switch the colors for one class of images and not the other.
- zbowling 6y agoBig fan of rust-analyzer and have been using it since early alpha. Much better than RLS and approaching all the features in the Rust plugin for Clion/JetBrains. Got me off Clion during WFH because of the massive memory/CPU requirements of using a big IDE on a laptop when developing. Rust being a terse language with generics and macros, sometimes figuring out what type an object is is hard and can easily get lost. Rust analyzer + vscode instantly gives context visually in all my code and even names types better than when the compiler errors at you when you get it wrong. This is especially true when dealing with a lot of async rust and you need to know the exact fully declared type of an object so you can fully decl it's type for a pin/box to pass around. Game changer. Being able to use to jump to definition is a huge win. I can walk code so much easier now and understand issues without a lot of mental energy or digging. It also updates in realtime as I code. Big productivity boost I know for a lot of devs on Fuchsia. It would take me at least twice as long to get up with a new crate and be productive with it. The same is true as my own code base grows and I can't keep it all in my memory and remember. Impossible to stay as productive as code grows in rust without something like this anymore. Also a huge win for the fact that it works remotely with vscode's remote features so I can have my code + rust-analyzer on my big linux machine remotely but still edit that code and get the context locally on my dinky/slower/older macbook. My only wish is that it eventually gains some of the deeper refactoring features in vscode you can still get in Rust + Clion/JetBrains. Almost there.
- monadic3 6y agoStill waiting on my favorite jetbrains feature—show type of selected expression. Probably the single most used IDE feature in my toolbox when I used scala.
- ibraheemdev 6y agoIt looks like this is blocked upstream by the language server protocol not passing the current selection for hover requests [0]. 0: https://github.com/microsoft/language-server-protocol/issues/377 https://github.com/microsoft/language-server-protocol/issues...
- the_duke 6y ago
- skrtskrt 6y agoIs it possible to get the inline inferred type annotations to show up in Vim the way they do in VSCode? I have been making a strong push to move to 100% Vim for development, but those inline annotations in VSCode with rust analyzer are amazing, especially while I'm still learning Rust. I'm currently using YouCompleteMe with rust-analyzer, plus rust-vim for autoformatting
- ibraheemdev 6y agoI use coc.nvim with rust-analyzer and I find it amazing. I used a more lightweight lsp client in the past, but I find the more full-featured coc.nvim to be the best balance - I get all the benefits of an IDE + the productivity of vim. coc is based on the VSCode intelli-sense engine and enables inline type-annotations by default, but I am not sure if "regular" vim (not neovim) supports it.
- ruph123 6y agoCan you please share your config? I find configuring coc quite painful.
- ibraheemdev 6y agoI actually find configuration really nice with json auto completion. My config is here: https://github.com/ibraheemdev/dotfiles/tree/master/.vim https://github.com/ibraheemdev/dotfiles/tree/master/.vim.
- ruph123 6y agoThank you!
- addcninblue 6y agoTake a look at neovim 0.5 beta [0]. It has native support for LSP [1], and it's on par with other editors. Also, the setup is nearly zero overhead, as there are default configs [2] that others maintain. [0]: https://github.com/neovim/neovim https://github.com/neovim/neovim [1]: https://neovim.io/doc/user/lsp.html https://neovim.io/doc/user/lsp.html [2]: https://github.com/neovim/nvim-lspconfig https://github.com/neovim/nvim-lspconfig
- solmag 6y agoRust-Analyzer is much better than whatever IDEA/Clion uses IME.
- lights0123 6y agoIs there anything other than performance and proc macro compatibility that RA has over IntelliJ-Rust? All of the alternatives to IntelliJ-Rust are just missing critical (to me) features like refactoring.
- the_duke 6y agoRA uses chalk [1], which is a trait solver rewrite for rustc. You can already use it on nightly with a feature flag. So RA can get close to the trait resolution of the compiler, which is probably the most challenging part. I haven't used Intellij in a while, but I doubt they can ever get close with their custom implementation. I always had trouble with trait resolution/autocompletion, which is often where you need from the IDE the most. [1] https://github.com/rust-lang/chalk https://github.com/rust-lang/chalk
- brundolf 6y agoWhen was the last time you tried RA? I ask because they've been adding features at a rapid clip, and lately they seem to be focusing on adding new refactoring features. I wouldn't be surprised to hear they still don't have everything CLion does, but I also wouldn't be surprised to see them get there before long.
- atsuzaki 6y agoYou have to consider that both plugins were pioneered by the same lead developer, and rust-analyzer came as a second system leveraging things learned from the IntelliJ Rust project.
- jiggawatts 6y agoI try to install the VS Code Rust plugin every couple of months. Every time, it doesn't work. It does literally nothing. No syntax highlighting, no tab complete, nothing. I look up the issue and there's always some excuse of why it happens to be broken right this second. "The next Rust release will fix it" or whatever. I've given up and I've been using the IntelliJ Rust plugin, which just works. I don't know what the Rust Analyzer and RLS teams are doing wrong, maybe it's insufficient QA or something, but it's a huge turnoff when after repeated attempts over a year I've experienced nothing but failure after failure.
- mrec 6y agoNot sure if you were just abbreviating, but my understanding is that there's a "Rust" plugin for VS Code which is not the same as the rust-analyzer plugin, is nowhere near as good and yet shows up first in searches.
- Waterluvian 6y agoI suffered this a year ago and it sucked. But I scraped together help and advice and got it working and now it's just amazing and works perfectly with no maintenance. I'd love to pay it forward by working 1:1 with you to get yours working. I'm free any time during Toronto office hours if you'd like to take up the offer. And of course if you want to keep using IntelliJ, that's an awesome tool as well.