馃崚 YAML toolkit for Neovim users
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

Lua 89.2%
Dockerfile 10.6%
Vim Script 0.2%
63 1 0

Clone this repository

https://tangled.org/cuducos.me/yaml.nvim https://tangled.org/did:plc:3272gdrjsuikiff7qsgokgas/yaml.nvim
git@tangled.org:cuducos.me/yaml.nvim git@tangled.org:did:plc:3272gdrjsuikiff7qsgokgas/yaml.nvim

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

yaml.nvim Tests status#

Simple tools to help developers working YAML in Neovim.

Assuming yaml = require("yaml_nvim") for the Lua API:

Command Lua API Description
:YAMLView yaml.view() Shows the full path and value of the current key/value pair
:YAMLYank [register] yaml.yank_all([register]) Yanks the full path and value of the current key/value pair. The default register is the unnamed one (")
:YAMLYankKey [register] yaml.yank_key([register]) Yanks the full path of the key for the current key/value pair. The default register is the unnamed one (")
:YAMLYankValue [regster] yaml.yank_value([register]) Yanks the value of the current key/value pair. The default register is the unnamed one (")
:YAMLQuickfix yaml.quickfix() Generates a quickfix with key/value pairs
:YAMLTelescope yaml.telescope() Full path key/value fuzzy finder via Telescope if installed

Example GIF

Requirements#

Telescope is optional.

What about older versions of Neovim?
  • For Neovim 0.7 or 0.8, pin to 7925bd2
  • For Neovim 0.5 or 0.6, pin to 155c23d

Install#

With lazy.nvim#

{
  "cuducos/yaml.nvim",
  ft = { "yaml" }, -- optional
  dependencies = {
    "nvim-treesitter/nvim-treesitter",
    "nvim-telescope/telescope.nvim", -- optional
  },
}

With packer.nvim:#

use {
  "cuducos/yaml.nvim",
  ft = { "yaml" }, -- optional
  requires = {
    "nvim-treesitter/nvim-treesitter",
    "nvim-telescope/telescope.nvim" -- optional
  },
}

With vim-plug:#

Plug 'nvim-telescope/telescope.nvim' " optional
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'cuducos/yaml.nvim'

Configuration#

Showing the YAML path and value#

Neovim's winbar#

-- Get yaml key
vim.api.nvim_create_autocmd({ "FileType" }, {
	pattern = { "yaml" },
	callback = function()
		vim.opt_local.winbar = [[%{%v:lua.require("yaml_nvim").get_yaml_key()%}]]
	end,
})

-- Get yaml key and value
vim.api.nvim_create_autocmd({ "FileType" }, {
	pattern = { "yaml" },
	callback = function()
		vim.opt_local.winbar = [[%{%v:lua.require("yaml_nvim").get_yaml_key_and_value()%}]]
	end,
})

Neovim's statusline (with lualine.nvim)#

require("lualine").setup({
	sections = {
		lualine_x = { require("yaml_nvim").get_yaml_key_and_value },
		-- etc
    }
})

Reporting bugs and contributing#

There is a mini toolchain to help you test the plugin in isolation using a container. It requires:

Command Description
./manage build Builds the container
./manage test Runs the tests inside the container
./manage nvim Opens the container's Neovim with a sample YAML file