windwp / nvim-ts-autotag

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

Doesn't work even though installed + setup + autotag enabled #186

Closed KMint1819 closed 1 month ago

KMint1819 commented 1 month ago

Sorry to bother with a niche problem but I could never get this plugin working after hours of researching. I'm using lazy.nvim + nvim 0.9.5 and AFAIK to enable this plugin I'll have to:

  1. Enable autotag in treesitter

    local options = {
    ensure_installed = { "lua", "vim", "vimdoc" },
    
    highlight = {
    enable = true,
    use_languagetree = true,
    },
    
    autotag = {
    enable = true,
    },
    
    indent = { enable = true },
    }
    return options
  2. Install through lazy.nvim and setup
    
    {
    "windwp/nvim-ts-autotag",
    lazy = false,
    dependencies = "nvim-treesitter/nvim-treesitter",
    config = function()
      require 'nvim-ts-autotag'.setup()
    end,
    },

Am I missing anything? You can see my config file [here](https://github.com/KMint1819/nvimda/tree/autotag)
I'm mainly working on `.jsx` files but `html` files don't work as well. 
PriceHiller commented 1 month ago

Alright, this has become enough of a problem that I need to add documentation around this 😅.

So for your case, try adding html and other languages you want autotag support in to your ensure_installed section for nvim-treesitter. You can see how we do this for our test suite: https://github.com/windwp/nvim-ts-autotag/blob/8ae54b90e36ef1fc5267214b30c2cbff71525fe4/tests/minimal_init.lua?plain=1#L64-L78

Alternatively, you can set auto_install = true for nvim-treesitter which will install the parsers as needed. Autotag won't/can't work without the associated treesitter parser installed for a given language.

See https://github.com/windwp/nvim-ts-autotag/issues/64#issuecomment-2119580720 for a response to a previous issue of this sort.

I'll keep this issue open and create a PR to update documentation and close it from there.

KMint1819 commented 1 month ago

omg that response was quick :100: Setting auto_install = true shows this error:

Nvim Treesitter Setup is deprecated, use `require('nvim-ts-autotag').setup()` instead.                                                            
This feature will be removed in nvim-ts-autotag version 1.0.0  

but setting ensure_installed works. Thanks!

PriceHiller commented 1 month ago

Setting auto_install = true shows this error:

Remove these lines from your config.

We no longer use nvim-treesitter modules.

Use the plain require("nvim-ts-autotag").setup method.

KMint1819 commented 1 month ago

That was it!!! :tada: :tada: