Skip to main content

AI Coding Assistants

GentlemanNvim integrates multiple AI coding assistants, providing flexible workflows for different use cases. The configuration includes 5 AI tools, with OpenCode currently enabled as the primary assistant.

Available AI Assistants

OpenCode

Currently Active - Primary AI assistant

GitHub Copilot

Enabled - Inline completions

Copilot Chat

Disabled - Chat interface (available)

Avante

Disabled - Cursor-like experience

CodeCompanion

Disabled - Agentic AI assistant
You can enable/disable AI assistants in lua/plugins/disabled.lua. Only one chat-based AI should be active at a time to avoid keybinding conflicts.

OpenCode (Primary)

Overview

OpenCode provides a clean AI chat interface integrated with Snacks picker:
return {
  "NickvanDyke/opencode.nvim",
  dependencies = {
    { "folke/snacks.nvim", opts = { input = {}, picker = {}, terminal = {} } },
  },
  config = function()
    vim.g.opencode_opts = {
      provider = {
        snacks = {
          win = {
            position = "left",
          },
        },
      },
    }
    vim.o.autoread = true
  end,
}

Key Features

1

Context-Aware

Use @file, @this:, and visual selections for precise context
2

Built-in Prompts

Pre-configured prompts for explain, fix, diagnose, review, test, optimize
3

Left Sidebar

Chat window positioned on the left for comfortable reading
4

File Integration

Auto-reads file changes for seamless workflow

Keybindings

KeymapModeActionContext
<leader>aanToggle OpenCodeOpen/close chat
<leader>asn, xSelect & submitAuto-submit with context
<leader>ain, xAsk (blank)Empty prompt
<leader>aIn, xAsk with @this:Include current context
<leader>abn, xAsk about bufferQuery about @file
<leader>apn, xPrompt with @thisCustom prompt

Built-in Prompts

KeymapPromptUse Case
<leader>apeexplainExplain how code works
<leader>apffixFix bugs and issues
<leader>apddiagnoseDiagnose problems
<leader>aprreviewCode review
<leader>apttestGenerate unit tests
<leader>apooptimizeOptimize performance
Use visual mode to select code, then press <leader>ape to get instant explanations of complex code blocks.

Workflow Examples

1

Explain Function

  1. Position cursor on function
  2. Press <leader>aI (ask with context)
  3. Type: “Explain this function”
  4. AI receives function context automatically
2

Fix Bug

  1. Select problematic code (visual mode)
  2. Press <leader>apf (fix prompt)
  3. AI analyzes and suggests fixes
3

Generate Tests

  1. Select function to test
  2. Press <leader>apt (test prompt)
  3. AI generates comprehensive unit tests

GitHub Copilot

Overview

Inline AI completions as you type:
return {
  "zbirenbaum/copilot.lua",
  optional = true,
  opts = function()
    require("copilot.api").status = require("copilot.status")
    require("copilot.api").filetypes = {
      filetypes = {
        yaml = false,
        markdown = false,
        help = false,
        gitcommit = false,
        gitrebase = false,
      },
    }
  end,
}

Disabled File Types

Copilot is intentionally disabled in:
  • YAML files (configuration)
  • Markdown files (documentation)
  • Help files
  • Git commit messages
  • Git rebase sessions
This prevents unwanted AI suggestions in documentation and commit messages.

Default Keybindings

Inherited from LazyVim Copilot extra:
KeymapModeAction
<Tab>iAccept suggestion
<M-]>iNext suggestion
<M-[>iPrevious suggestion
<M-\>iDismiss suggestion

Setup Requirements

1

Install Copilot

Copilot requires a GitHub account with Copilot subscription
2

Authenticate

On first use, run :Copilot auth to authenticate with GitHub
3

Verify Status

Run :Copilot status to check connection

Copilot Chat (Available)

Overview

Conversational AI interface with custom system prompt:
return {
  "CopilotC-Nvim/CopilotChat.nvim",
  branch = "main",
  cmd = "CopilotChat",
  opts = {
    model = "claude-3.5-sonnet",
    answer_header = "󱗞  The Gentleman 󱗞  ",
    auto_insert_mode = true,
    window = {
      layout = "horizontal",
    },
  },
}

Custom System Prompt

The configuration includes a detailed Spanish-language system prompt:
Personality:
  • Frontend architect specialized in Angular and React
  • Expert in Clean Architecture and Hexagonal Architecture
  • Professional but approachable tone (Argentine Spanish)
  • Focus on practical, actionable advice
Areas of Expertise:
  • Frontend development (Angular, React, TypeScript)
  • State management (Redux, Signals, custom solutions)
  • Software architecture patterns
  • Testing and best practices
  • Modular design and atomic patterns
  • Developer productivity tools
Communication Style:
  • Technical but accessible
  • Uses practical analogies
  • Provides clear examples
  • Concise and direct

Predefined Prompts

prompts = {
  Explain = "Please explain how the following code works.",
  Review = "Please review the following code and provide suggestions for improvement.",
  Tests = "Please explain how the selected code works, then generate unit tests for it.",
  Refactor = "Please refactor the following code to improve its clarity and readability.",
  FixCode = "Please fix the following code to make it work as intended.",
  FixError = "Please explain the error in the following text and provide a solution.",
  BetterNamings = "Please provide better names for the following variables and functions.",
  Documentation = "Please provide documentation for the following code.",
  JsDocs = "Please provide JsDocs for the following code.",
  DocumentationForGithub = "Please provide documentation for the following code ready for GitHub using markdown.",
  CreateAPost = "Please provide documentation for the following code to post it in social media...",
  SwaggerApiDocs = "Please provide documentation for the following API using Swagger.",
  SwaggerJsDocs = "Please write JSDoc for the following API using Swagger.",
  Summarize = "Please summarize the following text.",
  Spelling = "Please correct any grammar and spelling errors in the following text.",
  Wording = "Please improve the grammar and wording of the following text.",
  Concise = "Please rewrite the following text to make it more concise.",
}

Chat Keybindings

In Chat Window:
KeymapModeAction
<Tab>iComplete
qnClose
<C-c>iClose
<C-l>n, iReset chat
<CR>nSubmit prompt
<C-s>iSubmit prompt
<C-y>n, iAccept diff
gdnShow diff
gynYank diff
ghnShow help

Enable Copilot Chat

To enable:
{
  "CopilotC-Nvim/CopilotChat.nvim",
  enabled = true,  -- Change from false to true
},

Avante (Available)

Overview

Cursor-like AI assistant with inline editing and file selection:
return {
  "yetone/avante.nvim",
  build = "make",
  opts = {
    provider = "copilot",
    providers = {
      copilot = {
        model = "claude-sonnet-4",
      },
    },
    windows = {
      position = "left",
      width = 30,
    },
    file_selector = {
      provider = "snacks",
    },
  },
}

Key Features

Cursor Planning

Enable cursor planning mode for multi-step edits

File Selection

Select multiple files for context

Inline Edits

AI suggests changes directly in your code

Diff View

Preview changes before accepting

Advanced Configuration

Avante includes complex resize handling to prevent UI issues:
The configuration includes:
  • VimResized handler - Manages terminal resize events
  • Duplicate window cleanup - Prevents multiple Ask/Select panels
  • Cursor management - Temporarily moves cursor during resize
  • Redraw forcing - Ensures clean UI updates
vim.api.nvim_create_autocmd({ "VimResized" }, {
  group = "AvanteResizeFix",
  callback = function()
    -- Complex resize handling logic
  end,
})

Enable Avante

{
  "yetone/avante.nvim",
  enabled = true,  -- Change from false to true
},
Avante and OpenCode use similar keybindings. Only enable one chat-based AI at a time.

CodeCompanion (Available)

Overview

Full-featured agentic AI with tool support:
return {
  "olimorris/codecompanion.nvim",
  cmd = { "CodeCompanion", "CodeCompanionActions", "CodeCompanionChat" },
  opts = {
    adapters = {
      copilot_4o = { model = "gpt-4o" },
      copilot_41 = { model = "gpt-4.1" },
      copilot_gemini_25_pro = { model = "gemini-2.5-pro" },
    },
    strategies = {
      chat = {
        adapter = "copilot",
      },
    },
  },
}

Tool Support

CodeCompanion includes agentic tools:
full_stack_dev:
  • cmd_runner - Execute shell commands
  • editor - Edit buffer contents
  • files - File system operations
gentleman (Custom):
  • Same tools as full_stack_dev
  • Custom system prompt for frontend architecture
  • Requires approval for destructive operations
tools = {
  groups = {
    ["gentleman"] = {
      description = "The Gentleman",
      system_prompt = "Este GPT es un clon del usuario...",
      tools = { "cmd_runner", "editor", "files" },
    },
  },
}

Multiple Model Support

GPT-4o

copilot_4o adapter

GPT-4.1

copilot_41 adapter

Gemini 2.5 Pro

copilot_gemini_25_pro

Slash Commands

Custom slash commands for enhanced context:
slash_commands = {
  ["git_files"] = {
    description = "List git files",
    callback = function(chat)
      local handle = io.popen("git ls-files")
      if handle then
        local result = handle:read("*a")
        handle:close()
        chat:add_reference({ role = "user", content = result }, "git", "<git_files>")
      end
    end,
  },
}
Use /git_files in chat to include all tracked files as context.

Keybindings (When Enabled)

KeymapModeAction
<leader>acn, vToggle chat
<leader>ann, vNew chat
<leader>aan, vActions menu
gavAdd to chat
<leader>aevExplain
In Chat:
  • <CR> (normal) - Send
  • <C-s> (insert) - Send
  • <C-c> - Close
  • ga - Accept change
  • gr - Reject change

Enable CodeCompanion

{
  "olimorris/codecompanion.nvim",
  enabled = true,  -- Change from false to true
},
All AI assistants integrate with the Blink completion engine:
opts = {
  sources = {
    default = { "avante_commands", "avante_mentions", "avante_files" },
    compat = { "avante_commands", "avante_mentions", "avante_files" },
    providers = {
      avante_commands = { score_offset = 90 },
      avante_files = { score_offset = 100 },
      avante_mentions = { score_offset = 1000 },
    },
  },
}
Provides:
  • @mentions completion in AI chat
  • File path completion
  • Command completion

Choosing the Right Assistant

Use CaseRecommended ToolReason
Inline completionsGitHub CopilotFast, context-aware suggestions
Quick questionsOpenCodeLightweight, built-in prompts
Complex refactoringAvanteInline editing with preview
Multi-file changesCodeCompanionAgentic tools, file operations
Code reviewCopilot ChatDedicated review prompt
Learning/explanationsOpenCode/Copilot ChatConversational interface

Configuration Tips

Best Practice: Enable only one chat-based AI at a time:
  • OpenCode (lightweight, good default)
  • OR Avante (Cursor-like experience)
  • OR CodeCompanion (advanced features)
  • OR Copilot Chat (GitHub integration)
GitHub Copilot (inline) can run alongside any chat assistant.

Switching AI Assistants

1

Open disabled.lua

Edit lua/plugins/disabled.lua
2

Toggle Enabled

Change enabled = false to enabled = true for desired AI
3

Disable Others

Set other chat-based AIs to enabled = false
4

Restart Neovim

Run :Lazy sync or restart Neovim

Authentication

All AI assistants use GitHub Copilot authentication:
1

Install Copilot

Ensure GitHub Copilot plugin is installed
2

Authenticate

Run :Copilot auth and follow prompts
3

Verify

Run :Copilot status to confirm connection
4

Use AI Tools

All Copilot-based tools will now work
Avante, CodeCompanion, and Copilot Chat all use the same Copilot authentication. You only need to authenticate once.

Performance Considerations

Running multiple AI assistants simultaneously:
  • Increases memory usage
  • May cause keybinding conflicts
  • Can slow down completions
Enable only the tools you actively use.

Troubleshooting

AI Not Responding

1

Check Authentication

Run :Copilot status to verify connection
2

Restart LSP

Run :LspRestart to restart language servers
3

Check Logs

View plugin logs with :messages

Keybinding Conflicts

If multiple AI assistants are enabled, keybindings may conflict. Check plugins/disabled.lua and ensure only one chat-based AI is active.

Next Steps

Keymaps

Learn all AI assistant keybindings

Plugins

Explore all installed plugins

Build docs developers (and LLMs) love