@@ -8,7 +8,7 @@ local logger = require("copilot.logger")
88--- @field filetypes table<string , boolean> Filetypes to enable Copilot for
99--- @field auth_provider_url string | nil URL for the authentication provider
1010--- @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
1212--- @field copilot_model string | nil Model to use for Copilot , LSP server dictates the default
1313--- @field root_dir RootDirFuncOrString Root directory for the project , defaults to the nearest .git directory
1414--- @field should_attach ShouldAttachFunc Function to determine if Copilot should attach to the buffer
@@ -32,6 +32,7 @@ local M = {
3232 copilot_node_command = " node" ,
3333}
3434
35+ --- @param user_configs CopilotConfig
3536function M .merge_with_user_configs (user_configs )
3637 logger .trace (" setting up configuration, opts" , user_configs )
3738
@@ -45,11 +46,32 @@ function M.merge_with_user_configs(user_configs)
4546 M [k ] = v
4647 end
4748
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 )
5150
5251 initialized = true
5352end
5453
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+
5577return M
0 commit comments