From 58df3fd4226544844ca1562c74b1a14bb070f1a3 Mon Sep 17 00:00:00 2001 From: Nikurasu Date: Fri, 17 Feb 2023 12:34:39 +0100 Subject: [PATCH] Worked on cmp completion --- nvim/init.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nvim/init.lua b/nvim/init.lua index df8493f..1aa9627 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -13,7 +13,7 @@ require('packer').startup(function(use) use 'nvim-treesitter/nvim-treesitter' use { 'hrsh7th/nvim-cmp', - requires = { 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lua' } + requires = { 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lua', 'onsails/lspkind.nvim' } } if is_bootstrap then require('packer').sync() @@ -33,6 +33,7 @@ end -- Some basic settings vim.wo.number = true vim.wo.relativenumber = true +vim.o.pumheight = 20 -- Additional keybinds if lsp running local on_attach = function(client, bufnr) @@ -71,6 +72,7 @@ require('nvim-treesitter.configs').setup{ -- autocompletion local cmp = require 'cmp' +local lspkind = require 'lspkind' cmp.setup { sources = { { name = 'nvim_lsp' }, @@ -78,5 +80,17 @@ cmp.setup { { name = 'cmdline' }, { name = 'path' }, { name = 'nvim-lua' } + }, + formatting = { + format = lspkind.cmp_format() + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, {'i', 's'}) } }