|
| 1 | +-- AI-powered code assistant with CLI interface and edit suggestions. |
| 2 | +-- Provides keybindings for sending code context to AI and applying suggestions. |
| 3 | + |
| 4 | +---@module 'lazy' |
| 5 | +---@type LazySpec |
| 6 | +return { |
| 7 | + 'folke/sidekick.nvim', |
| 8 | + opts = { |
| 9 | + nes = { enabled = false }, |
| 10 | + cli = { |
| 11 | + prompts = { |
| 12 | + refactor = 'Please refactor {function} to be more maintainable', |
| 13 | + security = 'Review {file} for security vulnerabilities', |
| 14 | + }, |
| 15 | + }, |
| 16 | + }, |
| 17 | + keys = { |
| 18 | + -- NES: jump to next edit, or apply if already on one |
| 19 | + { |
| 20 | + '<tab>', |
| 21 | + function() |
| 22 | + if require('sidekick').nes_jump_or_apply() then return end |
| 23 | + return '<tab>' -- fall back to normal tab |
| 24 | + end, |
| 25 | + mode = { 'i', 'n' }, |
| 26 | + expr = true, |
| 27 | + desc = 'Goto/Apply Next Edit Suggestion', |
| 28 | + }, |
| 29 | + |
| 30 | + -- CLI window management |
| 31 | + { '<c-.>', function() require('sidekick.cli').focus() end, mode = { 'n', 't', 'i', 'x' }, desc = 'Sidekick Focus' }, |
| 32 | + { '<leader>aa', function() require('sidekick.cli').toggle() end, desc = 'Sidekick Toggle CLI' }, |
| 33 | + { '<leader>as', function() require('sidekick.cli').select() end, desc = 'Select CLI Tool' }, |
| 34 | + { '<leader>ad', function() require('sidekick.cli').close() end, desc = 'Detach CLI Session' }, |
| 35 | + |
| 36 | + -- Send context to CLI |
| 37 | + -- {this} resolves to {position} in a file, or appends {selection} otherwise |
| 38 | + { '<leader>at', function() require('sidekick.cli').send { msg = '{this}' } end, mode = { 'x', 'n' }, desc = 'Send [T]his to Sidekick' }, |
| 39 | + { '<leader>aS', function() require('sidekick.cli').send { msg = '{selection}' } end, mode = { 'x' }, desc = 'Send [S]election to Sidekick' }, |
| 40 | + { '<leader>af', function() require('sidekick.cli').send { msg = '{function}' } end, desc = 'Send [F]unction to Sidekick' }, |
| 41 | + { '<leader>aF', function() require('sidekick.cli').send { msg = '{file}' } end, desc = 'Send [F]ile to Sidekick' }, |
| 42 | + { '<leader>ae', function() require('sidekick.cli').send { msg = '{diagnostics}' } end, desc = 'Send Diagnostics ([E]rrors) to Sidekick' }, |
| 43 | + |
| 44 | + -- Prompt shortcuts |
| 45 | + { '<leader>ax', function() require('sidekick.cli').send { msg = 'explain {function}' } end, desc = 'E[x]plain Function' }, |
| 46 | + { |
| 47 | + '<leader>aX', |
| 48 | + function() |
| 49 | + require('sidekick.cli').send { msg = 'fix the diagnostics in {function}. Here are the current buffer diagnostics for context:\n{diagnostics}' } |
| 50 | + end, |
| 51 | + desc = 'Fi[x] Diagnostics in Function', |
| 52 | + }, |
| 53 | + { '<leader>ap', function() require('sidekick.cli').prompt() end, desc = 'Sidekick Select [P]rompt' }, |
| 54 | + }, |
| 55 | +} |
0 commit comments