diff options
| author | delta <darkussdelta@gmail.com> | 2026-04-17 08:10:30 +0200 |
|---|---|---|
| committer | delta <darkussdelta@gmail.com> | 2026-04-17 08:10:30 +0200 |
| commit | a7c79cb5a04562be10347856642a80f0c4be89fc (patch) | |
| tree | 98fac95855d84f5037a1c6f44061cbe94b550600 /.config/nvim/lua/plugins/nvim-cmp.lua | |
| parent | 225eeafcea67d63a608f9c666faf2a2ef014be4a (diff) | |
Diffstat (limited to '.config/nvim/lua/plugins/nvim-cmp.lua')
| -rw-r--r-- | .config/nvim/lua/plugins/nvim-cmp.lua | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..d95d0bc --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,64 @@ +return { + "hrsh7th/nvim-cmp", + opts = function() + vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) + local cmp = require "cmp" + local defaults = require "cmp.config.default"() + return { + enabled = function() + local context = require "cmp.config.context" + if vim.api.nvim_get_mode().mode == "c" then + return true + else + return not context.in_treesitter_capture "comment" and not context.in_syntax_group "Comment" + end + end, + + completion = { + completeopt = "menu,menuone,noinsert", + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert { + ["<C-j>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + ["<C-k>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + ["<C-b>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<S-CR>"] = cmp.mapping.abort(), + ["<CR>"] = cmp.mapping.confirm { select = false }, + }, + sources = cmp.config.sources { + { name = "nvim_lsp" }, + { name = "path" }, + }, + formatting = { + format = function(_, item) + local icons = require("icons").kinds + if icons[item.kind] then + item.kind = icons[item.kind] .. item.kind + end + return item + end, + }, + experimental = { + ghost_text = { + hl_group = "CmpGhostText", + }, + }, + sorting = defaults.sorting, + } + end, + dependencies = { + { "L3MON4D3/LuaSnip", build = "make install_jsregexp" }, + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, + enabled = false, +} |
