robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqMerge pull request #38176 from zeertzjq/vim-99ea2b5f111b954a2

master
1.4 KiB51 linesraw
1" Vim syntax file
2" Language:     Glimmer
3" Maintainer:   Devin Weaver
4" Last Change:  2026 Feb 20
5" Origin:       https://github.com/joukevandermaas/vim-ember-hbs
6" Credits:      Jouke van der Maas
7" License:      Same as Vim
8
9" Vim detects GJS/GTS files as {java,type}script.glimmer
10" Vim will read the javascript/typescript syntax files first and set
11" b:current_syntax accordingly then it will read the glimmer syntax file.
12" This is why we use b:current_syntax to make sure we are in the correct state
13" to continue.
14
15if exists('b:current_syntax') && b:current_syntax !~# '\v%(type|java)script'
16  finish
17endif
18
19let base_syntax = b:current_syntax
20unlet! b:current_syntax
21
22let s:cpo_save = &cpo
23set cpo&vim
24
25syntax include @hbs syntax/handlebars.vim
26
27if base_syntax == "javascript"
28  syntax region glimmerTemplateBlock
29    \ start="<template>" end="</template>"
30    \ contains=@hbs
31    \ keepend fold
32
33  let b:current_syntax = "javascript.glimmer"
34else
35  " syntax/typescript.vim adds typescriptTypeCast which is in conflict with
36  " <template> typescriptreact doesn't define it but we want to not include
37  " the JSX syntax.
38  syntax clear typescriptTypeCast
39
40  syntax region glimmerTemplateBlock
41    \ start="<template>" end="</template>"
42    \ contains=@hbs
43    \ containedin=typescriptClassBlock,typescriptFuncCallArg
44    \ keepend fold
45
46  let b:current_syntax = "typescript.glimmer"
47endif
48
49let &cpo = s:cpo_save
50unlet s:cpo_save
51unlet! base_syntax