From 783bb72a6c9d093671df6fe889dbe0838723ae14 Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 13 Jan 2025 21:17:10 -0500 Subject: [PATCH] further refine cmp plugin config (still WIP) --- lua/plugins/cmp.lua | 105 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 2 deletions(-) diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index e159a17..e297e16 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -48,8 +48,109 @@ if vim.g.useblinkcmp then or not vim.tbl_contains({ '/', '?' }, vim.fn.getcmdtype()) end, }, + list = { + selection = { + preselect = function(ctx) + return ctx.mode ~= 'cmdline' + and not require('blink.cmp').snippet_active({ direction = 1 }) + end, + auto_insert = true, + }, + }, + }, + snippets = { + preset = 'luasnip', + }, + sources = { + -- default = { + -- 'digraphs', + -- -- 'cmp_yanky', + -- 'emoji', + -- 'dictionary', + -- 'snippets', + -- }, + -- providers = { + -- digraphs = { + -- name = 'digraphs', + -- module = 'blink.compat.source', + -- score_offset = -3, + -- opts = { + -- cache_digraphs_on_start = true, + -- }, + -- }, + -- -- cmp_yanky = { + -- -- name = 'cmp_yanky', + -- -- module = 'blink.compat.source', + -- -- score_offset = -3, + -- -- opts = { + -- -- -- only suggest items which match the current filetype + -- -- onlyCurrentFiletype = false, + -- -- -- only suggest items with a minimum length + -- -- minLength = 3, + -- -- }, + -- -- }, + -- emoji = { + -- module = 'blink-emoji', + -- name = 'Emoji', + -- score_offset = 15, -- Tune by preference + -- opts = { insert = true }, -- Insert emoji (default) or complete its name + -- }, + -- dictionary = { + -- module = 'blink-cmp-dictionary', + -- name = 'Dict', + -- opts = { + -- get_command = { + -- 'rg', -- make sure this command is available in your system + -- '--color=never', + -- '--no-line-number', + -- '--no-messages', + -- '--no-filename', + -- '--ignore-case', + -- '--', + -- '${prefix}', -- this will be replaced by the result of 'get_prefix' function + -- vim.fn.expand('~/.config/nvim/dict/en_dict.txt'), -- where you dictionary is + -- }, + -- documentation = { + -- enable = true, -- enable documentation to show the definition of the word + -- get_command = { + -- 'dict', -- make sure this command is available in your system + -- '${word}', -- this will be replaced by the word to search + -- ' -s lev', + -- }, + -- }, + -- }, + -- }, + -- }, + cmdline = function() + local type = vim.fn.getcmdtype() + -- Search forward and backward + if type == '/' or type == '?' then + return { 'buffer' } + end + -- Commands + if type == ':' or type == '@' then + return { 'cmdline' } + end + return {} + end, + }, + keymap = { + preset = 'enter', + [''] = { 'select_and_accept' }, + cmdline = { + preset = 'enter', + [''] = { 'select_and_accept' }, + [''] = { 'select_prev', 'fallback' }, + [''] = { 'select_next', 'fallback' }, + }, }, }, + -- dependencies = { + -- { 'dmitmel/cmp-digraphs' }, + -- { 'chrisgrieser/cmp_yanky' }, + -- { 'moyiz/blink-emoji.nvim' }, + -- { 'Kaiser-Yang/blink-cmp-dictionary' }, + -- }, }, { -- Blink compat 'saghen/blink.compat', @@ -67,7 +168,7 @@ if vim.g.useblinkcmp then } end --- Else use classic cmp +-- Else use nvim-cmp return { { import = 'lazyvim.plugins.extras.coding.nvim-cmp' }, { -- cmp @@ -166,7 +267,7 @@ return { end, { 'i', 's' }), }), sources = { - { name = 'ecolog' }, + -- { name = 'ecolog' }, { name = 'nvim_lsp', priority = 1000 }, { name = 'luasnip', priority = 750 }, { name = 'path', priority = 250 },