From 0f886683f00d9b8be979bd0138a2f1144c26e5d1 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 29 Dec 2024 12:02:45 +0100 Subject: [PATCH] nvim/lua/user/plugins/editor/autocomplete.lua: update --- nvim/lua/user/plugins/editor/autocomplete.lua | 60 +++++++++++++++++-- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/nvim/lua/user/plugins/editor/autocomplete.lua b/nvim/lua/user/plugins/editor/autocomplete.lua index 4f0cd82..0a41ac7 100644 --- a/nvim/lua/user/plugins/editor/autocomplete.lua +++ b/nvim/lua/user/plugins/editor/autocomplete.lua @@ -3,19 +3,54 @@ local icons = require('user.icons') return { 'saghen/blink.cmp', lazy = false, - version = 'v0.*', build = 'cargo build --release', dependencies = { { 'L3MON4D3/LuaSnip', version = 'v2.*' }, }, opts = { - keymap = { preset = 'enter' }, + keymap = { + [''] = { 'select_prev', 'fallback' }, + [''] = { 'select_next', 'fallback' }, + [''] = { 'select_prev', 'fallback' }, + [''] = { 'select_next', 'fallback' }, + [''] = { + function(cmp) + if cmp.snippet_active() then + return cmp.accept() + else + return cmp.select_prev() + end + end, + 'snippet_backward', + 'fallback' + }, + + [''] = { + function(cmp) + if cmp.snippet_active() then + return cmp.accept() + else + return cmp.select_next() + end + end, + 'snippet_forward', + 'fallback' + }, + [''] = { 'accept', 'fallback' }, + }, appearance = { nerd_font_variant = 'mono', kind_icons = icons.symbols }, sources = { - default = { 'lsp', 'path', 'luasnip', 'buffer' }, + default = function(_) + local success, node = pcall(vim.treesitter.get_node) + if success and node and vim.tbl_contains({ 'comment', 'line_comment', 'block_comment' }, node:type()) then + return { 'buffer' } + else + return { 'lsp', 'path', 'luasnip', 'buffer' } + end + end }, snippets = { expand = function(snippet) require('luasnip').lsp_expand(snippet) end, @@ -29,18 +64,31 @@ return { }, completion = { menu = { - winblend = 5, + min_width = 18, + winblend = 10, + draw = { + columns = { + { "kind_icon" }, + { "label", "label_description", "source_name", gap = 1 }, + }, + } }, documentation = { auto_show = true, window = { - winblend = 5 + winblend = 10 } }, ghost_text = { enabled = true, } }, - signature = { enabled = true } + signature = { + enabled = true, + window = { + scrollbar = false, + winblend = 10, + } + } } }