๐ŸŒ babel.nvim

December 7, 2025 ยท View on GitHub

๐ŸŒ babel.nvim

Translate text without leaving Neovim

Neovim Lua License


โœจ Features

  • ๐Ÿ”ค Translate selected text or word under cursor
  • ๐ŸชŸ Multiple display modes (float, picker)
  • ๐Ÿ” Auto-detect installed picker
  • ๐Ÿ“‹ Copy translation to clipboard with y
  • โšก Async translation (non-blocking)

Supported Pickers

PickerStatus
Native floatโœ…
snacks.nvimโœ…
telescope.nvimโœ…
fzf-luaโœ…
mini.pickโœ…

โšก Requirements

  • Neovim >= 0.9.0
  • curl

Optional (for picker display):

  • snacks.nvim, telescope.nvim, fzf-lua, or mini.pick

๐Ÿ“ฆ Installation

lazy.nvim

{
  "acidsugarx/babel.nvim",
  version = "*", -- recomended for the latest tag, not main
  opts = {
    target = "ru",  -- target language
  },
  keys = {
    { "<leader>tr", mode = "v", desc = "Translate selection" },
    { "<leader>tw", desc = "Translate word" },
  },
}

โš™๏ธ Configuration

Minimal Setup

require("babel").setup({
  target = "ru",
})

Full Options

Default Configuration
require("babel").setup({
  source = "auto",        -- source language (auto-detect)
  target = "ru",          -- target language
  provider = "google",    -- translation provider: "google", "deepl"
  display = "float",      -- "float" or "picker"
  picker = "auto",        -- "auto", "telescope", "fzf", "snacks", "mini"
  float = {
    border = "rounded",
    max_width = 80,
    max_height = 20,
  },
  keymaps = {
    translate = "<leader>tr",
    translate_word = "<leader>tw",
  },
  -- DeepL provider settings (optional)
  deepl = {
    api_key = nil,        -- or use DEEPL_API_KEY env variable
    pro = nil,            -- nil = auto-detect, true = Pro, false = Free
    formality = "default", -- "default", "more", "less", "prefer_more", "prefer_less"
  },
})

Options

OptionTypeDefaultDescription
sourcestring"auto"Source language (auto-detect)
targetstring"ru"Target language code
providerstring"google"Translation provider: "google", "deepl"
displaystring"float"Display mode: "float" or "picker"
pickerstring"auto"Picker: "auto", "telescope", "fzf", "snacks", "mini"
deepl.api_keystringnilDeepL API key (or use DEEPL_API_KEY env)
deepl.probooleannilForce Pro/Free endpoint (nil = auto-detect by key)
deepl.formalitystring"default"Formality: "default", "more", "less", "prefer_more", "prefer_less"

Language Codes

Common language codes
CodeLanguage
enEnglish
ruRussian
deGerman
frFrench
esSpanish
itItalian
ptPortuguese
zhChinese
jaJapanese
koKorean
arArabic
hiHindi
trTurkish
plPolish
ukUkrainian

๐Ÿš€ Usage

Keymaps

KeymapModeDescription
<leader>trVisualTranslate selection
<leader>twNormalTranslate word under cursor

Commands

CommandDescription
:Babel [text]Translate provided text
:BabelWordTranslate word under cursor

In Translation Window

KeyAction
q / <Esc> / <CR>Close window
yCopy translation to clipboard
j / kScroll

๐ŸŒ Providers

ProviderStatusAPI KeyNotes
Google Translateโœ…NoDefault, unofficial API
DeepL๐ŸงชYes (free tier)Best quality, 500k chars/month free
LibreTranslate๐Ÿ”œNoOpen source, self-hostable
Yandex๐Ÿ”œYesGreat for Russian
Lingva๐Ÿ”œNoGoogle proxy, no rate limits

๐Ÿงช Testing: DeepL provider is implemented but needs testing. If you have a DeepL API key and want to help test, please open an issue with your feedback!

DeepL Setup
  1. Get a free API key at deepl.com/pro#developer (500k chars/month free)

  2. Set up the API key (choose one):

    Option A: Environment variable

    export DEEPL_API_KEY="your-api-key-here"
    

    Option B: In config

    require("babel").setup({
      provider = "deepl",
      deepl = {
        api_key = "your-api-key-here",
      },
    })
    
  3. The endpoint (Free/Pro) is auto-detected from the key suffix (:fx = Free). You can override with deepl.pro = true/false.

  4. If no API key is found, babel.nvim will automatically fall back to Google Translate with a warning.

๐Ÿค Contributing

Contributions are welcome! Feel free to:

  • ๐Ÿ› Report bugs
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ”ง Submit pull requests

๐Ÿ™ Acknowledgments

Thanks to the amazing Neovim plugin ecosystem:

๐Ÿ“ License

MIT ยฉ Ilya Gilev