mirror of
https://github.com/neovim/neovim.git
synced 2025-12-12 01:22:41 +00:00
feat(lsp): graduate ClientConfig exit_timeout #36750
Problem: The `flags` field calls its sub-fields "experimental". But `exit_timeout` is now used for multiple purposes. Solution: Graduate `exit_timeout` to a top-level ClientConfig field.
This commit is contained in:
@@ -550,8 +550,7 @@ end
|
||||
---
|
||||
--- @param name string|string[] Name(s) of client(s) to enable.
|
||||
--- @param enable? boolean `true|nil` to enable, `false` to disable (actively stops and detaches
|
||||
--- clients as needed, and force stops them if necessary after `client.flags.exit_timeout`
|
||||
--- milliseconds, with a default time of 3000 milliseconds)
|
||||
--- clients as needed, and force stops them if necessary after `client.exit_timeout` milliseconds)
|
||||
function lsp.enable(name, enable)
|
||||
validate('name', name, { 'string', 'table' })
|
||||
|
||||
@@ -588,9 +587,7 @@ function lsp.enable(name, enable)
|
||||
else
|
||||
for _, nm in ipairs(names) do
|
||||
for _, client in ipairs(lsp.get_clients({ name = nm })) do
|
||||
local t = client.flags.exit_timeout
|
||||
local force_timeout = t and tonumber(t) or (t ~= false and 3000 or nil)
|
||||
client:stop(force_timeout)
|
||||
client:stop(client.exit_timeout)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1147,7 +1144,7 @@ api.nvim_create_autocmd('VimLeavePre', {
|
||||
log.info('exit_handler', active_clients)
|
||||
|
||||
for _, client in pairs(active_clients) do
|
||||
client:stop(client.flags.exit_timeout)
|
||||
client:stop(client.exit_timeout)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -25,12 +25,6 @@ local all_clients = {}
|
||||
--- No debounce occurs if `nil`.
|
||||
--- (default: `150`)
|
||||
--- @field debounce_text_changes integer
|
||||
---
|
||||
--- Milliseconds to wait for server to exit cleanly after sending the
|
||||
--- "shutdown" request before sending kill -15. If set to false, nvim exits
|
||||
--- immediately after sending the "shutdown" request to the server.
|
||||
--- (default: `false`)
|
||||
--- @field exit_timeout integer|false
|
||||
|
||||
--- @class vim.lsp.ClientConfig
|
||||
---
|
||||
@@ -75,6 +69,12 @@ local all_clients = {}
|
||||
--- (default: `true`)
|
||||
--- @field detached? boolean
|
||||
---
|
||||
--- Milliseconds to wait for server to exit cleanly after sending the "shutdown" request before
|
||||
--- sending kill -15. If set to false, waits indefinitely. If set to true, nvim will kill the
|
||||
--- server immediately.
|
||||
--- (default: `3000`)
|
||||
--- @field exit_timeout? integer|boolean
|
||||
---
|
||||
--- A table with flags for the client. The current (experimental) flags are:
|
||||
--- @field flags? vim.lsp.Client.Flags
|
||||
---
|
||||
@@ -157,6 +157,12 @@ local all_clients = {}
|
||||
--- Capabilities provided at runtime (after startup).
|
||||
--- @field dynamic_capabilities lsp.DynamicCapabilities
|
||||
---
|
||||
--- Milliseconds to wait for server to exit cleanly after sending the "shutdown" request before
|
||||
--- sending kill -15. If set to false, waits indefinitely. If set to true, nvim will kill the
|
||||
--- server immediately.
|
||||
--- (default: `3000`)
|
||||
--- @field exit_timeout integer|boolean
|
||||
---
|
||||
--- A table with flags for the client. The current (experimental) flags are:
|
||||
--- @field flags vim.lsp.Client.Flags
|
||||
---
|
||||
@@ -314,6 +320,7 @@ local function validate_config(config)
|
||||
validate('cmd_cwd', config.cmd_cwd, optional_validator(is_dir), 'directory')
|
||||
validate('cmd_env', config.cmd_env, 'table', true)
|
||||
validate('detached', config.detached, 'boolean', true)
|
||||
validate('exit_timeout', config.exit_timeout, { 'number', 'boolean' }, true)
|
||||
validate('name', config.name, 'string', true)
|
||||
validate('on_error', config.on_error, 'function', true)
|
||||
validate('on_exit', config.on_exit, { 'function', 'table' }, true)
|
||||
@@ -388,6 +395,7 @@ function Client.create(config)
|
||||
commands = config.commands or {},
|
||||
settings = config.settings or {},
|
||||
flags = config.flags or {},
|
||||
exit_timeout = config.exit_timeout == nil and 3000 or config.exit_timeout --[[@as integer|boolean]],
|
||||
get_language_id = config.get_language_id or default_get_language_id,
|
||||
capabilities = config.capabilities,
|
||||
workspace_folders = lsp._get_workspace_folders(config.workspace_folders or config.root_dir),
|
||||
|
||||
Reference in New Issue
Block a user