astrocommunity icon indicating copy to clipboard operation
astrocommunity copied to clipboard

Add sidekick.nvim

Open Yorizel opened this issue 2 months ago • 5 comments

Is your feature related to a problem?

Folke released an awesome new p[lugin for handling ai with built in nes support using the copilot api

Describe the new feature

Add the new sidekick plugin on the editor support category

Additional context

this is my current config, if anyone is interested

return {
  "folke/sidekick.nvim",
  event = "VeryLazy",
  opts = {
    cli = {
      mux = {
        backend = "tmux",
        enabled = true,
      },
    },
    -- Remove the keys.accept = nil since we're handling Tab directly
  },
  specs = {
    {
      "AstroNvim/astrocore",
      ---@param opts AstroCoreOpts
      opts = function(_, opts)
        local maps = assert(opts.mappings)
        local prefix = "<Leader>a"

        -- Normal mode mappings
        maps.n[prefix] = { desc = "+ Sidekick" }
        maps.n[prefix .. "a"] = {
          function() require("sidekick.cli").toggle { focus = true } end,
          desc = "Sidekick Toggle CLI",
        }
        maps.n[prefix .. "c"] = {
          function() require("sidekick.cli").toggle { name = "claude", focus = true } end,
          desc = "Sidekick Claude Toggle",
        }
        maps.n[prefix .. "p"] = {
          function() require("sidekick.cli").prompt() end,
          desc = "Sidekick Ask Prompt",
        }

        -- Visual mode mappings
        maps.v[prefix] = { desc = "+ai" }
        maps.v[prefix .. "a"] = {
          function() require("sidekick.cli").toggle { focus = true } end,
          desc = "Sidekick Toggle CLI",
        }
        maps.v[prefix .. "p"] = {
          function() require("sidekick.cli").prompt() end,
          desc = "Sidekick Ask Prompt",
        }

        maps.n["<tab>"] = {
          function()
            -- if there is a next edit, jump to it, otherwise apply it if any
            if not require("sidekick").nes_jump_or_apply() then
              return "<Tab>" -- fallback to normal tab
            end
          end,
          expr = true,
          desc = "Goto/Apply Next Edit Suggestion",
        }
      end,
    },
  },
}

Yorizel avatar Oct 02 '25 13:10 Yorizel

Would be neat to also be able to toggle between the different CLI tools

ALameLlama avatar Oct 02 '25 13:10 ALameLlama

Would be neat to also be able to toggle between the different CLI tools

i think this is already possible

Yorizel avatar Oct 02 '25 14:10 Yorizel

Would be neat to also be able to toggle between the different CLI tools

i think this is already possible

Sorry, I should have been more clear, in our plugin we could have a vim.g.sidekick_model and then automatically pass this into the command so you don't need to always select which model you're gonna use

ALameLlama avatar Oct 03 '25 00:10 ALameLlama

Not a fan of bringing our own vim.g.* variables that are non-standard.

Uzaaft avatar Oct 03 '25 09:10 Uzaaft

Not a fan of bringing our own vim.g.* variables that are non-standard.

That's fair, I only suggested it since the default haviour you'll need to select your cli tool each time you want to use it.

we could do something like with a default value but makes it possible to update the cli tool without needing to competely replace the community plugin

local sidekick_cli_tool = vim.g.sidekick_cli_tool or opencode
map.n.[prefix .. "a"] = {
    function() require("sidekick.cli").toggle({name = sidekick_cli_tool }) end,
    desc = "Sidekick Toggle CLI",
]

ALameLlama avatar Oct 03 '25 10:10 ALameLlama