diff --git a/doc/rustaceanvim.txt b/doc/rustaceanvim.txt index 035696bc..ee053514 100644 --- a/doc/rustaceanvim.txt +++ b/doc/rustaceanvim.txt @@ -299,18 +299,16 @@ rustaceanvim.lsp.ClientOpts *rustaceanvim.lsp.ClientOpts* {load_vscode_settings?} (boolean) Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. If found, loaded settings will override configured options. - Default: true - - See: ~ - |vim.lsp.ClientConfig| + Default: `true` + {status_notify_level?} (rustaceanvim.server.status_notify_level) + Server status warning level to notify at. + Default: 'error' -rustaceanvim.dap.Opts *rustaceanvim.dap.Opts* +rustaceanvim.server.status_notify_level*rustaceanvim.server.status_notify_level* - Fields: ~ - {autoload_configurations} (boolean) - Whether to autoload nvim-dap configurations when rust-analyzer has attached? - Default: `true`. + Type: ~ + "error"|"warning"|rustaceanvim.disable rustaceanvim.disable *rustaceanvim.disable* @@ -319,6 +317,30 @@ rustaceanvim.disable *rustaceanvim.disable* false +rustaceanvim.dap.Opts *rustaceanvim.dap.Opts* + + Fields: ~ + {autoload_configurations?} (boolean) + Whether to autoload nvim-dap configurations when rust-analyzer has attached? + Default: `true` + {adapter?} (rustaceanvim.dap.executable.Config|rustaceanvim.dap.server.Config|rustaceanvim.disable|fun():rustaceanvim.dap.executable.Config|rustaceanvim.dap.server.Config|rustaceanvim.disable) + Defaults to creating the `rt_lldb` adapter, which is a |rustaceanvim.dap.server.Config| + if `codelldb` is detected, and a |rustaceanvim.dap.executable.Config|` if `lldb` is detected. + Set to `false` to disable. + {configuration?} (rustaceanvim.dap.client.Config|rustaceanvim.disable|fun():rustaceanvim.dap.client.Config|rustaceanvim.disable) + Dap client configuration. Defaults to a function that looks for a `launch.json` file + or returns a |rustaceanvim.dap.executable.Config| that launches the `rt_lldb` adapter. + Set to `false` to disable. + {add_dynamic_library_paths?} (boolean|fun():boolean) + Accommodate dynamically-linked targets by passing library paths to lldb. + Default: `true`. + {auto_generate_source_map?} (fun():boolean|boolean) + Whether to auto-generate a source map for the standard library. + {load_rust_types?} (fun():boolean|boolean) + Whether to get Rust types via initCommands (rustlib/etc/lldb_commands, lldb only). + Default: `true`. + + rustaceanvim.dap.Command *rustaceanvim.dap.Command* Type: ~ diff --git a/lua/rustaceanvim/config/init.lua b/lua/rustaceanvim/config/init.lua index 48f5d79f..afe6f53a 100644 --- a/lua/rustaceanvim/config/init.lua +++ b/lua/rustaceanvim/config/init.lua @@ -189,19 +189,28 @@ vim.g.rustaceanvim = vim.g.rustaceanvim --- ---Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. ---If found, loaded settings will override configured options. ----Default: true +---Default: `true` ---@field load_vscode_settings? boolean +--- +---Server status warning level to notify at. +---Default: 'error' +---@field status_notify_level? rustaceanvim.server.status_notify_level +--- ---@see vim.lsp.ClientConfig +---@alias rustaceanvim.server.status_notify_level 'error' | 'warning' | rustaceanvim.disable + +---@alias rustaceanvim.disable false + ---@class rustaceanvim.dap.Opts --- ---Whether to autoload nvim-dap configurations when rust-analyzer has attached? ----Default: `true`. ----@field autoload_configurations boolean +---Default: `true` +---@field autoload_configurations? boolean --- ---Defaults to creating the `rt_lldb` adapter, which is a |rustaceanvim.dap.server.Config| ---if `codelldb` is detected, and a |rustaceanvim.dap.executable.Config|` if `lldb` is detected. --- Set to `false` to disable. +---Set to `false` to disable. ---@field adapter? rustaceanvim.dap.executable.Config | rustaceanvim.dap.server.Config | rustaceanvim.disable | fun():(rustaceanvim.dap.executable.Config | rustaceanvim.dap.server.Config | rustaceanvim.disable) --- ---Dap client configuration. Defaults to a function that looks for a `launch.json` file @@ -220,8 +229,6 @@ vim.g.rustaceanvim = vim.g.rustaceanvim ---Default: `true`. ---@field load_rust_types? fun():boolean | boolean ----@alias rustaceanvim.disable false - ---@alias rustaceanvim.dap.Command string ---@class rustaceanvim.dap.executable.Config diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index b7797af5..f9dfbceb 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -295,6 +295,8 @@ local RustaceanDefaultConfig = { }, ---@type boolean Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. load_vscode_settings = true, + ---@type rustaceanvim.server.status_notify_level + status_notify_level = 'error', }, --- debugging stuff diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index 46d35314..89ae9b32 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -5,6 +5,22 @@ local M = {} ---@type { [integer]: boolean } local _ran_once = {} +---@param health rustaceanvim.lsp_server_health_status +---@return boolean +local function is_notify_enabled_for(health) + if health and health == 'ok' then + return false + end + local notify_level = config.server.status_notify_level + if not notify_level then + return false + end + if notify_level == 'error' then + return health == 'error' + end + return true +end + ---@param result rustaceanvim.internal.RAInitializedStatus function M.handler(_, result, ctx, _) -- quiescent means the full set of results is ready. @@ -12,7 +28,7 @@ function M.handler(_, result, ctx, _) return end -- notify of LSP errors/warnings - if result.health and result.health ~= 'ok' then + if is_notify_enabled_for(result.health) then local message = ([[ rust-analyzer health status is [%s]: %s