@@ -8,8 +8,6 @@ if vim.fn.has('nvim-' .. min_version) ~= 1 then
88 return
99end
1010
11- local chat = require (' CopilotChat' )
12-
1311-- Setup highlights
1412vim .api .nvim_set_hl (0 , ' CopilotChatStatus' , { link = ' DiagnosticHint' , default = true })
1513vim .api .nvim_set_hl (0 , ' CopilotChatHelp' , { link = ' DiagnosticInfo' , default = true })
@@ -21,6 +19,7 @@ vim.api.nvim_set_hl(0, 'CopilotChatSeparator', { link = '@punctuation.special.ma
2119
2220-- Setup commands
2321vim .api .nvim_create_user_command (' CopilotChat' , function (args )
22+ local chat = require (' CopilotChat' )
2423 local input = args .args
2524 if input and vim .trim (input ) ~= ' ' then
2625 chat .ask (input )
@@ -33,31 +32,40 @@ end, {
3332 range = true ,
3433})
3534vim .api .nvim_create_user_command (' CopilotChatPrompts' , function ()
35+ local chat = require (' CopilotChat' )
3636 chat .select_prompt ()
3737end , { force = true , range = true })
3838vim .api .nvim_create_user_command (' CopilotChatModels' , function ()
39+ local chat = require (' CopilotChat' )
3940 chat .select_model ()
4041end , { force = true })
4142vim .api .nvim_create_user_command (' CopilotChatAgents' , function ()
43+ local chat = require (' CopilotChat' )
4244 chat .select_agent ()
4345end , { force = true })
4446vim .api .nvim_create_user_command (' CopilotChatOpen' , function ()
47+ local chat = require (' CopilotChat' )
4548 chat .open ()
4649end , { force = true })
4750vim .api .nvim_create_user_command (' CopilotChatClose' , function ()
51+ local chat = require (' CopilotChat' )
4852 chat .close ()
4953end , { force = true })
5054vim .api .nvim_create_user_command (' CopilotChatToggle' , function ()
55+ local chat = require (' CopilotChat' )
5156 chat .toggle ()
5257end , { force = true })
5358vim .api .nvim_create_user_command (' CopilotChatStop' , function ()
59+ local chat = require (' CopilotChat' )
5460 chat .stop ()
5561end , { force = true })
5662vim .api .nvim_create_user_command (' CopilotChatReset' , function ()
63+ local chat = require (' CopilotChat' )
5764 chat .reset ()
5865end , { force = true })
5966
6067local function complete_load ()
68+ local chat = require (' CopilotChat' )
6169 local options = vim .tbl_map (function (file )
6270 return vim .fn .fnamemodify (file , ' :t:r' )
6371 end , vim .fn .glob (chat .config .history_path .. ' /*' , true , true ))
@@ -69,9 +77,11 @@ local function complete_load()
6977 return options
7078end
7179vim .api .nvim_create_user_command (' CopilotChatSave' , function (args )
80+ local chat = require (' CopilotChat' )
7281 chat .save (args .args )
7382end , { nargs = ' *' , force = true , complete = complete_load })
7483vim .api .nvim_create_user_command (' CopilotChatLoad' , function (args )
84+ local chat = require (' CopilotChat' )
7585 chat .load (args .args )
7686end , { nargs = ' *' , force = true , complete = complete_load })
7787
0 commit comments