nvim-ts-autotag
nvim-ts-autotag copied to clipboard
Autorename on .tsx files does not work
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.
it's working fine for me. have a look at my config packer treesitter ts-autotag
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>
- But typing
- 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?
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),
}
Thanks, that fixes the empty tsx element issue, but still the behavior is lacking in other aspects.
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..
You should install this too
:TSInstall tsx
Duplicate from #66
You should install this too :TSInstall tsx
Yes sure, it is installed
You should install this too
:TSInstall tsx
Duplicate from #66
That fixed for me, at least autoclosing jsx tags
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.