From 900c6c5214b0fcec9a71309d7b05186bbaa3fa48 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 18 Nov 2024 22:05:18 +0100 Subject: [PATCH] feat(lsp): pass `client_id` to `on_initialized` (#584) --- doc/rustaceanvim.txt | 38 ++++++++++++++-------------- lua/rustaceanvim/config/init.lua | 2 +- lua/rustaceanvim/config/internal.lua | 2 +- lua/rustaceanvim/server_status.lua | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index bf26be2c..690e2419 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -156,35 +156,35 @@ rustaceanvim.tools.Opts *rustaceanvim.tools.Opts* Fields: ~ {executor?} (rustaceanvim.Executor|rustaceanvim.executor_alias) - The executor to use for runnables/debuggables + The executor to use for runnables/debuggables {test_executor?} (rustaceanvim.Executor|rustaceanvim.test_executor_alias) - The executor to use for runnables that are tests / testables + The executor to use for runnables that are tests / testables {crate_test_executor?} (rustaceanvim.Executor|rustaceanvim.test_executor_alias) - The executor to use for runnables that are crate test suites (--all-targets) + The executor to use for runnables that are crate test suites (--all-targets) {cargo_override?} (string) - Set this to override the 'cargo' command for runnables, debuggables (etc., e.g. to 'cross'). - If set, this takes precedence over 'enable_nextest'. + Set this to override the 'cargo' command for runnables, debuggables (etc., e.g. to 'cross'). + If set, this takes precedence over 'enable_nextest'. {enable_nextest?} (boolean) - Whether to enable nextest. If enabled, `cargo test` commands will be transformed to `cargo nextest run` commands. - Defaults to `true` if cargo-nextest is detected. Ignored if `cargo_override` is set. + Whether to enable nextest. If enabled, `cargo test` commands will be transformed to `cargo nextest run` commands. + Defaults to `true` if cargo-nextest is detected. Ignored if `cargo_override` is set. {enable_clippy?} (boolean) - Whether to enable clippy checks on save if a clippy installation is detected. - Default: `true` - {on_initialized?} (fun(health:rustaceanvim.RAInitializedStatus)) - Function that is invoked when the LSP server has finished initializing + Whether to enable clippy checks on save if a clippy installation is detected. + Default: `true` + {on_initialized?} (fun(health:rustaceanvim.RAInitializedStatus,client_id:integer)) + Function that is invoked when the LSP server has finished initializing {reload_workspace_from_cargo_toml?} (boolean) - Automatically call `RustReloadWorkspace` when writing to a Cargo.toml file - {hover_actions?} (rustaceanvim.hover-actions.Opts) Options for hover actions - {code_actions?} (rustaceanvim.code-action.Opts) Options for code actions + Automatically call `RustReloadWorkspace` when writing to a Cargo.toml file + {hover_actions?} (rustaceanvim.hover-actions.Opts) Options for hover actions + {code_actions?} (rustaceanvim.code-action.Opts) Options for code actions {float_win_config?} (rustaceanvim.FloatWinConfig) - Options applied to floating windows. - See |api-win_config|. + Options applied to floating windows. + See |api-win_config|. {create_graph?} (rustaceanvim.crate-graph.Opts) - Options for showing the crate graph based on graphviz and the dot + Options for showing the crate graph based on graphviz and the dot {open_url?} (fun(url:string):nil) - If set, overrides how to open URLs + If set, overrides how to open URLs {rustc?} (rustaceanvim.rustc.Opts) - Options for `rustc` + Options for `rustc` rustaceanvim.Executor *rustaceanvim.Executor* diff --git a/lua/rustaceanvim/config/init.lua b/lua/rustaceanvim/config/init.lua index cbb5042e..252306be 100644 --- a/lua/rustaceanvim/config/init.lua +++ b/lua/rustaceanvim/config/init.lua @@ -78,7 +78,7 @@ vim.g.rustaceanvim = vim.g.rustaceanvim ---@field enable_clippy? boolean --- ---Function that is invoked when the LSP server has finished initializing ----@field on_initialized? fun(health:rustaceanvim.RAInitializedStatus) +---@field on_initialized? fun(health:rustaceanvim.RAInitializedStatus, client_id:integer) --- ---Automatically call `RustReloadWorkspace` when writing to a Cargo.toml file ---@field reload_workspace_from_cargo_toml? boolean diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index 4c736845..68852f93 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -106,7 +106,7 @@ local RustaceanDefaultConfig = { --- callback to execute once rust-analyzer is done initializing the workspace --- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" - ---@type fun(health:rustaceanvim.RAInitializedStatus) | nil + ---@type fun(health:rustaceanvim.RAInitializedStatus, client_id:integer) | nil on_initialized = nil, --- automatically call RustReloadWorkspace when writing to a Cargo.toml file. diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index fb3d2177..dbe59db8 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -58,7 +58,7 @@ see ':h rustaceanvim.lsp.ClientOpts'. end -- Load user on_initialized if config.tools.on_initialized then - config.tools.on_initialized(result) + config.tools.on_initialized(result, ctx.client_id) end if config.dap.autoload_configurations then require('rustaceanvim.commands.debuggables').add_dap_debuggables()