diff options
author | dundargoc <gocdundar@gmail.com> | 2024-01-22 18:23:28 +0100 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-02-03 16:53:41 +0100 |
commit | 2e982f1aad9f1a03562b7a451d642f76b04c37cb (patch) | |
tree | 7f689e027d93092a6a1c5f783ff0e4909b2ecb9d /runtime/lua/provider | |
parent | 51702e0aea99fddba74e299e2640dd350a348df3 (diff) | |
download | rneovim-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/provider')
-rw-r--r-- | runtime/lua/provider/perl/health.lua | 2 | ||||
-rw-r--r-- | runtime/lua/provider/python/health.lua | 4 | ||||
-rw-r--r-- | runtime/lua/provider/ruby/health.lua | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/runtime/lua/provider/perl/health.lua b/runtime/lua/provider/perl/health.lua index 6066c69968..535093d793 100644 --- a/runtime/lua/provider/perl/health.lua +++ b/runtime/lua/provider/perl/health.lua @@ -9,7 +9,7 @@ function M.check() return end - local perl_exec, perl_warnings = require('vim.provider.perl').detect() + local perl_exec, perl_warnings = vim.provider.perl.detect() if not perl_exec then health.warn(assert(perl_warnings), { diff --git a/runtime/lua/provider/python/health.lua b/runtime/lua/provider/python/health.lua index 8f77f1d4ba..333890b62b 100644 --- a/runtime/lua/provider/python/health.lua +++ b/runtime/lua/provider/python/health.lua @@ -238,7 +238,7 @@ function M.check() end local pythonx_warnings - pyname, pythonx_warnings = require('vim.provider.python').detect_by_module('neovim') + pyname, pythonx_warnings = vim.provider.python.detect_by_module('neovim') if not pyname then health.warn( @@ -363,7 +363,7 @@ function M.check() -- can import 'pynvim'. If so, that Python failed to import 'neovim' as -- well, which is most probably due to a failed pip upgrade: -- https://github.com/neovim/neovim/wiki/Following-HEAD#20181118 - local pynvim_exe = require('vim.provider.python').detect_by_module('pynvim') + local pynvim_exe = vim.provider.python.detect_by_module('pynvim') if pynvim_exe then local message = 'Detected pip upgrade failure: Python executable can import "pynvim" but not "neovim": ' .. pynvim_exe diff --git a/runtime/lua/provider/ruby/health.lua b/runtime/lua/provider/ruby/health.lua index d43d7cf9b3..04f6e303e6 100644 --- a/runtime/lua/provider/ruby/health.lua +++ b/runtime/lua/provider/ruby/health.lua @@ -20,7 +20,7 @@ function M.check() end health.info('Ruby: ' .. health.system({ 'ruby', '-v' })) - local ruby_detect_table = require('vim.provider.ruby').detect() + local ruby_detect_table = vim.provider.ruby.detect() local host = ruby_detect_table[1] if (not host) or host:find('^%s*$') then health.warn('`neovim-ruby-host` not found.', { |