@@ -8,7 +8,7 @@ local logger = require("copilot.logger")
8
8
--- @field filetypes table<string , boolean> Filetypes to enable Copilot for
9
9
--- @field auth_provider_url string | nil URL for the authentication provider
10
10
--- @field workspace_folders string[] Workspace folders to enable Copilot for
11
- --- @field server_opts_overrides table<string , any> Options to override for the server
11
+ --- @field server_opts_overrides ? table<string , any> Options to override for the server
12
12
--- @field copilot_model string | nil Model to use for Copilot , LSP server dictates the default
13
13
--- @field root_dir RootDirFuncOrString Root directory for the project , defaults to the nearest .git directory
14
14
--- @field should_attach ShouldAttachFunc Function to determine if Copilot should attach to the buffer
@@ -32,6 +32,7 @@ local M = {
32
32
copilot_node_command = " node" ,
33
33
}
34
34
35
+ --- @param user_configs CopilotConfig
35
36
function M .merge_with_user_configs (user_configs )
36
37
logger .trace (" setting up configuration, opts" , user_configs )
37
38
@@ -45,11 +46,32 @@ function M.merge_with_user_configs(user_configs)
45
46
M [k ] = v
46
47
end
47
48
48
- if M .server .custom_server_filepath then
49
- M .server .custom_server_filepath = vim .fs .normalize (M .server .custom_server_filepath )
50
- end
49
+ M .validate (M )
51
50
52
51
initialized = true
53
52
end
54
53
54
+ --- @param config CopilotConfig
55
+ function M .validate (config )
56
+ vim .validate (" panel" , config .panel , " table" )
57
+ vim .validate (" suggestion" , config .suggestion , " table" )
58
+ vim .validate (" logger" , config .logger , " table" )
59
+ vim .validate (" server" , config .server , " table" )
60
+ vim .validate (" filetypes" , config .filetypes , " table" )
61
+ vim .validate (" auth_provider_url" , config .auth_provider_url , { " string" , " nil" })
62
+ vim .validate (" workspace_folders" , config .workspace_folders , " table" )
63
+ vim .validate (" server_opts_overrides" , config .server_opts_overrides , " table" , true )
64
+ vim .validate (" copilot_model" , config .copilot_model , { " string" , " nil" })
65
+ vim .validate (" root_dir" , config .root_dir , { " string" , " function" })
66
+ vim .validate (" should_attach" , config .should_attach , " function" )
67
+ vim .validate (" copilot_node_command" , config .copilot_node_command , " string" )
68
+
69
+ require (" copilot.config.panel" ).validate (config .panel )
70
+ require (" copilot.config.suggestion" ).validate (config .suggestion )
71
+ require (" copilot.config.logger" ).validate (config .logger )
72
+ require (" copilot.config.server" ).validate (config .server )
73
+ require (" copilot.config.root_dir" ).validate (config .root_dir )
74
+ require (" copilot.config.should_attach" ).validate (config .should_attach )
75
+ end
76
+
55
77
return M
0 commit comments