Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Seamless integration between Claude Code AI assistant and Neovim

License

Notifications You must be signed in to change notification settings

b0o/claude-code.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Neovim Plugin

A Neovim plugin for seamless integration between Claude Code AI assistant and Neovim.

This plugin was entirely built with Claude Code in a Neovim terminal, and then inside itself using Claude Code for everything.

Claude Code in Neovim

Features

  • 🚀 Toggle Claude Code in a terminal window with a single key press
  • 🔄 Automatically detect and reload files modified by Claude Code
  • ⚡ Real-time buffer updates when files are changed externally
  • 📱 Customizable window position and size
  • 🤖 Integration with which-key (if available)
  • 📂 Automatically uses git project root as working directory (when available)

Requirements

Installation

Using lazy.nvim

return {
  "greggh/claude-code.nvim",
  dependencies = {
    "nvim-lua/plenary.nvim", -- Required for git operations
  },
  config = function()
    require("claude-code").setup()
  end
}
use {
  'greggh/claude-code.nvim',
  requires = {
    'nvim-lua/plenary.nvim', -- Required for git operations
  },
  config = function()
    require('claude-code').setup()
  end
}

Using vim-plug

Plug 'nvim-lua/plenary.nvim'
Plug 'greggh/claude-code.nvim'
" After installing, add this to your init.vim:
" lua require('claude-code').setup()

Configuration

The plugin can be configured by passing a table to the setup function. Here's the default configuration:

require("claude-code").setup({
  -- Terminal window settings
  window = {
    height_ratio = 0.3,     -- Percentage of screen height for the terminal window
    position = "botright",  -- Position of the window: "botright", "topleft", etc.
    enter_insert = true,    -- Whether to enter insert mode when opening Claude Code
    hide_numbers = true,    -- Hide line numbers in the terminal window
    hide_signcolumn = true, -- Hide the sign column in the terminal window
  },
  -- File refresh settings
  refresh = {
    enable = true,           -- Enable file change detection
    updatetime = 100,        -- updatetime when Claude Code is active (milliseconds)
    timer_interval = 1000,   -- How often to check for file changes (milliseconds)
    show_notifications = true, -- Show notification when files are reloaded
  },
  -- Git project settings
  git = {
    use_git_root = true,     -- Set CWD to git root when opening Claude Code (if in git project)
  },
  -- Keymaps
  keymaps = {
    toggle = {
      normal = "<leader>ac",  -- Normal mode keymap for toggling Claude Code
      terminal = "<C-.>",     -- Terminal mode keymap for toggling Claude Code
    }
  }
})

Usage

Commands

  • :ClaudeCode - Toggle the Claude Code terminal window

Key Mappings

Default key mappings:

  • <leader>ac - Toggle Claude Code terminal window (normal mode)
  • <C-,> - Toggle Claude Code terminal window (both normal and terminal modes)

Additionally, when in the Claude Code terminal:

  • <C-h> - Move to the window on the left
  • <C-j> - Move to the window below
  • <C-k> - Move to the window above
  • <C-l> - Move to the window on the right
  • <C-f> - Scroll full-page down
  • <C-b> - Scroll full-page up

Note: After scrolling with <C-f> or <C-b>, you'll need to press the i key to re-enter insert mode so you can continue typing to Claude Code.

When Claude Code modifies files that are open in Neovim, they'll be automatically reloaded.

How it Works

This plugin:

  1. Creates a terminal buffer running the Claude Code CLI
  2. Sets up autocommands to detect file changes on disk
  3. Automatically reloads files when they're modified by Claude Code
  4. Provides convenient keymaps and commands for toggling the terminal
  5. Automatically detects git repositories and sets working directory to the git root

License

MIT License - See LICENSE for more information.

Development Cost

This entire plugin was developed using Claude Code. Here's what it cost to build the initial version:

Total cost: $5.42
Total duration (API): 17m 12.9s
Total duration (wall): 2h 29m 29.2s

💻 Created by greggh

About

Seamless integration between Claude Code AI assistant and Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages

  • Lua 100.0%