๐Ÿ’ YAML toolkit for Neovim users

Drops `nvim-treesitter` as a dependency

Thank you @jemag : )

Closes #38

+27 -14
+4 -4
Dockerfile
··· 1 - FROM debian:bookworm-slim AS neovim 1 + FROM debian:trixie-slim AS neovim 2 2 ARG NVIM_VERSION 3 3 ENV NVIM_VERSION=${NVIM_VERSION:-stable} 4 - ENV BUILD_REQUIREMENTS "cmake curl gcc gettext git ninja-build unzip" 4 + ENV BUILD_REQUIREMENTS="cmake curl gcc gettext git ninja-build unzip" 5 5 RUN apt-get update && \ 6 6 apt-get install -y ${BUILD_REQUIREMENTS} && \ 7 7 git clone --branch ${NVIM_VERSION} https://github.com/neovim/neovim && \ ··· 12 12 apt-get autoremove -y && \ 13 13 rm -rf /var/lib/apt/lists/* 14 14 15 - FROM rust:slim-bookworm AS tree-sitter-cli 15 + FROM rust:slim-trixie AS tree-sitter-cli 16 16 RUN cargo install tree-sitter-cli 17 17 18 - FROM debian:bookworm-slim 18 + FROM debian:trixie-slim 19 19 COPY --from=neovim /usr/local/share/nvim /usr/local/share/nvim 20 20 COPY --from=neovim /usr/local/lib/nvim /usr/local/lib/nvim 21 21 COPY --from=neovim /usr/local/bin/nvim /usr/local/bin/nvim
+6 -7
README.md
··· 22 22 ## Requirements 23 23 24 24 * **Neovim 0.9** or newer 25 - * [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter) with [YAML support](https://github.com/ikatyang/tree-sitter-yaml) 25 + * [YAML support](https://github.com/ikatyang/tree-sitter-yaml) in [`treesitter`](https://neovim.viio/doc/user/treesitter.html) 26 26 27 - Snacks, Telescope and fzf-lua are **optional**. 27 + [Snacks](https://github.com/folke/snacks.nvim), [Telescope](https://github.com/nvim-telescope/telescope.nvim) and [fzf-lua](https://github.com/ibhagwan/fzf-lua) are **optional**. 28 28 29 29 <details> 30 30 ··· 44 44 "cuducos/yaml.nvim", 45 45 ft = { "yaml" }, -- optional 46 46 dependencies = { 47 - "nvim-treesitter/nvim-treesitter", 48 47 "folke/snacks.nvim", -- optional 49 48 "nvim-telescope/telescope.nvim", -- optional 50 49 "ibhagwan/fzf-lua" -- optional ··· 59 58 "cuducos/yaml.nvim", 60 59 ft = { "yaml" }, -- optional 61 60 requires = { 62 - "nvim-treesitter/nvim-treesitter", 63 61 "folke/snacks.nvim", -- optional 64 62 "nvim-telescope/telescope.nvim" -- optional 65 63 "ibhagwan/fzf-lua" --optional ··· 73 71 Plug 'folke/snacks.nvim' " optional 74 72 Plug 'nvim-telescope/telescope.nvim' " optional 75 73 Plug 'ibhagwan/fzf-lua' " optional 76 - Plug 'nvim-treesitter/nvim-treesitter' 77 74 Plug 'cuducos/yaml.nvim' 78 75 ``` 79 76 80 77 ### No YAML parser? 81 78 82 - If you get a <code>no parser for 'yaml' language</code> error message, this means that you need to install a parser such as [`tree-sitter-yaml`](https://github.com/ikatyang/tree-sitter-yaml). If that is the case, you need to enable it in your config. 79 + If you get a <code>no parser for 'yaml' language</code> error message, this means that you need to install a parser such as [`tree-sitter-yaml`](https://github.com/ikatyang/tree-sitter-yaml). From [Neovim's official `treesitter` docs](https://neovim.viio/doc/user/treesitter.html): 80 + 81 + > You can install more parsers manually, or with a plugin like [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter)โ€ 83 82 84 83 <details> 85 84 86 - <summary>Here is an example, using <code>lazy.nvim</code></summary> 85 + <summary>Here is an example, using <code>lazy.nvim</code> and <code>nvim-treesitter</code> plugin</summary> 87 86 88 87 ```lua 89 88 {
-1
lua/yaml_nvim/document.lua
··· 1 - local ts_utils = require("nvim-treesitter.ts_utils") 2 1 local M = {} 3 2 4 3 local function get_keys(root)
+17 -2
lua/yaml_nvim/pair.lua
··· 1 - local ts_utils = require("nvim-treesitter.ts_utils") 2 1 local M = {} 2 + 3 + -- ported from nvim-treestter master branch (to be deprecated) 4 + -- https://github.com/nvim-treesitter/nvim-treesitter/blob/42fc28ba918343ebfd5565147a42a26580579482/lua/nvim-treesitter/ts_utils.lua#L72-L90 5 + function is_parent(dest, source) 6 + if not (dest and source) then 7 + return false 8 + end 9 + local current = source 10 + while current ~= nil do 11 + if current == dest then 12 + return true 13 + end 14 + current = current:parent() 15 + end 16 + return false 17 + end 3 18 4 19 local function trim(value) 5 20 return (value:gsub("^%s*(.-)%s*$", "%1")) ··· 65 80 for block_sequence, _ in block:iter_children() do 66 81 local index = 0 67 82 for block_sequence_item, _ in block_sequence:iter_children() do 68 - if ts_utils.is_parent(block_sequence_item, key) then 83 + if is_parent(block_sequence_item, key) then 69 84 return index 70 85 end 71 86 index = index + 1