diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-04-29 17:29:21 +0300 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-04-29 17:30:08 +0300 |
| commit | ed5c4406a97b0e4a0480ef071d1d75efb22cb881 (patch) | |
| tree | f1f25728d651785cb288f544ad7544ccddad2641 /.config/nvim/lua/cmp_helper.lua | |
| parent | 0e692de1352504a49b7d84c736880210f2c0365b (diff) | |
Configured nvim blink-cmp plugin, a few notes:
Added nvim-scissors to make snippets easier to configure
Added colorful-menu to make completions cooler (more like
IntelliJ/vsc*de), disabled for now until carbonight has colors for it
Removed nvim-cmp
Installed jq for formatting json snippets
Diffstat (limited to '.config/nvim/lua/cmp_helper.lua')
| -rw-r--r-- | .config/nvim/lua/cmp_helper.lua | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/.config/nvim/lua/cmp_helper.lua b/.config/nvim/lua/cmp_helper.lua deleted file mode 100644 index ffa3418..0000000 --- a/.config/nvim/lua/cmp_helper.lua +++ /dev/null @@ -1,143 +0,0 @@ --- Load cmp_opts -for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/snippets/*.lua', true)) do - loadfile(ft_path)() -end - -local luasnip = require('luasnip') -local lspkind = require('lspkind') -local cmp = require('cmp') - --- Enable paretheses for function completions -cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm_done()) - --- Helper functions -local function snippet_jump(jump_amount) - return cmp.mapping(function(fallback) - if luasnip.locally_jumpable(jump_amount) then - luasnip.jump(jump_amount) - else - fallback() - end - end, { 'i', 's' }) -end - -local function is_enabled() - local context = require('cmp.config.context') - - local is_in_comment = context.in_treesitter_capture('comment') or context.in_syntax_group('Comment') - if is_in_comment then - return false - end - - return true -end - -cmp.setup({ - enabled = is_enabled, - preselect = cmp.PreselectMode.None, - completion = { completeopt = 'menu,menuone,noinsert' }, - sources = cmp.config.sources({ - { name = 'luasnip' }, -- for snippets - { - name = 'nvim_lsp', - option = { - markdown_oxide = { - keyword_pattern = [[\(\k\| \|\/\|#\)\+]], - }, - }, - }, -- for lsp - { name = 'lazydev', group_index = 0 }, -- for lazydev.nvim - { name = 'path' }, -- for filesystem - }, {}), - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - window = { - documentation = cmp.config.window.bordered(), - completion = { - border = 'rounded', - winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,Search:None', - col_offset = -3, - side_padding = 0, - }, - }, - ---@diagnostic disable-next-line: missing-fields - sorting = { - comparators = { - cmp.config.compare.offset, - cmp.config.compare.exact, - cmp.config.compare.recently_used, - require('clangd_extensions.cmp_scores'), - cmp.config.compare.kind, - cmp.config.compare.sort_text, - cmp.config.compare.length, - cmp.config.compare.order, - }, - }, - mapping = { - ['<Tab>'] = snippet_jump(1), - ['<S-Tab>'] = snippet_jump(-1), - ['<C-Space>'] = cmp.mapping.complete(), -- invoke completion - ['<CR>'] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }), - ['<C-u>'] = cmp.mapping.scroll_docs(-4), - ['<C-d>'] = cmp.mapping.scroll_docs(4), - ['<C-c>'] = cmp.mapping.abort(), - ['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), - ['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), - }, - ---@diagnostic disable-next-line: missing-fields - formatting = { - fields = { 'kind', 'abbr', 'menu' }, - format = function(entry, vim_item) - local kind = lspkind.cmp_format({ mode = 'symbol_text', maxwidth = 50 })(entry, vim_item) - local strings = vim.split(kind.kind, '%s', { trimempty = true }) - kind.kind = ' ' .. (strings[1] or '') .. ' ' -- left (icon) - kind.menu = ' ' .. (strings[2] or '') .. '' -- right (text) - return kind - end, - }, -}) - --- -- Customization for Pmenu --- vim.api.nvim_set_hl(0, 'PmenuSel', { bg = '#282C34', fg = 'NONE' }) --- vim.api.nvim_set_hl(0, 'Pmenu', { fg = '#C5CDD9', bg = '#22252A' }) --- -vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { fg = '#ff8294', bg = 'NONE', strikethrough = true }) --- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { fg = '#82AAFF', bg = 'NONE', bold = true }) --- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { fg = '#82AAFF', bg = 'NONE', bold = true }) --- vim.api.nvim_set_hl(0, 'CmpItemMenu', { fg = '#C792EA', bg = 'NONE', italic = true }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindField', { fg = '#EED8DA', bg = '#B5585F' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { fg = '#EED8DA', bg = '#B5585F' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEvent', { fg = '#EED8DA', bg = '#B5585F' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindText', { fg = '#C3E88D', bg = '#9FBD73' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEnum', { fg = '#C3E88D', bg = '#9FBD73' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { fg = '#C3E88D', bg = '#9FBD73' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindConstant', { fg = '#FFE082', bg = '#D4BB6C' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindConstructor', { fg = '#FFE082', bg = '#D4BB6C' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindReference', { fg = '#FFE082', bg = '#D4BB6C' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindStruct', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindClass', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindModule', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindOperator', { fg = '#EADFF0', bg = '#A377BF' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { fg = '#C5CDD9', bg = '#7E8294' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindFile', { fg = '#C5CDD9', bg = '#7E8294' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindUnit', { fg = '#F5EBD9', bg = '#D4A959' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindSnippet', { fg = '#F5EBD9', bg = '#D4A959' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindFolder', { fg = '#F5EBD9', bg = '#D4A959' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindValue', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEnumMember', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { fg = '#D8EEEB', bg = '#58B5A8' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindColor', { fg = '#D8EEEB', bg = '#58B5A8' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindTypeParameter', { fg = '#D8EEEB', bg = '#58B5A8' }) |
