Closed bendaws closed 2 months ago
A basic sample in /samples/Carbon
, and fixed the multiple extensions problem (.carbon is the most accepted extension, so I excluded .cb)
Do you really want to add support without syntax highlighting? Normally the only reason people add support for a language is to get syntax highlighting on GitHub.
There is no syntax highlighter for it avaliable, although I may try to add one in the future.
@btdw Usually when we add support for a language that doesn't have a syntax highlighting grammar (or one released under a permissive license), we sometimes use another language's grammar as a fallback that happens to produce "good enough" highlighting. For example, here's one of your Carbon samples highlighted using Rust:
@btdw Usually when we add support for a language that doesn't have a syntax highlighting grammar (or one released under a permissive license), we sometimes use another language's grammar as a fallback that happens to produce "good enough" highlighting. For example, here's one of your Carbon samples highlighted using Rust:
I've experimented with a couple and found the syntax for V works the best:
package Shapes api;
import Math;
// Circle
class Circle {
var Radius: f32 = 1;
const var Diameter: f32 = self.Radius * 2;
const var Pi: f32 = Math.Pi;
fn Area() -> self;
fn Circumference() -> self;
}
fn Circle.Area() -> self {
return Math.Pi * .Radius ^ 2
}
fn Circle.Circumference() -> self {
return 2 * Math.Pi * .Radius
}
// Rectangle
class Rectangle {
var Width: f32 = 3;
var Height: f32 = 1;
fn Area() -> self;
}
fn Rectangle.Area() -> self {
return .Width * .Height;
}
// Square (Note: Provides same functions as "Rectangle" class.)
class Square {
var Width: f32 = 3;
var Height: f32 = 1;
fn Area() -> self;
}
fn Square.Area() -> self {
return .Width * .Height;
}
// Triangle
class Triangle {
var Width: f32 = 3;
var Height: f32 = 3;
fn Area() -> self;
}
fn Triangle.Area() -> self {
return (.Width * .Height) / 2;
}
// Hexagon
class Hexagon {
var Side: f32 = 5;
fn Area() -> self;
}
fn Hexagon.Area() -> self {
return ((3 * 1.732) / 2) * .Side ^ 2
}
I've experimented with a couple and found the syntax for V works the best:
https://github.com/github-linguist/linguist/pull/7011/commits/9bdc91cf76fafacf81c515def9c4aac1214d7321 adds V syntax highlighting to Carbon files
Thanks for the suggestion, it was committed
@btdw You'll need to fix the failed test reported here. It simply involves updating vendor/README.md
to include Carbon in the list. Just add this to the file on line 75:
--- expected
+++ actual
@@ -83,6 +83,7 @@
- **Cairo:** [xshitaka/atom-language-cairo](https://github.com/xshitaka/atom-language-cairo)
- **CameLIGO:** [pewulfman/Ligo-grammar](https://github.com/pewulfman/Ligo-grammar)
- **Cap'n Proto:** [textmate/capnproto.tmbundle](https://github.com/textmate/capnproto.tmbundle)
+- **Carbon:** [0x9ef/vscode-vlang](https://github.com/0x9ef/vscode-vlang)
Adds support for the Carbon language. Carbon is an experimental language developed by Google.
Checklist
#222222
#000000
, but they are similar.Closes https://github.com/github-linguist/linguist/issues/6013