Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pr2502 committed Oct 20, 2023
1 parent 43cc77d commit abf8f93
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@ windows) to share a single `rust-analyzer` instance per cargo workspace.
`ra-multiplex` acts like `rust-analyzer` but only connects to a TCP socket at
`127.0.0.1:27631` and pipes stdin and stdout through it.

Depending on the working directory the `ra-multiplex` client was spawned from
it can reuse an already spawned `rust-analyzer` instance. It detects workspace
root as the furthermost ancestor directory containing a `Cargo.toml` file. If
the automatic workspace detection fails or if you're not using `rust-analyzer`
as a server you can create a marker file `.ra-multiplex-workspace-root` in the
directory you want to use as a workspace root, the first ancestor directory
containing this file will be used.

Depending on the `workspaceFolders` provided by your editor during
initialization it can reuse an already spawned `rust-analyzer` instance.

Because neither LSP nor `rust-analyzer` itself support multiple clients per
server `ra-multiplex` caches the handshake messages and modifies IDs of
requests & responses to track which response belongs to which client. Because
not all messages can be tracked this way it drops some, notably it drops any
requests from the server, this appears to not be a problem with
`coc-rust-analyzer` in neovim but YMMV.
server `ra-multiplex` intercepts the handshake process modifies IDs of requests
& responses to track which response belongs to which client. Because not all
messages can be tracked this way it drops some, notably it drops any requests
from the server, this appears to not be a problem with `coc-rust-analyzer` in
neovim but YMMV.

If you have any problems you're welcome to open issues on this repository.

Expand Down Expand Up @@ -70,6 +65,10 @@ CoC in neovim edit `~/.config/nvim/coc-settings.json`, add:
}
```

If your editor can connect to a language server via TCP you don't need to use
the `ra-multiplex` client and connect directly to the server. For this
[neovim example](examples/neovim/init.vim).


## Configuration

Expand Down Expand Up @@ -124,30 +123,24 @@ connect = ["127.0.0.1", 27631] # same as `listen`
# is documented in the `env_logger` documentation here:
# <https://docs.rs/env_logger/0.9.0/env_logger/index.html#enabling-logging>
log_filters = "info"

# attempt automatic workspace root detection
#
# when enabled every connected client will attempt to discover the root of the
# workspace it was spawned in. otherwise the client CWD is always used
workspace_detection = true
```


## Other LSP servers

By default `ra-multiplex` uses a `rust-analyzer` binary found in its `$PATH` as
the server. This can be overridden using the `--ra-mux-server` cli option or
`RA_MUX_SERVER` environment variable. You can usually configure one of these in
your editor configuration. If both are specified the cli option overrides the
environment variable.
By default `ra-multiplex` uses a `rust-analyzer` binary found in its `$PATH`
as the server. This can be overridden using the `--server-path` cli option with
the client subcommand or `RA_MUX_SERVER` environment variable. You can usually
configure one of these in your editor configuration. If both are specified the
cli option overrides the environment variable.

For example with `coc-clangd` in CoC for neovim add to
`~/.config/nvim/coc-settings.json`:

```json
{
"clangd.path": "/home/user/.cargo/bin/ra-multiplex",
"clangd.arguments": ["client", "--ra-mux-server", "/usr/bin/clangd"]
"clangd.arguments": ["client", "--server-path", "/usr/bin/clangd"]
}
```

Expand All @@ -168,7 +161,7 @@ need a script like `/usr/local/bin/clangd-proxy`:

```sh
#!/bin/sh
RA_MUX_SERVER=/usr/bin/clangd exec /home/user/.cargo/bin/ra-multiplex client --ra-mux-server /usr/bin/clangd $@
RA_MUX_SERVER=/usr/bin/clangd exec /home/user/.cargo/bin/ra-multiplex client --server-path /usr/bin/clangd $@
```

And configure the editor to use the wrapper script in
Expand Down

0 comments on commit abf8f93

Please sign in to comment.