@@ -222,7 +222,10 @@ function M.start_server(args)
222
222
223
223
utils .notify (' Minuet LSP attached to current buffer' , ' verbose' , vim .log .levels .INFO )
224
224
225
- if
225
+ if vim .b [bufnr ].minuet_lsp_enable_auto_trigger then
226
+ vim .lsp .completion .enable (true , client .id , bufnr , { autotrigger = true })
227
+ utils .notify (' Minuet LSP is enabled for auto triggering' , ' verbose' , vim .log .levels .INFO )
228
+ elseif
226
229
(vim .tbl_contains (auto_trigger_ft , ft ) or vim .tbl_contains (auto_trigger_ft , ' *' ))
227
230
and not vim .tbl_contains (disable_trigger_ft , ft )
228
231
then
@@ -288,4 +291,68 @@ function M.setup()
288
291
end
289
292
end
290
293
294
+ M .actions = {}
295
+
296
+ M .actions .attach = function ()
297
+ local bufnr = vim .api .nvim_get_current_buf ()
298
+ local lsps = vim .lsp .get_clients { name = ' minuet' , bufnr = bufnr }
299
+
300
+ if # lsps and # lsps > 0 then
301
+ utils .notify (' Minuet LSP already attached to current buffer' , ' verbose' , vim .log .levels .INFO )
302
+ return
303
+ end
304
+
305
+ M .start_server { buf = bufnr }
306
+ end
307
+
308
+ M .actions .detach = function ()
309
+ local bufnr = vim .api .nvim_get_current_buf ()
310
+ local lsps = vim .lsp .get_clients { name = ' minuet' , bufnr = bufnr }
311
+
312
+ if # lsps == 0 then
313
+ utils .notify (' Minuet LSP not attached to current buffer' , ' verbose' , vim .log .levels .INFO )
314
+ return
315
+ end
316
+
317
+ for _ , client in ipairs (lsps ) do
318
+ vim .lsp .buf_detach_client (bufnr , client .id )
319
+ end
320
+
321
+ utils .notify (' Minuet LSP detached from current buffer' , ' verbose' , vim .log .levels .INFO )
322
+ end
323
+
324
+ M .actions .enable_auto_trigger = function ()
325
+ local bufnr = vim .api .nvim_get_current_buf ()
326
+ local lsps = vim .lsp .get_clients { name = ' minuet' , bufnr = bufnr }
327
+
328
+ if # lsps == 0 then
329
+ vim .b [bufnr ].minuet_lsp_enable_auto_trigger = true
330
+ M .actions .attach ()
331
+ return
332
+ end
333
+
334
+ for _ , client in ipairs (lsps ) do
335
+ vim .lsp .completion .enable (false , client .id , bufnr )
336
+ vim .lsp .completion .enable (true , client .id , bufnr , { autotrigger = true })
337
+ end
338
+
339
+ utils .notify (' Minuet LSP is enabled for auto triggering' , ' verbose' , vim .log .levels .INFO )
340
+ end
341
+
342
+ M .actions .disable_auto_trigger = function ()
343
+ local bufnr = vim .api .nvim_get_current_buf ()
344
+ vim .b [bufnr ].minuet_lsp_enable_auto_trigger = nil
345
+ local lsps = vim .lsp .get_clients { name = ' minuet' , bufnr = bufnr }
346
+
347
+ if # lsps == 0 then
348
+ return
349
+ end
350
+
351
+ for _ , client in ipairs (lsps ) do
352
+ vim .lsp .completion .enable (false , client .id , bufnr )
353
+ vim .lsp .completion .enable (true , client .id , bufnr , { autotrigger = false })
354
+ utils .notify (' Minuet LSP is disabled for auto triggering' , ' verbose' , vim .log .levels .INFO )
355
+ end
356
+ end
357
+
291
358
return M
0 commit comments