windwp / nvim-ts-autotag

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

Autorename on .tsx files does not work #71

Closed juhaku closed 1 year ago

juhaku commented 2 years ago

Hello, Typing <div and then > will result <div></div> It works fine, but when renaming the field it doesn not work. When typing ciwspan<Esc> within the <div> does not result <span></span> but results only <span></div>.

Also when closing single type with slash / it does not add > the the end. Expected behaviour when typing <div and then / the close tag > should be automatically appended.

Also has noted here https://github.com/alvan/vim-closetag/issues/76 When editing tsx or jsx and using jsx and tsx react elements with <></> it does not automatically end or rename the tag either. When typed < and then closed with > it will not automatically add </> end tag.

shaeinst commented 2 years ago

it's working fine for me. have a look at my config packer treesitter ts-autotag

juhaku commented 2 years ago

The configs where not much different from mine. However I have previously not used <Esc> key but I prefer typing <C-c>. I know ctrl + c is cancel command / operation in neovim but I find it more intuitive than reaching out to the <Esc> or remapping <Esc> to some other key combination, because I want the pressing of <Esc> to consistent across the modes.

So as I have found out:

Is there a way to make the counterpart element update while typing within the element? The way pretty much any IDE does it?

shaeinst commented 2 years ago

you can use nvim-autopairs plugin for such task for example:

Typing <> will not autoclose </> jsx / tsx empty elements.

require('nvim-autopairs').add_rules {
Rule("%<%>$", "</>", { 'typescript', 'typescriptreact', 'javascript', 'javascriptreact' })
:use_regex(true),
}
juhaku commented 2 years ago

Thanks, that fixes the empty tsx element issue, but still the behavior is lacking in other aspects.

shaeinst commented 2 years ago

i am not trying to convince you but using <C-c> instead of ESC seems little weird to me. since ESC is one of the important key in vim, i would suggest you to swap ESC with Caps Lock. Then it would become more easy to use ESC (since your left hand fingers are always close to a,s,d,f). i use keyd to swap keys..

putra4648 commented 2 years ago

You should install this too :TSInstall tsx

Duplicate from #66

juhaku commented 2 years ago

You should install this too :TSInstall tsx

Yes sure, it is installed

waseidel commented 1 year ago

You should install this too :TSInstall tsx

Duplicate from #66

That fixed for me, at least autoclosing jsx tags

stale[bot] commented 1 year 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.