diff options
| author | seth <[email protected]> | 2024-07-13 20:12:35 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-07-14 13:47:39 -0400 |
| commit | 5ec30e9a2b9047713c060c90a5e7930fafc2a3d6 (patch) | |
| tree | 4c10736c3f5a69d2e214575f0ed1fc0e6d3f2f90 /plugin/cmp.lua | |
| parent | c9fb0eded5c69af78a1af12e5fdce7b347c40da3 (diff) | |
flatten plugin structure
Diffstat (limited to 'plugin/cmp.lua')
| -rw-r--r-- | plugin/cmp.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/plugin/cmp.lua b/plugin/cmp.lua new file mode 100644 index 0000000..10c750f --- /dev/null +++ b/plugin/cmp.lua @@ -0,0 +1,47 @@ +if vim.g.did_load_cmp_plugin then + return +end +vim.g.did_load_cmp_plugin = true + +local cmp = require("cmp") + +cmp.setup({ + completion = { + compleopt = "menu,menuone,insert", + }, + + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + mapping = { + ["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + ["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.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({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + else + fallback() + end + end, + + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }), + }, + + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "async_path" }, + { name = "buffer" }, + { name = "rg" }, + }), +}) |
