feat: add silent fallback for blink.cmp if binary or cargo is missing

This commit is contained in:
2026-04-22 12:35:44 -04:00
parent 688eec7498
commit cdb72cff4d
+16 -4
View File
@@ -224,13 +224,22 @@ lazyload.on_vim_enter(function()
vim.pack.add({ { src = "https://github.com/williamboman/mason-lspconfig.nvim", name = "mason-lspconfig" } })
vim.pack.add({ { src = "https://github.com/neovim/nvim-lspconfig", name = "nvim-lspconfig" } })
-- Completion
require("mason").setup()
-- Completion (Blink.cmp)
-- We check if the binary exists or if cargo is available to build it.
-- If neither, we skip loading to avoid errors.
local blink_path = vim.fn.stdpath("data") .. "/site/pack/core/opt/blink.cmp"
local has_blink_bin = vim.fn.filereadable(blink_path .. "/target/release/libblink_cmp_fuzzy.so") == 1
or vim.fn.filereadable(blink_path .. "/target/release/libblink_cmp_fuzzy.dylib") == 1
or vim.fn.filereadable(blink_path .. "/target/release/libblink_cmp_fuzzy.dll") == 1
local has_cargo = vim.fn.executable("cargo") == 1
if has_blink_bin or has_cargo then
vim.pack.add({ { src = "https://github.com/saghen/blink.cmp", name = "blink.cmp" } })
vim.pack.add({ { src = "https://github.com/rafamadriz/friendly-snippets", name = "friendly-snippets" } })
vim.pack.add({ { src = "https://github.com/fang2hou/blink-copilot", name = "blink-copilot" } })
require("mason").setup()
-- Blink.cmp setup
require("blink.cmp").setup({
keymap = { preset = "default" },
@@ -260,9 +269,12 @@ lazyload.on_vim_enter(function()
},
signature = { enabled = true },
})
else
vim.notify("blink.cmp: binary not found and cargo not installed. Completion disabled.", vim.log.levels.WARN)
end
local lspconfig = require("lspconfig")
local capabilities = require("blink.cmp").get_lsp_capabilities()
local capabilities = (has_blink_bin or has_cargo) and require("blink.cmp").get_lsp_capabilities() or nil
require("mason-lspconfig").setup({
ensure_installed = {