fix autocomplete

This commit is contained in:
2026-04-07 17:12:47 +01:00
parent 6d525d0971
commit fd2307eb0c
3 changed files with 36 additions and 30 deletions
+25 -1
View File
@@ -32,6 +32,23 @@ return {
}, },
"folke/lazydev.nvim", "folke/lazydev.nvim",
}, },
config = function(_, opts)
-- Monkey-patch blink's text_edits.get_from_item to clamp textEdit ranges
-- that extend past the cursor. Workaround for tsgo sending bad ranges
-- that eat text (e.g. in JSX string attributes like className="...").
local text_edits = require("blink.cmp.lib.text_edits")
local original_get_from_item = text_edits.get_from_item
text_edits.get_from_item = function(item)
local text_edit = original_get_from_item(item)
local cursor_col = require("blink.cmp.completion.trigger.context").get_cursor()[2]
if text_edit.range and text_edit.range["end"].character > cursor_col then
text_edit.range["end"].character = cursor_col
end
return text_edit
end
require("blink.cmp").setup(opts)
end,
--- @module 'blink.cmp' --- @module 'blink.cmp'
--- @type blink.cmp.Config --- @type blink.cmp.Config
opts = { opts = {
@@ -76,9 +93,16 @@ return {
}, },
sources = { sources = {
default = { "lsp", "path", "snippets", "lazydev" }, default = { "lsp", "path", "snippets", "lazydev", "minuet" },
providers = { providers = {
lazydev = { module = "lazydev.integrations.blink", score_offset = 100 }, lazydev = { module = "lazydev.integrations.blink", score_offset = 100 },
minuet = {
name = "minuet",
module = "minuet.blink",
async = true,
timeout_ms = 3000,
score_offset = 50,
},
}, },
}, },
+2 -2
View File
@@ -6,12 +6,12 @@ return {
-- Allows extra capabilities provided by blink.cmp -- Allows extra capabilities provided by blink.cmp
{ {
"saghen/blink.cmp", "saghen/blink.cmp",
config = function(_, opts) opts = function(_, opts)
require("blink.cmp").setup(opts)
-- Add blink.cmp capabilities to the default LSP client capabilities -- Add blink.cmp capabilities to the default LSP client capabilities
vim.lsp.config("*", { vim.lsp.config("*", {
capabilities = require("blink.cmp").get_lsp_capabilities(), capabilities = require("blink.cmp").get_lsp_capabilities(),
}) })
return opts
end, end,
}, },
+9 -27
View File
@@ -28,34 +28,16 @@ return {
end, end,
}, },
{ "nvim-lua/plenary.nvim" }, { "nvim-lua/plenary.nvim" },
-- optional, if you are using virtual-text frontend, blink is not required. -- Minuet blink.cmp integration (merged into main blink.lua spec via opts)
{ {
"Saghen/blink.cmp", "saghen/blink.cmp",
config = function() opts = function(_, opts)
require("blink-cmp").setup({ opts.keymap = opts.keymap or {}
keymap = { opts.keymap["<A-y>"] = require("minuet").make_blink_map()
-- Manually invoke minuet completion. opts.completion = opts.completion or {}
["<A-y>"] = require("minuet").make_blink_map(), opts.completion.trigger = opts.completion.trigger or {}
}, opts.completion.trigger.prefetch_on_insert = false
sources = { return opts
-- Enable minuet for autocomplete
default = { "lsp", "path", "buffer", "snippets", "minuet" },
-- For manual completion only, remove 'minuet' from default
providers = {
minuet = {
name = "minuet",
module = "minuet.blink",
async = true,
-- Should match minuet.config.request_timeout * 1000,
-- since minuet.config.request_timeout is in seconds
timeout_ms = 3000,
score_offset = 50, -- Gives minuet higher priority among suggestions
},
},
},
-- Recommended to avoid unnecessary request
completion = { trigger = { prefetch_on_insert = false } },
})
end, end,
}, },
} }