forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
25 lines (21 loc) · 808 Bytes
/
server.lua
File metadata and controls
25 lines (21 loc) · 808 Bytes
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
---@class (exact) ServerConfig
---@field type string<'nodejs', 'binary'> Type of the server
---@field custom_server_filepath? string|nil Path to the custom server file
local server = {
---@type ServerConfig
default = {
type = "nodejs",
custom_server_filepath = nil,
},
}
---@param config ServerConfig
function server.validate(config)
vim.validate("type", config.type, function(server_type)
return type(server_type) == "string" and (server_type == "nodejs" or server_type == "binary")
end, false, "nodejs or binary")
vim.validate("custom_server_filepath", config.custom_server_filepath, { "string", "nil" })
if config.custom_server_filepath then
config.custom_server_filepath = vim.fs.normalize(config.custom_server_filepath)
end
end
return server