windwp / nvim-ts-autotag

Use treesitter to auto close and auto rename html tag
MIT License
1.63k stars 87 forks source link

BUG: `enable_close_on_slash` should close the innermost child #209

Open aarondill opened 1 month ago

aarondill commented 1 month ago

Example:

<html>
  <head>
    <title>some content<*

When setting enable_close_on_slash = true (and enable_close=false) If the cursor is at * and the user presses /, it's expected that /title> will be inserted, however, instead /html> is inserted.

Minimal Repro ```lua ---Save as ./init.lua ---Load with `nvim -u ./init.lua` ---Plugins are installed in ./.repro/plugins ---Cleanup with `rm -rf ./.repro ./init.lua` local root = vim.fn.fnamemodify("./.repro", ":p") -- set stdpaths to use .repro for _, name in ipairs({ "config", "data", "state", "cache" }) do vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name end local lazypath = root .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath, }) end vim.opt.rtp:prepend(lazypath) require("lazy").setup({ { -- Colorscheme. Don't blind me pls :) "folke/tokyonight.nvim", init = function() require("tokyonight").load() end, opts = { transparent = true, dim_inactive = true, style = "night", styles = { sidebars = "transparent", floats = "transparent" }, }, }, { -- Set up treesitter "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", opts = { auto_install = true }, config = function(_, opts) return require("nvim-treesitter.configs").setup(opts) end, }, { -- Set up autotag "windwp/nvim-ts-autotag", dependencies = { "nvim-treesitter/nvim-treesitter" }, opts = { opts = { enable_close_on_slash = true, enable_close = false, }, }, }, }, { root = root .. "/plugins" }) ```
PriceHiller commented 1 month ago

This is related to an issue I noticed in #201.

We need to properly pick up the node pairs again.