Open norcalli opened 4 years ago
This is awesome to here @norcalli, thank you! I myself don't use vim, so I personally won't be able to really guide this, but I definitely would be glad to answer any questions!
The most important thing to keep in mind is that rust-analyzer is an experimental project at this stage, and so we don't follow LSP specification to the letter. For example, we don't always properly handle client capabilities (instead, we generally used the most recent revision of all requests), and we also implement some custom extensions on top of the base protocol (to better exercise underlying engine). So, if something doesn't work with rust-analyzer/nvim setup, it might be the case that we are at fault!
Adding a way to install rust-analyzer without superuser permissions
rust-analyzer doesn't need and never needed root permissions. The installation process is "build from source", and cargo
installs binaries to a user-writable ~/cargo/bin
, and not into /usr/bin
We have support for commands definitions for custom rust-analyzer commands, if any.
Yep, we do have quite a few of custom commands. There are no docs, but the server-side definitions are here, and we have client-side impl for emacs and vscode here.
We allow specifying default settings
Yeah, it's unclear how to specify settings in a way that is available for all editors. We try to document settings here
Note also that we maintain the "official" rust-analyzer plugin for emacs and VS Code in this repository. But it seems like https://github.com/neovim/nvim-lsp is indeed a better place for an nvim plugin.
What is the relationship between what :CocInstall coc-rust-analyzer
does to install coc-rust-analyzer
and neovim/nvim-lsp
? Thanks in advance. - E
@EdmundsEcho coc.nvim
and neovim/nvim-lsp
are completely unrelated, so I'm going to assume your question was in regards to the difference in user experience.
With neovim/nvim-lsp
and the Neovim built-in lsp in general, the idea is to be fast and thin with minimal to no configuration required. As a result, with neovim/nvim-lsp
, if you add it, you have all of the server templates available already, so you don't have to install anything to use rust-analyzer
. On the other hand, coc
plugins tend to do more than just what is available from the LSP, but they also have a hard requirement on node
and friends. With nvim-lsp
, no external dependencies are required for the framework (except for installation scripts which are platform dependent, but I'm going to be changing that in the future). Also, eventually nvim-lsp
is going to be merged into master, I only set it up there because it's going to change more rapidly than master does right now.
Personally, I don't want to install an npm plugin and maintain those dependencies to use neovim or the LSP, but if there are extra features you like that coc
provides, then coc
is good. However, the built in LSP is improving rapidly and will ostensibly be maintained forever by the neovim team.
Also, overall, the performance of the built in LSP should be the best because it can interface directly with the C API and because I wrote it with performance in mind. Lua is pretty quick.
Also @matklad I never thanked you for your response. It's definitely helpful. As far as settings go, I added a scraper that can get the settings directly from the package.json
in the released vscode extension from the microsoft store so as to avoid needing more work from LSP maintainers. It can even be useful for users other than neovim. It's here under "Available Settings".
@norcalli The README gives a configuration, but it fails. See here. A link to the project or configuration collection could be more useful.
Somehow it works now. The error message seems to pop up very shortly and then gets removed. Will send a PR to change the README.
Thanks to @h-michael no error messages are shown and it works.
@norcalli Can you update the status of the todos?
As far as settings go, I added a scraper that can get the settings directly
@norcalli you might have already seen it, but there's now a rust-analyzer --print-config-schema
.
Other than that, do you think there's anything else we can do here? Personally, I haven't tried the native LSP support in Neovim yet -- I thought I'd wait for 0.5
, but that might take a while I suppose.
@lnicola A wiki or something to collect plugins for Rust development would be great. areweideyet is sparse about plugins and tradeoffs in plugin choice.
We have every few weeks someone explaining the plugin configuration on reddit, but no central place to collect the ideas why and what (not) to use.
I recently added a built-in language server client for neovim, and in the process we began https://github.com/neovim/nvim-lsp, which is aiming to be a reference database of how to work with LSP servers as a non-VSCode/third-party editor. It's written in Lua, but written in an abstracted way so as to easily be used as a reference and make it easy for contributors. Someone recently opened a PR to add support for it here and I wanted to notify you guys about the project so that we could make sure it's correct and see about improving the definition beyond the basics.
The enhancements are, for example:
commands
definitions for custom rust-analyzer commands, if any.package.json
to generate documentation in the README right now, so that helps. You can see an example of these generated docs for rls herecallbacks
.Any help would be appreciated. Thanks.