vim-matchup icon indicating copy to clipboard operation
vim-matchup copied to clipboard

How to delete the whole tag with '<' and '>' in tsx or html-like filetypes?

Open zuoxinyu opened this issue 3 years ago • 3 comments
trafficstars

Explain the issue

I'm using neovim 0.7 with treesitter enabled,

Minimal configure

use {
    'andymass/vim-matchup',
    event = 'VimEnter',
    config = function()
        vim.g.matchup_matchparen_offscreen = { method = 'popup' }
        vim.g.matchup_matchpref = {
            html = { tagnameonly = 0 },
            tsx = { tagnameonly = 0 },
            typescriptreact = { tagnameonly = 0 },
        }
    end
}

Minimal working example

When I press da%, I'd expect to delete the whole block, but the open tag and closing tag will leave the < and `>'. For example:

<Group grow>
    <Button>Save</Button>
    <Button>Save</Button>
</Group>

It leaves

<>

zuoxinyu avatar Apr 26 '22 04:04 zuoxinyu

I can't seem to reproduce this. What is your nvim-tree-sitter configuration, if any? Where is your cursor located when you do da%?

andymass avatar Apr 26 '22 13:04 andymass

I can't seem to reproduce this. What is your nvim-tree-sitter configuration, if any? Where is your cursor located when you do da%?

Sorry, here is my treesitter config:

use {
    'nvim-treesitter/nvim-treesitter',
    run = ':TSUpdate',
    config = function()
        vim.o.foldmethod = 'expr'
        vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
        vim.o.foldlevel = 20
        require 'nvim-treesitter.configs'.setup {
            -- indent = { enable = true }, -- experimental
            highlight = { enable = true },
            matchup = { enable = true },
            incremental_selection = { enable = true },
            ensure_installed = {
                'vim', 'json', 'markdown', 'yaml', 'html', 'css', 'bash',
                'make', 'cmake', 'c', 'cpp', 'lua', 'rust', 'javascript',
                'typescript', 'go', 'haskell', 'tsx', 'vue', 'python', 'php',
            },
        }
    end
}

And the cursor locates on the tag, e.g. G of <Group> .

zuoxinyu avatar Apr 26 '22 18:04 zuoxinyu

matchup

zuoxinyu avatar Apr 26 '22 18:04 zuoxinyu