Yaml Revealer is a vim plugin which allows you to handle the full tree structure of a Yaml key.
If you often use Yaml files, you know they are very readable at the beginning, but also that they can become a bit harder to read when becoming longer and longer… Yaml Revealer is here to guide you when you're lost.
myRoot:
firstChild:
myVar: "foo"
secondChild:
myVar:
foo: "foo"
myVar2:
foo: "foo"
bar: "bar"
> specialKey: "Hi"
Moving to the indicated line will automatically make vim echo
myRoot > secondChild > myVar2
Typing :call SearchYamlKey() will display a prompt to search a specific key.
Search for a Yaml key:
Searching for
myVar2>specialKey
or
myvar2 > specialKey
will find the concerned line.
This plugin requires vim version superior to 8.0.1630 or neovim.
-
You can configure the separator between the keys by setting the variable
g:yaml_revealer_separator. Default is> -
By default, a list indicator (
[]) is added to the path. This can be removed by settingg:yaml_revealer_list_indicatorto 0 -
You can configure how the YAML path is displayed by setting
g:yaml_revealer_display_mode. Available options:'echo'(default): Display path in the command line'virtual': Show path as virtual text at the end of the current line (Neovim only)'statusline': Store path in a variable for status line integration
-
You can limit the maximum display width of YAML paths to prevent the "Press ENTER" prompt in Vim by setting
g:yaml_revealer_max_width. Set to 0 (default) for no truncation, or any positive number to limit path width. Paths exceeding this width will be truncated with "..." appended.
Virtual text mode (recommended for Neovim):
let g:yaml_revealer_display_mode = 'virtual'(or g:yaml_revealer_display_mode = 'virtual' in lua config)
Shows the YAML path as subtle text at the end of the current line.
Status line integration:
let g:yaml_revealer_display_mode = 'statusline'(or g:yaml_revealer_display_mode = 'statusline' in lua config)
Then add %{YamlRevealerStatusLine()} to your status line configuration.
If you use lualine, you can add this to your config:
{
function()
return vim.fn.YamlRevealerStatusLine()
end,
cond = function()
return vim.bo.filetype == "yaml"
end,
},Enhanced echo mode:
let g:yaml_revealer_display_mode = 'echo'(or g:yaml_revealer_display_mode = 'echo' in lua config)
Uses highlighted echo messages that are more visible than the default.
Truncation configuration:
" Limit path display to 80 characters to prevent "Press ENTER" prompts
let g:yaml_revealer_max_width = 80(or g:yaml_revealer_max_width = 80 in lua config)
Prevents long YAML paths from wrapping and causing Vim's "Press ENTER" prompt.
Add Plugin 'Einenlum/yaml-revealer' to your .vimrc, reload your config and run a Plugin:Install.
Add Plug 'Einenlum/yaml-revealer' to your .vimrc, reload your config and run a :PlugInstall.
{
'Einenlum/yaml-revealer',
config = function()
-- Recommended for Neovim users
vim.g.yaml_revealer_display_mode = 'virtual'
end,
ft = 'yaml',
}- Thanks to @PedroTroller for his useful help :).
- Thanks to @ezpuzz for improving performance.
- Thanks to @mosheavni for adding lists support.
