Skip to content

Commit e45c5db

Browse files
committed
feat!(lsp): don't explicitly disable auto trigger for filetypes not in enabled_auto_trigger_ft
Previously, auto-triggering was explicitly disabled for filetypes not enabled in `config.lsp.enabled_auto_trigger_ft`. This was done to avoid conflicts with users who enable auto-triggering for all LSP servers that support completion via the `LspAttach` event. However, this approach introduced unnecessary complexity. Now, Minuet no longer explicitly disables auto-triggering on attach. Instead, it is recommended on the user side to configure auto-triggering correctly, either through `config.lsp.enabled_auto_trigger_ft` or by checking the server name in their `LspAttach` handler.
1 parent 19ac488 commit e45c5db

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

README.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,32 @@ Therefore, consider the following options:
256256
Users might call `vim.lsp.completion.enable {autotrigger = true}` during the
257257
`LspAttach` event when the client supports completion. However, this is not the
258258
desired behavior for Minuet. As an LLM completion source, Minuet can face
259-
significant rate limits during automatic triggering. Consequently, Minuet
260-
disables auto trigger by default unless the user enables it in
261-
`config.lsp.enabled_auto_trigger_ft`.
259+
significant rate limits during automatic triggering.
260+
261+
Therefore, it's recommended to enable Minuet for automatic triggering using the
262+
`config.lsp.enabled_auto_trigger_ft` setting.
263+
264+
For users who uses `LspAttach` event, it is recommeded to verify that the
265+
server is not the Minuet server before enabling autotrigger. An example
266+
configuration is shown below:
267+
268+
```lua
269+
vim.api.nvim_create_autocmd('LspAttach', {
270+
callback = function(args)
271+
local client_id = args.data.client_id
272+
local bufnr = args.buf
273+
local client = vim.lsp.get_client_by_id(client_id)
274+
if not client then
275+
return
276+
end
277+
278+
if client.server_capabilities.completionProvider and client.name ~= 'minuet' then
279+
vim.lsp.completion.enable(true, client_id, bufnr, { autotrigger = true })
280+
end
281+
end,
282+
desc = 'Enable built-in auto completion',
283+
})
284+
```
262285

263286
</details>
264287

lua/minuet/lsp.lua

-18
Original file line numberDiff line numberDiff line change
@@ -232,22 +232,6 @@ function M.start_server(args)
232232
then
233233
vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true })
234234
utils.notify('Minuet LSP is enabled for auto triggering', 'verbose', vim.log.levels.INFO)
235-
else
236-
-- NOTE: Auto-triggering is explicitly disabled for
237-
-- filetypes that are not enabled auto triggering. This is
238-
-- because some users uses the `LspAttach` event to
239-
-- determine if a LSP supports completion, then enabling
240-
-- auto-triggering if it does.
241-
--
242-
-- Minuet, as a LLM completion source, can be subject to
243-
-- substantial rate limits during auto-triggering.
244-
-- Therefore, completion is disabled by default unless
245-
-- explicitly enabled by the user.
246-
vim.defer_fn(function()
247-
vim.lsp.completion.enable(false, client.id, bufnr)
248-
vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = false })
249-
utils.notify('Minuet LSP is disabled for auto triggering', 'verbose', vim.log.levels.INFO)
250-
end, 300)
251235
end
252236
end,
253237
}
@@ -334,7 +318,6 @@ M.actions.enable_auto_trigger = function()
334318
end
335319

336320
for _, client in ipairs(lsps) do
337-
vim.lsp.completion.enable(false, client.id, bufnr)
338321
vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true })
339322
end
340323

@@ -352,7 +335,6 @@ M.actions.disable_auto_trigger = function()
352335

353336
for _, client in ipairs(lsps) do
354337
vim.lsp.completion.enable(false, client.id, bufnr)
355-
vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = false })
356338
utils.notify('Minuet LSP is disabled for auto triggering', 'verbose', vim.log.levels.INFO)
357339
end
358340
end

0 commit comments

Comments
 (0)