Skip to content

Commit

Permalink
add the fish syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
vanyauhalin committed Apr 20, 2024
1 parent 00d766c commit f1978d3
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Moondust is developed for each syntax individually. Alongside each syntax, you w
| ------------------ | --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| CSS | [CSS Language Basics (builtin)](https://github.com/microsoft/vscode/tree/1.87.0/extensions/css/) | [View example](https://vanyauhalin.github.io/moondusttheme/css/) |
| Dockerfile | [Docker Language Basics (builtin)](https://github.com/microsoft/vscode/tree/1.87.0/extensions/docker/) | [View example](https://vanyauhalin.github.io/moondusttheme/dockerfile/) |
| Fish | [Fish](https://github.com/bmalehorn/vscode-fish/tree/2bdcfbea62cadc2a977eace3189d25b31df71e72/) | [View example](https://vanyauhalin.github.io/moondusttheme/fish/) |
| Go | [Builtin Extension (builtin)](https://github.com/microsoft/vscode/tree/1.87.0/extensions/go/) | [View example](https://vanyauhalin.github.io/moondusttheme/go/) |
| Go Module | [Go](https://github.com/golang/vscode-go/tree/v0.41.2/) | [View example](https://vanyauhalin.github.io/moondusttheme/go.mod/) |
| Go Sum | [Go](https://github.com/golang/vscode-go/tree/v0.41.2/) | [View example](https://vanyauhalin.github.io/moondusttheme/go.sum/) |
Expand Down
51 changes: 51 additions & 0 deletions extension/syntaxes/fish/fish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @typedef {import("../../../shared/meta.js").Meta} Meta
* @typedef {import("../../colors/themes.js").Syntax} Syntax
*/

/**
* @returns {Meta}
*/
export function meta() {
return {
title: "fish",
name: "fish",
scope: "source.fish",
grammars: ["https://github.com/bmalehorn/vscode-fish/blob/2bdcfbea62cadc2a977eace3189d25b31df71e72/syntaxes/fish.tmLanguage.json/"],
example: {
author: {
name: "Jorge Bucaran",
url: "https://github.com/jorgebucaran/"
},
source: {
name: "A plugin manager for Fish",
url: "https://github.com/jorgebucaran/fisher/blob/4.4.4/functions/fisher.fish/"
}
}
}
}

/**
* @param {Syntax} s
* @returns {Record<string, string>}
*/
export function tokenColors(s) {
const c0 = s.comment[0]
const p0 = s.plain[0]
const p1 = s.plain[1]
const s0 = s.string[0]
const s1 = s.string[1]

return {
"comment.line.number-sign.fish": c0,
"keyword.control.fish": p0,
"punctuation.definition.string.begin.fish": s0,
"punctuation.definition.string.end.fish": s0,
"punctuation.definition.variable.fish": p0,
"source.fish": p1,
"string.quoted.double.fish": s1,
"string.quoted.single.fish": s1,
"variable.language.fish": p1,
"variable.other.normal.fish": p1
}
}
4 changes: 4 additions & 0 deletions extension/syntaxes/fish/fish.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {t} from "../../../shared/test.js"
import * as s from "./fish.js"

await t(s, import.meta.url)
28 changes: 28 additions & 0 deletions extension/syntaxes/fish/fixtures/000/.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# comment

s
$s
$argv

"s$s$argv"
's'

function
while
if
else
switch
case
for
in
begin
end
continue
break
return
source
exit
wait
and
or
not
49 changes: 49 additions & 0 deletions extension/syntaxes/fish/fixtures/000/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @typedef {import("hast").Root} Root
* @typedef {import("../../../../colors/themes.js").Syntax} Syntax
*/

import {r, w} from "../../../../../shared/test.js"

/**
* @param {Syntax} s
* @returns {Root}
*/
export function fn(s) {
const c0 = w(s.comment[0])
const p0 = w(s.plain[0])
const p1 = w(s.plain[1])
const s0 = w(s.string[0])
const s1 = w(s.string[1])

return r(
c0("# comment"),

p1("s"),
p0("$"), p1("s"),
p0("$"), p1("argv"),

s0('"'), s1("s"), p0("$"), p1("s"), p0("$"), p1("argv"), s0('"'),
s0("'"), s1("s"), s0("'"),

p0("function"),
p0("while"),
p0("if"),
p0("else"),
p0("switch"),
p0("case"),
p0("for"),
p0("in"),
p0("begin"),
p0("end"),
p0("continue"),
p0("break"),
p0("return"),
p0("source"),
p0("exit"),
p0("wait"),
p0("and"),
p0("or"),
p0("not")
)
}
4 changes: 4 additions & 0 deletions extension/syntaxes/syntaxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import * as _dockerfile from "./dockerfile/dockerfile.js"
/** @type {Syntax} */
export const dockerfile = _dockerfile

import * as _fish from "./fish/fish.js"
/** @type {Syntax} */
export const fish = _fish

import * as _go from "./go/go.js"
/** @type {Syntax} */
export const go = _go
Expand Down

0 comments on commit f1978d3

Please sign in to comment.