A Neovim plugin for translating text in-place using the DeepL API. Select any text in your editor and translate it instantly without leaving your workflow.
- Neovim >= 0.7.0
- plenary.nvim (for
plenary.curl) - curl available in your $PATH
- DeepL API key (see DeepL API)
Using lazy.nvim
{
"alassek/deepl.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
api_token = os.getenv("DEEPL_API_TOKEN"),
}
}require('deepl').setup({
api_token = '', -- Your DeepL API token (required)
target_lang = 'EN-US', -- Default target language
model_type = 'quality_optimized', -- Translation model type
formality = 'default', -- Formality level
})Supported target languages include:
EN-US- English (American)EN-GB- English (British)DE- GermanFR- FrenchES- SpanishIT- ItalianJA- JapaneseZH-HANS- Chinese (Simplified)ZH-HANT- Chinese (Traditional)
See the DeepL API documentation for the complete list.
quality_optimizedprefer_quality_optimizedlatency_optimized
defaultmorelessprefer_moreprefer_less
- Select text in visual mode (
v,V, orCtrl-v) - Run
:Translateto translate to your default target language - The selected text will be replaced with the translation
If DeepL can't detect the source language correctly, specify it manually:
:Translate DEThis tells DeepL that the source text is in German.
Use the :DeepL command to access configuration menus:
:DeepL " Open main configuration menu
:DeepL target_language " Directly open target language selection
:DeepL model " Directly open model type selection
:DeepL formality " Directly open formality selectionInteractive configuration will set buffer-local settings. This means if you switch buffers you will revert to the global
configuration. Global settings can be updated dynamically via vim.g.deepl_formality etc.
-- Change target language globally
vim.g.deepl_target_language = "FR"
-- Set for current buffer only
vim.b.deepl_formality = "more"
vim.b.deepl_model_type = "latency_optimized"The plugin automatically detects your account type based on your API token:
- Free API tokens end with
:fx - Pro API tokens don't have this suffix
For security, store your API token in an environment variable:
export DEEPL_API_TOKEN="your-token-here"Then in your Neovim config:
api_token = os.getenv("DEEPL_API_TOKEN")