Added base folke setup
This commit is contained in:
60
lua/plugins/cmp.lua
Normal file
60
lua/plugins/cmp.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
local M = {
|
||||
event = "InsertEnter",
|
||||
module = "cmp",
|
||||
requires = {
|
||||
{ "hrsh7th/cmp-nvim-lsp", module = "cmp_nvim_lsp" },
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-emoji",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"dmitmel/cmp-cmdline-history",
|
||||
"hrsh7th/cmp-path",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-nvim-lsp-signature-help",
|
||||
},
|
||||
}
|
||||
|
||||
function M.config()
|
||||
vim.o.completeopt = "menuone,noselect"
|
||||
|
||||
-- Setup nvim-cmp.
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert",
|
||||
},
|
||||
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.close(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
{ name = "emoji" },
|
||||
{ name = "nvim_lsp_signature_help" },
|
||||
}),
|
||||
formatting = {
|
||||
format = require("plugins.lsp.kind").cmp_format(),
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = {
|
||||
hl_group = "LspCodeLens",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
|
||||
end
|
||||
|
||||
return M
|
Reference in New Issue
Block a user