|
| 1 | +-- TODO: Need to see if the tab causes issues with swapping modes with opencode |
| 2 | +---@type LazySpec |
| 3 | +return { |
| 4 | + "folke/sidekick.nvim", |
| 5 | + lazy = false, |
| 6 | + specs = { |
| 7 | + -- TODO: Currently, I'm manually starting the copilot lsp with LspStart and then LspCopilotSignIn |
| 8 | + -- If you use copilot.lua this is handled for you. |
| 9 | + { |
| 10 | + "williamboman/mason-lspconfig.nvim", |
| 11 | + optional = true, |
| 12 | + opts = function(_, opts) |
| 13 | + opts.ensure_installed = |
| 14 | + require("astrocore").list_insert_unique(opts.ensure_installed, { "copilot-language-server" }) |
| 15 | + end, |
| 16 | + }, |
| 17 | + { |
| 18 | + "WhoIsSethDaniel/mason-tool-installer.nvim", |
| 19 | + optional = true, |
| 20 | + opts = function(_, opts) |
| 21 | + opts.ensure_installed = |
| 22 | + require("astrocore").list_insert_unique(opts.ensure_installed, { "copilot-language-server" }) |
| 23 | + end, |
| 24 | + }, |
| 25 | + { |
| 26 | + "AstroNvim/astrocore", |
| 27 | + ---@param opts AstroCoreOpts |
| 28 | + opts = function(_, opts) |
| 29 | + local maps = assert(opts.mappings) |
| 30 | + local prefix = "<Leader>A" |
| 31 | + local cli_tool = vim.g.sidekick_cli_tool or "opencode" |
| 32 | + maps.n[prefix] = { desc = require("astroui").get_icon("Sidekick", 1, true) .. "Sidekick" } |
| 33 | + maps.x[prefix] = { desc = require("astroui").get_icon("Sidekick", 1, true) .. "Sidekick" } |
| 34 | + |
| 35 | + maps.n[prefix .. "a"] = { |
| 36 | + function() require("sidekick.cli").toggle { name = cli_tool } end, |
| 37 | + desc = "Sidekick Toggle CLI", |
| 38 | + } |
| 39 | + maps.n[prefix .. "s"] = { |
| 40 | + function() require("sidekick.cli").select { name = cli_tool } end, |
| 41 | + -- Or to select only installed tools: |
| 42 | + -- require("sidekick.cli").select({ filter = { installed = true } }) |
| 43 | + desc = "Select CLI", |
| 44 | + } |
| 45 | + for _, mode in ipairs { "n", "x" } do |
| 46 | + maps[mode][prefix .. "t"] = { |
| 47 | + function() require("sidekick.cli").send { name = cli_tool, msg = "{this}" } end, |
| 48 | + desc = "Send This", |
| 49 | + } |
| 50 | + end |
| 51 | + maps.x[prefix .. "v"] = { |
| 52 | + function() require("sidekick.cli").send { name = cli_tool, msg = "{selection}" } end, |
| 53 | + desc = "Send Visual Selection", |
| 54 | + } |
| 55 | + for _, mode in ipairs { "n", "x" } do |
| 56 | + maps[mode][prefix .. "p"] = { |
| 57 | + function() require("sidekick.cli").prompt { name = cli_tool } end, |
| 58 | + desc = "Sidekick Select Prompt", |
| 59 | + } |
| 60 | + end |
| 61 | + for _, mode in ipairs { "n", "x", "i", "t" } do |
| 62 | + maps[mode]["<c-.>"] = { |
| 63 | + function() require("sidekick.cli").focus() end, |
| 64 | + desc = "Sidekick Switch Focus", |
| 65 | + } |
| 66 | + end |
| 67 | + end, |
| 68 | + }, |
| 69 | + { "AstroNvim/astroui", opts = { icons = { Sidekick = "" } } }, |
| 70 | + }, |
| 71 | + opts = { |
| 72 | + nes = { |
| 73 | + enabled = true, |
| 74 | + }, |
| 75 | + cli = { |
| 76 | + mux = { |
| 77 | + backend = vim.g.sidekick_mux_backend or "tmux", -- tmux / zellij |
| 78 | + enabled = true, |
| 79 | + }, |
| 80 | + }, |
| 81 | + }, |
| 82 | + -- TODO: see how we want to handle tabs, I think we'll need to do something so it works with existing tab to do inline completions |
| 83 | + keys = { |
| 84 | + { |
| 85 | + "<tab>", |
| 86 | + function() |
| 87 | + -- if there is a next edit, jump to it, otherwise apply it if any |
| 88 | + if not require("sidekick").next_jump_or_apply() then |
| 89 | + return "<Tab>" -- fallback to normal tab |
| 90 | + end |
| 91 | + end, |
| 92 | + expr = true, |
| 93 | + desc = "Goto/Apply Next Edit Suggestion", |
| 94 | + }, |
| 95 | + }, |
| 96 | +} |
0 commit comments