windwp/nvim-ts-autotag

bug: lazy loading `nvim-ts-autotag` breaks it in `typescriptreact` files -- documentation issue

Closed this issue · 2 comments

With the default config/setup — auto-close and auto-rename works with html, but not with typescriptreact:

require('nvim-ts-autotag').setup({
  opts = {
    enable_close = true,
    enable_rename = true,
    enable_close_on_slash = false
  },
})

Versions

  • nvim-ts-autotag cb57b07
  • nvim v0.10.0
  • tree-sitter 0.22.6

html

Expected behavior:

Before        Input         After
------------------------------------
<div           >              <div></div>
<div></div>    ciwspan<esc>   <span></span>
------------------------------------

Actual behavior:

Before        Input         After
------------------------------------
<div           >              <div></div>
<div></div>    ciwspan<esc>   <span></span>
------------------------------------

typescriptreact 🔴

Expected behavior:

Before        Input         After
------------------------------------
<div           >              <div></div>
<div></div>    ciwspan<esc>   <span></span>
------------------------------------

Actual behavior:

Before        Input         After
------------------------------------
<div           >              <div>          🔴
<div></div>    ciwspan<esc>   <span></div>   🔴
------------------------------------

I found related issues to the usage with lazy.nvim

Setting lazy = false or event = 'VeryLazy' seems to fix it:

return {
  'https://github.com/windwp/nvim-ts-autotag',
  event = 'VeryLazy',
  opts = {
    opts = {
      enable_close = true,
      enable_rename = true,
      enable_close_on_slash = false,
    },
  },
}

I'll add a PR later today addressing lazy loading for nvim-ts-autotag.

If this was better documented, you'd have never had this problem in the first place.

I'm going to reopen this issue with that in mind and close it via PR -- no need for you to do anything, just for tracking 🙂.