Repository: neovim
Issue: LSP: slow diagnostics publish from server after client sends didChange
Labels: bug,performance,needs:repro,lsp

### Problem

### Description

I use sourcekit and xcode build server to swift, the diagnostic is very slowly, but the same lsp server(sourcekit) use vscode is very fast. I feel very obviously between nvim-lspconfig and vscode then the video shows.

**nvim lsp** use sourcekit video **(slowly) (update_in_insert = true)**:

https://github.com/user-attachments/assets/71812718-ee19-4d0d-b64b-85a8dcb907df


**vscode lsp** use sourcekit video **(fast)**:

https://github.com/user-attachments/assets/49ed0375-746c-4f48-b04e-eb1bae29362d



Here is my config:
```
return {
	'neovim/nvim-lspconfig',
	config = function()
		vim.diagnostic.config({
			virtual_text = true,
			signs = true,
			update_in_insert = true,
			underline = true,
			severity_sort = false,
			float = true,
		})

		local capabilities = require('cmp_nvim_lsp').default_capabilities()
		local lspconfig = require('lspconfig');

                --...
                -- other language confg
                -- ...

		lspconfig.sourcekit.setup {
			capabilities = capabilities,
			cmd = {
				"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp",
			},
			root_dir = function(filename, _)
				local util = require("lspconfig.util")
				return util.root_pattern("buildServer.json")(filename)
						or util.root_pattern("*.xcodeproj", "*.xcworkspace")(filename)
						or util.find_git_ancestor(filename)
						or util.root_pattern("Package.swift")(filename)
			end,
		}

		local util = require('lspconfig/util')

		local path = util.path

		local function get_python_path(workspace)
			-- Use activated virtualenv.
			if vim.env.VIRTUAL_ENV then
				return path.join(vim.env.VIRTUAL_ENV, 'bin', 'python')
			end

			-- Find and use virtualenv in workspace directory.
			for _, pattern in ipairs({ '*', '.*' }) do
				local match = vim.fn.glob(path.join(workspace, pattern, 'pyvenv.cfg'))
				if match ~= '' then
					return path.join(path.dirname(match), 'bin', 'python')
				end
			end

			-- Fallback to system Python.
			return vim.fn.exepath('python3') or vim.fn.exepath('python') or 'python'
		end

		lspconfig.pyright.setup({
			-- -- ...
			-- before_init = function(_, config)
			--   config.settings.python.pythonPath = get_python_path(config.root_dir)
			-- end,
			on_init = function(client)
				local p = get_python_path(client.config.root_dir)

				print(p)
				client.config.settings.python.pythonPath = get_python_path(client.config.root_dir)
			end
		})

		lspconfig.rust_analyzer.setup {}
	end
}
```

Here is my nvim-lspconfig log(:LspLog) :
![Image](https://github.com/user-attachments/assets/278682e7-1ced-4ddd-9d28-2495149d06fa)

The nvim-lsp log shows, the last "didChange" time is 59:22, but "publishDiagnostic"(empty msg) is 59:24, after 2 seconds ...

But the vscode lsp logs, show the last "didChange" and the "publishDiagnostic empty msg(clear)" at the same second.

Buy the way I tried to close other plugins such as cmp as the logs show ..., only left lspconfg, but is slowly nether.

Full logs:

[nvim_lsp_swift_log.txt](https://github.com/user-attachments/files/18309190/nvim_lsp_swift_log.txt)



### Steps to reproduce using "nvim -u minimal_init.lua"

as the configs show.

### Expected behavior

_No response_

### Nvim version (nvim -v)

0.10

### Language server name/version

current

### Operating system/version

macos 15

### Log file

_No response_