return { { 'tzachar/cmp-ai', dependencies = 'nvim-lua/plenary.nvim'}, { 'petertriho/cmp-git'}, { 'hrsh7th/nvim-cmp', dependencies = { 'dcampos/cmp-snippy', --'mstanciu552/cmp-matlab', 'petertriho/cmp-git', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp-signature-help', 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc', 'tzachar/cmp-ai' }, event = "InsertEnter", config = function() local cmp = require'cmp' local snippy = require'snippy' local cmp_ai = require('cmp_ai.config') cmp_ai:setup({ max_lines = 100, provider = 'Ollama', provider_options = { model = 'deepseek-coder:6.7b', base_url = 'http://batman.local:11434/api/generate', prompt = function(lines_before, lines_after) -- prompt depends on the model you use. Here is an example for deepseek coder return '
 ' .. lines_before .. ' ' .. lines_after .. ' ' -- for codellama
        end,
      },
      debounce_delay = 600, -- ms llama may be GPU hungry, wait x ms after last key input, before sending request to it
      notify = true,
      notify_callback = function(msg)
        vim.notify(msg)
      end,
      run_on_every_keystroke = true,
      ignored_file_types = {
        -- default is not to ignore
        -- uncomment to ignore in lua:
        -- lua = true
      },
    })

    local default_cmp_sources = cmp.config.sources({
        { name = 'nvim_lsp' },
        { name = 'nvim_lsp_signature_help' },
        { name = 'path' },
        { name = 'snippy' },
        { name = 'calc' },
        --{ name = 'cmp_git' },
        --{ name = 'cmp_ai' },
    })

    local bufIsBig = function(bufnr)
      local max_filesize = 100 * 1024 -- 100 KB
      local ok, stats = vim.loop.fs_stat(vim.api.nvim_buf_get_name(bufnr))
      if ok and stats and stats.size > max_filesize then
        return true
      else
        return false
      end
    end
    -- If a file is too large, I don't want to add to it's cmp sources treesitter, see:
    -- https://github.com/hrsh7th/nvim-cmp/issues/1522
    vim.api.nvim_create_autocmd('BufReadPre', {
      callback = function(t)
        local sources = default_cmp_sources
        if not bufIsBig(t.buf) then
          sources[#sources+1] = {name = 'treesitter', group_index = 2}
        end
      cmp.setup.buffer {
        sources = sources
      }
      end
    })

    cmp.setup({
        snippet = {
            expand = function(args)
                snippy.expand_snippet(args.body)
            end,
        },
        window = {
            completion = cmp.config.window.bordered(),
            documentation = cmp.config.window.bordered(),
        },
        experimental = {
          ghost_text = true,
        },
        mapping = cmp.mapping.preset.insert({
            [''] = cmp.mapping.select_prev_item(),
            [''] = cmp.mapping.select_next_item(),
            [''] = cmp.mapping.scroll_docs(-4),
            [''] = cmp.mapping.scroll_docs(4),
            [''] = cmp.mapping.complete(),
            [''] = cmp.mapping.abort(),
            [''] = cmp.mapping.confirm({ select = true }),
        }),
        sources = cmp.config.sources({
            { name = 'nvim_lsp' },
            { name = 'nvim_lsp_signature_help' },
            { name = 'path' },
            { name = 'snippy' },
            { name = 'calc' },
            { name = 'cmp_git' },
        }, {
            { name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
        }),
        sources = sources,
        sorting = {
            comparators = {
                require('cmp_ai.compare'),
                cmp.config.compare.offset,
                cmp.config.compare.exact,
                cmp.config.compare.recently_used,
                require("clangd_extensions.cmp_scores"),
                cmp.config.compare.kind,
                cmp.config.compare.sort_text,
                cmp.config.compare.length,
                cmp.config.compare.order,
            },
        },
    })

    cmp.setup.cmdline({'/', '?'}, {
        mapping = cmp.mapping.preset.cmdline(),
        sources = {
            { name = 'buffer' }
        }
    })

    cmp.setup.cmdline(':', {
        mapping = cmp.mapping.preset.cmdline(),
        sources = cmp.config.sources({
            { name = 'path' }
        }, {
            { name = 'cmdline' }
        })
    })

    cmp.setup.filetype('gitcommit', {
        sources = cmp.config.sources({
            {name = 'cmp_git' },
        }, {
            {name = 'buffer' }
        })
    })

    require("cmp_git").setup()
  end
}
}