aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2025-05-19 07:56:31 +0200
committerGitHub <noreply@github.com>2025-05-19 07:56:31 +0200
commit1d6730459c42f591602500da994f01ae43a97dbc (patch)
treec78417dd383456d2ef8a00600375534d17a9cd45 /tests
parentchore: fix references to williamboman/mason.nvim (#542) (diff)
downloadmason-lspconfig-1d6730459c42f591602500da994f01ae43a97dbc.tar
mason-lspconfig-1d6730459c42f591602500da994f01ae43a97dbc.tar.gz
mason-lspconfig-1d6730459c42f591602500da994f01ae43a97dbc.tar.bz2
mason-lspconfig-1d6730459c42f591602500da994f01ae43a97dbc.tar.lz
mason-lspconfig-1d6730459c42f591602500da994f01ae43a97dbc.tar.xz
mason-lspconfig-1d6730459c42f591602500da994f01ae43a97dbc.tar.zst
mason-lspconfig-1d6730459c42f591602500da994f01ae43a97dbc.zip
perf: host pre-compiled filetype mappings (#555)
Generating the filetype mappings by accessing `vim.lsp.config` turns out to be a bad idea because: 1) performance 2) some `lsp/` configurations in nvim-lspconfig execute code immediately (see angularls) 3) accessing `vim.lsp.config[server_name]` seems to populate `:checkhealth vim.lsp`
Diffstat (limited to 'tests')
-rw-r--r--tests/mason-lspconfig/api/api_spec.lua15
-rw-r--r--tests/mason-lspconfig/api/command_spec.lua4
2 files changed, 14 insertions, 5 deletions
diff --git a/tests/mason-lspconfig/api/api_spec.lua b/tests/mason-lspconfig/api/api_spec.lua
index 53b3a27..e0a189e 100644
--- a/tests/mason-lspconfig/api/api_spec.lua
+++ b/tests/mason-lspconfig/api/api_spec.lua
@@ -1,4 +1,7 @@
+local stub = require "luassert.stub"
+
local _ = require "mason-core.functional"
+local mappings = require "mason-lspconfig.mappings"
local mason_lspconfig = require "mason-lspconfig"
describe("mason-lspconfig API", function()
@@ -16,6 +19,10 @@ describe("mason-lspconfig API", function()
end)
it("should return all available servers for given filetype", function()
+ stub(mappings, "get_filetype_map", {
+ ["dummylang"] = { "dummylsp" },
+ })
+
assert.same(
{ "dummylsp" },
_.sort_by(
@@ -28,11 +35,9 @@ describe("mason-lspconfig API", function()
end)
it("should return all available servers for given filetypes", function()
- vim.lsp.config("dummylsp", {
- filetypes = { "dummylang" },
- })
- vim.lsp.config("dummy2lsp", {
- filetypes = { "madeuplang" },
+ stub(mappings, "get_filetype_map", {
+ ["dummylang"] = { "dummylsp" },
+ ["madeuplang"] = { "dummy2lsp" },
})
assert.same(
{ "dummy2lsp", "dummylsp" },
diff --git a/tests/mason-lspconfig/api/command_spec.lua b/tests/mason-lspconfig/api/command_spec.lua
index 3cd6679..7b39c59 100644
--- a/tests/mason-lspconfig/api/command_spec.lua
+++ b/tests/mason-lspconfig/api/command_spec.lua
@@ -4,6 +4,7 @@ local stub = require "luassert.stub"
local Pkg = require "mason-core.package"
local api = require "mason-lspconfig.api.command"
+local mappings = require "mason-lspconfig.mappings"
local registry = require "mason-registry"
describe(":LspInstall", function()
@@ -23,6 +24,9 @@ describe(":LspInstall", function()
local dummy = registry.get_package "dummy"
spy.on(Pkg, "install")
stub(vim.ui, "select")
+ stub(mappings, "get_filetype_map", {
+ ["dummylang"] = { "dummylsp" },
+ })
vim.ui.select.invokes(function(items, opts, callback)
callback "dummylsp"
end)