mirror of
https://github.com/boxpositron/absolute-vim.git
synced 2026-02-28 03:30:36 +00:00
feat(nvim-cmp.lua): add custom source "otter" for otter completion in autocompletion sources
37 lines
1.1 KiB
Lua
37 lines
1.1 KiB
Lua
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
local lspkind = require("lspkind")
|
|
|
|
-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
|
|
|
cmp.setup({
|
|
completion = {
|
|
completeopt = "menu,menuone,preview,noselect",
|
|
},
|
|
snippet = { -- configure how nvim-cmp interacts with snippet engine
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
|
["<CR>"] = cmp.mapping.confirm({ select = false }), -- accept current selection
|
|
}),
|
|
-- sources for autocompletion
|
|
sources = cmp.config.sources({
|
|
{ name = "otter" }, -- custom source for otter completion
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" }, -- snippets
|
|
{ name = "buffer" }, -- text within current buffer
|
|
{ name = "path" }, -- file system paths
|
|
}),
|
|
-- configure lspkind for vs-code like pictograms in completion menu
|
|
formatting = {
|
|
format = lspkind.cmp_format({
|
|
maxwidth = 50,
|
|
ellipsis_char = "...",
|
|
}),
|
|
},
|
|
})
|