mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
feat(lsp): enable default debounce of 150 ms (#16908)
This commit is contained in:
committed by
GitHub
parent
f65b0d4236
commit
55a59e56ed
@@ -887,10 +887,10 @@ start_client({config}) *vim.lsp.start_client()*
|
|||||||
default true): Allow using
|
default true): Allow using
|
||||||
incremental sync for buffer edits
|
incremental sync for buffer edits
|
||||||
• debounce_text_changes (number,
|
• debounce_text_changes (number,
|
||||||
default nil): Debounce didChange
|
default 150): Debounce didChange
|
||||||
notifications to the server by the
|
notifications to the server by the
|
||||||
given number in milliseconds. No
|
given number in milliseconds. No
|
||||||
debounce occurs if nil
|
debounce occurs if set to 0.
|
||||||
• exit_timeout (number, default 500):
|
• exit_timeout (number, default 500):
|
||||||
Milliseconds to wait for server to
|
Milliseconds to wait for server to
|
||||||
exit cleanly after sending the
|
exit cleanly after sending the
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ local function validate_client_config(config)
|
|||||||
(not config.flags
|
(not config.flags
|
||||||
or not config.flags.debounce_text_changes
|
or not config.flags.debounce_text_changes
|
||||||
or type(config.flags.debounce_text_changes) == 'number'),
|
or type(config.flags.debounce_text_changes) == 'number'),
|
||||||
"flags.debounce_text_changes must be nil or a number with the debounce time in milliseconds"
|
"flags.debounce_text_changes must be a number with the debounce time in milliseconds"
|
||||||
)
|
)
|
||||||
|
|
||||||
local cmd, cmd_args = lsp._cmd_parts(config.cmd)
|
local cmd, cmd_args = lsp._cmd_parts(config.cmd)
|
||||||
@@ -383,8 +383,8 @@ do
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local state = state_by_client[client.id]
|
local state = state_by_client[client.id]
|
||||||
local debounce = client.config.flags.debounce_text_changes
|
local debounce = client.config.flags.debounce_text_changes or 150
|
||||||
if not debounce then
|
if debounce == 0 then
|
||||||
local changes = state.use_incremental_sync and incremental_changes(client) or full_changes()
|
local changes = state.use_incremental_sync and incremental_changes(client) or full_changes()
|
||||||
client.notify("textDocument/didChange", {
|
client.notify("textDocument/didChange", {
|
||||||
textDocument = {
|
textDocument = {
|
||||||
|
|||||||
@@ -73,8 +73,11 @@ local function fake_lsp_server_setup(test_name, timeout_ms, options)
|
|||||||
on_init = function(client, result)
|
on_init = function(client, result)
|
||||||
TEST_RPC_CLIENT = client
|
TEST_RPC_CLIENT = client
|
||||||
vim.rpcrequest(1, "init", result)
|
vim.rpcrequest(1, "init", result)
|
||||||
client.config.flags.allow_incremental_sync = options.allow_incremental_sync or false
|
|
||||||
end;
|
end;
|
||||||
|
flags = {
|
||||||
|
allow_incremental_sync = options.allow_incremental_sync or false;
|
||||||
|
debounce_text_changes = 0;
|
||||||
|
};
|
||||||
on_exit = function(...)
|
on_exit = function(...)
|
||||||
vim.rpcnotify(1, "exit", ...)
|
vim.rpcnotify(1, "exit", ...)
|
||||||
end;
|
end;
|
||||||
|
|||||||
Reference in New Issue
Block a user