feat: integrate Blink completion support for enhanced coding experience
This commit is contained in:
+58
-3
@@ -12,9 +12,7 @@ local function cmp_provider(performance)
|
|||||||
if performance then
|
if performance then
|
||||||
return {
|
return {
|
||||||
-- Experiemental cmp performance fork
|
-- Experiemental cmp performance fork
|
||||||
url = 'hrsh7th/nvim-cmp',
|
url = 'https://github.com/iguanacucumber/magazine.nvim',
|
||||||
--url = "iguanacucumber/magazine.nvim",
|
|
||||||
dev = true,
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return {
|
return {
|
||||||
@@ -26,12 +24,64 @@ local function cmp_provider(performance)
|
|||||||
end
|
end
|
||||||
local cmp_repo = cmp_provider(perf)
|
local cmp_repo = cmp_provider(perf)
|
||||||
|
|
||||||
|
if vim.g.useblinkcmp then
|
||||||
|
if vim.g.cmp_performance_enabled then
|
||||||
|
vim.g.lazyvim_blink_main = true
|
||||||
|
end
|
||||||
|
return {
|
||||||
|
{ -- Blink completion
|
||||||
|
import = 'lazyvim.plugins.extras.coding.blink',
|
||||||
|
},
|
||||||
|
{ -- Blink compat
|
||||||
|
'saghen/blink.compat',
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'saghen/blink.cmp',
|
||||||
|
opts = {
|
||||||
|
keymap = {
|
||||||
|
preset = 'super-tab',
|
||||||
|
['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
|
||||||
|
['<C-e>'] = { 'hide', 'fallback' },
|
||||||
|
|
||||||
|
['<Tab>'] = {
|
||||||
|
function(cmp)
|
||||||
|
if cmp.is_in_snippet() then
|
||||||
|
-- If the completion is in a snippet, accept it
|
||||||
|
return cmp.accept()
|
||||||
|
else
|
||||||
|
-- If the completion is not in a snippet, select the next one
|
||||||
|
return cmp.select_next()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
'snippet_forward',
|
||||||
|
'fallback',
|
||||||
|
},
|
||||||
|
['<S-Tab>'] = { 'snippet_backward', 'fallback' },
|
||||||
|
|
||||||
|
['<Up>'] = { 'select_prev', 'fallback' },
|
||||||
|
['<Down>'] = { 'select_next', 'fallback' },
|
||||||
|
['<C-p>'] = { 'select_prev', 'fallback' },
|
||||||
|
['<C-n>'] = { 'select_next', 'fallback' },
|
||||||
|
|
||||||
|
['<C-b>'] = { 'scroll_documentation_up', 'fallback' },
|
||||||
|
['<C-f>'] = { 'scroll_documentation_down', 'fallback' },
|
||||||
|
},
|
||||||
|
windows = {
|
||||||
|
selection = 'manual',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
-- Else use classic cmp
|
-- Else use classic cmp
|
||||||
return { -- cmp
|
return { -- cmp
|
||||||
url = cmp_repo.url,
|
url = cmp_repo.url,
|
||||||
build = cmp_repo.build,
|
build = cmp_repo.build,
|
||||||
branch = cmp_repo.branch,
|
branch = cmp_repo.branch,
|
||||||
dev = cmp_repo.dev,
|
dev = cmp_repo.dev,
|
||||||
|
enabled = not vim.g.useblinkcmp,
|
||||||
event = 'VeryLazy',
|
event = 'VeryLazy',
|
||||||
dependencies = require('data.deps').cmp,
|
dependencies = require('data.deps').cmp,
|
||||||
config = function()
|
config = function()
|
||||||
@@ -89,16 +139,21 @@ return { -- cmp
|
|||||||
['<C-Space>'] = cmp.mapping.complete({}),
|
['<C-Space>'] = cmp.mapping.complete({}),
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
|
-- If the completion popup is visible, select the next item
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
elseif luasnip.expand_or_locally_jumpable() then
|
elseif luasnip.expand_or_locally_jumpable() then
|
||||||
|
-- If a snippet can be expanded or jump to the next location, do so
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
elseif vim.snippet.active({ direction = 1 }) then
|
elseif vim.snippet.active({ direction = 1 }) then
|
||||||
|
-- If a snippet is active, jump to the next location
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
vim.snippet.jump(1)
|
vim.snippet.jump(1)
|
||||||
end)
|
end)
|
||||||
elseif has_words_before() then
|
elseif has_words_before() then
|
||||||
|
-- If there are words before the cursor, complete them
|
||||||
cmp.complete()
|
cmp.complete()
|
||||||
else
|
else
|
||||||
|
-- Otherwise, fallback to the default behavior of the Tab key
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { 'i', 's' }),
|
end, { 'i', 's' }),
|
||||||
|
|||||||
Reference in New Issue
Block a user