mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
refactor: create function for deferred loading
The benefit of this is that users only pay for what they use. If e.g.
only `vim.lsp.buf_get_clients()` is called then they don't need to load
all modules under `vim.lsp` which could lead to significant startuptime
saving.
Also `vim.lsp.module` is a bit nicer to user compared to
`require("vim.lsp.module")`.
This isn't used for some nested modules such as `filetype` as it breaks
tests with error messages such as "attempt to index field 'detect'".
It's not entirely certain the reason for this, but it is likely it is
due to filetype being precompiled which would imply deferred loading
isn't needed for performance reasons.
This commit is contained in:
@@ -120,7 +120,7 @@ M[ms.client_registerCapability] = function(_, result, ctx)
|
||||
local unsupported = {}
|
||||
for _, reg in ipairs(result.registrations) do
|
||||
if reg.method == ms.workspace_didChangeWatchedFiles then
|
||||
require('vim.lsp._watchfiles').register(reg, ctx)
|
||||
vim.lsp._watchfiles.register(reg, ctx)
|
||||
elseif not client.dynamic_capabilities:supports_registration(reg.method) then
|
||||
unsupported[#unsupported + 1] = reg.method
|
||||
end
|
||||
@@ -144,7 +144,7 @@ M[ms.client_unregisterCapability] = function(_, result, ctx)
|
||||
|
||||
for _, unreg in ipairs(result.unregisterations) do
|
||||
if unreg.method == ms.workspace_didChangeWatchedFiles then
|
||||
require('vim.lsp._watchfiles').unregister(unreg, ctx)
|
||||
vim.lsp._watchfiles.unregister(unreg, ctx)
|
||||
end
|
||||
end
|
||||
return vim.NIL
|
||||
@@ -223,19 +223,19 @@ M[ms.workspace_workspaceFolders] = function(_, _, ctx)
|
||||
end
|
||||
|
||||
M[ms.textDocument_publishDiagnostics] = function(...)
|
||||
return require('vim.lsp.diagnostic').on_publish_diagnostics(...)
|
||||
return vim.lsp.diagnostic.on_publish_diagnostics(...)
|
||||
end
|
||||
|
||||
M[ms.textDocument_diagnostic] = function(...)
|
||||
return require('vim.lsp.diagnostic').on_diagnostic(...)
|
||||
return vim.lsp.diagnostic.on_diagnostic(...)
|
||||
end
|
||||
|
||||
M[ms.textDocument_codeLens] = function(...)
|
||||
return require('vim.lsp.codelens').on_codelens(...)
|
||||
return vim.lsp.codelens.on_codelens(...)
|
||||
end
|
||||
|
||||
M[ms.textDocument_inlayHint] = function(...)
|
||||
return require('vim.lsp.inlay_hint').on_inlayhint(...)
|
||||
return vim.lsp.inlay_hint.on_inlayhint(...)
|
||||
end
|
||||
|
||||
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
|
||||
@@ -643,7 +643,7 @@ end
|
||||
|
||||
---@see https://microsoft.github.io/language-server-protocol/specification/#workspace_inlayHint_refresh
|
||||
M[ms.workspace_inlayHint_refresh] = function(err, result, ctx, config)
|
||||
return require('vim.lsp.inlay_hint').on_refresh(err, result, ctx, config)
|
||||
return vim.lsp.inlay_hint.on_refresh(err, result, ctx, config)
|
||||
end
|
||||
|
||||
-- Add boilerplate error validation and logging for all of these.
|
||||
|
||||
Reference in New Issue
Block a user