windwp / nvim-ts-autotag

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

How to make this plugin work on html.heex templates from Phoenix #149

Closed jpx40 closed 5 months ago

jpx40 commented 9 months ago

Hey, i am using Elixir Phoenix for an Project but this Plugins seems to not really work with heex files.

sharkby7e commented 9 months ago

commenting for visibility! Would also be nice for other embedded languages if erb files for ruby on rails!

sharkby7e commented 9 months ago

I figured it out, I have two separate config files, one to load the plugin and call setup which is lazy loaded nvim-ts-autotag.lua

return {
  "windwp/nvim-ts-autotag",
  config = function()
    require('nvim-ts-autotag').setup({})
  end,
  lazy = true
}

and then my nvim-treesitter.lua has

return {
  'nvim-treesitter/nvim-treesitter',
  lazy = false,
  priority = 999,
  build = ":TSUpdate",
  cmd = { "TSUpdateSync" },
  dependencies = {
    "windwp/nvim-ts-autotag",
    "tpope/vim-endwise",
    "HiPhish/nvim-ts-rainbow2",
    "nvim-treesitter/nvim-treesitter-textobjects",
  },
  config = function()
    require 'nvim-treesitter.configs'.setup {
      ensure_installed = { "elixir", "heex", "eex", "ruby" },
      autotag = {
        enable = true,
        filetypes = { "html", "xml", "eruby", "heex", "elixir", "embedded_template" },
      },
    }
  end
}(rest of config)
jpx40 commented 9 months ago

@sharkby7e could you solve the Issue?

jpx40 commented 9 months ago

@sharkby7e so i could try to add the autotag to nvimtreesitter

sharkby7e commented 9 months ago

@jpx40 yeah that's what fixed it for me!

jpx40 commented 9 months ago

@sharkby7e Can you help me fix my config? It doesn't work yet. I changed to another file format in Golang templ.

sharkby7e commented 9 months ago

@jpx40 sure, post ur config!

jpx40 commented 9 months ago

@sharkby7e https://github.com/jpx40/dotfiles/tree/main/dot_config/nvim

jpx40 commented 9 months ago

It's based on LazyVim, so i kinda don't made the most my self.

sharkby7e commented 9 months ago

@jpx40 I think ur missing the treesitter config. Check out my config here https://github.com/sharkby7e/nvim

sharkby7e commented 9 months ago

@jpx40 did the pr you pushed fix this?

jpx40 commented 9 months ago

I don't know if the commit is right way since templ is an custom file. I figured out that autotag is pre-configured in Lazyvim. The easiest way would be an fork.

Vagab commented 8 months ago

hey guys, not sure if this is the right issue for it, but I'm trying to make autotag work with ~H sigil inside ex files, but for some reason it does not. I'm using lunarvim and my current config for autotag looks like this:

  {
    "windwp/nvim-ts-autotag",
    config = function()
      require("nvim-ts-autotag").setup({
        enable = true,
        filetypes = { "html", "xml", "eruby", "heex", "elixir", "embedded_template" }
      })
    end,
    lazy = true,
  },

any help is greatly appreciated!

jpx40 commented 8 months ago

@Vagab sry, i still have similar problems my knowledge about this plugin and neovim is not good enough to help you. If i figure something out i will help you.

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.