Skip to content

Commit

Permalink
Добавлено: Cинтаксис vala, gitflic Fiersik
Browse files Browse the repository at this point in the history
  • Loading branch information
Ampernic committed Mar 25, 2024
1 parent b229839 commit b293a9a
Show file tree
Hide file tree
Showing 5 changed files with 302 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { telegram, gitflic, vk } from './icons'
import * as navbar from './../_data/navigations'
import { normalize } from './utils'
import { rewrites } from './paths'
import languages from './theme/syntaxes'
import * as config from './config.json'
export const META_DESCRIPTION = config.meta_description

Expand Down Expand Up @@ -178,6 +179,7 @@ export default defineConfig({
},
rewrites: rewrites,
markdown: {
languages,
container: {
tipLabel: 'Подсказка',
warningLabel: 'Внимание',
Expand Down
16 changes: 16 additions & 0 deletions .vitepress/theme/syntaxes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { LanguageInput } from 'shiki'
import { createRequire } from 'module'

const require = createRequire(import.meta.url)

const valaTML = require('./vala.json')


const vala = {
...valaTML,
aliases: ['vala']
}

export default [
vala
] as LanguageInput[]
196 changes: 196 additions & 0 deletions .vitepress/theme/syntaxes/vala.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
{
"name": "Vala",
"scopeName": "source.vala",
"fileTypes": [
"vala",
"vapi",
"gs"
],
"uuid": "5fbc8212-3c2f-45ac-83d2-0c9195878913",
"patterns": [
{
"include": "#code"
}
],
"repository": {
"code": {
"patterns": [
{
"include": "#comments"
},
{
"include": "#constants"
},
{
"include": "#strings"
},
{
"include": "#keywords"
},
{
"include": "#types"
},
{
"include": "#functions"
},
{
"include": "#variables"
}
]
},
"comments": {
"patterns": [
{
"name": "comment.block.empty.vala",
"match": "/\\*\\*/",
"captures": {
"0": {
"name": "punctuation.definition.comment.vala"
}
}
},
{
"include": "text.html.javadoc"
},
{
"include": "#comments-inline"
}
]
},
"comments-inline": {
"patterns": [
{
"name": "comment.block.vala",
"begin": "/\\*",
"captures": {
"0": {
"name": "punctuation.definition.comment.vala"
}
},
"end": "\\*/"
},
{
"match": "\\s*((//).*$\\n?)",
"captures": {
"1": {
"name": "comment.line.double-slash.vala"
},
"2": {
"name": "punctuation.definition.comment.vala"
}
}
}
]
},
"constants": {
"patterns": [
{
"name": "constant.numeric.vala",
"match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)([LlFfUuDd]|UL|ul)?\\b"
},
{
"name": "variable.other.constant.vala",
"match": "\\b([A-Z][A-Z0-9_]+)\\b"
}
]
},
"strings": {
"patterns": [
{
"name": "string.quoted.triple.vala",
"begin": "\"\"\"",
"end": "\"\"\""
},
{
"name": "string.quoted.interpolated.vala",
"begin": "@\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.vala",
"match": "\\\\."
},
{
"name": "constant.character.escape.vala",
"match": "\\$\\w+"
},
{
"name": "constant.character.escape.vala",
"match": "\\$\\(([^)(]|\\(([^)(]|\\([^)]*\\))*\\))*\\)"
}
]
},
{
"name": "string.quoted.double.vala",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.vala",
"match": "\\\\."
}
]
},
{
"name": "string.quoted.single.vala",
"begin": "'",
"end": "'",
"patterns": [
{
"name": "constant.character.escape.vala",
"match": "\\\\."
}
]
},
{
"name": "string.regexp.vala",
"match": "/((\\\\/)|([^/]))*/(?=\\s*[,;)\\.\\n])"
}
]
},
"keywords": {
"patterns": [
{
"name": "keyword.vala",
"match": "(?<=^|[^@\\w\\.])(as|do|if|in|is|not|or|and|for|get|new|out|ref|set|try|var|base|case|else|enum|lock|null|this|true|void|weak|async|break|catch|class|const|false|owned|throw|using|while|with|yield|delete|extern|inline|params|public|return|sealed|signal|sizeof|static|struct|switch|throws|typeof|unlock|default|dynamic|ensures|finally|foreach|private|unowned|virtual|abstract|continue|delegate|internal|override|requires|volatile|construct|interface|namespace|protected|errordomain)\\b"
},
{
"name": "keyword.vala",
"match": "(?<=^|[^@\\w\\.])(bool|double|float|unichar|unichar2|char|uchar|int|uint|long|ulong|short|ushort|size_t|ssize_t|string|string16|string32|void|signal|int8|int16|int32|int64|uint8|uint16|uint32|uint64|va_list|time_t)\\b"
},
{
"name": "keyword.vala",
"match": "(#if|#elif|#else|#endif)"
}
]
},
"types": {
"patterns": [
{
"name": "storage.type.primitive.vala",
"match": "(?<=^|[^@\\w\\.])(bool|double|float|unichar|unichar2|char|uchar|int|uint|long|ulong|short|ushort|size_t|ssize_t|string|string16|string32|void|signal|int8|int16|int32|int64|uint8|uint16|uint32|uint64|va_list|time_t)\\b"
},
{
"name": "entity.name.type.vala",
"match": "\\b([A-Z]+\\w*)\\b"
}
]
},
"functions": {
"patterns": [
{
"name": "entity.name.function.vala",
"match": "(\\w+)(?=\\s*(<[\\s\\w.]+>\\s*)?\\()"
}
]
},
"variables": {
"patterns": [
{
"name": "variable.other.vala",
"match": "\\b([_a-z]+\\w*)\\b"
}
]
}
}
}
8 changes: 7 additions & 1 deletion _data/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ export const contributions = [
name: 'Кирилл Уницаев',
title: 'Участник',
links: [
{ icon: 'github', link: 'https://github.com/fiersik' }
{ icon: 'github', link: 'https://github.com/fiersik' },
{
icon: {
svg: gitflic
},
link: 'https://gitflic.ru/user/fiersik'
},
],
actionText: 'Поддержать',
sponsor: 'https://www.tinkoff.ru/cf/4p7xYDHEH2y'
Expand Down
81 changes: 81 additions & 0 deletions docs/developers/vala.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,84 @@ vala sample.vala
valac sample.vala -o sample
./sample
```

## Тест

```vala
using Application.Gui;
namespace Application {
public errordomain ShitError {
BIG,
MIDDLE,
FIRE
}
}
[GtkTemplate (ui = "/path/to/resources/app-id/ui/main_window.ui")]
public class Application.Gui.Window : Object {
[GtkChild]
unowned Gtk.Button button;
public string app_id { get; set; }
public signal void done (uint64 what);
public Window (app_id) {
Object (app_id: app_id)
}
construct {
do_thing.begin (32, (obj, res) => {
var result = do_thing.end (res);
message (result);
});
done.connect (do_thing);
done (21);
done.emit (62);
}
public async string do_thing (int64 kek) {
string shit;
int64 shit_int = 0;
for (int64 i = 0; i > kek; i++) {
shit_int += kek;
Idle.add (do_thing.callback);
yield;
}
return shit_int.to_string ();
}
[GtkCallback]
public void on_button_clicked () {
close ();
try {
do_another (false);
} catch (ShitError e) {
message (e.message);
}
}
protected override void size_allocate (
int width,
int height,
int baseline
) {
base.size_allocate (width, height, baseline);
}
void do_another (bool yes) throws ShitError {
if (yes) {
throw new ShitError.FIRE;
}
}
}
```

0 comments on commit b293a9a

Please sign in to comment.