Skip to content

Commit

Permalink
perf: lazy-require some modules during config (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtomjhj authored Apr 6, 2024
1 parent 7d4fa27 commit 1505b7a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lua/mason-lspconfig/server_configurations/astro/init.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local typescript = require "mason-lspconfig.typescript"

---@param install_dir string
return function(install_dir)
return {
on_new_config = function(new_config, workspace_dir)
local typescript = require "mason-lspconfig.typescript"

new_config.init_options.typescript.serverPath = typescript.resolve_tsserver(install_dir, workspace_dir)
new_config.init_options.typescript.tsdk = typescript.resolve_tsdk(install_dir, workspace_dir)
end,
Expand Down
9 changes: 5 additions & 4 deletions lua/mason-lspconfig/server_configurations/pylsp/init.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
local _ = require "mason-core.functional"
local a = require "mason-core.async"
local notify = require "mason-lspconfig.notify"
local pip3 = require "mason-core.managers.pip3"
local process = require "mason-core.process"
local spawn = require "mason-core.spawn"

---@param install_dir string
return function(install_dir)
vim.api.nvim_create_user_command(
"PylspInstall",
a.scope(function(opts)
local notify = require "mason-lspconfig.notify"
local pip3 = require "mason-core.managers.pip3"
local process = require "mason-core.process"
local spawn = require "mason-core.spawn"

local plugins = opts.fargs
local plugins_str = table.concat(plugins, ", ")
notify(("Installing %s..."):format(plugins_str))
Expand Down
4 changes: 2 additions & 2 deletions lua/mason-lspconfig/server_configurations/volar/init.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local typescript = require "mason-lspconfig.typescript"

---@param install_dir string
return function(install_dir)
return {
on_new_config = function(new_config, workspace_dir)
local typescript = require "mason-lspconfig.typescript"

local tsdk = typescript.resolve_tsdk(install_dir, workspace_dir)
new_config.init_options.typescript.serverPath = tsdk
new_config.init_options.typescript.tsdk = tsdk
Expand Down

0 comments on commit 1505b7a

Please sign in to comment.