lifeart / vsc-ember-syntax

Ember Syntax For VS Code
https://marketplace.visualstudio.com/items?itemName=lifeart.vscode-glimmer-syntax
MIT License
12 stars 8 forks source link

fix precompileTemplate highlighting #37

Closed evoactivity closed 1 year ago

evoactivity commented 1 year ago

fixes #35

image
lifeart commented 1 year ago

@evoactivity still getting issue:

import Component from '@glimmer/component';
import { precompileTemplate } from '@ember/template-compilation';
import Local from './local';
import TemplateOnlyComponent from '@/components/OnlyTemplate/component.hbs';

const calculateSummary = (a: number, b: number) => `${a}+${b}=${a + b}`;
export default class HelloWorld extends Component {

  static template = precompileTemplate(
    `
    `,
    {
      isStrictMode: true,
      scope: () => ({
        Local,
        calculateSummary,
        TemplateOnlyComponent,
      }),
    }
  );
}
image
evoactivity commented 1 year ago

Looking ok for me

image
evoactivity commented 1 year ago

I tried again today and now I see what you see.

image

I'll keep looking into this.

evoactivity commented 1 year ago

So I can get it to be this

image

but if I put a new line after the comma it breaks and I don't know why

image
evoactivity commented 1 year ago

I got a fix :)

image
evoactivity commented 1 year ago

This isn't a blocker but just maing a note.

The only thing that seems to be missing is prettier running on the embedded handlebars, I'm not sure what is missing to make that work or if that is something handled outside of the grammar.

It is registered as handlebars, but not sure if that is what triggers it.

image
lifeart commented 1 year ago

@evoactivity may be from here: https://github.com/search?q=repo%3Alifeart%2Fvsc-ember-syntax%20handlebars&type=code

Also, may be a case here: https://github.com/lifeart/typescript-hbs-plugin/blob/main/src/embeddedSupport.ts#L152 https://github.com/lifeart/typescript-hbs-plugin/blob/main/src/virtual-document-provider.ts#L19 https://github.com/lifeart/typescript-hbs-plugin/blob/92e1caf5c62ba7a8e0d1124bed7ac566097ad213/src/html-template-language-service.ts#L171

evoactivity commented 1 year ago

I also don't get prettier running for hbs`<div></div>` blocks, which I haven't touched. Ultimately prettier just sees them as strings. I guess we'd need a prettier plugin to mark those strings as embedded languages.

lifeart commented 1 year ago

@evoactivity try to comment this line: https://github.com/lifeart/vsc-ember-syntax/blob/master/package.json#L36 (where we importing support scripts, to avoid side-effects caused by typescript-hbs-plugin)

evoactivity commented 1 year ago

Doesn't seem to make a difference.