diff options
author | Christian Segundo | 2024-02-18 08:19:51 +0100 |
---|---|---|
committer | Christian Segundo | 2024-02-18 08:19:51 +0100 |
commit | 85d7d7c082bd84d3c701ceec3d477ee37db5c827 (patch) | |
tree | b78f09285c5120783f94cf9c2465a46439af2b71 /lua/plugins/lsp/cmp.lua | |
parent | 7869bf2c310fbed680abd01d45a17057f857bf30 (diff) | |
download | config-85d7d7c082bd84d3c701ceec3d477ee37db5c827.tar.gz |
bootstrap
Diffstat (limited to 'lua/plugins/lsp/cmp.lua')
-rw-r--r-- | lua/plugins/lsp/cmp.lua | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/lua/plugins/lsp/cmp.lua b/lua/plugins/lsp/cmp.lua new file mode 100644 index 0000000..004c265 --- /dev/null +++ b/lua/plugins/lsp/cmp.lua @@ -0,0 +1,97 @@ +return { + "hrsh7th/nvim-cmp", + opts = { + sources = { + { name = "ledger" }, + { + name = "luasnip", + option = { + show_autosnippets = true, + use_show_condition = true, + }, + }, + { name = "nvim_lsp", priority = 1 }, + { name = "nvim_lsp_signature_help" }, + { name = "nvim_lua" }, + { name = "path" }, + { name = "emoji" }, + }, + formatting = { + format = { + mode = "symbol_text", + maxwidth = 50, + before = function(entry, vim_item) + return vim_item + end, + menu = { + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + luasnip = "[LuaSnip]", + nvim_lua = "[Lua]", + latex_symbols = "[Latex]", + }, + }, + }, + }, + config = function(_, opts) + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + cmp.setup({ + sources = opts.sources, + --experimental = { ghost_text = { hl_group = "Comment" } }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + formatting = { format = lspkind.cmp_format(opts.formatting.format) }, + mapping = { + ["<C-p>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + ["<C-n>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + ["<C-l>"] = cmp.mapping(function(fallback) + if luasnip.choice_active() then + luasnip.change_choice(1) + else + fallback() + end + end, { "i", "s" }), + ["<C-d>"] = 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({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, -- Automatically select first item on CR + }), + }, + }) + end, + dependencies = { + { "L3MON4D3/LuaSnip" }, + { "hrsh7th/cmp-emoji" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-nvim-lsp-signature-help" }, + { "hrsh7th/cmp-nvim-lua" }, + { "hrsh7th/cmp-path" }, + { "onsails/lspkind.nvim" }, + { "saadparwaiz1/cmp_luasnip" }, + { "someone-stole-my-name/cmp-ledger" }, + }, +} |