Skip to content

Commit bf6bc0f

Browse files
committed
feat: bump to copilot.vim 1.6.1
1 parent 51599d4 commit bf6bc0f

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

lua/copilot/client.lua

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ local util = require("copilot.util")
33

44
local M = { params = {} }
55

6-
local register_autocmd = function ()
6+
local copilot_node_version = nil
7+
function M.get_node_version()
8+
if not copilot_node_version then
9+
copilot_node_version = string.match(table.concat(vim.fn.systemlist(M.params.copilot_node_command .. " --version", nil, false)), "v(%S+)")
10+
end
11+
return copilot_node_version
12+
end
13+
14+
local register_autocmd = function()
715
vim.api.nvim_create_autocmd({ "BufEnter" }, {
816
callback = vim.schedule_wrap(M.buf_attach_copilot),
917
})
@@ -35,22 +43,26 @@ M.buf_attach_copilot = function()
3543
M.buf_attach()
3644
end
3745

38-
M.merge_server_opts = function (params)
46+
M.merge_server_opts = function(params)
3947
return vim.tbl_deep_extend("force", {
4048
cmd = {
41-
params.copilot_node_command or "node",
42-
require("copilot.util").get_copilot_path(params.plugin_manager_path)
49+
params.copilot_node_command,
50+
require("copilot.util").get_copilot_path(params.plugin_manager_path),
4351
},
44-
cmd_cwd = vim.fn.expand('~'),
52+
cmd_cwd = vim.fn.expand("~"),
4553
root_dir = vim.loop.cwd(),
4654
name = "copilot",
4755
autostart = true,
4856
single_file_support = true,
4957
on_init = function(client)
50-
---@type copilot_set_editor_info_params
51-
local set_editor_info_params = util.get_editor_info()
52-
set_editor_info_params.editorConfiguration = util.get_editor_configuration()
53-
api.set_editor_info(client, set_editor_info_params)
58+
vim.schedule(function ()
59+
---@type copilot_set_editor_info_params
60+
local set_editor_info_params = util.get_editor_info()
61+
set_editor_info_params.editorInfo.version = set_editor_info_params.editorInfo.version .. ' + Node.js ' .. M.get_node_version()
62+
set_editor_info_params.editorConfiguration = util.get_editor_configuration()
63+
print(vim.inspect(set_editor_info_params))
64+
api.set_editor_info(client, set_editor_info_params)
65+
end)
5466
vim.schedule(M.buf_attach_copilot)
5567
vim.schedule(register_autocmd)
5668
end,
@@ -71,6 +83,10 @@ M.start = function(params)
7183
end
7284
end
7385

86+
if not M.params.copilot_node_command then
87+
M.params.copilot_node_command = "node"
88+
end
89+
7490
vim.lsp.start_client(M.merge_server_opts(params))
7591
end
7692

lua/copilot/util.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function M.get_editor_info()
1515
},
1616
editorPluginInfo = {
1717
name = "copilot.vim",
18-
version = '1.6.0',
18+
version = "1.6.1",
1919
},
2020
}
2121
return info

0 commit comments

Comments
 (0)