1
1
local errs = require (" copilot-lsp.errors" )
2
2
local nes_ui = require (" copilot-lsp.nes.ui" )
3
3
local utils = require (" copilot-lsp.util" )
4
+ local config = require (" copilot-lsp.config" ).config
4
5
5
6
local M = {}
6
7
102
103
103
104
--- This function applies the pending nes edit to the current buffer and then clears the marks for the pending
104
105
--- suggestion
106
+ --- If there is no edit and auto_trigger is false, then a new suggestion will be requested
105
107
--- @param bufnr ? integer
106
108
--- @return boolean --if the nes was applied
107
109
function M .apply_pending_nes (bufnr )
@@ -110,7 +112,11 @@ function M.apply_pending_nes(bufnr)
110
112
--- @type copilotlsp.InlineEdit
111
113
local state = vim .b [bufnr ].nes_state
112
114
if not state then
113
- return false
115
+ if not config .auto_trigger then
116
+ M .request_nes ()
117
+ else
118
+ return false
119
+ end
114
120
end
115
121
vim .schedule (function ()
116
122
utils .apply_inline_edit (state )
@@ -142,14 +148,18 @@ end
142
148
--- @param au integer
143
149
function M .lsp_on_init (client , au )
144
150
-- NOTE: NES Completions
145
- local debounced_request =
146
- require (" copilot-lsp.util" ).debounce (require (" copilot-lsp.nes" ).request_nes , vim .g .copilot_nes_debounce or 500 )
147
- vim .api .nvim_create_autocmd ({ " TextChangedI" , " TextChanged" }, {
148
- callback = function ()
149
- debounced_request (client )
150
- end ,
151
- group = au ,
152
- })
151
+ if config .nes .auto_trigger then
152
+ local debounced_request = require (" copilot-lsp.util" ).debounce (
153
+ require (" copilot-lsp.nes" ).request_nes ,
154
+ vim .g .copilot_nes_debounce or 500
155
+ )
156
+ vim .api .nvim_create_autocmd ({ " TextChangedI" , " TextChanged" }, {
157
+ callback = function ()
158
+ debounced_request (client )
159
+ end ,
160
+ group = au ,
161
+ })
162
+ end
153
163
154
164
-- NOTE: didFocus
155
165
vim .api .nvim_create_autocmd (" BufEnter" , {
0 commit comments