add treesitter, which-key, nvim-cmp
This commit is contained in:
84
lua/dkelly/plugins/nvim-cmp.lua
Normal file
84
lua/dkelly/plugins/nvim-cmp.lua
Normal 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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user