11local a = vim .api
2- local cmd = vim .cmd
32local wo = vim .wo
43local handler = require (" copilot.handlers" )
54local format = require (" copilot_cmp.format" )
65local print_panel = {}
76
87local set_text = function (full_text )
9- vim . api . nvim_buf_set_lines (print_panel .bufnr , 0 , - 1 , false , {} )
10- vim . api . nvim_buf_set_option (print_panel .bufnr , " modifiable " , true )
11- vim . api . nvim_buf_set_option (print_panel .bufnr , " readonly " , false )
8+ a . nvim_buf_set_option (print_panel .bufnr , " modifiable " , true )
9+ a . nvim_buf_set_option (print_panel .bufnr , " readonly " , false )
10+ a . nvim_buf_set_lines (print_panel .bufnr , 0 , - 1 , false , {} )
1211
1312 local ft = vim .bo .filetype
14- vim . api .nvim_buf_call (print_panel .bufnr , function ()
13+ a .nvim_buf_call (print_panel .bufnr , function ()
1514 vim .bo .filetype = ft
1615 end )
17- vim . api .nvim_buf_set_lines (print_panel .bufnr , 0 , # full_text , false ,full_text )
16+ a .nvim_buf_set_lines (print_panel .bufnr , 0 , # full_text , false ,full_text )
1817
19- vim . api .nvim_buf_set_option (print_panel .bufnr , " modifiable" , false )
20- vim . api .nvim_buf_set_option (print_panel .bufnr , " readonly" , true )
18+ a .nvim_buf_set_option (print_panel .bufnr , " modifiable" , false )
19+ a .nvim_buf_set_option (print_panel .bufnr , " readonly" , true )
2120end
2221
2322local format_entry = function (number , str )
7776
7877local create_win = function ()
7978 local oldwin = a .nvim_get_current_win () -- record current window
80- local height = tostring (math.floor (vim . api .nvim_win_get_height (oldwin )* .3 ))
79+ local height = tostring (math.floor (a .nvim_win_get_height (oldwin )* .3 ))
8180 cmd (height .. " split" )
8281 local win = a .nvim_get_current_win ()
8382 wo .number = false
9190print_panel .select = function (id )
9291 if not id then id = print_panel .current or 1 end
9392 local selection = print_panel .entries [id ]
94- vim . api .nvim_win_set_cursor (print_panel .win , {selection .linenr , 0 })
93+ a .nvim_win_set_cursor (print_panel .win , {selection .linenr , 0 })
9594 vim .cmd (" normal zt" )
9695 print_panel .current = id
9796 print_panel .linenr = selection .linenr
@@ -117,11 +116,11 @@ print_panel.set_options = function ()
117116 buf = { bufhidden = " wipe" , buftype = " nofile" , swapfile = false , buflisted = false , }
118117 }
119118 for option , value in pairs (opts .win ) do
120- vim . api .nvim_win_set_option (print_panel .win , option , value )
119+ a .nvim_win_set_option (print_panel .win , option , value )
121120 end
122121
123122 for option , value in pairs (opts .buf ) do
124- vim . api .nvim_buf_set_option (print_panel .bufnr , option , value )
123+ a .nvim_buf_set_option (print_panel .bufnr , option , value )
125124 end
126125end
127126
@@ -146,19 +145,20 @@ print_panel.create = function (bufnr)
146145 })
147146 end
148147
149- local id = vim . api .nvim_create_augroup (" Panel" , {
148+ local id = a .nvim_create_augroup (" Panel" , {
150149 clear = false
151150 })
152151
153- vim . api .nvim_create_autocmd ({" TextChangedI" , " TextChangedP" }, {
152+ a .nvim_create_autocmd ({" TextChangedI" , " TextChangedP" }, {
154153 callback = function ()
155- print (" callback" )
156- require (" copilot.extensions.panel" ).send_request ()
154+ require (" copilot.extensions.panel" ).send_request ({
155+ uri = " pb"
156+ })
157157 end ,
158158 group = id ,
159159 })
160160
161- vim . api .nvim_create_autocmd (" WinEnter" , {
161+ a .nvim_create_autocmd (" WinEnter" , {
162162 callback = function ()
163163 if print_panel .entries then
164164 print_panel .select (print_panel .entries .current )
@@ -168,11 +168,11 @@ print_panel.create = function (bufnr)
168168 group = id ,
169169 })
170170
171- vim . api .nvim_create_autocmd (" WinClosed" , {
171+ a .nvim_create_autocmd (" WinClosed" , {
172172 pattern = { tostring (print_panel .win ) },
173173 callback = function ()
174174 -- cleanup panel triggers
175- vim . api .nvim_create_augroup (" Panel" , { clear = true })
175+ a .nvim_create_augroup (" Panel" , { clear = true })
176176 handler .remove_handler_callback (" PanelSolution" , " pb" )
177177 handler .remove_handler_callback (" PanelSolutionsDone" , " pb" )
178178 end ,
0 commit comments