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

Fix indentation logic to be context aware #2

Open
ohcibi opened this issue Jun 6, 2017 · 8 comments
Open

Fix indentation logic to be context aware #2

ohcibi opened this issue Jun 6, 2017 · 8 comments
Assignees

Comments

@ohcibi
Copy link
Collaborator

ohcibi commented Jun 6, 2017

With the current indentation logic its kinda impossible to correctly indent the following:

{{#multiline
  mustache=with
  block}}
  .
{{/multiline}}

as we cannot easily tell wether block}} actually ends a block-opener-mustache ({{#multiline) vs a simple mustache ({{input)). In the first case we need to keep the indent and in the last case it should de-dented.

I'm thinking of some kind of state-logic that not only counts the indent's width but also it's context.

@ohcibi ohcibi self-assigned this Jun 6, 2017
@jsit
Copy link

jsit commented Nov 26, 2018

I recently addressed this in the official Vim mustache syntax plugin:

mustache/vim-mustache-handlebars@678cc34

Try switching to that, or adopting something similar here.

@NullVoxPopuli
Copy link
Contributor

This should be handled ember-template-lint, yeah?

@jsit
Copy link

jsit commented Jul 31, 2019

@NullVoxPopuli Indentation is commonly handled in language syntax plugins.

@ohcibi This was recently fixed in the mustache/vim-mustache-handlebars#93 repo very cleverly by @AndrewRadev. No need for state logic!

@NullVoxPopuli
Copy link
Contributor

vim-mustache-handlebars doesn't have all the additional syntax that ember templates have, though. because ember-templates are not handlebars :-\

@jsit
Copy link

jsit commented Jul 31, 2019

vim-mustache-handlebars doesn't have all the additional syntax that ember templates have, though. because ember-templates are not handlebars :-\

This is true, however, one of Mustache's maintainers @bruno- let me know in an email exchange last year that he is comfortable with putting Ember-specific syntax in there, as long as it doesn't break basic Mustache/Handlebars highlighting.

@ohcibi
Copy link
Collaborator Author

ohcibi commented Sep 2, 2019

@jsit I dont know how to proceed here to be honest. I'm neither a maintainer of vim-ember-hbs nor of vim-mustache handlebars. I dont know about the future of standalone handlebars/mustache either. If those are something that exist outside of ember and ember-hbs just extends on that syntax, I'd prefer to have the vim-ember-hbs-plugin specify vim-mustache-handlebars as a dependency and to move anything thats pure mustache into that plugin.

If on the other hand the only application of mustache was actually ember-hbs, I'd rather prefer to have only one plugin.

If both plugins continue to exist we should additionally ensure that the names of the highlight groups etc. do align such that e.g. custom colorschemes don't have to support two different plugins.

@joukevandermaas whats your take on this? Fwiw I can help maintaining this (vim-ember-hbs) plugin if theres need for that.

@joukevandermaas
Copy link
Owner

I created this one, because mustache has syntax that is not valid (ember) hbs, and (ember) hbs has syntax that is not valid mustache. My opinion is, they are different languages and there is little to no value in code-sharing of syntax files.

However, for indentation I can see the value as the hbs rules really are kind of an extension of the mustache ones (as far as I can tell). Either way I'm happy to do anything that makes users of this plugin more productive. I'll take PRs that copy from the other plugin, or any kind of setup that enables code-sharing.

@ohcibi as far as maintenance goes, there are very few prs, and I tend to review them somewhat quickly. However if you want to have commit access to make the process quicker I'm open to that.

Finally as for this issue, the template linter actually does not like it, it prefers to put the closing braces on the next line:

{{#multiline
  mustache=with
  block
}}
  .
{{/multiline}}

Maybe following that suggestion solves the problem also?

@ohcibi
Copy link
Collaborator Author

ohcibi commented Sep 3, 2019

@joukevandermaas the template linter had some issues with that when I found that issue back in the days. So this might be a valid workaround although the position of the closing braces is still somewhat in discussion although this one is about multilines in combination with as. So I'd say both styles should be supported by the indenting logic

Regarding both projects I agree that they should kept separated. I wasn't looking into the mustache only plugin because of said differences. Maybe it is still possible to find a common base plugin as besides those differences both languages are pretty similar.

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

No branches or pull requests

4 participants