mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
feat(extras): blink (#4680)
## Description Extra to use [blink.cmp](https://github.com/Saghen/blink.cmp) instead of **nvim-cmp**. ## Todo - [x] tokyonight suport - [x] basic integration - [ ] check / update all cmp sources - [ ] copilot and others integration - [x] native lazydev source ## Limitations There's no copilot source, so instead when enabling both blink and copilot: - blink ghost text is disabled - copilot suggestions are enabled - use `<tab>` to navigate snippets and accept copilot completions ## Related Issue(s) - https://github.com/LazyVim/LazyVim/discussions/4679
This commit is contained in:
parent
a66b44a9fe
commit
ad52bf91bc
5 changed files with 148 additions and 1 deletions
96
lua/lazyvim/plugins/extras/coding/blink.lua
Normal file
96
lua/lazyvim/plugins/extras/coding/blink.lua
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
-- TODO: use release version
|
||||||
|
-- version = "*",
|
||||||
|
opts_extend = { "sources.completion.enabled_providers" },
|
||||||
|
dependencies = {
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
-- add blink.compat to dependencies
|
||||||
|
-- { "saghen/blink.compat", opts = {} },
|
||||||
|
},
|
||||||
|
event = "InsertEnter",
|
||||||
|
|
||||||
|
---@module 'blink.cmp'
|
||||||
|
---@type blink.cmp.Config
|
||||||
|
opts = {
|
||||||
|
fuzzy = {
|
||||||
|
prebuilt_binaries = {
|
||||||
|
download = true,
|
||||||
|
force_version = "v0.5.0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
highlight = {
|
||||||
|
-- sets the fallback highlight groups to nvim-cmp's highlight groups
|
||||||
|
-- useful for when your theme doesn't support blink.cmp
|
||||||
|
-- will be removed in a future release, assuming themes add support
|
||||||
|
use_nvim_cmp_as_default = false,
|
||||||
|
},
|
||||||
|
-- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||||
|
-- adjusts spacing to ensure icons are aligned
|
||||||
|
nerd_font_variant = "mono",
|
||||||
|
windows = {
|
||||||
|
autocomplete = {
|
||||||
|
draw = "reversed",
|
||||||
|
},
|
||||||
|
documentation = {
|
||||||
|
auto_show = true,
|
||||||
|
},
|
||||||
|
ghost_text = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- experimental auto-brackets support
|
||||||
|
accept = { auto_brackets = { enabled = true } },
|
||||||
|
|
||||||
|
-- experimental signature help support
|
||||||
|
-- trigger = { signature_help = { enabled = true } }
|
||||||
|
sources = {
|
||||||
|
completion = {
|
||||||
|
-- remember to enable your providers here
|
||||||
|
enabled_providers = { "lsp", "path", "snippets", "buffer" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
keymap = {
|
||||||
|
preset = "enter",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- add icons
|
||||||
|
{
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
opts = function(_, opts)
|
||||||
|
opts.kind_icons = LazyVim.config.icons.kinds
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- lazydev
|
||||||
|
{
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
opts = {
|
||||||
|
sources = {
|
||||||
|
completion = {
|
||||||
|
-- add lazydev to your completion providers
|
||||||
|
enabled_providers = { "lazydev" },
|
||||||
|
},
|
||||||
|
providers = {
|
||||||
|
lsp = {
|
||||||
|
-- dont show LuaLS require statements when lazydev has items
|
||||||
|
fallback_for = { "lazydev" },
|
||||||
|
},
|
||||||
|
lazydev = {
|
||||||
|
name = "LazyDev",
|
||||||
|
module = "lazydev.integrations.blink",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
|
@ -80,4 +80,44 @@ return {
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
optional = true,
|
||||||
|
specs = {
|
||||||
|
{
|
||||||
|
"zbirenbaum/copilot.lua",
|
||||||
|
event = "InsertEnter",
|
||||||
|
opts = {
|
||||||
|
suggestion = {
|
||||||
|
enabled = true,
|
||||||
|
auto_trigger = true,
|
||||||
|
keymap = { accept = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
opts = {
|
||||||
|
windows = {
|
||||||
|
ghost_text = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
keymap = {
|
||||||
|
["<Tab>"] = {
|
||||||
|
function(cmp)
|
||||||
|
if cmp.is_in_snippet() then
|
||||||
|
return cmp.accept()
|
||||||
|
elseif require("copilot.suggestion").is_visible() then
|
||||||
|
require("copilot.suggestion").accept()
|
||||||
|
else
|
||||||
|
return cmp.select_and_accept()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
"snippet_forward",
|
||||||
|
"fallback",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,11 +184,13 @@ return {
|
||||||
|
|
||||||
local servers = opts.servers
|
local servers = opts.servers
|
||||||
local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
local has_blink, blink = pcall(require, "blink.cmp")
|
||||||
local capabilities = vim.tbl_deep_extend(
|
local capabilities = vim.tbl_deep_extend(
|
||||||
"force",
|
"force",
|
||||||
{},
|
{},
|
||||||
vim.lsp.protocol.make_client_capabilities(),
|
vim.lsp.protocol.make_client_capabilities(),
|
||||||
has_cmp and cmp_nvim_lsp.default_capabilities() or {},
|
has_cmp and cmp_nvim_lsp.default_capabilities() or {},
|
||||||
|
has_blink and blink.get_lsp_capabilities() or {},
|
||||||
opts.capabilities or {}
|
opts.capabilities or {}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ local prios = {
|
||||||
["lazyvim.plugins.extras.dap.core"] = 1,
|
["lazyvim.plugins.extras.dap.core"] = 1,
|
||||||
["lazyvim.plugins.extras.ui.edgy"] = 2,
|
["lazyvim.plugins.extras.ui.edgy"] = 2,
|
||||||
["lazyvim.plugins.extras.lang.typescript"] = 5,
|
["lazyvim.plugins.extras.lang.typescript"] = 5,
|
||||||
|
["lazyvim.plugins.extras.coding.blink"] = 5,
|
||||||
["lazyvim.plugins.extras.formatting.prettier"] = 10,
|
["lazyvim.plugins.extras.formatting.prettier"] = 10,
|
||||||
-- default priority is 50
|
-- default priority is 50
|
||||||
["lazyvim.plugins.extras.editor.aerial"] = 100,
|
["lazyvim.plugins.extras.editor.aerial"] = 100,
|
||||||
|
|
|
@ -71,9 +71,17 @@ function M.add_missing_snippet_docs(window)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.visible()
|
function M.visible()
|
||||||
|
---@module 'blink.cmp'
|
||||||
|
local blink = package.loaded["blink.cmp"]
|
||||||
|
if blink then
|
||||||
|
return blink.windows and blink.windows.autocomplete.win:is_open()
|
||||||
|
end
|
||||||
---@module 'cmp'
|
---@module 'cmp'
|
||||||
local cmp = package.loaded["cmp"]
|
local cmp = package.loaded["cmp"]
|
||||||
return cmp and cmp.core.view:visible()
|
if cmp then
|
||||||
|
return cmp.core.view:visible()
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This is a better implementation of `cmp.confirm`:
|
-- This is a better implementation of `cmp.confirm`:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue