add treesitter, which-key, nvim-cmp

This commit is contained in:
2025-04-23 09:23:46 -05:00
parent 842b0218b9
commit 88efb97344
7 changed files with 159 additions and 12 deletions

View File

@@ -0,0 +1,84 @@
return {
'hrsh7th/nvim-cmp',
dependencies = {
-- Core completion sources
'hrsh7th/cmp-nvim-lsp',
-- 'hrsh7th/cmp-treesitter', -- Uncomment if you have a cmp-treesitter source
-- Cmdline support
'hrsh7th/cmp-cmdline',
-- Icons
'onsails/lspkind-nvim',
-- Extras you can enable later:
-- 'windwp/nvim-autopairs', -- autopairs integration
-- 'lukas-reineke/cmp-under-comparator', -- fuzzy sorting
},
config = function()
local cmp = require('cmp')
local lspkind = require('lspkind')
cmp.setup({
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text", -- or "symbol" for just icons, "text" for just text
maxwidth = 50,
}),
},
snippet = {
expand = function(args)
-- no-op, snippet engine not installed
end,
},
mapping = {
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-e>'] = cmp.mapping.abort(),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
-- { name = 'treesitter' }, -- Uncomment if you actually have cmp-treesitter
}),
-- Extras you can enable later:
-- window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
-- },
-- experimental = {
-- ghost_text = true,
-- },
})
-- Cmdline completion for : (commands & paths)
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' },
{ name = 'cmdline' },
}),
})
-- Search completion for / (buffer)
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' },
},
})
-- Autopairs integration (uncomment when you install nvim-autopairs)
-- require('nvim-autopairs').setup{}
-- local cmp_autopairs = require('nvim-autopairs.completion.cmp')
-- cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
-- Fuzzy sorting (uncomment when you install cmp-under-comparator)
-- table.insert(cmp.config.sorting.comparators, require('cmp-under-comparator').under)
end,
}