2 -- mostly got this stuff from here: https://raw.githubusercontent.com/tjdevries/config_manager/master/xdg_config/nvim/after/plugin/completion.lua
3 vim.opt.completeopt = { "menu", "menuone", "noselect" }
5 -- Don't show the dumb matching stuff.
6 vim.opt.shortmess:append "c"
9 local ok, lspkind = pcall(require, "lspkind")
16 local cmp = require "cmp"
20 ["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
21 ["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
22 ["<C-d>"] = cmp.mapping.scroll_docs(-4),
23 ["<C-f>"] = cmp.mapping.scroll_docs(4),
24 ["<C-e>"] = cmp.mapping.abort(),
25 ["<c-y>"] = cmp.mapping(
27 behavior = cmp.ConfirmBehavior.Insert,
33 ["<c-space>"] = cmp.mapping {
34 i = cmp.mapping.complete(),
39 if not cmp.confirm { select = true } then
49 ["<tab>"] = cmp.config.disable,
52 ["<c-q>"] = cmp.mapping.confirm {
53 behavior = cmp.ConfirmBehavior.Replace,
61 -- Youtube: Could enable this only for lua, but nvim_lua handles that already.
62 { name = "nvim_lua" },
63 { name = "nvim_lsp" },
65 { name = "buffer", keyword_length = 3 },
69 -- TODO: Would be cool to add stuff like "See variable names before method names" in rust, or something like that.
71 cmp.config.compare.offset,
72 cmp.config.compare.exact,
73 cmp.config.compare.score,
75 -- copied from cmp-under, but I don't think I need the plugin for this.
76 -- I might add some more of my own.
77 function(entry1, entry2)
78 local _, entry1_under = entry1.completion_item.label:find "^_+"
79 local _, entry2_under = entry2.completion_item.label:find "^_+"
80 entry1_under = entry1_under or 0
81 entry2_under = entry2_under or 0
82 if entry1_under > entry2_under then
84 elseif entry1_under < entry2_under then
89 cmp.config.compare.kind,
90 cmp.config.compare.sort_text,
91 cmp.config.compare.length,
92 cmp.config.compare.order,
98 -- expand = function(args)
99 -- require("luasnip").lsp_expand(args.body)
104 -- Youtube: How to set up nice formatting for your sources.
105 format = lspkind.cmp_format {
113 gh_issues = "[issues]",