forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
78 lines (64 loc) · 1.71 KB
/
init.lua
File metadata and controls
78 lines (64 loc) · 1.71 KB
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
73
74
75
76
77
78
local logger = require("copilot.logger")
local M = {
binary = require("copilot.lsp.binary"),
nodejs = require("copilot.lsp.nodejs"),
---@type ServerConfig
config = nil,
}
---@return boolean
function M.initialization_failed()
if M.config.type == "nodejs" then
return M.nodejs.initialization_failed
elseif M.config.type == "binary" then
return M.binary.initialization_failed
end
return true
end
---@return boolean
function M.init()
if M.config.type == "nodejs" then
return M.nodejs.init()
elseif M.config.type == "binary" then
return M.binary.init()
end
return false
end
---@param client vim.lsp.Client|nil
---@return string
function M.get_server_info(client)
if M.config.type == "nodejs" then
return M.nodejs.get_server_info(client)
elseif M.config.type == "binary" then
return M.binary.get_server_info(client)
end
return ""
end
---@return table
function M.get_execute_command()
if M.config.type == "nodejs" then
return M.nodejs.get_execute_command()
elseif M.config.type == "binary" then
return M.binary.get_execute_command()
end
return {}
end
---@param server_config ServerConfig
---@param copilot_node_command string
---@return boolean
function M.setup(server_config, copilot_node_command)
local result = true
if not server_config then
logger.error("server_config is required")
end
if server_config.type == "nodejs" then
result = M.nodejs.setup(copilot_node_command, server_config.custom_server_filepath)
elseif server_config.type == "binary" then
M.binary.setup(server_config.custom_server_filepath)
else
logger.error("invalid server_config.type")
result = false
end
M.config = server_config
return result
end
return M