neovim/runtime/autoload/provider/ruby.vim
dundargoc 2e982f1aad 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.
2024-02-03 16:53:41 +01:00

17 lines
494 B
VimL

if exists('g:loaded_ruby_provider')
finish
endif
function! provider#ruby#Require(host) abort
return v:lua.vim.provider.ruby.require(a:host)
endfunction
function! provider#ruby#Call(method, args) abort
return v:lua.vim.provider.ruby.call(a:method, a:args)
endfunction
let s:prog = v:lua.vim.provider.ruby.detect()
let g:loaded_ruby_provider = empty(s:prog) ? 1 : 2
let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb'
call v:lua.require'vim.provider.ruby'.start(s:plugin_path)