Skip to content

A minimal Neovim plugin for chatting with xAI's Grok models via API. Floating UI, streaming responses, and code analysis—plug-and-play with <500 LOC.

License

Notifications You must be signed in to change notification settings

acris-software/grok-nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grok.nvim

grok-nvim

Project Overview

grok-nvim is a Neovim plugin for interacting with xAI's Grok models via their API. It provides a floating chat window for queries, supports streaming responses, and aims for a plug-and-play experience. Users install via a plugin manager, set their API key, and customize via require("grok").setup(opts).

Goals:

  • Clean: Minimalist code (<500 LOC total), modular files.
  • Simple: Easy setup; intuitive commands/keymaps.
  • Performant: Async operations; lightweight (only plenary.nvim dep for curl/async).
  • Plug-and-Play: Override model/tokens/temperature in setup; no code changes needed.

Dependencies: plenary.nvim (for curl, async).

Features

  • Interactive Chat: Use :Grok <prompt> or <leader>gg to query Grok (e.g., "Explain this Lua code"). (Note: Commands and keymaps must be defined in your Neovim config.)
  • Code Analysis: Select code in visual mode and press <leader>gg to explain or refactor. (Note: Keymaps must be defined in your Neovim config.)
  • Configurable: Supports grok-beta or grok-4, customizable temperature and max tokens.
  • Lightweight: Built with plenary.nvim for HTTP requests, no heavy dependencies.

Installation

Obtain an xAI API key from x.ai/api. For free testing, use the Grok interface on grok.com or x.com before integrating with the API.

With lazy.nvim (General)

Add to your Neovim plugin manager (e.g., in lua/plugins.lua):

return {
  {
    "acris-software/grok-nvim",
    dependencies = { "nvim-lua/plenary.nvim" },
    branch = "master",
    config = function()
      require("grok").setup({
        model = "grok-3-mini",
        base_url = "https://api.x.ai/v1",
        temperature = 0.7,
        max_tokens = 256,
        debug = false, -- Set true for debug mode
      })
    end,
  },
}

Usage

Chat: :Grok "Explain my Hyprland config" or gg to open a floating chat window. Code Analysis: In visual mode, select code and press gg to get explanations. Customize: Adjust model, temperature, or max_tokens in the setup function.

Requirements

Neovim 0.9.0+ plenary.nvim xAI API key (free or paid tier, see x.ai/api)

Project Structure

grok-nvim/
├── lua/
│   ├── grok/
│   │   ├── init.lua
│   │   ├── ui.lua
├── README.md
├── .gitignore
├── LICENSE

License

MIT License

Contributing

Issues and PRs are welcome! Fork the repo, make changes, and submit a pull request.

Roadmap

Streaming responses with plenary.async. LSP integration for code actions (e.g., "Grok refactor"). Prompt history integration with Telescope.nvim. Support for Grok-4's tool-calling features.

About

A minimal Neovim plugin for chatting with xAI's Grok models via API. Floating UI, streaming responses, and code analysis—plug-and-play with <500 LOC.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages