Skip to content

Commit

Permalink
Merge branch 'main' into fix/init_options
Browse files Browse the repository at this point in the history
  • Loading branch information
pr2502 authored Oct 8, 2024
2 parents 7c584b1 + a3f1a5c commit 8ee3430
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 9 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/.direnv
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]
## [v0.2.5] - 2024-08-08

### Added
- configuration option `pass_environment` which specifies a list of env var names to be passed from ra-multiplex client proxy to the spawned language server (rust-analyzer)
- added the option to use unix sockets instead of TCP sockets on unix family operating systems

### Fixed
- on windows remove leading `/` before drive letter


## [v0.2.4] - 2024-05-15

Expand All @@ -34,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- handle `workspace/configuration` server request to fix rust-analyzer configuration with some LSP clients
- handle `workDoneProgress/create` server request to fix progress indicators in editors
- handle url encoded paths


## [v0.2.2] - 2023-05-02
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ra-multiplex"
version = "0.2.4"
version = "0.2.5"
description = "share one rust-analyzer server instance between multiple LSP clients to save resources"
repository = "https://github.com/pr2502/ra-multiplex"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion examples/neovim/init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require'lspconfig'.rust_analyzer.setup {
cmd = vim.lsp.rpc.connect("127.0.0.1", 27631),
-- When using unix domain sockets, use something like:
--cmd = vim.lsp.rpc.domain_socket_connect("/path/to/ra-multiplex.sock"),
-- cmd = vim.lsp.rpc.connect("/path/to/ra-multiplex.sock"),
settings = {
["rust-analyzer"] = {
lspMux = {
Expand Down
82 changes: 82 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
description = ''
Language server proxy which enables sharing a single language server,
like rust-analyzer, between multiple LSP clients (editor windows).
'';

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
utils.url = "github:numtide/flake-utils";

rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, rust-overlay, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};

rustToolchain = pkgs.rust-bin.stable."1.80.1".minimal;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};

rustDev = rustToolchain.override {
extensions = ["rust-src" "rust-analyzer" "rust-docs" "clippy"];
};
# We want to use some unstable options in `rustfmt.toml` and
# unfortunately the only way to do that is use nightly rustfmt.
rustFmt = pkgs.rust-bin.nightly."2024-07-07".minimal.override {
extensions = ["rustfmt"];
};
in {
packages.default = rustPlatform.buildRustPackage {
pname = "ra-multiplex";
version = "0.2.5";
src = self;
cargoLock.lockFile = ./Cargo.lock;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
rustDev
rustFmt
];
};
});
}
6 changes: 3 additions & 3 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,15 @@ async fn spawn(
.or_else(|| env::var("PATH").ok())
.unwrap_or_default();
format!(
"spawning langauge server: server={server:?}, args={args:?}, \
"spawning language server: server={server:?}, args={args:?}, \
cwd={workspace_root:?}, path={path:?}, env={env:?}",
)
})?;

let pid = child.id().context("child exited early, couldn't get PID")?;
tracing::Span::current().record("pid", pid);

info!(server = ?key.server, args = ?key.args, cwd = ?key.workspace_root, "spawned langauge server");
info!(server = ?key.server, args = ?key.args, cwd = ?key.workspace_root, "spawned language server");

let stderr = child.stderr.take().unwrap();
task::spawn(stderr_task(stderr).in_current_span());
Expand Down Expand Up @@ -542,7 +542,7 @@ async fn initialize_handshake(
Ok(result)
}

/// Read errors from langauge server stderr and log them
/// Read errors from language server stderr and log them
async fn stderr_task(stderr: ChildStderr) {
let mut stderr = BufReader::new(stderr);
let mut buffer = String::new();
Expand Down

0 comments on commit 8ee3430

Please sign in to comment.