-- Copilot must be enabled in comnfig/options.lua or config/local.lua if vim.g.copilot ~= true then return {} end -- TODO: -- - stop cmp when whitespace only -- - fix indentation on insert -- filetypes copilot is enabled for local ft = { "lua", "perl", "python", "zsh", } -- just duplicate the above table in a format copilot.lua wants local filetypes = {} for _, f in ipairs(ft) do filetypes[f] = true end filetypes["*"] = false return { -- copilot { -- https://github.com/zbirenbaum/copilot.lua "zbirenbaum/copilot.lua", build = ":Copilot auth", --ft = ft, opts = { suggestion = { enabled = false }, panel = { enabled = false }, filetypes = filetypes, }, }, -- copilot cmp source -- don't set ut up as a dependency, because we don't want it to load unless ft matches { -- https://github.com/zbirenbaum/copilot-cmp "zbirenbaum/copilot-cmp", dependencies = "copilot.lua", init = function() require("lazyAnd").FileType_InsertEnter(ft, "copilot-cmp") end, config = function(_, opts) local copilot_cmp = require("copilot_cmp") copilot_cmp.setup(opts) -- attach cmp source whenever copilot attaches -- fixes lazy-loading issues with the copilot cmp source require("lazyvim.util").lsp.on_attach(function(client) if client.name == "copilot" then copilot_cmp._on_insert_enter({}) end end) end, }, -- add copilot as cmp source { -- https://github.com/hrsh7th/nvim-cmp "hrsh7th/nvim-cmp", ---@param opts cmp.ConfigSchema opts = function(_, opts) table.insert(opts.sources, 1, { name = "copilot", group_index = 1, priority = 100, }) end, }, { -- https://github.com/ellisonleao/gruvbox.nvim "ellisonleao/gruvbox.nvim", opts = { overrides = { St_Cplt_C = { fg = "#232323", bg = "#fb4934", bold = true }, St_Cplt_p = { fg = "#232323", bg = "#b8bb26", bold = true }, St_Cplt_l = { fg = "#232323", bg = "#83a598", bold = true }, St_Cplt_t = { fg = "#232323", bg = "#fabd2f", bold = true }, }, }, }, { -- https://github.com/nvim-lualine/lualine.nvim "nvim-lualine/lualine.nvim", optional = true, event = "VeryLazy", opts = function(_, opts) local Util = require("lazyvim.util") local colors = { [""] = Util.ui.fg("Special"), ["Normal"] = Util.ui.fg("Special"), ["Warning"] = Util.ui.fg("DiagnosticError"), ["InProgress"] = Util.ui.fg("DiagnosticWarn"), } table.insert(opts.sections.lualine_x, { function() local icon = require("lazyvim.config").icons.kinds.Copilot local status = require("copilot.api").status.data -- local text = "" text = text .. "%#St_Cplt_C#" .. "C" text = text .. "%#St_Cplt_p#" .. "p" text = text .. "%#St_Cplt_l#" .. "l" text = text .. "%#St_Cplt_t#" .. "t" text = text .. "%#StText#" return icon .. text .. (status.message or text) end, cond = function() if not package.loaded["copilot"] then return end local ok, clients = pcall(require("lazyvim.util").lsp.get_clients, { name = "copilot", bufnr = 0 }) if not ok then return false end return ok and #clients > 0 end, color = function() if not package.loaded["copilot"] then return end local status = require("copilot.api").status.data return colors[status.status] or colors[""] end, padding = 0, }) end, }, }