windwp / nvim-ts-autotag

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

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

Closed oedotme closed 4 months ago

oedotme commented 4 months ago

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

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>   šŸ”“
------------------------------------
oedotme commented 4 months ago

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,
    },
  },
}
PriceHiller commented 4 months ago

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 šŸ™‚.