aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-04-21 20:54:37 -0700
committerMichael Lingelbach <m.j.lbach@gmail.com>2021-04-23 00:57:36 -0700
commit04f223f3d08388eac74a571516145154bf5af64c (patch)
treee63d5848e642f2d29dc4bd2e695f0ad25763cb8c /lua/lspconfig.lua
parentMerge pull request #859 from mjlbach/lazy_require_lspinfo (diff)
downloadnvim-lspconfig-04f223f3d08388eac74a571516145154bf5af64c.tar
nvim-lspconfig-04f223f3d08388eac74a571516145154bf5af64c.tar.gz
nvim-lspconfig-04f223f3d08388eac74a571516145154bf5af64c.tar.bz2
nvim-lspconfig-04f223f3d08388eac74a571516145154bf5af64c.tar.lz
nvim-lspconfig-04f223f3d08388eac74a571516145154bf5af64c.tar.xz
nvim-lspconfig-04f223f3d08388eac74a571516145154bf5af64c.tar.zst
nvim-lspconfig-04f223f3d08388eac74a571516145154bf5af64c.zip
Use dofile instead of require for faster setup({})
* closes #239 * For 76 language servers, this decreases time to invoke setup({}) from ~126 ms to ~1ms
Diffstat (limited to 'lua/lspconfig.lua')
-rw-r--r--lua/lspconfig.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua
index 7a6fb080..1023167b 100644
--- a/lua/lspconfig.lua
+++ b/lua/lspconfig.lua
@@ -4,6 +4,8 @@ local M = {
util = require 'lspconfig/util';
}
+local script_path = M.util.script_path()
+
M._root = {}
function M.available_servers()
@@ -84,7 +86,9 @@ end
local mt = {}
function mt:__index(k)
if configs[k] == nil then
- pcall(require, 'lspconfig/'..k)
+ -- dofile is used here as a performance hack to increase the speed of calls to setup({})
+ -- dofile does not cache module lookups, and requires the absolute path to the target file
+ dofile(script_path .. 'lspconfig/' .. k .. ".lua")
end
return configs[k]
end