windwp / nvim-ts-autotag

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

Does not work with xml #79

Closed TornaxO7 closed 1 year ago

TornaxO7 commented 1 year ago

TL;DR

My tags aren't getting completed in xml files, even I explicitely set it in the config.

Reproduction

~/.config/nvim/init.lua

local packer = require("packer")

packer.startup(function(use)
    use "windwp/nvim-ts-autotag"
    use {
        "nvim-treesitter/nvim-treesitter",
        run = ":TSUpdate",
        config = function() require("treesitter_settings.settings") end
    }
end)

~/.config/nvim/lua/treesitter_settings/settings.lua

local treesitter = require('nvim-treesitter.configs')

treesitter.setup({
    ensure_installed = "all",

    // ...

    autotag = {
        enable = true,
        filetypes = {"html", "xml"},
    }
})

Now open any .xml file and type <div>, I don't get the closing tag.

oncomouse commented 1 year ago

Do you have a treesitter parser installed for xml? There's not one in nvim-treesitter, so you have to add it yourself. Here's how I do it in my config. Then you can add xml to ensure_installed and you will have XML support in treesitter (and this plugin).

TornaxO7 commented 1 year ago

Oh, I didn't know that xml is not part of nvim-treesitter. That fixed it for me, thanks!