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:
dundargoc
2024-01-22 18:23:28 +01:00
committed by dundargoc
parent 51702e0aea
commit 2e982f1aad
23 changed files with 119 additions and 117 deletions

View File

@@ -3,7 +3,7 @@ local snippet = require('vim.lsp._snippet_grammar')
local validate = vim.validate
local api = vim.api
local list_extend = vim.list_extend
local highlight = require('vim.highlight')
local highlight = vim.highlight
local uv = vim.uv
local npcall = vim.F.npcall
@@ -636,7 +636,7 @@ end
---@see complete-items
function M.text_document_completion_list_to_complete_items(result, prefix)
vim.deprecate('vim.lsp.util.text_document_completion_list_to_complete_items()', nil, '0.11')
return require('vim.lsp._completion')._lsp_to_complete_items(result, prefix)
return vim.lsp._completion._lsp_to_complete_items(result, prefix)
end
--- Like vim.fn.bufwinid except it works across tabpages.