1
1
local config = require (" copilot.config" )
2
2
local logger = require (" copilot.logger" )
3
- local unpack = unpack or table.unpack
4
3
5
4
local M = {}
6
5
@@ -186,8 +185,8 @@ M.get_completion_params = function(opts)
186
185
return M .get_doc_params (opts )
187
186
end
188
187
189
- --- @return copilot_editor_configuration
190
- function M .get_editor_configuration ()
188
+ --- @return copilot_workspace_configurations
189
+ function M .get_workspace_configurations ()
191
190
local conf = config .get () --[[ @as copilot_config]]
192
191
193
192
local filetypes = vim .deepcopy (conf .filetypes ) --[[ @as table<string, boolean>]]
@@ -205,77 +204,17 @@ function M.get_editor_configuration()
205
204
table.sort (disabled_filetypes )
206
205
207
206
return {
208
- github = {
209
- copilot = {
210
- selectedCompletionModel = copilot_model ,
207
+ settings = {
208
+ github = {
209
+ copilot = {
210
+ selectedCompletionModel = copilot_model ,
211
+ },
211
212
},
213
+ enableAutoCompletions = not not (conf .panel .enabled or conf .suggestion .enabled ),
214
+ disabledLanguages = vim .tbl_map (function (ft )
215
+ return { languageId = ft }
216
+ end , disabled_filetypes ),
212
217
},
213
- enableAutoCompletions = not not (conf .panel .enabled or conf .suggestion .enabled ),
214
- disabledLanguages = vim .tbl_map (function (ft )
215
- return { languageId = ft }
216
- end , disabled_filetypes ),
217
- }
218
- end
219
-
220
- --- @param str string
221
- local function url_decode (str )
222
- return vim .fn .substitute (str , [[ %\(\x\x\)]] , [[ \=iconv(nr2char("0x".submatch(1)), "utf-8", "latin1")]] , " g" )
223
- end
224
-
225
- --- @return copilot_network_proxy | nil
226
- function M .get_network_proxy ()
227
- local proxy_uri = vim .g .copilot_proxy
228
-
229
- if type (proxy_uri ) ~= " string" then
230
- return
231
- end
232
-
233
- proxy_uri = string.gsub (proxy_uri , " ^[^:]+://" , " " )
234
-
235
- --- @type string | nil , string | nil
236
- local user_pass , host_port = unpack (vim .split (proxy_uri , " @" , { plain = true , trimempty = true }))
237
-
238
- if not host_port then
239
- host_port = user_pass --[[ @as string]]
240
- user_pass = nil
241
- end
242
-
243
- local query_string
244
- host_port , query_string = unpack (vim .split (host_port , " ?" , { plain = true , trimempty = true }))
245
-
246
- local rejectUnauthorized = vim .g .copilot_proxy_strict_ssl
247
-
248
- if query_string then
249
- local query_params = vim .split (query_string , " &" , { plain = true , trimempty = true })
250
- for _ , query_param in ipairs (query_params ) do
251
- local strict_ssl = string.match (query_param , " strict_?ssl=(.*)" )
252
-
253
- if string.find (strict_ssl , " ^[1t]" ) then
254
- rejectUnauthorized = true
255
- break
256
- end
257
-
258
- if string.find (strict_ssl , " ^[0f]" ) then
259
- rejectUnauthorized = false
260
- break
261
- end
262
- end
263
- end
264
-
265
- local host , port = unpack (vim .split (host_port , " :" , { plain = true , trimempty = true }))
266
- local username , password
267
-
268
- if user_pass then
269
- username , password = unpack (vim .split (user_pass , " :" , { plain = true , trimempty = true }))
270
- username , password = username and url_decode (username ), password and url_decode (password )
271
- end
272
-
273
- return {
274
- host = host ,
275
- port = tonumber (port or 80 ),
276
- username = username ,
277
- password = password ,
278
- rejectUnauthorized = rejectUnauthorized ,
279
218
}
280
219
end
281
220
0 commit comments