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

Does not work in template literals of JS/TS files #32

Closed
benfrain opened this issue Oct 26, 2021 · 9 comments · Fixed by #78
Closed

Does not work in template literals of JS/TS files #32

benfrain opened this issue Oct 26, 2021 · 9 comments · Fixed by #78

Comments

@benfrain
Copy link

Treesitter understands nested tags in Template Literals but I can't get auto-tag to see them (working fine in HTML files)

Example - typing standard js file:

const ex = html`<div>|`

Would expect:

const ex = html`<div>|</div>`

Actually get:

const ex = html`<div>|`

Possibly related to #21

@windwp
Copy link
Owner

windwp commented Oct 26, 2021

it can't work on template

@windwp windwp closed this as completed Oct 26, 2021
@benfrain
Copy link
Author

@windwp thanks, do you know if this is due to a limitation in Treesitter/Neovim? Is that something I could raise there?

@bennypowers
Copy link
Contributor

This could definitely work within template literals. Tree sitter injects the HTML grammar into html-tagged template literals; see attached screenshot:
below: Typescript source code, cursor is on a <slot> element within an html-tagged template literal. above: TSPlayground showing that cursor is on a tag_name node within an HTML grammar tree

@colepeters
Copy link

Sorry to bump an old issue, just wondering if there's any chance for an update here? @bennypowers suggests this should be possible, and with JS functions returning HTML templates becoming more common, this would be a great quality of life improvement! :)

@bennypowers
Copy link
Contributor

bennypowers commented Oct 6, 2022

see #78 which fixes this

Screencast.from.10-06-2022.11.47.39.AM.trimmed.1.mp4

@colepeters
Copy link

Wow that was fast, many thanks @bennypowers! Fingers crossed for a merge on this soon.

@bennypowers
Copy link
Contributor

sure thing
use my fork in the mean time

use { 'bennypowers/nvim-ts-autotag', { branch = 'template-tags' } }

@benfrain
Copy link
Author

@windwp would you be able to merge this in?

@marlun
Copy link

marlun commented Jan 10, 2023

I'm also using this and would really appreciate it getting in, I'm using the bennypowers branch for now though and it's working great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants