mirror of
https://github.com/pnx/dotfiles
synced 2026-07-02 14:33:40 +02:00
nvim/lua/user/plugins/editor/autocomplete.lua: use blink.cmp
This commit is contained in:
parent
2362a3ec2a
commit
b56933fe41
1 changed files with 40 additions and 86 deletions
|
|
@ -1,92 +1,46 @@
|
||||||
|
local icons = require('user.icons')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"hrsh7th/nvim-cmp",
|
'saghen/blink.cmp',
|
||||||
version = false,
|
lazy = false,
|
||||||
event = "InsertEnter",
|
version = 'v0.*',
|
||||||
|
build = 'cargo build --release',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-buffer", -- autocomplete from buffer
|
{ 'L3MON4D3/LuaSnip', version = 'v2.*' },
|
||||||
"hrsh7th/cmp-path", -- autocomplete from filesystem
|
|
||||||
"f3fora/cmp-spell",
|
|
||||||
},
|
},
|
||||||
opts = function()
|
opts = {
|
||||||
local cmp = require("cmp")
|
keymap = { preset = 'enter' },
|
||||||
local utils = require("user.utils.cmp")
|
appearance = {
|
||||||
local format = require("user.utils.cmp_format")
|
nerd_font_variant = 'mono',
|
||||||
-- local lspkind = require("user.utils.lspkind")
|
kind_icons = icons.symbols
|
||||||
|
|
||||||
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",
|
|
||||||
},
|
|
||||||
view = {
|
|
||||||
entries = { name = "custom", selection_order = "near_cursor" },
|
|
||||||
},
|
|
||||||
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 = {
|
sources = {
|
||||||
{ name = "nvim_lsp" },
|
default = { 'lsp', 'path', 'luasnip', 'buffer' },
|
||||||
{ 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,
|
|
||||||
},
|
},
|
||||||
},
|
snippets = {
|
||||||
},
|
expand = function(snippet) require('luasnip').lsp_expand(snippet) end,
|
||||||
experimental = {
|
active = function(filter)
|
||||||
ghost_text = {
|
if filter and filter.direction then
|
||||||
hl_group = "NonText",
|
return require('luasnip').jumpable(filter.direction)
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
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
|
||||||
|
return require('luasnip').in_snippet()
|
||||||
end,
|
end,
|
||||||
|
jump = function(direction) require('luasnip').jump(direction) end,
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
menu = {
|
||||||
|
winblend = 5,
|
||||||
|
},
|
||||||
|
documentation = {
|
||||||
|
auto_show = true,
|
||||||
|
window = {
|
||||||
|
winblend = 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ghost_text = {
|
||||||
|
enabled = true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
signature = { enabled = true }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue