1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
local util = require "lspconfig.util"
local a = require "nvim-lsp-installer.core.async"
local servers = require "nvim-lsp-installer.servers"
local middleware = require "nvim-lsp-installer.middleware"
describe("middleware", function()
local server
before_each(function()
-- 1. setup dummy server
local default_options = {
cmd = { "dummy-lsp" },
cmd_env = { PATH = "/keep/my/path/out/your/f/mouth" },
}
server = ServerGenerator {
default_options = default_options,
}
servers.register(server)
-- 2. register hook
middleware.register_lspconfig_hook()
end)
after_each(function()
-- reset hook
util.on_setup = nil
end)
it(
"should apply config changes to installed servers",
async_test(function()
server:install()
assert.wait_for(function()
assert.is_true(server:is_installed())
end)
local config = {
name = "dummy",
cmd = { "should", "be", "overwritten" },
custom = "setting",
cmd_env = { SOME_DEFAULT_ENV = "important" },
}
util.on_setup(config)
assert.are.same({
cmd = { "dummy-lsp" },
name = "dummy",
custom = "setting",
cmd_env = {
PATH = "/keep/my/path/out/your/f/mouth",
SOME_DEFAULT_ENV = "important",
},
}, config)
end)
)
it(
"should not apply config changes to uninstalled servers",
async_test(function()
local config = {
name = "uninstalled_dummy",
cmd = { "should", "not", "be", "overwritten" },
custom = "setting",
cmd_env = { SOME_DEFAULT_ENV = "important" },
}
util.on_setup(config)
assert.are.same({
name = "uninstalled_dummy",
cmd = { "should", "not", "be", "overwritten" },
custom = "setting",
cmd_env = { SOME_DEFAULT_ENV = "important" },
}, config)
end)
)
end)
|