An open API service indexing awesome lists of open source software.

https://github.com/sdglbl/context-groups.nvim


https://github.com/sdglbl/context-groups.nvim

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

          

# Context-Groups.nvim

A Neovim plugin for managing context files for AI-assisted coding.

## Overview

Context Groups is a Neovim plugin designed to enhance AI-assisted coding by managing context files on a per-buffer basis. It allows users to maintain groups of related files that provide additional context for AI models like Claude, GPT, and others.

## Features

- Per-buffer context group management
- Project-level configuration persistence
- Automatic project root detection
- Telescope integration for file selection and preview
- Enhanced diagnostics and code sharing:
- Inline LSP diagnostics with code context
- Git diff integration for tracking changes
- Buffer path utilities for easy reference
- AI-optimized code formatting and export capabilities

## Installation

### Using packer.nvim

```lua
use {
'username/context-groups.nvim',
requires = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
}
}
```

### Using lazy.nvim

```lua
{
'username/context-groups.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
}
}
```

## Setup

Basic setup with default settings:

```lua
require('context-groups').setup()
```

Setup with custom configuration:

```lua
require('context-groups').setup({
keymaps = {
add_context = "ca",
add_context_all = "cA",
show_context = "cs",
code2prompt_current = "cy",
code2prompt = "cY",
lsp_diagnostics_current = "cl",
lsp_diagnostics_all = "cL",
lsp_diagnostics_inline_current = "ci",
lsp_diagnostics_inline_all = "cI",
git_diff_current = "cg",
git_diff_all_modified = "cG",
buffer_paths = "cp",
},
storage_path = vim.fn.stdpath("data") .. "/context-groups",
project_markers = {
".git",
".svn",
"package.json",
"Cargo.toml",
"go.mod",
"requirements.txt",
},
})
```

## Usage

### Basic Workflow

1. **Add files to context group:**
- Use `:ContextGroupAdd` command or press `ca` (respects ignore patterns)
- Use `cA` to add files without any ignore patterns (includes .venv, node_modules, etc.)
- Select files using Telescope interface
- Press to add a file or to add without closing

2. **View current context group:**
- Use `:ContextGroupShow` command or press `cs`
- Preview file contents
- Remove files using
- Open files in split with

3. **Get enhanced code context:**
- Copy buffer content with LSP diagnostics: `:ContextGroupLSPDiagnosticsInlineCurrent` or `ci`
- Copy all buffers with LSP diagnostics: `:ContextGroupLSPDiagnosticsInlineAll` or `cI`
- Copy buffer with Git diff comparison: `:ContextGroupGitDiffCurrent` or `cg`
- Copy all modified buffers with Git diffs: `:ContextGroupGitDiffAllModified` or `cG`
- Copy all buffer paths: `:ContextGroupCopyBufferPaths` or `cp`

4. **Format code for AI tools:**
- Use `:ContextGroupBuffer2PromptCurrent` or `cy` to format current buffer for sharing with AI tools
- Use `:ContextGroupBuffer2Prompt` or `cY` to format all open buffer contents for sharing with AI tools

## Recent Updates

- **July 2025**: Major refactoring to reorganize module structure and extract components into focused modules (diagnostics, git_diff, export, storage, project utilities).
- **July 2025**: Removed LSP integration and language handlers to simplify the codebase and focus on core context management functionality.
- **May 2025**: Added Git diff integration for tracking file changes and comparing with Git history.
- **May 2025**: Added inline LSP diagnostics feature for enhanced error visualization within code context.
- **May 2025**: Added buffer paths utilities for easy reference and sharing.
- **March 2025**: Enhanced buffer formatting for better AI tool integration.

## License

MIT License

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.