fix autocomplete
This commit is contained in:
@@ -32,6 +32,23 @@ return {
|
||||
},
|
||||
"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'
|
||||
--- @type blink.cmp.Config
|
||||
opts = {
|
||||
@@ -76,9 +93,16 @@ return {
|
||||
},
|
||||
|
||||
sources = {
|
||||
default = { "lsp", "path", "snippets", "lazydev" },
|
||||
default = { "lsp", "path", "snippets", "lazydev", "minuet" },
|
||||
providers = {
|
||||
lazydev = { module = "lazydev.integrations.blink", score_offset = 100 },
|
||||
minuet = {
|
||||
name = "minuet",
|
||||
module = "minuet.blink",
|
||||
async = true,
|
||||
timeout_ms = 3000,
|
||||
score_offset = 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ return {
|
||||
-- Allows extra capabilities provided by blink.cmp
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
config = function(_, opts)
|
||||
require("blink.cmp").setup(opts)
|
||||
opts = function(_, opts)
|
||||
-- Add blink.cmp capabilities to the default LSP client capabilities
|
||||
vim.lsp.config("*", {
|
||||
capabilities = require("blink.cmp").get_lsp_capabilities(),
|
||||
})
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
|
||||
|
||||
@@ -28,34 +28,16 @@ return {
|
||||
end,
|
||||
},
|
||||
{ "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",
|
||||
config = function()
|
||||
require("blink-cmp").setup({
|
||||
keymap = {
|
||||
-- Manually invoke minuet completion.
|
||||
["<A-y>"] = require("minuet").make_blink_map(),
|
||||
},
|
||||
sources = {
|
||||
-- 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 } },
|
||||
})
|
||||
"saghen/blink.cmp",
|
||||
opts = function(_, opts)
|
||||
opts.keymap = opts.keymap or {}
|
||||
opts.keymap["<A-y>"] = require("minuet").make_blink_map()
|
||||
opts.completion = opts.completion or {}
|
||||
opts.completion.trigger = opts.completion.trigger or {}
|
||||
opts.completion.trigger.prefetch_on_insert = false
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user