dotfiles/config/neovim/after/plugin/completion.lua

75 lines
1.6 KiB
Lua
Raw Normal View History

local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then
return
end
vim.opt.shortmess:append "c"
cmp.setup {
snippet = {
expand = function(args)
2022-01-08 23:47:23 +00:00
luasnip.lsp_expand(args.body)
2022-01-09 00:07:35 +00:00
end,
},
mapping = cmp.mapping.preset.insert {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-e>"] = cmp.mapping.close(),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-y>"] = cmp.mapping.confirm { select = true },
["<tab>"] = cmp.config.disable,
},
sources = {
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "cmp_tabnine" },
{ name = "path" },
{ name = "luasnip" },
{ name = "buffer", keyword_length = 5, max_item_count = 5 },
},
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
formatting = {
2022-01-09 00:07:35 +00:00
format = require("lspkind").cmp_format {
with_text = true,
menu = {
buffer = "[buf]",
cmp_tabnine = "[tn]",
luasnip = "[snip]",
nvim_lsp = "[lsp]",
nvim_lua = "[lua]",
path = "[path]",
},
},
},
experimental = {
ghost_text = false,
native_menu = false,
},
}
vim.cmd [[
augroup DadbodSql
au!
autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer { sources = { { name = 'vim-dadbod-completion' } } }
augroup END
]]