-- AI code completion if vim.fn.getenv 'COPILOT_API_KEY' ~= vim.NIL then return { 'zbirenbaum/copilot.lua', event = 'InsertEnter', config = function() require('copilot').setup { suggestion = { enabled = true, auto_trigger = true, keymap = { accept = '', }, }, filetypes = { yaml = true, markdown = true, gitcommit = true, gitrebase = true, }, } end, } end return { 'milanglacier/minuet-ai.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, config = function() require('minuet').setup { virtualtext = { auto_trigger_ft = { '*' }, auto_trigger_ignore_ft = { 'help', 'TelescopePrompt', 'codecompanion' }, keymap = { accept = '', accept_line = '', -- accept n lines (prompts for number) -- e.g. "A-z 2 CR" will accept 2 lines accept_n_lines = '', -- Cycle to prev completion item, or manually invoke completion prev = '', -- Cycle to next completion item, or manually invoke completion next = '', dismiss = '', }, }, provider = 'openai_compatible', request_timeout = 3, throttle = 500, -- Increase to reduce costs and avoid rate limits debounce = 400, -- Increase to reduce costs and avoid rate limits n_completions = 1, before_cursor_filter_length = 10, provider_options = { openai_compatible = { api_key = 'COMPLETION_OPENAI_API_KEY', end_point = vim.env.COMPLETION_OPENAI_API_BASE .. '/v1/chat/completions', model = vim.env.COMPLETION_MODEL, name = 'Openrouter', optional = { max_tokens = 300, top_p = 0.9, provider = { -- Prioritize throughput for faster completion sort = 'throughput', }, }, }, }, } end, }