wsdjeg/chat.nvim

website github github
ai
stars 11
issues 2
subscribers 1
forks 1
CREATED

UPDATED


chat.nvim

chat.nvim is a lightweight, extensible chat plugin for Neovim with AI integration. Chat with AI assistants directly in your editor using a clean, floating window interface. It supports 20+ AI providers, a three-tier memory system, 45+ built-in tools, MCP protocol, IM integrations, and an HTTP API for external access. Full documentation is available at nvim.chat.

Run Tests GitHub License GitHub Issues or Pull Requests GitHub commit activity GitHub Release luarocks

chat-nvim

✨ Features

  • 🤖 20+ AI Providers - DeepSeek, OpenAI, Anthropic, GitHub Models, Gemini, Ollama, Baidu, Xiaomi, Alibaba Cloud, Moonshot, Tencent, and more
  • 🧠 Three-Tier Memory - Working, daily, and long-term memory with automatic extraction and priority-based retrieval
  • 🛠️ 45+ Built-in Tools - File operations, Git integration, web search and fetch, email, scheduling, user profiles
  • 🧩 Slash Commands - Built-in skills (/model, /provider, /cwd, /pin, /title, /retry, ...) with custom skill registration
  • 🔍 Lazy Tool Discovery - Only essential tools are sent with each request; other tools are activated on demand via a built-in catalog
  • 🔄 Parallel Sessions - Multiple conversations with different models simultaneously
  • 🔌 MCP Protocol - Native Model Context Protocol support via stdio and HTTP transports
  • 💬 IM Integration - Discord, Telegram, Slack, Lark, DingTalk, WeCom, WeChat
  • 🌐 HTTP API - Built-in server for external integration with API key authentication
  • 👤 User Profiles - Per-user preferences and skills for personalized assistance
  • ⏰ Scheduled Tasks - One-time or recurring tasks that persist across Neovim restarts
  • ⚡ Streaming Responses - Real-time AI responses with cancellation and token tracking

📦 Installation

chat.nvim works with all major Neovim plugin managers.

  • Using lazy.nvim

    {
      'wsdjeg/chat.nvim',
      dependencies = {
        'wsdjeg/job.nvim', -- Required
        'wsdjeg/picker.nvim', -- Optional but recommended
      },
    }
    
  • Using nvim-plug

    require('plug').add({
      {
        'wsdjeg/chat.nvim',
        depends = {
          'wsdjeg/job.nvim',
          'wsdjeg/picker.nvim',
        },
      },
    })
    
  • Using luarocks

    luarocks install chat.nvim
    

🔧 Configuration

The following is the default configuration of chat.nvim. See the Configuration Guide for full details.

require('chat').setup({
  -- window options
  width = 0.8,
  height = 0.8,
  auto_scroll = true,
  border = 'rounded',
  -- default AI provider and model
  provider = 'deepseek',
  model = 'deepseek-v4-flash',
  -- time display format
  strftime = '%m-%d %H:%M:%S',
  -- display names for the AI and user, used in the chat window
  -- and on role badges in the HTML preview
  names = {
    bot = 'Bot',
    user = 'You',
  },
  -- enable RenderMarkdown for result buffer
  render_markdown = true,
  -- default system prompt
  system_prompt = '',
  -- restrict file tool access to specific paths (string or list of strings)
  allowed_path = '',
  -- HTTP server for external integration
  http = {
    host = '127.0.0.1',
    port = 7777,
    api_key = '', -- set to non-empty to enable
  },
  -- API keys for providers
  api_key = {
    deepseek = 'your-deepseek-api-key',
    openai = 'your-openai-api-key',
    -- ...
  },
})

⚙️ Basic Usage

Open the chat window:

:Chat

Switch provider or model with slash commands (in the prompt window):

/provider openai
/model gpt-4o

Or use picker.nvim keybindings (in the input window):

Key Binding Action
<Leader>fp Switch provider via picker
<Leader>fm Switch model via picker
<Leader>fr Browse session history via picker

Navigate and manage sessions:

:Chat new      " create a new session
:Chat prev     " previous session
:Chat next     " next session
:Chat delete   " delete the current session
:Chat save f   " save the session to a file
:Chat load f   " load a session from a file or URL
:Chat share    " share the session to a pastebin
:Chat preview  " open the HTML preview in your browser

See the Usage Guide for all commands and keybindings.

🧠 Memory System

chat.nvim implements a three-tier memory system:

Type Lifetime Purpose
Working Session Current context, decisions, active tasks
Daily 7-30 days Tasks, reminders, schedules
Long-term Permanent Preferences, facts, skills

Memories are automatically extracted during conversations and retrieved with priority-based ranking. See the Memory Guide for details.

🛠️ Tools

45+ built-in tools are available for AI assistants to interact with your environment:

  • File Operations - Read, write, copy, move, and search files and directories
  • Git Integration - Status, diff, log, commit, push, branch, rebase, stash, tag
  • Web Search - Search the web via Firecrawl, Google, or SerpAPI
  • Web Fetch - Fetch URLs and convert HTML to markdown
  • Email - Send emails via the system mail command
  • Mastodon - Read-only Mastodon: fetch toots, threads, and timelines
  • Memory Management - Extract and recall memories
  • Scheduled Tasks - One-time or recurring tasks, persisted across restarts
  • User Profiles - Manage per-user preferences and skills
  • Task Plans - Create and manage task plans
  • Office Documents - View Excel files with multiple modes
  • Development - Run make targets, check LSP diagnostics, get weather/time, convert images via ffmpeg

Tools are lazy-loaded by default: only the essential tools plus a find_tool discovery catalog are sent with each request to save prompt tokens, and other tools are activated on demand for the current turn. Set tools.lazy = false to send all tools with every request.

See the Tools Guide for the full list and usage.

🔌 MCP Support

Native Model Context Protocol support for extended tool capabilities:

require('chat').setup({
  mcp = {
    mcpServers = {
      -- stdio transport
      filesystem = {
        command = 'npx',
        args = { '-y', '@modelcontextprotocol/server-filesystem', '/path/to/dir' },
      },
      -- HTTP transport
      remote = {
        url = 'http://localhost:3000/mcp',
      },
    },
  },
})

See the MCP Guide for details.

💬 IM Integration

Connect messaging platforms for remote AI interaction:

  • Discord - Chat with AI via Discord bot
  • Telegram - Send messages and receive AI responses
  • Slack - Slash command integration
  • Lark - Feishu/Lark bot support
  • DingTalk - DingTalk robot integration
  • WeCom - WeChat Work integration
  • WeChat - WeChat official account support

See the Integrations Guide for setup instructions.

🌐 HTTP API

The built-in HTTP server allows external applications to send messages to chat.nvim:

curl -X POST http://127.0.0.1:7777/ \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-secret-api-key" \
  -d '{"content":"Hello","session":"default"}'

See the API Guide for all endpoints.

📣 Self-Promotion

If you like this plugin, please star it on GitHub. Also check out my other Neovim plugins:

💬 Feedback

If you encounter any bugs or have suggestions, please file an issue in the issue tracker

📄 License

Licensed under GPL-3.0.