neovim configuration using rocks.nvim plugin manager
at main 2.8 kB view raw
1--[[ 2local cmp = require("cmp") 3 4cmp.setup({ 5 snippet = { 6 expand = function(args) 7 vim.snippet.expand(args.body) 8 end, 9 }, 10 mapping = cmp.mapping.preset.insert({ 11 ["<C-n>"] = cmp.mapping(function () 12 if not cmp.visible() then 13 cmp.complete() 14 else 15 cmp.select_next_item() 16 end 17 end), 18 ["<C-p>"] = cmp.mapping.select_prev_item(), 19 ["<C-d>"] = cmp.mapping.scroll_docs(4), 20 ["<C-u>"] = cmp.mapping.scroll_docs(-4), 21 ["<C-e>"] = cmp.mapping.abort(), 22 ["<C-c>"] = cmp.mapping.close(), 23 ["<c-y>"] = cmp.mapping.confirm({ select = true }), 24 }), 25 completion = { 26 -- https://github.com/hrsh7th/nvim-cmp/blob/v0.0.1/lua/cmp/config/default.lua#L38 27 autocomplete = false, 28 -- keyword_pattern = "", 29 -- keyword_length = 2, 30 }, 31 sources = cmp.config.sources({ 32 { name = "nvim_lsp" }, 33 -- { name = "luasnip" }, 34 { name = "neorg" }, 35 { name = "path" }, 36 { name = "crates" }, 37 { name = "buffer" }, 38 }), 39 -- sorting = { 40 -- comparators = { 41 -- cmp.config.compare.offset, 42 -- cmp.config.compare.exact, 43 -- cmp.config.compare.score, 44 -- cmp.config.compare.recently_used, 45 -- -- require("cmp-under-comparator").under, 46 -- cmp.config.compare.kind, 47 -- cmp.config.compare.sort_text, 48 -- cmp.config.compare.length, 49 -- cmp.config.compare.order, 50 -- }, 51 -- }, 52 formatting = { 53 fields = { "abbr", "kind", "menu" }, 54 format = function(entry, item) 55 -- local icons = require("config.icons").kinds 56 -- if icons[item.kind] then 57 -- item.kind = icons[item.kind] .. item.kind 58 -- end 59 local label = item.abbr 60 local truncated_label = vim.fn.strcharpart(label, 0, 30) 61 if truncated_label ~= label then 62 item.abbr = truncated_label .. "…" 63 end 64 -- stylua: ignore 65 item.menu = ({ 66 nvim_lsp = "[LSP]", 67 luasnip = "[SNIP]", 68 luasnip_choice = "[SNIP]", 69 buffer = "[BUF]", 70 path = "[PATH]", 71 emoji = "[EMOJI]", 72 crates = "[CRATES]", 73 npm = "[NPM]", 74 neorg = "[NEORG]", 75 orgmode = "[ORG]", 76 git = "[GIT]", 77 })[entry.source.name] 78 return item 79 end, 80 }, 81 experimental = { 82 ghost_text = false, 83 }, 84}) 85]]