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

feat: add support for gjs and gts #9940

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
| git-config | ✓ | | | |
| git-ignore | ✓ | | | |
| git-rebase | ✓ | | | |
| gjs | ✓ | ✓ | ✓ | `typescript-language-server`, `vscode-eslint-language-server`, `ember-language-server` |
| gleam | ✓ | ✓ | | `gleam` |
| glimmer | ✓ | | | `ember-language-server` |
| glsl | ✓ | ✓ | ✓ | |
Expand All @@ -73,6 +74,7 @@
| gowork | ✓ | | | `gopls` |
| graphql | ✓ | ✓ | | `graphql-lsp` |
| groovy | ✓ | | | |
| gts | ✓ | ✓ | ✓ | `typescript-language-server`, `vscode-eslint-language-server`, `ember-language-server` |
| hare | ✓ | | | |
| haskell | ✓ | ✓ | | `haskell-language-server-wrapper` |
| haskell-persistent | ✓ | | | |
Expand Down
70 changes: 70 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,28 @@ inlayHints.functionLikeReturnTypes.enabled = true
inlayHints.enumMemberValues.enabled = true
inlayHints.parameterNames.enabled = "all"

[language-server.vscode-eslint-language-server]
command = "vscode-eslint-language-server"
args = ["--stdio"]

[language-server.vscode-eslint-language-server.config]
validate = "on"
experimental = { useFlatConfig = false }
rulesCustomizations = []
run = "onType"
problems = { shortenToSingleLine = false }
nodePath = ""

[language-server.vscode-eslint-language-server.config.codeAction.disableRuleComment]
enable = true
location = "separateLine"

[language-server.vscode-eslint-language-server.config.codeAction.showDocumentation]
enable = true

[language-server.vscode-eslint-language-server.config.workingDirectory]
mode = "location"

[[language]]
name = "rust"
scope = "source.rust"
Expand Down Expand Up @@ -3579,3 +3601,51 @@ language-servers = ["pest-language-server"]
[[grammar]]
name = "pest"
source = { git = "https://github.com/pest-parser/tree-sitter-pest", rev = "a8a98a824452b1ec4da7f508386a187a2f234b85" }

[[language]]
name = "gjs"
scope = "source.gjs"
file-types = ["gjs"]
roots = ["package.json", "ember-cli-build.js"]
comment-token = "//"
block-comment-tokens = { start = "/*", end = "*/" }
language-servers = [
{ except-features = [
"format", "diagnostics",
], name = "typescript-language-server" },
"vscode-eslint-language-server",
"ember-language-server",
]
indent = { tab-width = 2, unit = " " }
grammar = "javascript"

[language.auto-pairs]
'<' = '>'
"'" = "'"
"{" = "}"
"(" = ")"
'"' = '"'

[[language]]
name = "gts"
scope = "source.gts"
file-types = ["gts"]
roots = ["package.json", "ember-cli-build.js"]
comment-token = "//"
block-comment-tokens = { start = "/*", end = "*/" }
language-servers = [
{ except-features = [
"format", "diagnostics",
], name = "typescript-language-server" },
"vscode-eslint-language-server",
"ember-language-server",
]
indent = { tab-width = 2, unit = " " }
grammar = "typescript"

[language.auto-pairs]
'<' = '>'
"'" = "'"
"{" = "}"
"(" = ")"
'"' = '"'
5 changes: 5 additions & 0 deletions runtime/queries/_gjs/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
(glimmer_opening_tag)
(glimmer_closing_tag)
] @constant.builtin
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved

20 changes: 20 additions & 0 deletions runtime/queries/_gjs/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; PARSE GLIMMER TEMPLATES
(call_expression
function: [
(identifier) @injection.language
(member_expression
property: (property_identifier) @injection.language)
]
arguments: (template_string) @injection.content)

; e.g.: <template><SomeComponent @arg={{double @value}} /></template>
((glimmer_template) @injection.content
(#set! injection.language "hbs"))

; Parse Ember/Glimmer/Handlebars/HTMLBars/etc. template literals
; e.g.: await render(hbs`<SomeComponent />`)
(call_expression
function: ((identifier) @_name
(#eq? @_name "hbs"))
arguments: ((template_string) @glimmer
(#offset! @glimmer 0 1 0 -1)))
Comment on lines +16 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support #offset!. This will also need to be updated to use injection.content and injection.language rather than tagging with @glimmer - that's the way nvim-treesitter did injections in the past.

Something like

(call_expression
  function: ((identifier) @_name
             (#eq? @_name "hbs"))
  arguments: ((template_string) @injection.content
              (#set! injection.language "glimmer")))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably just be dropped due to RFC 0779

As of [RFC 0779][rfc-0779], we decided on <template> over hbs; see the RFC for the full rationale. The hbs format is still technically supported by this repo for transition purposes for the early adopters who helped us get here, but will be removed at some point in the near future! hbs has been removed -- if you rely on this feature, please use ember-template-imports @ < v4, until migrated to <template>

If anywhere this probably belongs into the javascript/typescript injections instead of gjs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah let's drop this pattern. It won't do anything in its current form anyways because of the @glimmer capture

1 change: 1 addition & 0 deletions runtime/queries/gjs/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_javascript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gjs/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_javascript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gjs/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_javascript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gjs/locals.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_javascript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gjs/tags.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_javascript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gjs/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_javascript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gts/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_typescript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gts/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_typescript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gts/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_typescript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gts/locals.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_typescript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gts/tags.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_typescript,ecma
1 change: 1 addition & 0 deletions runtime/queries/gts/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: _gjs,_typescript,ecma
Loading