Worked on cmp completion

This commit is contained in:
Nikurasu 2023-02-17 12:34:39 +01:00
parent 7ed897230b
commit 58df3fd422
Signed by: Nikurasu
GPG key ID: 9E7F14C03EF1F271

View file

@ -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 {
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, {'i', 's'})
}
}