• Home
Name Date Size #Lines LOC

..--

src/03-May-2024-365274

Cargo.lockD03-May-20243.8 KiB148129

Cargo.tomlD03-May-2024341 1814

README.mdD03-May-20242.3 KiB6245

README.md

1# rust-analyzer-chromiumos-wrapper
2
3## Intro
4
5rust-analyzer is an LSP server for the Rust language. It allows editors like
6vim, emacs, or VS Code to provide IDE-like features for Rust.
7
8This program, `rust-analyzer-chromiumos-wrapper`, is a wrapper around
9`rust-analyzer`. It exists to translate paths between an instance of
10rust-analyzer running inside the chromiumos chroot and a client running outside
11the chroot.
12
13It is of course possible to simply run `rust-analyzer` outside the chroot, but
14version mismatch issues may lead to a suboptimal experience.
15
16It should run outside the chroot. If invoked in a `chromiumos` repo in a
17subdirectory of either `chromiumos/src` or `chromiumos/chroot`, it will attempt
18to invoke `rust-analyzer` inside the chroot and translate paths. Otherwise, it
19will attempt to invoke a `rust-analyzer` outside the chroot and will not
20translate paths.
21
22It supports none of rust-analyzer's command line options, which aren't
23necessary for acting as a LSP server anyway.
24
25## Quickstart
26
27*Outside* the chroot, install the `rust-analyzer-chromiumos-wrapper` binary:
28
29```
30cargo install --path /path-to-a-chromiumos-checkout/src/third_party/toolchain-utils/rust-analyzer-chromiumos-wrapper
31```
32
33Make sure `~/.cargo/bin' is in your PATH, or move/symlink `~/.cargo/bin/rust-analyzer-chromiumos-wrapper` to a location in your PATH.
34
35Configure your editor to use the binary `rust-analyzer-chromiumos-wrapper` as
36`rust-analyzer`. In Neovim, if you're using
37[nvim-lspconfig](https://github.com/neovim/nvim-lspconfig), this can be done by
38putting the following in your `init.lua`:
39
40```
41require('lspconfig')['rust_analyzer'].setup {
42  cmd = {'rust-analyzer-chromiumos-wrapper'},
43}
44```
45
46This configuration is specific to your editor, but see the
47[Rust analyzer manual](https://rust-analyzer.github.io/manual.html) for
48more about several different editors.
49
50Once the above general configuration is set up, you'll need to install
51`rust-analyzer` inside each chroot where you want to edit code:
52```
53sudo emerge rust-analyzer
54```
55
56## Misc
57
58A wrapper isn't necessary for clangd, because clangd supports the option
59`--path-mappings` to translate paths. In principle a similar option could be
60added to `rust-analyzer`, obviating the need for this wrapper. See this
61[issue on github](https://github.com/rust-lang/rust-analyzer/issues/12485).
62