1
Fork 0
dots/nvim/lua/plugins/completion.lua

43 lines
974 B
Lua
Raw Normal View History

2023-08-21 09:56:16 +00:00
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
2024-08-21 06:25:00 +00:00
"hrsh7th/cmp-buffer",
2024-04-19 14:17:03 +00:00
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip"
2023-08-21 09:56:16 +00:00
},
config = function()
local cmp = require("cmp")
2024-08-21 06:25:00 +00:00
vim.opt.completeopt = {"menu", "menuone", "noinsert"}
2023-08-21 09:56:16 +00:00
cmp.setup {
2024-04-19 14:17:03 +00:00
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end
},
2023-08-21 09:56:16 +00:00
mapping = cmp.mapping.preset.insert {
2024-08-21 06:25:00 +00:00
['<C-Space>'] = cmp.mapping.complete(),
2023-08-30 02:00:57 +00:00
["<C-Y>"] = function(fallback)
2023-08-21 09:56:16 +00:00
if cmp.visible() then
cmp.confirm { select=true }
else
fallback()
end
end
},
sources = {
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "buffer" },
{ name = "path" }
},
experimental = {
native_menu = false,
ghost_text = { hl_group = "Comment" }
}
}
end
}