nvim-ts-autotag
                                
                                 nvim-ts-autotag copied to clipboard
                                
                                    nvim-ts-autotag copied to clipboard
                            
                            
                            
                        Not working exclusively on .tsx files
I'm on NVIM v0.9.1. and have installed the nvim-ts-autotag with packer:
use 'windwp/nvim-ts-autotag'
And set it up as per the instructions:
require('nvim-ts-autotag').setup()
It seems to be working fine in .html .jsx and .svelte files, however, in .tsx files it simply doesn't work.
I have also tried to explicitly pass tsx as an argument to the setup function to no avail:
require('nvim-ts-autotag').setup({
    filetypes = { 'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx',
        'jsx', 'rescript', },
})
Because the problem is present on tsx files I'll also provide whatever else I have running on my tsx files:
require 'nvim-treesitter.configs'.setup {
    ensure_installed = { "javascript", "typescript", "go", "python", "c", "lua", "vim", "vimdoc", "query" },
    sync_install = false,
    auto_install = false,
    highlight = {
        enable = true,
        additional_vim_regex_highlighting = false,
    },
}
local lsp = require("lsp-zero")
local cmp = require('cmp')
local function on_attach(client, bufnr)
    local opts = { buffer = bufnr, remap = false }
    vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
    vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
    vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
    vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
    vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
    vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
    vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
    vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
    vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
    vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
end
-- Set up LSP and Pyright
lsp.preset("recommended")
lsp.ensure_installed({
    'tsserver',
    'gopls',
    'pyright',
    'clangd',
})
lsp.nvim_workspace()
lsp.set_preferences({
    suggest_lsp_servers = false,
    sign_icons = {
        error = 'E',
        warn = 'W',
        hint = 'H',
        info = 'I'
    }
})
-- Set up cmp mappings for completion
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mappings = lsp.defaults.cmp_mappings({
    ['<S-k>'] = cmp.mapping.select_prev_item(cmp_select),
    ['<S-j>'] = cmp.mapping.select_next_item(cmp_select),
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
    ["<C-Space>"] = cmp.mapping.complete(),
})
cmp_mappings['<Tab>'] = nil
cmp_mappings['<S-Tab>'] = nil
-- Set up nvim-cmp
lsp.setup_nvim_cmp({
    mapping = cmp_mappings
})
-- Set up LSP for gopls and Pyright
lsp.setup({
    gopls = {
        on_attach = on_attach,
        cmd = { "gopls" },
        settings = {
            gopls = {
                completeUnimported = true,
                usePlaceholders = true,
                analyses = {
                    unusedparams = true
                },
            },
        },
    },
    pyright = {
        on_attach = on_attach,
        settings = {
            python = {
                analysis = {
                    autoSearchPaths = true,
                    useLibraryCodeForTypes = true,
                    diagnosticMode = "workspace",
                },
                autoImportCompletions = true,
            },
        },
    },
})
-- Configure diagnostic display
vim.diagnostic.config({
    virtual_text = true
})
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.
I got the same problem. I working with other files except the tsx files.
same problem here
hey, i just had the same issue, and i think i see your issue!
unlike how the javascript treesitter parser includes jsx, the typescript treesitter parser doesn't include tsx. make sure you have the tsx treesitter parser installed: https://github.com/sdodson99/.dotfiles/commit/16aa31595ca8026374f328220dafdab40c5a70e7
basically, treesitter wasn't working at all for me in tsx files, so this autotag thing wasn't working either 😱
I'm also having this issue, even with the treesitter tsx parser installed
Update: Actually it works, but only if I use the treesitter config option, but not if I use the setup function
For me, the problem was the InsertLeave autocmd was always cleared after the first invocation, the following patch fixed the issue on my end
diff --git a/lua/nvim-ts-autotag/internal.lua b/lua/nvim-ts-autotag/internal.lua
index bab1345..a7815d8 100644
--- a/lua/nvim-ts-autotag/internal.lua
+++ b/lua/nvim-ts-autotag/internal.lua
@@ -554,7 +554,7 @@ M.attach = function(bufnr, lang)
 
     if is_in_table(M.tbl_filetypes, vim.bo.filetype) then
         setup_ts_tag()
-        local group = vim.api.nvim_create_augroup('nvim-ts-autotag', { clear = true })
+        local group = vim.api.nvim_create_augroup('nvim-ts-autotag', { clear = false })
         if M.enable_close == true then
             vim.api.nvim_buf_set_keymap(bufnr or 0, "i", ">", ">", {
                 noremap = true,
Try checking :au nvim-ts-autotag to see if the autocmds are not cleared
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.
I seem to have this same issue, @windwp Can you or somebody submit a patch to fix this issue for the tsx files?
~Hey folks, I've started maintaining a fork over at https://github.com/PriceHiller/nvim-ts-autotag/ until windwp returns.~
~I can't reproduce this over there. I have incorporated a few patches thus far, so perhaps that's why it works for me.~
~If you're still having trouble, try the fork and if it's still not working, open an issue and I'll take another look 🙂.~
I am now helping maintain this plugin, that fork has been merged.
Should be fully resolved with the merging of #173