Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorename on .tsx files does not work #71

Closed
juhaku opened this issue Aug 11, 2022 · 9 comments
Closed

Autorename on .tsx files does not work #71

juhaku opened this issue Aug 11, 2022 · 9 comments
Labels
wontfix This will not be worked on

Comments

@juhaku
Copy link

juhaku commented Aug 11, 2022

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 alvan/vim-closetag#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
Copy link

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

@juhaku
Copy link
Author

juhaku commented Aug 27, 2022

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:

  • Typing <div an then > will result <div></div>
  • Typing ciwspan<Esc> within div results <span></span>
    • But typing ciwspan<C-c> will not work and will result <span></div>
  • Typing <> will not autoclose </> jsx / tsx empty elements.
  • Also typing <div and then / will not close with >, so end result will be <div/ not <div/>

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

@shaeinst
Copy link

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
Copy link
Author

juhaku commented Aug 27, 2022

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

@shaeinst
Copy link

shaeinst commented Aug 27, 2022

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
Copy link

putra4648 commented Aug 30, 2022

You should install this too
:TSInstall tsx

Duplicate from #66

@juhaku
Copy link
Author

juhaku commented Aug 30, 2022

You should install this too
:TSInstall tsx

Yes sure, it is installed

@waseidel
Copy link

waseidel commented Oct 3, 2022

You should install this too :TSInstall tsx

Duplicate from #66

That fixed for me, at least autoclosing jsx tags

@stale
Copy link

stale bot commented Dec 2, 2022

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.

@stale stale bot added the wontfix This will not be worked on label Dec 2, 2022
@stale stale bot closed this as completed Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants