1+ local config = require (" copilot.config" )
2+
13local M = {}
24
35local id = 0
@@ -95,11 +97,10 @@ local function is_ft_disabled(ft, filetypes)
9597 return false
9698end
9799
98- --- @param filetypes table<string , boolean>
99100--- @return boolean should_attach
100101--- @return string ? no_attach_reason
101- function M .should_attach (filetypes )
102- local ft_disabled , ft_disabled_reason = is_ft_disabled (vim .bo .filetype , filetypes )
102+ function M .should_attach ()
103+ local ft_disabled , ft_disabled_reason = is_ft_disabled (vim .bo .filetype , config . get ( " filetypes" ) )
103104
104105 if ft_disabled then
105106 return not ft_disabled , ft_disabled_reason
@@ -207,14 +208,14 @@ M.get_completion_params = function(opts)
207208 return M .get_doc_params (opts )
208209end
209210
210-
211211--- @return copilot_editor_configuration
212212function M .get_editor_configuration ()
213- local c = require (" copilot.client" )
213+ local conf = config .get ()
214+
215+ local filetypes = vim .deepcopy (conf .filetypes )
214216
215- local filetypes = vim .deepcopy (c .params .filetypes )
216- if filetypes [' *' ] == nil then
217- filetypes = vim .tbl_deep_extend (' keep' , filetypes , internal_filetypes )
217+ if filetypes [" *" ] == nil then
218+ filetypes = vim .tbl_deep_extend (" keep" , filetypes , internal_filetypes )
218219 end
219220
220221 --- @type string[]
@@ -224,7 +225,7 @@ function M.get_editor_configuration()
224225 table.sort (disabled_filetypes )
225226
226227 return {
227- enableAutoCompletions = not not (c . params . panel .enabled or c . params .suggestion .enabled ),
228+ enableAutoCompletions = not not (conf . panel .enabled or conf .suggestion .enabled ),
228229 disabledLanguages = disabled_filetypes ,
229230 }
230231end
@@ -234,7 +235,7 @@ M.get_copilot_path = function()
234235 if vim .fn .filereadable (copilot_path ) ~= 0 then
235236 return copilot_path
236237 else
237- print (" [Copilot] could not read" .. copilot_path )
238+ print (" [Copilot] could not read" .. copilot_path )
238239 end
239240end
240241
0 commit comments