File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,14 @@ local client_config = require("copilot.client.config")
8
8
local is_disabled = false
9
9
10
10
--- @class CopilotClient
11
+ --- @field augroup string | nil
11
12
--- @field id integer | nil
12
13
--- @field capabilities lsp.ClientCapabilities | nil
13
14
--- @field config vim.lsp.ClientConfig | nil
14
15
--- @field startup_error string | nil
15
16
--- @field initialized boolean
16
17
local M = {
17
- augroup = " copilot.client " ,
18
+ augroup = nil ,
18
19
id = nil ,
19
20
capabilities = nil ,
20
21
config = nil ,
@@ -150,7 +151,11 @@ function M.setup()
150
151
is_disabled = false
151
152
152
153
M .id = nil
153
- vim .api .nvim_create_augroup (M .augroup , { clear = true })
154
+
155
+ -- nvim_clear_autocmds throws an error if the group does not exist
156
+ local augroup = " copilot.client"
157
+ vim .api .nvim_create_augroup (augroup , { clear = true })
158
+ M .augroup = augroup
154
159
155
160
vim .api .nvim_create_autocmd (" FileType" , {
156
161
group = M .augroup ,
165
170
function M .teardown ()
166
171
is_disabled = true
167
172
168
- vim .api .nvim_clear_autocmds ({ group = M .augroup })
173
+ -- nvim_clear_autocmds throws an error if the group does not exist
174
+ if M .augroup then
175
+ vim .api .nvim_clear_autocmds ({ group = M .augroup })
176
+ end
169
177
170
178
if M .id then
171
179
vim .lsp .stop_client (M .id )
You can’t perform that action at this time.
0 commit comments