updated lsp config

This commit is contained in:
Saeed Afzal
2023-04-29 16:17:55 +01:00
parent 86cc9b52ec
commit 1d3df81f8f
6 changed files with 196 additions and 6 deletions

55
lua/plugins/cmp.lua Normal file
View File

@@ -0,0 +1,55 @@
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lua"
},
event = { "InsertEnter", "CmdlineEnter" },
config = function()
local cmp = require("cmp")
cmp.setup {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping.select_next_item(),
["<S-Tab>"] = cmp.mapping.select_prev_item()
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" }
}, {
{ name = "buffer" },
{ name = "path" }
})
}
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = { name = "buffer" }
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" }
}, {
{ name = "cmdline" }
})
})
end
}