aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/_completion.lua
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-01-22 18:23:28 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-02-03 16:53:41 +0100
commit2e982f1aad9f1a03562b7a451d642f76b04c37cb (patch)
tree7f689e027d93092a6a1c5f783ff0e4909b2ecb9d /runtime/lua/vim/lsp/_completion.lua
parent51702e0aea99fddba74e299e2640dd350a348df3 (diff)
downloadrneovim-2e982f1aad9f1a03562b7a451d642f76b04c37cb.tar.gz
rneovim-2e982f1aad9f1a03562b7a451d642f76b04c37cb.tar.bz2
rneovim-2e982f1aad9f1a03562b7a451d642f76b04c37cb.zip
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.
Diffstat (limited to 'runtime/lua/vim/lsp/_completion.lua')
-rw-r--r--runtime/lua/vim/lsp/_completion.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/_completion.lua b/runtime/lua/vim/lsp/_completion.lua
index 7a607d6c13..84dbf9083e 100644
--- a/runtime/lua/vim/lsp/_completion.lua
+++ b/runtime/lua/vim/lsp/_completion.lua
@@ -8,7 +8,7 @@ local ms = protocol.Methods
---@return string parsed snippet
local function parse_snippet(input)
local ok, parsed = pcall(function()
- return require('vim.lsp._snippet_grammar').parse(input)
+ return vim.lsp._snippet_grammar.parse(input)
end)
return ok and tostring(parsed) or input
end
@@ -206,7 +206,7 @@ function M.omnifunc(findstart, base)
local params = util.make_position_params(win, client.offset_encoding)
client.request(ms.textDocument_completion, params, function(err, result)
if err then
- require('vim.lsp.log').warn(err.message)
+ vim.lsp.log.warn(err.message)
end
if result and vim.fn.mode() == 'i' then
local matches