1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 03:14:55 +02:00

nvim/lua/user/plugins/editor/autocomplete.lua: use blink.cmp

This commit is contained in:
Henrik Hautakoski 2024-12-17 22:53:42 +01:00
parent 2362a3ec2a
commit b56933fe41

View file

@ -1,92 +1,46 @@
local icons = require('user.icons')
return {
"hrsh7th/nvim-cmp",
version = false,
event = "InsertEnter",
'saghen/blink.cmp',
lazy = false,
version = 'v0.*',
build = 'cargo build --release',
dependencies = {
"hrsh7th/cmp-buffer", -- autocomplete from buffer
"hrsh7th/cmp-path", -- autocomplete from filesystem
"f3fora/cmp-spell",
{ 'L3MON4D3/LuaSnip', version = 'v2.*' },
},
opts = function()
local cmp = require("cmp")
local utils = require("user.utils.cmp")
local format = require("user.utils.cmp_format")
-- local lspkind = require("user.utils.lspkind")
local selectPrev = utils.selectPrev({ behavior = cmp.SelectBehavior.Select })
local selectNext = utils.selectNext({ behavior = cmp.SelectBehavior.Select })
return {
preselect = false,
completion = {
completeopt = "menu,menuone,longest,popup",
opts = {
keymap = { preset = 'enter' },
appearance = {
nerd_font_variant = 'mono',
kind_icons = icons.symbols
},
sources = {
default = { 'lsp', 'path', 'luasnip', 'buffer' },
},
snippets = {
expand = function(snippet) require('luasnip').lsp_expand(snippet) end,
active = function(filter)
if filter and filter.direction then
return require('luasnip').jumpable(filter.direction)
end
return require('luasnip').in_snippet()
end,
jump = function(direction) require('luasnip').jump(direction) end,
},
completion = {
menu = {
winblend = 5,
},
view = {
entries = { name = "custom", selection_order = "near_cursor" },
documentation = {
auto_show = true,
window = {
winblend = 5
}
},
window = {
documentation = {
border = { "", "", "", "", "", "", "", " " },
},
completion = {
scrolloff = 4,
},
},
mapping = {
["<Up>"] = selectPrev,
["<S-Tab>"] = selectPrev,
["<Down>"] = selectNext,
["<Tab>"] = selectNext,
["<C-c>"] = cmp.mapping.abort(),
["<CR>"] = utils.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
},
-- snippet = {
-- expand = function(args)
-- require("luasnip").lsp_expand(args.body)
-- end,
-- },
formatting = {
fields = { "kind", "abbr", "menu" },
format = format({
symbol_map = require('user.utils.cmp_symbols'),
widths = {
menu = 0,
}
}),
},
sources = {
{ name = "nvim_lsp" },
{ name = 'nvim_lsp_signature_help' },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
{
name = "spell",
keyword_length = 3,
option = {
keep_all_entries = false,
enable_in_context = function()
return require('cmp.config.context').in_treesitter_capture('spell')
end,
preselect_correct_word = true,
},
},
},
experimental = {
ghost_text = {
hl_group = "NonText",
},
},
}
end,
config = function(_, opts)
local cmp = require("cmp")
cmp.setup(opts)
-- insert () on function completion using autopairs
local has_autopair, autopair = pcall(require, "nvim-autopairs.completion.cmp")
if has_autopair then
cmp.event:on("confirm_done", autopair.on_confirm_done())
end
end,
ghost_text = {
enabled = true,
}
},
signature = { enabled = true }
}
}