diff options
| author | William Boman <william@redwill.se> | 2023-03-18 16:20:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-18 16:20:52 +0100 |
| commit | 2b811031febe5f743e07305738181ff367e1e452 (patch) | |
| tree | 5f2ca0cbaa515c256e6bcf40a925120d42360b41 /tests | |
| parent | chore: update generated code (#174) (diff) | |
| download | mason-lspconfig-2b811031febe5f743e07305738181ff367e1e452.tar mason-lspconfig-2b811031febe5f743e07305738181ff367e1e452.tar.gz mason-lspconfig-2b811031febe5f743e07305738181ff367e1e452.tar.bz2 mason-lspconfig-2b811031febe5f743e07305738181ff367e1e452.tar.lz mason-lspconfig-2b811031febe5f743e07305738181ff367e1e452.tar.xz mason-lspconfig-2b811031febe5f743e07305738181ff367e1e452.tar.zst mason-lspconfig-2b811031febe5f743e07305738181ff367e1e452.zip | |
fix: don't auto install servers when headless (#175)
You should be able to run headless commands without mason-lspconfig starting installations in the background with
limited ability to wait until they're done.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mason-lspconfig/setup_spec.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/mason-lspconfig/setup_spec.lua b/tests/mason-lspconfig/setup_spec.lua index 1441c4f..e1fab26 100644 --- a/tests/mason-lspconfig/setup_spec.lua +++ b/tests/mason-lspconfig/setup_spec.lua @@ -5,6 +5,7 @@ local stub = require "luassert.stub" local Pkg = require "mason-core.package" local filetype_mappings = require "mason-lspconfig.mappings.filetype" local mason_lspconfig = require "mason-lspconfig" +local platform = require "mason-core.platform" local registry = require "mason-registry" local server_mappings = require "mason-lspconfig.mappings.server" @@ -51,6 +52,7 @@ describe("mason-lspconfig setup", function() local fail_dummy = registry.get_package "fail_dummy" spy.on(Pkg, "install") + platform.is_headless = false mason_lspconfig.setup { ensure_installed = { "dummylsp@1.0.0", "fail_dummylsp" } } assert.spy(Pkg.install).was_called(2) @@ -64,10 +66,23 @@ describe("mason-lspconfig setup", function() ) it( + "should not install servers listed in ensure_installed when headless", + async_test(function() + spy.on(Pkg, "install") + + platform.is_headless = true + mason_lspconfig.setup { ensure_installed = { "dummylsp@1.0.0", "fail_dummylsp" } } + + assert.spy(Pkg.install).was_called(0) + end) + ) + + it( "should notify when installing servers listed in ensure_installed", async_test(function() spy.on(vim, "notify") + platform.is_headless = false mason_lspconfig.setup { ensure_installed = { "dummylsp", "fail_dummylsp" } } assert @@ -100,6 +115,7 @@ describe("mason-lspconfig setup", function() spy.on(Pkg, "install") spy.on(vim, "notify") + platform.is_headless = false mason_lspconfig.setup { automatic_installation = true } local lspconfig = require "lspconfig" lspconfig.dummylsp.setup {} @@ -139,6 +155,7 @@ describe("mason-lspconfig setup", function() local dummy2 = registry.get_package "dummy2" spy.on(Pkg, "install") + platform.is_headless = false mason_lspconfig.setup { automatic_installation = true } local lspconfig = require "lspconfig" spy.on(lspconfig.dummylsp, "setup") @@ -159,6 +176,23 @@ describe("mason-lspconfig setup", function() end) ) + it( + "should not automatically install servers when headless", + async_test(function() + spy.on(Pkg, "install") + + platform.is_headless = true + mason_lspconfig.setup { automatic_installation = true } + local lspconfig = require "lspconfig" + spy.on(lspconfig.dummylsp, "setup") + spy.on(lspconfig.dummy2lsp, "setup") + lspconfig.dummylsp.setup {} + lspconfig.dummy2lsp.setup {} + + assert.spy(Pkg.install).was_called(0) + end) + ) + it("should apply mason-lspconfig server configs", function() stub(registry, "is_installed") registry.is_installed.on_call_with("dummy").returns(true) @@ -247,6 +281,7 @@ describe("mason-lspconfig setup_handlers", function() it("should print warning when providing invalid server entries in ensure_installed", function() spy.on(vim, "notify") + platform.is_headless = false mason_lspconfig.setup { ensure_installed = { "yamllint", "hadolint" }, } |
