A Neovim plugin that uses LLMs to improve the grammar and spelling of natural language text.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Benno Richters 14280b879a test command registration and rename ollama parse_stream tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 11:02:39 +02:00
assets cropped images 2025-11-13 18:50:10 +01:00
doc report request and stream errors and log everything shown to the user 2026-10-11 10:57:06 +02:00
lua/taal report request and stream errors and log everything shown to the user 2026-10-11 10:57:06 +02:00
scripts consistent formatting 2025-10-16 18:15:40 +02:00
tests test command registration and rename ollama parse_stream tests 2026-10-11 11:02:39 +02:00
.gitignore shouldn't ignore lua folder 2025-02-03 08:56:12 +01:00
.luarc.json no unused warning for _* 2025-11-13 08:30:47 +01:00
.stylua.toml formatting 2025-10-18 21:52:47 +02:00
CHANGELOG.md report request and stream errors and log everything shown to the user 2026-10-11 10:57:06 +02:00
CLAUDE.md report request and stream errors and log everything shown to the user 2026-10-11 10:57:06 +02:00
LICENSE 2026 2026-05-16 21:42:14 +02:00
README.md report request and stream errors and log everything shown to the user 2026-10-11 10:57:06 +02:00

Taal

A Neovim plugin that uses LLMs to improve the grammar and spelling of natural language text.

Features

  • Suggests grammar and spelling improvements. This feature is language agnostic, as long as the chosen LLM is capable of that.
  • Offers a word-by-word diff of the original text and the suggested improvements.
  • Applies improvements all at once, or on a one-to-one basis.
  • Interacts with the LLM using a user command and the selected text.
  • Supports three LLMs: Claude, Gemini, OpenAI-responses.

Show errors and suggestions as inlay hints Show errors wih inlay hints

or in a scratch buffer. Show errors wih in a scratch buffer

Limitations

  • Suggestions are only made for the line under cursor. Text that is hard-wrapped over several lines is checked one line at a time.
  • When the user enters insert mode, the suggestions will be deleted.

Installation

This plugin uses curl.

  • Make sure curl is installed on your system.
  • Requires Neovim 0.10+.

Examples:

vim.pack (built-in, Neovim 0.12+)
vim.pack.add({
  { src = "https://git.bnor.org/benno/taal.nvim" },
})

require("taal").setup()

vim.keymap.set("n", "<leader>tg", "<Cmd>TaalGrammar scratch<Cr>")
vim.keymap.set("n", "<leader>tl", "<Cmd>TaalGrammar inlay<Cr>")
vim.keymap.set("n", "<leader>tr", "<Cmd>TaalGrammar<Cr>")
vim.keymap.set("n", "<leader>th", "<Cmd>TaalHover<Cr>")
vim.keymap.set("n", "<leader>ta", "<Cmd>TaalApplySuggestion<Cr>")
vim.keymap.set("n", "<leader>ts", "<Cmd>TaalSetSpelllang<Cr>")
vim.keymap.set("v", "<leader>ti", "<Cmd>TaalInteract<Cr>")
mini.deps
MiniDeps.later(function()
  MiniDeps.add {
    source = "https://git.bnor.org/benno/taal.nvim",
  }

  require("taal").setup()

  vim.keymap.set("n", "<leader>tg", "<Cmd>TaalGrammar scratch<Cr>")
  vim.keymap.set("n", "<leader>tl", "<Cmd>TaalGrammar inlay<Cr>")
  vim.keymap.set("n", "<leader>tr", "<Cmd>TaalGrammar<Cr>")
  vim.keymap.set("n", "<leader>th", "<Cmd>TaalHover<Cr>")
  vim.keymap.set("n", "<leader>ta", "<Cmd>TaalApplySuggestion<Cr>")
  vim.keymap.set("n", "<leader>ts", "<Cmd>TaalSetSpelllang<Cr>")
  vim.keymap.set("v", "<leader>ti", "<Cmd>TaalInteract<Cr>") 
end)
lazy.nvim
{
  "benno/taal.nvim",
  url = "https://git.bnor.org/benno/taal.nvim",
  keys = {
    { "<leader>tg", "<cmd>TaalGrammar<cr>" },
    { "<leader>tl", "<Cmd>TaalGrammar inlay<Cr>" },
    { "<leader>tr", "<Cmd>TaalGrammar<Cr>" },
    { "<leader>th", "<Cmd>TaalHover<Cr>" },
    { "<leader>ta", "<Cmd>TaalApplySuggestion<Cr>" }, 
    { "<leader>ts", "<Cmd>TaalSetSpelllang<Cr>" },
    { "<leader>ti", "<Cmd>TaalInteract<Cr>", mode = "v" }, 
  },
  opts = {},
},

API keys

The LLMs need an API key. These keys should be made available via an environment variable:

  • Claude: {{CLAUDE_API_KEY}}
  • Gemini: {{GEMINI_API_KEY}}
  • OpenAI_responses: {{OPENAI_API_KEY}}

(If you want to use Claude or OpenAI_responses instead of the default Gemini, do not forget to configure the plugin accordingly, see below.)

Setup

This plugin needs to be set up with require("taal").setup({}). The setup arg {} is optional and can be a custom config table, to overwrite the defaults. Calling the setup function, with or without a table, is mandatory.

Default config
  {
    -- one of: trace, debug, info, warn, error, fatal. The log is written to
    -- taal.log in stdpath("log"), and emptied at startup when over 10 MB.
    -- Errors and warnings that taal shows are written to the log too.
    log_level = "error",
    timeout = 6000, -- time out for API requests to LLM in ms
	
    -- function that can be overriden to take control over the template, i.e.,
    -- the prompt, that will be sent to the LLM
    -- see doc/taal.txt (or `:h taal.txt`) for detailed information
    template_fn = function(_command, default_template, _user_input)
      return default_template
    end,

    adapters = {
      claude = {
        -- URL for Claude
        url = "https://api.anthropic.com",
      },
      gemini = {
        -- URL for Gemini
        url = "https://generativelanguage.googleapis.com"
      },
      openai_responses = {
        -- URL for Openai_responses
        url = "https://api.openai.com", 
      },
    },

    -- default LLM and model, used by all commands if not overriden by one
    -- of the options below. If this or a command's adapter is not supported,
    -- taal shows a warning and uses the default configuration.
    adapter = "gemini", -- one of: claude, gemini, openai_responses
    model = "gemini-2.5-flash", 

    commands = {
      grammar = {
  	    adapter = nil, -- overrides default LLM for TaalGrammar
	    model = nil, -- overrides default model for TaalGrammar
      },
      set_spelllang = {
	    adapter = nil,  -- overrides default LLM for TaalSetSpelllang
	    model = nil,  -- overrides default model for TaalSetSpelllang
      },
	  interact = {
	    adapter = nil, -- overrides default LLM for TaalInteract
	    model = nil, -- overrides default model for TaalInteract
      },
    },
  }
Example config

This example uses Gemini and the model gemini-2.5-flash as the default LLM (because this config does not override the default), except for the interact command. For that command it will use Claude with the model claude-sonnet-4-5-20250929.

  require("taal").setup({ 
    commands = {
      interact = { 
	    adapter = "claude", model = "claude-sonnet-4-5-20250929", 
      }
    }
  })

Commands

The following commands are exposed:

  • TaalGrammar
    Checks grammar and spelling of the line of text currently under cursor. Grammar and spelling errors are highlighted with the 'TaalIssue' highlight group. The check runs in the background, so you can keep working. If the line changes before the result arrives, the result is discarded. This command takes two optional arguments:
    • inlay - Shows grammar and spelling improvements as inlay hints using the 'TaalInlay' highlight group.
    • scratch - Writes the complete improved line in a scratch buffer in a vertical split.
  • TaalHover
    Shows the grammar improvement of the text with the error currently under cursor in a popup.
  • TaalNextSuggestion / TaalPrevSuggestion
    Moves the cursor to the next or previous suggestion. Wraps around the end of the buffer if 'wrapscan' is set.
  • TaalApplySuggestion
    Applies the suggested improvement of the text with the error currently under cursor.
  • TaalApplyAllSuggestions
    Applies all suggested improvements in the current buffer.
  • TaalDismissSuggestion
    Removes the suggestion under cursor without applying it.
  • TaalDismissAllSuggestions
    Removes all suggestions in the current buffer without applying them.
  • TaalSetSpelllang
    Recognizes the language of the text under cursor and sets the spelling language accordingly using the 'spelllang' option. It is set for the buffer the command was run in, also if you have moved to another buffer by the time the result arrives.
  • TaalInteract
    Asks the user for a prompt and sends this, together with the selected text to the LLM. Use in Visual Mode. Note that this ex command cannot be used by using :TaalInteract as using the colon will switch Neovim back to normal mode. Map this command to a key using <Cmd>TaalInteract<Cr> instead, as in the example below.

Key mapping

No default key mapping is provided. Here is an example mapping you can use.

vim.keymap.set("n", "<leader>tg", "<Cmd>TaalGrammar scratch<Cr>")
vim.keymap.set("n", "<leader>tl", "<Cmd>TaalGrammar inlay<Cr>")
vim.keymap.set("n", "<leader>tr", "<Cmd>TaalGrammar<Cr>")
vim.keymap.set("n", "<leader>th", "<Cmd>TaalHover<Cr>")
vim.keymap.set("n", "<leader>ta", "<Cmd>TaalApplySuggestion<Cr>")
vim.keymap.set("n", "<leader>tA", "<Cmd>TaalApplyAllSuggestions<Cr>")
vim.keymap.set("n", "<leader>td", "<Cmd>TaalDismissSuggestion<Cr>")
vim.keymap.set("n", "<leader>tD", "<Cmd>TaalDismissAllSuggestions<Cr>")
vim.keymap.set("n", "]t", "<Cmd>TaalNextSuggestion<Cr>")
vim.keymap.set("n", "[t", "<Cmd>TaalPrevSuggestion<Cr>")
vim.keymap.set("n", "<leader>ts", "<Cmd>TaalSetSpelllang<Cr>")

-- Note that this mapping is for Visual Mode
vim.keymap.set("v", "<leader>ti", "<Cmd>TaalInteract<Cr>")