Skip to content

Commit 81eb5d1

Browse files
committed
feat: bump to copilot.vim 1.8.0
1 parent 79e560c commit 81eb5d1

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

lua/copilot/api.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ end
3030

3131
---@alias copilot_editor_info { name: string, version: string }
3232
---@alias copilot_editor_plugin_info { name: string, version: string }
33-
---@alias copilot_network_proxy { host: string, port: integer, username?: string, password?: string }
33+
---@alias copilot_network_proxy { host: string, port: integer, username?: string, password?: string, rejectUnauthorized?: boolean }
3434
---@alias copilot_set_editor_info_params { editorInfo: copilot_editor_info, editorPluginInfo: copilot_editor_plugin_info, editorConfiguration: copilot_editor_configuration, networkProxy?: copilot_network_proxy }
3535

3636
---@param params copilot_set_editor_info_params

lua/copilot/util.lua

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function M.get_editor_info()
1919
},
2020
editorPluginInfo = {
2121
name = "copilot.vim",
22-
version = "1.7.0",
22+
version = "1.8.0",
2323
},
2424
}
2525
return info
@@ -124,12 +124,6 @@ function M.is_attached(client)
124124
return client and vim.lsp.buf_is_attached(0, client.id) or false
125125
end
126126

127-
local eol_by_fileformat = {
128-
unix = "\n",
129-
dos = "\r\n",
130-
mac = "\r",
131-
}
132-
133127
local language_normalization_map = {
134128
bash = "shellscript",
135129
bst = "bibtex",
@@ -179,12 +173,6 @@ function M.get_doc()
179173
position = params.position,
180174
}
181175

182-
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
183-
if vim.bo.endofline and vim.bo.fixendofline then
184-
table.insert(lines, "")
185-
end
186-
doc.source = table.concat(lines, eol_by_fileformat[vim.bo.fileformat] or "\n")
187-
188176
return doc
189177
end
190178

@@ -255,6 +243,28 @@ function M.get_network_proxy()
255243
user_pass = nil
256244
end
257245

246+
local query_string
247+
host_port, query_string = unpack(vim.split(host_port, "?", { plain=true, trimempty=true }))
248+
249+
local rejectUnauthorized = vim.g.copilot_proxy_strict_ssl
250+
251+
if query_string then
252+
local query_params = vim.split(query_string, '&', { plain = true, trimempty = true })
253+
for _, query_param in ipairs(query_params) do
254+
local strict_ssl = string.match(query_param, 'strict_?ssl=(.*)')
255+
256+
if string.find(strict_ssl, '^[1t]') then
257+
rejectUnauthorized = true
258+
break
259+
end
260+
261+
if string.find(strict_ssl, '^[0f]') then
262+
rejectUnauthorized = false
263+
break
264+
end
265+
end
266+
end
267+
258268
local host, port = unpack(vim.split(host_port, ":", { plain = true, trimempty = true }))
259269
local username, password
260270

@@ -268,6 +278,7 @@ function M.get_network_proxy()
268278
port = tonumber(port or 80),
269279
username = username,
270280
password = password,
281+
rejectUnauthorized = rejectUnauthorized,
271282
}
272283
end
273284

0 commit comments

Comments
 (0)