Skip to content

Commit

Permalink
Add Glimmer TS language (#6680)
Browse files Browse the repository at this point in the history
* Add Glimmer TS language

* Add Glimmer TS samples

* Run script/update-ids

* Added a naive heuristic to disambiguate .gts files between Gerber Image and Glimmer TS languages

* Add heuristic test for gts files

* Run script/list-grammars

* Update grammar submodule for vsc-ember-syntax

* Update grammar submodule for vsc-ember-syntax

* Update grammar submodule for vsc-ember-syntax

---------

Co-authored-by: Colin Seymour <[email protected]>
  • Loading branch information
gilest and lildude authored Mar 8, 2024
1 parent df4abbc commit dabba4a
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ disambiguations:
rules:
- language: GSC
named_pattern: gsc
- extensions: ['.gts']
rules:
- language: Gerber Image
pattern: '^G0.'
- language: Glimmer TS
negative_pattern: '^G0.'
- extensions: ['.h']
rules:
- language: Objective-C
Expand Down
9 changes: 9 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,15 @@ Glimmer JS:
tm_scope: source.gjs
group: JavaScript
language_id: 5523150
Glimmer TS:
type: programming
extensions:
- ".gts"
ace_mode: typescript
color: "#3178c6"
tm_scope: source.gts
group: TypeScript
language_id: 95110458
Glyph:
type: programming
color: "#c1ac7f"
Expand Down
58 changes: 58 additions & 0 deletions samples/Glimmer TS/class.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import Component from '@glimmer/component';
import FreestyleUsage from 'ember-freestyle/components/freestyle/usage';
import BoxelInputTime, { Time } from './index';
import { tracked } from '@glimmer/tracking';
import { cssVariable, CSSVariableInfo } from 'ember-freestyle/decorators/css-variable';
import { fn } from '@ember/helper';
import { action } from '@ember/object';

export default class BoxelInputTimeUsage extends Component {
cssClassName = 'boxel-input-time';

@cssVariable declare boxelInputTimeBackgroundColor: CSSVariableInfo; // TODO: replace or remove
@tracked value = new Date(2022,2,3,13,45);
@tracked minValue = new Date(2022,2,3,11,0);
@tracked minuteInterval = 5;
@action timeChanged(val: Time) {
this.value = val as Date; //TODO: casting???
}
<template>
<FreestyleUsage @name="Input::Time">
<:description>
A succint version of a time picker.
</:description>
<:example>
<BoxelInputTime
@value={{this.value}}
@minValue={{this.minValue}}
@minuteInterval={{this.minuteInterval}}
@onChange={{this.timeChanged}}
/>
</:example>
<:api as |Args|>
<Args.Object
@name="value"
@description="The current value (undefined or conforming to a Time interface that is a subset of JavaScript's Date API"
@value={{this.value}}
@onInput={{fn (mut this.value)}}
/>
<Args.Object
@name="minValue"
@description="The times before this value will disabled"
@value={{this.minValue}}
/>
<Args.Number
@name="minuteInterval"
@description="The interval at which to show minute options"
@defaultValue={{5}}
@value={{this.minuteInterval}}
@onInput={{fn (mut this.minuteInterval)}}
/>
<Args.Action
@name="onChange"
@description="Called when the user changed the time"
/>
</:api>
</FreestyleUsage>
</template>
}
48 changes: 48 additions & 0 deletions samples/Glimmer TS/template-only.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { LinkTo } from '@ember/routing';
import { TOC } from '@ember/component/template-only';
import Resource from 'ember-crate/models/resource';
import HeroIcon from 'ember-heroicons/components/hero-icon';

const formatDate = (date: Date) => {
const options: Intl.DateTimeFormatOptions = { month: 'short', day: 'numeric', year: 'numeric' };
return new Intl.DateTimeFormat('en-US', options).format(new Date(date));
};

export const ResourceCard: TOC<{ Args: { resource: Resource } }> = <template>
<LinkTo
@route='resources.resource'
@model={{@resource.slug}}
class='block max-w-sm rounded-lg border border-gray-200 bg-white drop-shadow-sm hover:bg-slate-50'
>
<div class='p-3 md:p-4'>
<div class='flex gap-2'>
<h5
class='text-l mb-2 h-[3em] font-medium tracking-tight text-gray-900 line-clamp-2 xl:text-xl tracking-tight'
>{{@resource.title}}</h5>
{{#if @resource.isFeatured}}
<HeroIcon
@icon='star'
@type='solid'
class='mt-2 h-4 w-4 shrink-0 text-yellow-400'
/>
{{/if}}
</div>

<div
class='flex flex-col justify-between gap-2 lg:flex-row lg:items-center'
>
<div class='flex items-center text-sm text-slate-700'>
<HeroIcon @icon='clock' @type='outline' class='mr-2 h-4 w-4' />
<span>{{formatDate @resource.publishDate}}</span>
</div>
<div
class='w-fit grow-0 rounded bg-slate-100 px-2.5 py-0.5 text-xs font-medium text-slate-800'
>
{{@resource.type}}
</div>
</div>
</div>
</LinkTo>
</template>;

export default ResourceCard;
7 changes: 7 additions & 0 deletions test/test_heuristics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,13 @@ def test_gsh_by_heuristics
})
end

def test_gts_by_heuristics
assert_heuristics({
"Gerber Image" => all_fixtures("Gerber Image", "*.gts"),
"Glimmer TS" => all_fixtures("Glimmer TS", "*.gts"),
})
end

def test_h_by_heuristics
assert_heuristics({
"Objective-C" => all_fixtures("Objective-C", "*.h"),
Expand Down
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Git Revision List:** [Nixinova/NovaGrammars](https://github.com/Nixinova/NovaGrammars)
- **Gleam:** [gleam-lang/tree-sitter-gleam](https://github.com/gleam-lang/tree-sitter-gleam) 🐌
- **Glimmer JS:** [lifeart/vsc-ember-syntax](https://github.com/lifeart/vsc-ember-syntax)
- **Glimmer TS:** [lifeart/vsc-ember-syntax](https://github.com/lifeart/vsc-ember-syntax)
- **Glyph:** [textmate/tcl.tmbundle](https://github.com/textmate/tcl.tmbundle)
- **Glyph Bitmap Distribution Format:** [Alhadis/language-fontforge](https://github.com/Alhadis/language-fontforge)
- **Gnuplot:** [mattfoster/gnuplot-tmbundle](https://github.com/mattfoster/gnuplot-tmbundle)
Expand Down
2 changes: 1 addition & 1 deletion vendor/licenses/git_submodule/vsc-ember-syntax.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: vsc-ember-syntax
version: 3921656e616580b9036b60a06abc1aa4fb436d64
version: e92ccb2776c37a538eee5eee09c444cff799c59a
type: git_submodule
homepage: https://github.com/lifeart/vsc-ember-syntax.git
license: mit
Expand Down

0 comments on commit dabba4a

Please sign in to comment.