aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig.lua6
-rw-r--r--lua/lspconfig/util.lua5
2 files changed, 10 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
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index dc06f181..5c45a78c 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -74,6 +74,11 @@ function M.has_bins(...)
return true
end
+M.script_path = function()
+ local str = debug.getinfo(2, "S").source:sub(2)
+ return str:match("(.*/)")
+end
+
-- Some path utilities
M.path = (function()
local function exists(filename)