diff options
author | Squibid <me@zacharyscheiman.com> | 2025-04-17 11:41:32 -0500 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2025-04-17 11:41:32 -0500 |
commit | 3094bf2a3983b375f4adeccd25c3b12bbbded2aa (patch) | |
tree | 860f0a9cfd3d83bf73837e2f3a0ccc1b0c75cf5b /lua/conf/plugins/cmp.lua | |
parent | 8eaa615596be321a3be12378c5e7d65cc7e482b6 (diff) | |
download | nvim-3094bf2a3983b375f4adeccd25c3b12bbbded2aa.tar.gz nvim-3094bf2a3983b375f4adeccd25c3b12bbbded2aa.tar.bz2 nvim-3094bf2a3983b375f4adeccd25c3b12bbbded2aa.zip |
a lot more stuff
Diffstat (limited to 'lua/conf/plugins/cmp.lua')
-rw-r--r-- | lua/conf/plugins/cmp.lua | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/lua/conf/plugins/cmp.lua b/lua/conf/plugins/cmp.lua index ebca929..d6d7766 100644 --- a/lua/conf/plugins/cmp.lua +++ b/lua/conf/plugins/cmp.lua @@ -1,14 +1,22 @@ +local lsp = require('core.lsp.functions') + return { 'hrsh7th/nvim-cmp', requires = { 'nvim-treesitter/nvim-treesitter', - 'lukas-reineke/cmp-under-comparator' -- better results + 'lukas-reineke/cmp-under-comparator', -- better results + 'xzbdmw/colorful-menu.nvim' -- fancy colors }, -- suppliers for completions (they require nvim-cmp to be loaded before they are) deps = { 'hrsh7th/cmp-buffer', -- buffers 'FelipeLema/cmp-async-path', -- path - 'hrsh7th/cmp-nvim-lsp', -- lsp + { 'hrsh7th/cmp-nvim-lsp', + function() + -- add lsp capabilities + lsp.add_capabilities(require('cmp_nvim_lsp').default_capabilities()) + end + }, -- lsp 'hrsh7th/cmp-nvim-lsp-signature-help', -- completion information { 'L3MON4D3/cmp-luasnip-choice', -- luasnip requires = 'L3MON4D3/LuaSnip' @@ -19,6 +27,7 @@ return { 'hrsh7th/nvim-cmp', local cmp = require('cmp') local luasnip = require('luasnip') + -- setup cmp cmp.setup { -- disable when in comments enabled = function() @@ -44,8 +53,8 @@ return { 'hrsh7th/nvim-cmp', -- how to sort results sorting = { comparators = { - cmp.config.compare.offset, cmp.config.compare.exact, + cmp.config.compare.offset, cmp.config.compare.score, require('cmp-under-comparator').under, cmp.config.compare.kind, @@ -80,16 +89,24 @@ return { 'hrsh7th/nvim-cmp', formatting = { fields = { 'menu', 'abbr', 'kind' }, format = function(entry, item) + local hl_info = require("colorful-menu").cmp_highlights(entry) local menu_icon = { nvim_lsp = 'λ', - nvim_lua = 'v', luasnip = '%', buffer = '@', path = '#', async_path = '#' } + -- add a little icon item.menu = menu_icon[entry.source.name] + + -- add highlights + if hl_info ~= nil then + item.abbr_hl_group = hl_info.highlights + item.abbr = hl_info.text + end + return item end }, @@ -107,25 +124,14 @@ return { 'hrsh7th/nvim-cmp', -- mappings mapping = cmp.mapping.preset.insert { - ["<C-y>"] = cmp.mapping(function() - cmp.confirm({ select = true }) - end, { "i", "c" }), - - ["<C-n>"] = cmp.mapping(function() - if cmp.visible() then - cmp.select_next_item() - end - end), - - ["<C-p>"] = cmp.mapping(function() - if cmp.visible() then - cmp.select_prev_item() - end - end), - + ["<C-y>"] = cmp.mapping.confirm { + select = true + }, + ["<C-n>"] = cmp.mapping.select_next_item(), + ["<C-p>"] = cmp.mapping.select_prev_item(), ["<C-u>"] = cmp.mapping.scroll_docs(-4), ["<C-d>"] = cmp.mapping.scroll_docs(4), - ['<ESC>'] = cmp.mapping.close() + ["<ESC>"] = cmp.mapping.close() } } end |