11local errs = require (" copilot-lsp.errors" )
22local nes_ui = require (" copilot-lsp.nes.ui" )
33local utils = require (" copilot-lsp.util" )
4+ local config = require (" copilot-lsp.config" ).config
45
56local M = {}
67
102103
103104--- This function applies the pending nes edit to the current buffer and then clears the marks for the pending
104105--- suggestion
106+ --- If there is no edit and auto_trigger is false, then a new suggestion will be requested
105107--- @param bufnr ? integer
106108--- @return boolean --if the nes was applied
107109function M .apply_pending_nes (bufnr )
@@ -110,7 +112,11 @@ function M.apply_pending_nes(bufnr)
110112 --- @type copilotlsp.InlineEdit
111113 local state = vim .b [bufnr ].nes_state
112114 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
114120 end
115121 vim .schedule (function ()
116122 utils .apply_inline_edit (state )
@@ -142,14 +148,18 @@ end
142148--- @param au integer
143149function M .lsp_on_init (client , au )
144150 -- 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
153163
154164 -- NOTE: didFocus
155165 vim .api .nvim_create_autocmd (" BufEnter" , {
0 commit comments