Skip to content

Commit 1898423

Browse files
authored
feat(api): add set_editor_info (zbirenbaum#55)
1 parent 2202f7a commit 1898423

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

lua/copilot/api.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ function mod.notify(client, method, params)
2828
return client.notify(method, params)
2929
end
3030

31+
---@alias copilot_set_editor_info_params { editorInfo: { name: string, version: string }, editorPluginInfo: { name: string, version: string } }
32+
33+
---@param params copilot_set_editor_info_params
34+
function mod.set_editor_info(client, params)
35+
return mod.notify(client, "setEditorInfo", params)
36+
end
37+
3138
---@alias copilot_check_status_data { user?: string }
3239

3340
---@return any|nil err

lua/copilot/client.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ M.merge_server_opts = function (params)
3232
name = "copilot",
3333
autostart = true,
3434
single_file_support = true,
35-
on_init = function(client, initialize_result)
36-
local notify = client.rpc.notify
37-
notify('setEditorInfo', util.get_editor_info())
35+
on_init = function(client)
36+
api.set_editor_info(client, util.get_editor_info())
3837
vim.schedule(M.buf_attach_copilot)
3938
vim.schedule(register_autocmd)
4039
end,

lua/copilot/util.lua

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ function M.get_next_id()
66
return id
77
end
88

9-
-- keep for debugging reasons
10-
M.get_editor_info = function ()
11-
local info = vim.empty_dict()
12-
info.editorInfo = vim.empty_dict()
13-
info.editorInfo.name = 'Neovim'
14-
info.editorInfo.version = '0.8.0-dev-809-g7dde6d4fd'
15-
info.editorPluginInfo = vim.empty_dict()
16-
info.editorPluginInfo.name = 'copilot.vim'
17-
info.editorPluginInfo.version = '1.5.3'
9+
---@return copilot_set_editor_info_params
10+
function M.get_editor_info()
11+
local info = {
12+
editorInfo = {
13+
name = "Neovim",
14+
version = string.match(vim.fn.execute("version"), "NVIM v(%S+)"),
15+
},
16+
editorPluginInfo = {
17+
name = "copilot.vim",
18+
version = '1.5.3',
19+
},
20+
}
1821
return info
1922
end
2023

0 commit comments

Comments
 (0)