diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index ea8c4bf..6abfe1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/.direnv diff --git a/CHANGELOG.md b/CHANGELOG.md index c652be9..c7e8388 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/Cargo.lock b/Cargo.lock index a427512..da0bc8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -253,9 +253,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lock_api" @@ -410,7 +410,7 @@ dependencies = [ [[package]] name = "ra-multiplex" -version = "0.2.4" +version = "0.2.5" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 232294f..07ff814 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/examples/neovim/init.lua b/examples/neovim/init.lua index 6ac150e..57778dc 100644 --- a/examples/neovim/init.lua +++ b/examples/neovim/init.lua @@ -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 = { diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..185f624 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1722813957, + "narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", + "utils": "utils" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723343015, + "narHash": "sha256-oS8Qhpo71B/6OOsuVBFJbems7RKD/5e3TN2AdXhwMjg=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "ed4fe9af3814694d59c572649e881a6aa6eba533", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..da1051d --- /dev/null +++ b/flake.nix @@ -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 + ]; + }; + }); +} diff --git a/src/instance.rs b/src/instance.rs index c358308..fa19a56 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -446,7 +446,7 @@ 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:?}", ) })?; @@ -454,7 +454,7 @@ async fn spawn( 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()); @@ -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();