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

Add support for Svelte. #4323

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,9 @@
[submodule "vendor/grammars/sublimetext-cuda-cpp"]
path = vendor/grammars/sublimetext-cuda-cpp
url = https://github.com/harrism/sublimetext-cuda-cpp
[submodule "vendor/grammars/svelte-atom"]
path = vendor/grammars/svelte-atom
url = https://github.com/umanghome/svelte-atom
[submodule "vendor/grammars/swift.tmbundle"]
path = vendor/grammars/swift.tmbundle
url = https://github.com/textmate/swift.tmbundle
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ vendor/grammars/sublimeprolog:
- source.prolog.eclipse
vendor/grammars/sublimetext-cuda-cpp:
- source.cuda-c++
vendor/grammars/svelte-atom:
- source.svelte
vendor/grammars/swift.tmbundle:
- source.swift
vendor/grammars/tcl.tmbundle:
Expand Down
11 changes: 11 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4343,6 +4343,17 @@ STON:
tm_scope: source.smalltalk
ace_mode: text
language_id: 336
Svelte:
Copy link
Contributor

Choose a reason for hiding this comment

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

Items in languages.yml should be alphabetically sorted, with uppercase letters first.

type: markup
tm_scope: text.html.svelte
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be source.svelte.

group: HTML
ace_mode: html
codemirror_mode: htmlmixed
codemirror_mime_type: text/html
color: "#e34c26"
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to set a color since it has a group; it will automatically take the parent's color.

extensions:
- ".svelte"
Copy link
Contributor

Choose a reason for hiding this comment

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

I counted 117 repositories by 102 users from the search query you provided. That a bit low considering our usual requirement of hundreds of repositories, but it's unlikely we'll get any conflicts in the future given the extension. @lildude What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, that usage is not high enough for inclusion right now, it's barely over a hundred let alone hundreds.

- ".htmlx"
SVG:
type: data
extensions:
Expand Down
37 changes: 37 additions & 0 deletions samples/Svelte/Form.htmlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<form on:submit="createHandler(event)">
<div>
<label for="slinky-title">Title</label>
<input
bind:value='title'
id="slinky-title"
name="title"
type="text"
/>
</div>
<button type="submit">Add Now</button>
<button type="button" on:click="logState()">Log</button>
</form>

<script>
const defaultData = {
title: '',
}

export default {
data: () => defaultData,

methods: {
logState() {
console.log(this.get())
},

createHandler(event) {
event.preventDefault()
// parse, validate, fire, reset
const slinky = this.get()
this.fire('create', slinky)
this.set(defaultData)
}
},
}
</script>
37 changes: 37 additions & 0 deletions samples/Svelte/Form.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<form on:submit="createHandler(event)">
<div>
<label for="slinky-title">Title</label>
<input
bind:value='title'
id="slinky-title"
name="title"
type="text"
/>
</div>
<button type="submit">Add Now</button>
<button type="button" on:click="logState()">Log</button>
</form>

<script>
const defaultData = {
title: '',
}

export default {
data: () => defaultData,

methods: {
logState() {
console.log(this.get())
},

createHandler(event) {
event.preventDefault()
// parse, validate, fire, reset
const slinky = this.get()
this.fire('create', slinky)
this.set(defaultData)
}
},
}
</script>
1 change: 1 addition & 0 deletions vendor/grammars/svelte-atom
Submodule svelte-atom added at 5a6914
27 changes: 27 additions & 0 deletions vendor/licenses/grammar/svelte-atom.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
type: grammar
name: svelte-atom
version: 5a6914d90972db02b57822b47682107fc26f13bc
license: mit
---
MIT License

Copyright (c) 2018 Umang Galaiya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.