build core, basic and go variants and add template
This commit is contained in:
94
basic/nvim/plugconf/cmp.lua
Normal file
94
basic/nvim/plugconf/cmp.lua
Normal file
@@ -0,0 +1,94 @@
|
||||
local cmp = require 'cmp'
|
||||
local context = require 'cmp.config.context'
|
||||
local luasnip = require 'luasnip'
|
||||
|
||||
vim.o.completeopt = nil
|
||||
|
||||
-- General setup
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args) luasnip.lsp_expand(args.body) end,
|
||||
},
|
||||
window = {
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
formatting = {
|
||||
fields = { 'menu', 'abbr', 'kind' },
|
||||
format = function(entry, item)
|
||||
item.menu = ({
|
||||
nvim_lsp = 'λ',
|
||||
luasnip = '⋗',
|
||||
buffer = 'Ω',
|
||||
path = '🖫',
|
||||
})[entry.source.name]
|
||||
return item
|
||||
end,
|
||||
},
|
||||
preselect = cmp.PreselectMode.None,
|
||||
mapping = {
|
||||
-- Confirm, jump or select with tab
|
||||
['<tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.get_selected_entry() then
|
||||
cmp.confirm()
|
||||
elseif luasnip.jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
elseif luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
elseif cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
-- Jump back with shift tab
|
||||
['<s-tab>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
-- Navigate options with ctrl n and ctrl p
|
||||
['<c-n>'] = cmp.mapping(function(fallback)
|
||||
if not cmp.visible() then
|
||||
cmp.complete()
|
||||
else
|
||||
cmp.select_next_item()
|
||||
end
|
||||
end),
|
||||
['<c-p>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then cmp.select_prev_item() else fallback() end
|
||||
end),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'nvim_lua' },
|
||||
}, {
|
||||
{ name = 'buffer', keyword_length = 5 },
|
||||
{ name = 'path' },
|
||||
}),
|
||||
completion = {
|
||||
keyword_length = 3
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
-- Disable in comments
|
||||
enabled = function()
|
||||
return not context.in_syntax_group('Comment')
|
||||
end,
|
||||
}
|
||||
|
||||
-- Command line setup
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' },
|
||||
},{
|
||||
{ name = 'cmdline' },
|
||||
}),
|
||||
completion = {
|
||||
keyword_length = 2
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user