From 4c137ac067294ded0e6dadf252c279353c0442b1 Mon Sep 17 00:00:00 2001 From: Dinesh Salunke Date: Mon, 26 Jun 2023 23:23:11 +0530 Subject: [PATCH] refactor: add lspkind --- lua/plugins/coding.lua | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index 9b4971a..4e3a905 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -35,14 +35,33 @@ return { dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", + "hrsh7th/cmp-nvim-lua", + "mtoohey31/cmp-fish", "hrsh7th/cmp-path", "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp-signature-help", + "onsails/lspkind.nvim", }, opts = function() vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local cmp = require("cmp") + local border_opts = { + border = "single", + winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None", + } return { + formatting = { + fields = { + "abbr", + "kind", + "menu", + }, + format = require("lspkind").cmp_format({ + mode = "symbol", + maxwidth = 50, + ellipsis_char = "...", + }), + }, completion = { completeopt = "menu,menuone,noinsert", }, @@ -52,19 +71,23 @@ return { end, }, mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Replace, select = true }), }), sources = cmp.config.sources({ - { name = "path" }, { name = "nvim_lsp" }, - { name = "buffer", keyword_length = 5 }, - { name = "luasnip", keyword_length = 3 }, { name = "nvim_lsp_signature_help" }, + { name = "luasnip", keyword_length = 3 }, + { name = "buffer", keyword_length = 5 }, + { name = "path" }, }), + window = { + completion = cmp.config.window.bordered(border_opts), + documentation = cmp.config.window.bordered(border_opts), + }, } end, },