···11-# yaml.nvim [](https://github.com/cuducos/yaml.nvim/actions/workflows/tests.yml)
11+# yaml.nvim
2233Simple tools to help developers working YAML in [Neovim](https://neovim.io).
44···30303131<summary>What about older versions of Neovim?</summary>
32323333-* For **Neovim 0.7 or 0.8**, pin to [`7925bd2`](https://github.com/cuducos/yaml.nvim/commit/7925bd2bf03c718996ccad7e1a49eafe40cd3246)
3434-* For **Neovim 0.5 or 0.6**, pin to [`155c23d`](https://github.com/cuducos/yaml.nvim/commit/155c23de8f99fdb424f8aa713bcb993cc2538c6c)
3333+* For **Neovim 0.7 or 0.8**, pin to `7925bd2`
3434+* For **Neovim 0.5 or 0.6**, pin to `155c23d`
35353636 </details>
3737···41414242```lua
4343{
4444- "cuducos/yaml.nvim",
4444+ "https://tangled.org/cuducos.me/yaml.nvim",
4545 ft = { "yaml" }, -- optional
4646 dependencies = {
4747 "folke/snacks.nvim", -- optional
···55555656```lua
5757use {
5858- "cuducos/yaml.nvim",
5858+ "https://tangled.org/cuducos.me/yaml.nvim",
5959 ft = { "yaml" }, -- optional
6060 requires = {
6161 "folke/snacks.nvim", -- optional
···7171Plug 'folke/snacks.nvim' " optional
7272Plug 'nvim-telescope/telescope.nvim' " optional
7373Plug 'ibhagwan/fzf-lua' " optional
7474-Plug 'cuducos/yaml.nvim'
7474+Plug 'https://tangled.org/cuducos.me/yaml.nvim'
7575```
76767777### No YAML parser?
···130130131131<summary>For non-named buffers</summary>
132132133133-See [#33](https://github.com/cuducos/yaml.nvim/pull/33), for example:
134134-135133```lua
136134vim.api.nvim_create_autocmd({ "BufEnter", "FileType" }, {
137135 group = vim.api.nvim_create_augroup("bufent_winbar", { clear = true }),
···173171174172| Command | Description |
175173|---|---|
176176-| `./manage build` | Builds the container |
177174| `./manage test` | Runs the tests inside the container |
178175| `./manage nvim` | Opens the container's Neovim with a sample YAML file |
+39-22
manage
···1313end
14141515local exec_and_exit = function(cmd)
1616- local status, _ = os.execute(cmd)
1717- os.exit(status)
1818-end
1616+ print("Command: " .. cmd)
19172020-local build_with = function(bin)
2121- exec_and_exit(bin .. " build -t yaml.nvim .")
2222-end
1818+ local bin = select_bin()
1919+ print("Binary: " .. bin)
23202424-local test_with = function(bin)
2525- for line in io.lines(".github/workflows/tests.yml") do
2626- if string.find(line, "PlenaryBustedDirectory") then
2727- local cleaned = string.gsub(line, "-? run: ", "")
2828- exec_and_exit(bin .. " run -it yaml.nvim " .. cleaned)
2929- end
3030- end
3131-end
2121+ local container = "nixery.dev/shell/curl/findutils/fzf/gcc/git/gnutar/gzip/neovim/tree-sitter"
2222+ local pwd = io.popen("pwd"):read("*l")
2323+2424+ local args = {
2525+ bin,
2626+ "run",
2727+ "--rm",
2828+ "-v",
2929+ pwd .. ":/yaml.nvim",
3030+ "--workdir",
3131+ "/yaml.nvim",
3232+ "-it",
3333+ container,
3434+ cmd,
3535+ }
3636+ local arg = table.concat(args, " ")
3737+ print("$ " .. arg)
32383333-local nvim_with = function(bin)
3434- exec_and_exit(bin .. " run -it yaml.nvim")
3939+ local status, _ = os.execute(arg)
4040+ os.exit(status)
3541end
36423743local main = function()
3844 local opts = {}
3939- local bin = select_bin()
4040- local cmds = { build = build_with, test = test_with, nvim = nvim_with }
4141- for cmd, func in pairs(cmds) do
4242- table.insert(opts, cmd)
4343- if cmd == arg[1] then
4444- func(bin)
4545+ local cmds = {
4646+ nvim = function()
4747+ return "nvim -u tests/init.lua tests/sample.yaml"
4848+ end,
4949+ test = function()
5050+ for line in io.lines(".tangled/workflows/tests.yaml") do
5151+ if string.find(line, "PlenaryBustedDirectory") then
5252+ return string.gsub(line, "^%s*(.-)%s*$", "%1")
5353+ end
5454+ end
5555+ end,
5656+ }
5757+ for name, cmd in pairs(cmds) do
5858+ table.insert(opts, name)
5959+ if name == arg[1] then
6060+ local arg = cmd()
6161+ exec_and_exit(arg)
4562 end
4663 end
4764
+8-1
tests/init.lua
···11+-- In Nixery (container test and CI) fzf-lua fails to load with LuaJIT 5.1 (the
22+-- version in the Nix package), but it is something we can ignore for simple
33+-- tests.
44+if vim.fn.isdirectory("/nix/store") == 1 then
55+ _VERSION = "Lua 5.2"
66+end
77+18local install_from_github = function(uri)
29 local repo = string.gsub(uri, "^[^/]+/", "")
310 local name = string.gsub(repo, "%p?nvim%p?", "")
···3037vim.cmd("runtime plugin/yaml.vim")
3138vim.cmd("set noswapfile")
32393333-require("nvim-treesitter.configs").setup({ ensure_installed = { "yaml" }, sync_install = true })
4040+require("nvim-treesitter").install({ "yaml" }):wait()
3441require("plenary.busted")