-
Notifications
You must be signed in to change notification settings - Fork 3
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
Indent module support #60
Comments
I would also like to see this land |
This isn't something I will be working on myself, unfortunately; my OSS time is severely limited these days, and I am no longer actively using Ember or NeoVim. My workflow for Handlebars files in the last few years has been to lean into Prettier, even if it's not always ideal in the way it chooses to format things. I'd be happy to review a PR that adds support for indentation, as long as it included tests to ensure that it isn't broken by changes down the road! |
Would it be worth transferring it to the |
I just ran in to the need for this! |
So there's this PR #112 but you can use my fork in the meantime. I'm not sure when it will be merged. |
I just tried out the upstream indent module support, and there is an off by one (indent level) error it seems. in gjs/gts when I go to a new line, I'm always one indent level left of where I actually want my cursor to be. Start:
What happens:
What I expect:
in normal hbs indents seem to work as expected, except that hitting enter does not do what I expect. What happens:
where, I would expect
it seems the behavhior in hbs is actually the same as gjs/gts, but I was through off by the starting-indentation of my elements, and my very few remaining hbs files have no indentation at all typically. it just depends on where your cursor starts... which needs fixing! is there anything we can do about this from a treesitter perspective? |
I don't think this has anything to do with treesitter. Try disabling the indent module and you'll get the same behaviour. I think the behaviour you're seeing in html files is likely from https://github.com/windwp/nvim-autopairs or a similar plugin |
If you are using the nvim-autopairs plugin, you can add this rule to your configuration to get the same behaviour
Got it from https://github.com/windwp/nvim-autopairs/blob/master/lua/nvim-autopairs/rules/basic.lua#L63 |
I don't have autopairs working in gjs 😅 how does that rule get set tho? that syntax looks goofy/unfamiliar |
Here is a video of the behavior I'm seeingn: Screencast.from.2023-11-10.15-45-30.webm |
That was not the behaviour I was seeing. I was seeing what you had in Normal mode I guess. This is my autopairs configuration for glimmer
|
is there any way to get this behavior built in? rather than in each of our configs? but also, I feel like these control flow things would be better as lua-snip snippets? but also, how do we fix the tag/element behavior? |
I'm not really sure what to tell you. There's likely something in your
config that's causing this issue. Like I said before I added the config
above I was not experiencing the problem you had. Try disabling the indent
module and confirm if this is actually being caused by treesitter indent.
…On Fri, Nov 10, 2023, 9:10 PM NullVoxPopuli ***@***.***> wrote:
is there any way to get this behavior built in? rather than in each of our
configs?
—
Reply to this email directly, view it on GitHub
<#60 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEAYZYSRIWQFVTISD3RYTTYD33BZAVCNFSM5MIPME7KU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBQGY3DMOBVGE3A>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
My lua intent behavior is flawless. |
Ok the first clip is with the autopairs rule I posted above and the second is without it. I have no idea with a gjs is. Screen.Recording.2023-11-15.at.12.02.28.PM.movScreen.Recording.2023-11-15.at.12.03.24.PM.mov |
Gjs is ember's new file format. Made a whole tutorial: https://tutorial.glimdown.com Can try it out as early as 3.28 with ember-template-imports |
Thanks for linking that. I suspect you're having issues with gjs and not hbs? I tried out gjs and indentation is indeed "broken" in gjs. Part of it is because
treesitter thinks the indentation for the div above is actually 0. So that's why you're seeing the closing div tag go back 1 indentation level when you press Enter. The way it works with jsx is that jsx is part of the javascript parser, rather than an injected language. Perhaps that should be the approach for gjs files as well? |
correct.
Maybe I defined the injection incorrectly.
since we have to change tree-sitter-javascript for that, it's unlikely to happen, unless we formally propose content-tag to tc39 https://wycats.github.io/polaris-sketchwork/content-tag.html |
anyone know how to test this stuff, in my local env, it feels like all local changes aren't detected or break everything.
this breaks TypeScript |
I used to use treesitter-playground, but I guess you have:
|
right, but how do you actually preview that your highlight addition works? editing queries only selects things in the TSPlayground |
This has landed! |
It looks like the indent module for this parser is disabled. What would be required to get it working? Right now indentation is totally broken in my hbs templates. This is my treesitter config:
I do have
'mustache/vim-mustache-handlebars'
installed, but it doesn't seem to help with the indentation at all. Currently I've set up prettier to auto format hbs files on save, but prettier is very opinionated on how to format handlebars files, so I would rather use something that has a lighter touch.The text was updated successfully, but these errors were encountered: