tzachar / cmp-ai

MIT License
120 stars 22 forks source link

Working cmp-ai configuration for NVChad? #20

Open awonglk opened 4 weeks ago

awonglk commented 4 weeks ago

Not an issue as such. Does anyone have a working configuration sample for cmp-ai plugin working with NVChad? I haven't been able to get this working, and would appreciate any "best practices".

I believe I need to:

  1. Install and setup plugins in /lua/plugins/init.lua: {'tzachar/cmp-ai', dependencies = 'nvim-lua/plenary.nvim'},

    This one-liner seems to work fine

  2. A step to configure cmp-ai to use a specific external AI source (e.g. Codestral) in /lua/configs/cmp-ai.lua?

  3. A step that involves nvm-cmp sources override? I assume also a file in /lua/configs/nvim-cmp.lua

Much appreciated!

milanglacier commented 5 days ago

I don't use nvchad, but I believe nvchad uses lazy.nvim and you need to utilize lazy's feature to merge options to set up cmp.

Not tested, but should be something like this:

That is, you fetch the option tables configured by nvchad previously, and then add cmp_ai to it.


{"hrsh7th/nvim-cmp", opts = function(_, opts)
        table.insert(opts.sources, 1, "cmp_ai")
       -- you need to take a look at the nvchad's original configuration of nvim-cmp to
       -- ensure you are using the correct location to insert "cmp_ai"
    end,
    dependencies = { 
        { 'tzachar/cmp-ai', config = "your configuration here"}
    }
}