Skip to content

Commit 21d8ef6

Browse files
committed
feat(client): store capabilities
1 parent 25a4160 commit 21d8ef6

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

lua/copilot/client.lua

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ local util = require("copilot.util")
55
local is_disabled = false
66

77
local M = {
8-
id = nil,
98
augroup = "copilot.client",
9+
id = nil,
10+
capabilities = nil,
11+
config = nil,
1012
}
1113

14+
---@param id number
1215
local function store_client_id(id)
1316
if M.id and M.id ~= id then
1417
if vim.lsp.get_client_by_id(M.id) then
@@ -147,7 +150,11 @@ M.merge_server_opts = function(params)
147150
get_language_id = function(_, filetype)
148151
return util.language_for_file_type(filetype)
149152
end,
150-
on_init = function(client)
153+
on_init = function(client, initialize_result)
154+
if M.id == client.id then
155+
M.capabilities = initialize_result.capabilities
156+
end
157+
151158
vim.schedule(function()
152159
---@type copilot_set_editor_info_params
153160
local set_editor_info_params = util.get_editor_info()
@@ -163,6 +170,12 @@ M.merge_server_opts = function(params)
163170
end)
164171
end)
165172
end,
173+
on_exit = function(_code, _signal, client_id)
174+
if M.id == client_id then
175+
M.id = nil
176+
M.capabilities = nil
177+
end
178+
end,
166179
handlers = {
167180
PanelSolution = api.handlers.PanelSolution,
168181
PanelSolutionsDone = api.handlers.PanelSolutionsDone,
@@ -206,7 +219,6 @@ function M.teardown()
206219

207220
if M.id then
208221
vim.lsp.stop_client(M.id)
209-
M.id = nil
210222
end
211223
end
212224

lua/copilot/util.lua

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,6 @@ function M.get_copilot_lua_version()
3737
return copilot_lua_version
3838
end
3939

40-
-- keep for debugging reasons
41-
local get_capabilities = function()
42-
return {
43-
capabilities = {
44-
textDocumentSync = {
45-
change = 2,
46-
openClose = true,
47-
},
48-
workspace = {
49-
workspaceFolders = {
50-
changeNotifications = true,
51-
supported = true,
52-
},
53-
},
54-
},
55-
}
56-
end
57-
5840
-- use `require("copilot.client").get()`
5941
---@deprecated
6042
M.get_copilot_client = function()

0 commit comments

Comments
 (0)