NvChad / starter

Starter config for NvChad
The Unlicense
137 stars 482 forks source link

Override cmp default mappings #41

Closed qbnil closed 3 months ago

qbnil commented 3 months ago

Ik that in nvchad config i could do this in chadrc file M.cmp = { .... and override the mappings here but how do i do that in this case. I tried overriding myself but every override just wipes all the default cmp settings which were brought by nvchad...

siduck commented 3 months ago

  {
    "hrsh7th/nvim-cmp",
    config = function(_, opts)
      local cmp = require "cmp"

      local myopts = {
        mapping = {
          ["<CR>"] = cmp.mapping(function(fallback)
            fallback()
          end),
        },
      }

      opts = vim.tbl_deep_extend("force", myopts, opts)
      require("cmp").setup(opts)
    end,
  }
qbnil commented 3 months ago

Thx for that :)

siduck commented 3 months ago

Thx for that :)

you can directly modify opts table too, instead of merging


opts.mapping ["<CR>"] = cmp.mapping(function(fallback)
            fallback()
          end)
qbnil commented 3 months ago

Thx again, that was exactly what i needed