Skip to content

Commit bb725d9

Browse files
committed
feat(vscode): add devsper VS Code extension with snippets and grammar
1 parent 018dafb commit bb725d9

4 files changed

Lines changed: 149 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"comments": {
3+
"lineComment": "--",
4+
"blockComment": ["--[[", "]]"]
5+
},
6+
"brackets": [
7+
["{", "}"],
8+
["[", "]"],
9+
["(", ")"]
10+
],
11+
"autoClosingPairs": [
12+
{ "open": "{", "close": "}" },
13+
{ "open": "[", "close": "]" },
14+
{ "open": "(", "close": ")" },
15+
{ "open": "\"", "close": "\"" },
16+
{ "open": "'", "close": "'" },
17+
{ "open": "--[[", "close": "]]" }
18+
],
19+
"surroundingPairs": [
20+
["{", "}"],
21+
["[", "]"],
22+
["(", ")"],
23+
["\"", "\""],
24+
["'", "'"]
25+
]
26+
}

tools/vscode/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "devsper-lsp",
3+
"displayName": "Devsper Language Support",
4+
"description": "Autocomplete, hover docs, and diagnostics for .devsper workflow and tool files",
5+
"version": "0.1.0",
6+
"publisher": "devsper",
7+
"engines": { "vscode": "^1.85.0" },
8+
"categories": ["Programming Languages", "Snippets"],
9+
"contributes": {
10+
"languages": [
11+
{
12+
"id": "devsper",
13+
"aliases": ["Devsper", "devsper"],
14+
"extensions": [".devsper"],
15+
"configuration": "./language-configuration.json"
16+
}
17+
],
18+
"grammars": [
19+
{
20+
"language": "devsper",
21+
"scopeName": "source.devsper",
22+
"path": "./syntaxes/devsper.tmLanguage.json"
23+
}
24+
],
25+
"snippets": [
26+
{
27+
"language": "devsper",
28+
"path": "./snippets/devsper.json"
29+
}
30+
]
31+
}
32+
}

tools/vscode/snippets/devsper.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"Workflow": {
3+
"prefix": "workflow",
4+
"body": [
5+
"local wf = devsper.workflow({",
6+
"\tname = \"${1:my-workflow}\",",
7+
"\tmodel = \"${2:auto}\",",
8+
"\tworkers = ${3:4},",
9+
"})",
10+
"",
11+
"wf.task(\"${4:task-1}\", {",
12+
"\tprompt = \"${5:Describe what this task should do.}\",",
13+
"})",
14+
"",
15+
"return wf"
16+
],
17+
"description": "New devsper workflow"
18+
},
19+
"Task": {
20+
"prefix": "task",
21+
"body": [
22+
"wf.task(\"${1:task-name}\", {",
23+
"\tprompt = \"${2:Describe what this task should do.}\",",
24+
"\tdepends_on = { ${3} },",
25+
"})"
26+
],
27+
"description": "Add a task to the workflow DAG"
28+
},
29+
"Plugin": {
30+
"prefix": "plugin",
31+
"body": [
32+
"wf.plugin(\"${1:git}\", { source = \"builtin:${1:git}\" })"
33+
],
34+
"description": "Load a builtin plugin (git, search, http, code, filesystem)"
35+
},
36+
"Input": {
37+
"prefix": "input",
38+
"body": [
39+
"wf.input(\"${1:param_name}\", {",
40+
"\ttype = \"${2|string,number,boolean,object|}\",",
41+
"\trequired = ${3|true,false|},",
42+
"})"
43+
],
44+
"description": "Declare a typed workflow input"
45+
},
46+
"Tool": {
47+
"prefix": "tool",
48+
"body": [
49+
"devsper.tool(\"${1:tool.name}\", {",
50+
"\tdescription = \"${2:What this tool does.}\",",
51+
"\tparams = {",
52+
"\t\t${3:param} = { type = \"${4|string,number,boolean,object|}\", required = ${5|true,false|} },",
53+
"\t},",
54+
"\trun = function(ctx, args)",
55+
"\t\t${6:-- implementation}",
56+
"\tend,",
57+
"})"
58+
],
59+
"description": "Register a new devsper tool"
60+
}
61+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3+
"name": "Devsper",
4+
"scopeName": "source.devsper",
5+
"patterns": [
6+
{ "include": "#devsper-keywords" },
7+
{ "include": "source.lua" }
8+
],
9+
"repository": {
10+
"devsper-keywords": {
11+
"patterns": [
12+
{
13+
"comment": "devsper global and wf builder",
14+
"match": "\\b(devsper|wf)\\b(?=\\.)",
15+
"name": "support.class.devsper"
16+
},
17+
{
18+
"comment": "builtin: plugin name prefix",
19+
"match": "\"builtin:[a-zA-Z0-9_-]+\"",
20+
"name": "support.constant.devsper"
21+
},
22+
{
23+
"comment": "devsper method names",
24+
"match": "\\.(workflow|tool|exec|log|http|get|post|task|plugin|input)\\b",
25+
"name": "support.function.devsper"
26+
}
27+
]
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)