diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-05-01 11:11:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-01 11:11:19 -0700 |
| commit | 6e48e492432b241652ab0bb5d6a2acf89f5bda55 (patch) | |
| tree | 726164bd042ed4851d4f32811ac0b5a810f7802d /lua | |
| parent | Merge pull request #864 from nanotee/zeta_note (diff) | |
| parent | Use dofile instead of require for faster setup({}) (diff) | |
| download | nvim-lspconfig-6e48e492432b241652ab0bb5d6a2acf89f5bda55.tar nvim-lspconfig-6e48e492432b241652ab0bb5d6a2acf89f5bda55.tar.gz nvim-lspconfig-6e48e492432b241652ab0bb5d6a2acf89f5bda55.tar.bz2 nvim-lspconfig-6e48e492432b241652ab0bb5d6a2acf89f5bda55.tar.lz nvim-lspconfig-6e48e492432b241652ab0bb5d6a2acf89f5bda55.tar.xz nvim-lspconfig-6e48e492432b241652ab0bb5d6a2acf89f5bda55.tar.zst nvim-lspconfig-6e48e492432b241652ab0bb5d6a2acf89f5bda55.zip | |
Merge pull request #861 from mjlbach/dofile
Use dofile instead of require for faster loading
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig.lua | 6 | ||||
| -rw-r--r-- | lua/lspconfig/util.lua | 5 |
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) |
