A Neovim plugin for displaying inline translation values from Paraglide JS i18n method calls. Shows actual translation text next to m.methodName() calls using virtual text.
Inspired by the VSCode ElementaryWatson extension, this is a simple, focused Neovim implementation that provides essential translation preview functionality.
- Inline Translation Display: Shows translation values as virtual text next to
m.methodName()calls - Text Extraction: Extract hard-coded strings to translation keys with
<leader>i(visual mode) - inlang Project Support: Automatically detects and uses inlang project configuration
- Multi-language Support: Works with multiple locales with easy switching
- Real-time Updates: Updates translations as you type (configurable)
- Flexible Configuration: Configurable locale, styling, and update behavior
- Lightweight: Pure Lua implementation with minimal dependencies
- Neovim 0.5+ (for virtual text support)
- JavaScript/TypeScript/Svelte project with Paraglide JS setup
- Translation files in JSON format
# Clone and test the plugin
cd nelementary-watson
lua test/standalone_test.lua # Test core functionality
./demo.sh # View plugin structure and test filesUsing lazy.nvim:
{
"romerramos/nelementary-watson",
config = function()
require("nelementary-watson").setup({
default_locale = "en",
update_in_insert = true,
-- other options...
})
end,
}require("nelementary-watson").setup({
-- Default locale to display (fallback if not found in inlang settings)
default_locale = "en",
-- Whether to update translations while typing in insert mode
update_in_insert = true,
-- Debounce delay for updates (milliseconds)
update_delay = 300,
-- Virtual text highlighting group
hl_group = "Comment",
-- Enable debug logging
debug = false,
})- JavaScript (
.js) - TypeScript (
.ts) - Svelte (
.svelte)
The plugin automatically reads project.inlang/settings.json to:
- Use the
pathPatternfromplugin.inlang.messageFormatfor locating translation files - Use the
baseLocaleas the default display locale
If no inlang configuration is found, falls back to:
./messages/{locale}.jsonstructure- "en" as the default locale
- Scans for
m.methodName()calls in supported file types - Loads translation files based on inlang configuration or fallback structure
- Displays translation values as virtual text with configurable styling
- Updates in real-time as you edit the code
import * as m from '$lib/paraglide/messages';
const title = m.hello_world(); // → "Hello World"
const greeting = m.welcome_message(); // → "Welcome, User"- Select text in visual mode
- Press
<leader>ito extract to translation key - Plugin generates unique snake_case key (e.g.,
blue_mountain_swift_river) - Adds entry to current locale's JSON file (e.g.,
messages/en.json) - Replaces selected text with appropriate function call
- JS/TS files:
m.generated_key() - Svelte files:
{m.generated_key()} - Other files: Prompts for format choice
<leader>i(visual mode): Extract selected text:ElementaryWatsonExtract: Alternative extraction command:ElementaryWatsonChangeLocale: Change display locale
MIT