neovim-dotfiles/lua/plugins/blink-cmp.lua

68 lines
1.7 KiB
Lua

---@module "utils.plugins"
---@type Plugin
return {
configures = "blink.cmp",
configure = function(load)
load("folke/lazydev.nvim")
require("lazydev").setup({})
load("rafamadriz/friendly-snippets")
load("saghen/blink.cmp")
---@module "blink.cmp"
require("blink.cmp").setup({
keymap = { preset = "super-tab" },
appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = "mono",
},
-- (Default) Only show the documentation popup when manually triggered
completion = {
documentation = { auto_show = true },
list = {
selection = {
preselect = true,
auto_insert = false,
},
},
},
signature = { enabled = true },
sources = {
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
score_offset = 100,
},
},
},
fuzzy = { implementation = "prefer_rust" },
})
end,
onUpdate = function()
vim.notify("Building blink.cmp", vim.log.levels.INFO)
local cmd
if vim.fn.executable("nix") == 1 then
cmd = { "nix", "run", ".#build-plugin" }
elseif vim.fn.executable("cargo") == 1 then
cmd = { "cargo", "build", "--release" }
else
print("either cargo or nix is needed to build blink.cmp fzf")
return
end
local obj = vim.system(cmd, { cwd = vim.pack.get({ "blink.cmp" })[1].path })
:wait()
if obj.code == 0 then
vim.notify("Building blink.cmp done", vim.log.levels.INFO)
else
vim.notify("Building blink.cmp failed", vim.log.levels.ERROR)
end
end,
}