๐Ÿ’ YAML toolkit for Neovim users

Migrates from GitHub

+94 -110
-1
.github/FUNDING.yml
··· 1 - github: [cuducos]
-19
.github/workflows/stylua.yml
··· 1 - --- 2 - on: [push, pull_request] 3 - name: Stylua 4 - 5 - jobs: 6 - 7 - stylua: 8 - runs-on: ubuntu-latest 9 - strategy: 10 - matrix: 11 - nvim-versions: ["stable", "nightly"] 12 - name: Stylua 13 - steps: 14 - - uses: actions/checkout@v3 15 - - uses: JohnnyMorganz/stylua-action@v2 16 - with: 17 - token: ${{ secrets.GITHUB_TOKEN }} 18 - version: latest 19 - args: --check .
-21
.github/workflows/tests.yml
··· 1 - --- 2 - on: [push, pull_request] 3 - name: Tests 4 - 5 - jobs: 6 - 7 - tests: 8 - runs-on: ubuntu-latest 9 - strategy: 10 - matrix: 11 - nvim-versions: ["stable", "nightly"] 12 - name: Tests 13 - steps: 14 - - uses: rhysd/action-setup-vim@v1 15 - with: 16 - neovim: true 17 - version: ${{ matrix.nvim-versions }} 18 - - uses: actions/setup-node@v3 19 - - run: npm install -g tree-sitter-cli 20 - - uses: actions/checkout@v3 21 - - run: nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/yaml_nvim { minimal_init = 'tests/init.lua' }"
+15
.tangled/workflows/format.yaml
··· 1 + when: 2 + - event: ["push", "manual"] 3 + branch: ["main"] 4 + - event: ["pull_request"] 5 + branch: ["main"] 6 + 7 + engine: "nixery" 8 + 9 + dependencies: 10 + nixpkgs: 11 + - stylua 12 + 13 + steps: 14 + - name: Stylua 15 + command: stylua --check .
+25
.tangled/workflows/tests.yaml
··· 1 + when: 2 + - event: ["push", "manual"] 3 + branch: ["main"] 4 + - event: ["pull_request"] 5 + branch: ["main"] 6 + 7 + engine: "nixery" 8 + 9 + dependencies: 10 + nixpkgs: 11 + - curl 12 + - findutils 13 + - fzf 14 + - gcc 15 + - git 16 + - gnutar 17 + - gzip 18 + - neovim 19 + - shell 20 + - tree-sitter 21 + 22 + steps: 23 + - name: Stylua 24 + command: | 25 + nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/yaml_nvim { minimal_init = 'tests/init.lua' }"
-36
Dockerfile
··· 1 - FROM debian:trixie-slim AS neovim 2 - ARG NVIM_VERSION 3 - ENV NVIM_VERSION=${NVIM_VERSION:-stable} 4 - ENV BUILD_REQUIREMENTS="cmake curl gcc gettext git ninja-build unzip" 5 - RUN apt-get update && \ 6 - apt-get install -y ${BUILD_REQUIREMENTS} && \ 7 - git clone --branch ${NVIM_VERSION} https://github.com/neovim/neovim && \ 8 - cd neovim && \ 9 - make install && \ 10 - rm -rf ../neovim && \ 11 - apt-get remove -y ${BUILD_REQUIREMENTS} && \ 12 - apt-get autoremove -y && \ 13 - rm -rf /var/lib/apt/lists/* 14 - 15 - FROM rust:slim-trixie AS tree-sitter-cli 16 - RUN cargo install tree-sitter-cli 17 - 18 - FROM debian:trixie-slim 19 - COPY --from=neovim /usr/local/share/nvim /usr/local/share/nvim 20 - COPY --from=neovim /usr/local/lib/nvim /usr/local/lib/nvim 21 - COPY --from=neovim /usr/local/bin/nvim /usr/local/bin/nvim 22 - COPY --from=tree-sitter-cli /usr/local/cargo/bin/tree-sitter /usr/local/bin/tree-sitter 23 - 24 - RUN apt-get update && \ 25 - apt-get install -y curl fzf g++ git && \ 26 - apt-get autoremove -y && \ 27 - rm -rf /var/lib/apt/lists/* && \ 28 - useradd -ms /bin/bash yaml 29 - 30 - USER yaml 31 - WORKDIR /home/yaml/ 32 - RUN mkdir -p .config/nvim/ 33 - ADD tests/init.lua .config/nvim/init.lua 34 - ADD . . 35 - 36 - CMD ["nvim", "tests/sample.yaml"]
+6 -9
README.md
··· 1 - # yaml.nvim [![Tests status](https://github.com/cuducos/yaml.nvim/actions/workflows/tests.yml/badge.svg)](https://github.com/cuducos/yaml.nvim/actions/workflows/tests.yml) 1 + # yaml.nvim 2 2 3 3 Simple tools to help developers working YAML in [Neovim](https://neovim.io). 4 4 ··· 30 30 31 31 <summary>What about older versions of Neovim?</summary> 32 32 33 - * For **Neovim 0.7 or 0.8**, pin to [`7925bd2`](https://github.com/cuducos/yaml.nvim/commit/7925bd2bf03c718996ccad7e1a49eafe40cd3246) 34 - * For **Neovim 0.5 or 0.6**, pin to [`155c23d`](https://github.com/cuducos/yaml.nvim/commit/155c23de8f99fdb424f8aa713bcb993cc2538c6c) 33 + * For **Neovim 0.7 or 0.8**, pin to `7925bd2` 34 + * For **Neovim 0.5 or 0.6**, pin to `155c23d` 35 35 36 36 </details> 37 37 ··· 41 41 42 42 ```lua 43 43 { 44 - "cuducos/yaml.nvim", 44 + "https://tangled.org/cuducos.me/yaml.nvim", 45 45 ft = { "yaml" }, -- optional 46 46 dependencies = { 47 47 "folke/snacks.nvim", -- optional ··· 55 55 56 56 ```lua 57 57 use { 58 - "cuducos/yaml.nvim", 58 + "https://tangled.org/cuducos.me/yaml.nvim", 59 59 ft = { "yaml" }, -- optional 60 60 requires = { 61 61 "folke/snacks.nvim", -- optional ··· 71 71 Plug 'folke/snacks.nvim' " optional 72 72 Plug 'nvim-telescope/telescope.nvim' " optional 73 73 Plug 'ibhagwan/fzf-lua' " optional 74 - Plug 'cuducos/yaml.nvim' 74 + Plug 'https://tangled.org/cuducos.me/yaml.nvim' 75 75 ``` 76 76 77 77 ### No YAML parser? ··· 130 130 131 131 <summary>For non-named buffers</summary> 132 132 133 - See [#33](https://github.com/cuducos/yaml.nvim/pull/33), for example: 134 - 135 133 ```lua 136 134 vim.api.nvim_create_autocmd({ "BufEnter", "FileType" }, { 137 135 group = vim.api.nvim_create_augroup("bufent_winbar", { clear = true }), ··· 173 171 174 172 | Command | Description | 175 173 |---|---| 176 - | `./manage build` | Builds the container | 177 174 | `./manage test` | Runs the tests inside the container | 178 175 | `./manage nvim` | Opens the container's Neovim with a sample YAML file |
+39 -22
manage
··· 13 13 end 14 14 15 15 local exec_and_exit = function(cmd) 16 - local status, _ = os.execute(cmd) 17 - os.exit(status) 18 - end 16 + print("Command: " .. cmd) 19 17 20 - local build_with = function(bin) 21 - exec_and_exit(bin .. " build -t yaml.nvim .") 22 - end 18 + local bin = select_bin() 19 + print("Binary: " .. bin) 23 20 24 - local test_with = function(bin) 25 - for line in io.lines(".github/workflows/tests.yml") do 26 - if string.find(line, "PlenaryBustedDirectory") then 27 - local cleaned = string.gsub(line, "-? run: ", "") 28 - exec_and_exit(bin .. " run -it yaml.nvim " .. cleaned) 29 - end 30 - end 31 - end 21 + local container = "nixery.dev/shell/curl/findutils/fzf/gcc/git/gnutar/gzip/neovim/tree-sitter" 22 + local pwd = io.popen("pwd"):read("*l") 23 + 24 + local args = { 25 + bin, 26 + "run", 27 + "--rm", 28 + "-v", 29 + pwd .. ":/yaml.nvim", 30 + "--workdir", 31 + "/yaml.nvim", 32 + "-it", 33 + container, 34 + cmd, 35 + } 36 + local arg = table.concat(args, " ") 37 + print("$ " .. arg) 32 38 33 - local nvim_with = function(bin) 34 - exec_and_exit(bin .. " run -it yaml.nvim") 39 + local status, _ = os.execute(arg) 40 + os.exit(status) 35 41 end 36 42 37 43 local main = function() 38 44 local opts = {} 39 - local bin = select_bin() 40 - local cmds = { build = build_with, test = test_with, nvim = nvim_with } 41 - for cmd, func in pairs(cmds) do 42 - table.insert(opts, cmd) 43 - if cmd == arg[1] then 44 - func(bin) 45 + local cmds = { 46 + nvim = function() 47 + return "nvim -u tests/init.lua tests/sample.yaml" 48 + end, 49 + test = function() 50 + for line in io.lines(".tangled/workflows/tests.yaml") do 51 + if string.find(line, "PlenaryBustedDirectory") then 52 + return string.gsub(line, "^%s*(.-)%s*$", "%1") 53 + end 54 + end 55 + end, 56 + } 57 + for name, cmd in pairs(cmds) do 58 + table.insert(opts, name) 59 + if name == arg[1] then 60 + local arg = cmd() 61 + exec_and_exit(arg) 45 62 end 46 63 end 47 64
+8 -1
tests/init.lua
··· 1 + -- In Nixery (container test and CI) fzf-lua fails to load with LuaJIT 5.1 (the 2 + -- version in the Nix package), but it is something we can ignore for simple 3 + -- tests. 4 + if vim.fn.isdirectory("/nix/store") == 1 then 5 + _VERSION = "Lua 5.2" 6 + end 7 + 1 8 local install_from_github = function(uri) 2 9 local repo = string.gsub(uri, "^[^/]+/", "") 3 10 local name = string.gsub(repo, "%p?nvim%p?", "") ··· 30 37 vim.cmd("runtime plugin/yaml.vim") 31 38 vim.cmd("set noswapfile") 32 39 33 - require("nvim-treesitter.configs").setup({ ensure_installed = { "yaml" }, sync_install = true }) 40 + require("nvim-treesitter").install({ "yaml" }):wait() 34 41 require("plenary.busted")
+1 -1
tests/yaml_nvim/commands_spec.lua
··· 81 81 assert.stub(telescope).was_called_with() 82 82 end) 83 83 84 - it("YAMLFzFLua calls Lua function", function() 84 + it("YAMLFzfLua calls Lua function", function() 85 85 local fzf_lua = stub(require("yaml_nvim"), "fzf_lua") 86 86 vim.cmd("YAMLFzfLua") 87 87 assert.stub(fzf_lua).was_called_with()