local cmp = require("cmp") require("luasnip.loaders.from_vscode").lazy_load() local function border(hl_name) return { { "╭", hl_name }, { "─", hl_name }, { "╮", hl_name }, { "│", hl_name }, { "╯", hl_name }, { "─", hl_name }, { "╰", hl_name }, { "│", hl_name }, } end cmp.setup { completion = { completeopt = "menu,menuone", }, window = { completion = { border = border "CmpBorder", side_padding = 1, winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:None", scrollbar = true, }, documentation = { border = border "CmpDocBorder", winhighlight = "Normal:CmpDoc", }, }, snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, mapping = { [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), [""] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Insert, select = true, }, [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif require("luasnip").expand_or_jumpable() then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif require("luasnip").jumpable(-1) then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") else fallback() end end, { "i", "s" }), }, sources = { { name = "nvim_lsp" }, { name = "luasnip" }, { name = "buffer" }, { name = "nvim_lua" }, { name = "path" }, }, } local signs = { Error = "󰀨 ", Warn = " ", Hint = " ", Info = " " } for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, { text = icon, texthl= hl, numhl = hl }) end