summaryrefslogtreecommitdiff
path: root/lua/plugins/nvim-cmp.lua
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-01-22 00:44:19 +0000
committermhsn <mail@mhsn.net>2025-01-22 00:44:19 +0000
commitdc17ab2fb051efceafddc3b97ebe9f67c775e9b7 (patch)
treeb9c65af3f8d64f1bd5f48488afd69f2596ab4dec /lua/plugins/nvim-cmp.lua
parentc0ee49298161bccb75b9e23ed64fe80aacec2fd4 (diff)
downloadnvim-dc17ab2fb051efceafddc3b97ebe9f67c775e9b7.tar.gz
nvim-dc17ab2fb051efceafddc3b97ebe9f67c775e9b7.zip
split plugins into separate files and other changes
Diffstat (limited to 'lua/plugins/nvim-cmp.lua')
-rw-r--r--lua/plugins/nvim-cmp.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua
new file mode 100644
index 0000000..c4dd59d
--- /dev/null
+++ b/lua/plugins/nvim-cmp.lua
@@ -0,0 +1,48 @@
+return {
+ {
+ "L3MON4D3/LuaSnip",
+ version = "v2.*",
+ },
+ {
+ "hrsh7th/nvim-cmp",
+ dependencies = {
+ "hrsh7th/cmp-buffer",
+ "hrsh7th/cmp-nvim-lsp",
+ "hrsh7th/cmp-path",
+ "L3MON4D3/LuaSnip",
+ },
+ opts = function()
+ local cmp = require("cmp")
+ return {
+ snippet = {
+ expand = function(args)
+ require("luasnip").lsp_expand(args.body)
+ end,
+ },
+ mapping = cmp.mapping.preset.insert({
+ ["<C-h>"] = cmp.mapping.scroll_docs(-4),
+ ["<C-l>"] = cmp.mapping.scroll_docs(4),
+ ["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-Space>"] = cmp.mapping(function(fallback)
+ -- Confirm with C-Space. If none selected, confirm first.
+ if cmp.visible() then
+ local entry = cmp.get_selected_entry()
+ if not entry then
+ cmp.select_next_item({ behaviour = cmp.SelectBehavior.Select })
+ end
+ cmp.confirm()
+ else
+ fallback()
+ end
+ end, { "i", "s", "c" }),
+ }),
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "path" },
+ { name = "buffer" },
+ }),
+ }
+ end,
+ },
+}