diff --git a/.gitignore b/.gitignore index dfacd4d..19eed1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.vsix \ No newline at end of file +*.vsix +test.art \ No newline at end of file diff --git a/package.json b/package.json index 33713b3..82a68f5 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,12 @@ "extensions": [".art"], "configuration": "./language-configuration.json" }], + "snippets": [ + { + "language": "arturo", + "path": "./snippets/*.json" + } + ], "grammars": [{ "language": "art", "scopeName": "source.arturo", diff --git a/snippets/arithmetic.json b/snippets/arithmetic.json new file mode 100644 index 0000000..72f6b7b --- /dev/null +++ b/snippets/arithmetic.json @@ -0,0 +1,117 @@ +{ + + "add function": { + "scope": "art", + "prefix": "add", + "body": "add $1 $2" + }, + + "add sign": { + "scope": "art", + "prefix": "add", + "body": "$1 + $2" + }, + + "dec function": { + "scope": "art", + "prefix": "dec", + "body": "dec $1" + }, + + "div function": { + "scope": "art", + "prefix": "div", + "body": "div $1 $2" + }, + + "div sign": { + "scope": "art", + "prefix": "div", + "body": "$1 / $2" + }, + + "divmod function": { + "scope": "art", + "prefix": "divmod", + "body": "divmod $1 $2" + }, + + "divmod sign": { + "scope": "art", + "prefix": "divmod", + "body": "$1 /% $2" + }, + + "fdiv function": { + "scope": "art", + "prefix": "fdiv", + "body": "fdiv $1 $2" + }, + + "fdiv sign": { + "scope": "art", + "prefix": "fdiv", + "body": "$1 // $2" + }, + + "inc function": { + "scope": "art", + "prefix": "inc", + "body": "inc $1 $2" + }, + + "mod function": { + "scope": "art", + "prefix": "mod", + "body": "mod $1 $2" + }, + + "mod sign": { + "scope": "art", + "prefix": "mod", + "body": "$1 % $2" + }, + + "mul function": { + "scope": "art", + "prefix": "mul", + "body": "mul $1 $2" + }, + + "mul sign": { + "scope": "art", + "prefix": "mul", + "body": "$1 * $2" + }, + + "neg function": { + "scope": "art", + "prefix": "neg", + "body": "neg $1" + }, + + "power function": { + "scope": "art", + "prefix": "pow", + "body": "pow $1 $2" + }, + + "power sign": { + "scope": "art", + "prefix": "pow", + "body": "$1 ^ $2" + }, + + "sub function": { + "scope": "art", + "prefix": "sub", + "body": "sub $1 $2" + }, + + "sub sign": { + "scope": "art", + "prefix": "sub", + "body": "$1 - $2" + } + +} \ No newline at end of file diff --git a/snippets/core.json b/snippets/core.json new file mode 100644 index 0000000..e3909ff --- /dev/null +++ b/snippets/core.json @@ -0,0 +1,365 @@ +{ + + "alias function": { + "scope": "art", + "prefix": "alias", + "body": "alias ${1:symbol} ${2:function}" + }, + + "alias.infix function": { + "scope": "art", + "prefix": "alias.infix", + "body": "alias.infix ${1:symbol} ${2:function}" + }, + + "break function": { + "scope": "art", + "prefix": "break", + "body": "break" + }, + + "call function": { + "scope": "art", + "prefix": "call", + "body": "call ${1:function} ${2|params,[],@[]|}" + }, + + "call external function": { + "scope": "art", + "prefix": "call.external", + "body": "call.external: ${0:path} ${1:function} ${2|params,[],@[]|}" + }, + + "call expect function": { + "scope": "art", + "prefix": "call.expect", + "body": "call.expect: ${0:type} ${1:function} ${2|params,[],@[]|}" + }, + + "case function": { + "scope": "art", + "prefix": "case", + "body": [ + "case ${1|predicate,[],@[]|}", + " $2" + ] + }, + + "coalesce function": { + "scope": "art", + "prefix": "coalesce", + "body": "coalesce ${1:variable} ${2:default}" + }, + + "coalesce sign": { + "scope": "art", + "prefix": "coalesce", + "body": "${1:variable} ?? ${2:default}" + }, + + "continue function": { + "scope": "art", + "prefix": "continue", + "body": "continue" + }, + + "do function": { + "scope": "art", + "prefix": "do", + "body": "do ${1|code,\"\",[],-> |}" + }, + + "do.times function": { + "scope": "art", + "prefix": "do.times", + "body": "do.times: $0 ${1|code,\"\",[],-> |}" + }, + + "dup function": { + "scope": "art", + "prefix": "dup", + "body": "dup ${0:value}" + }, + + "dup sign": { + "scope": "art", + "prefix": "dup", + "body": "<= ${0:value}" + }, + + "else function": { + "scope": "art", + "prefix": "else", + "body": "else ${1|block,-> ,[]|}" + }, + + "else multiline function": { + "scope": "art", + "prefix": "else", + "body": [ + "else [", + " $0", + "]" + ] + }, + + "ensure function": { + "scope": "art", + "prefix": "ensure", + "body": "ensure ${1|block,-> ,[]|}" + }, + + "ensure.that function": { + "scope": "art", + "prefix": "ensure.that", + "body": [ + "ensure.that: \"$1\"", + " ${2|block,-> ,[]|}" + ] + }, + + "function function": { + "scope": "art", + "prefix": "function", + "body": [ + "function [${1:args}][", + " $3", + "]" + ] + }, + + "function sign": { + "scope": "art", + "prefix": "function", + "body": [ + "$[${1:args}][", + " $2", + "]" + ] + }, + + "if function": { + "scope": "art", + "prefix": "if", + "body": "if ${1:condition} ${2|block,-> ,[]|}" + }, + + "if multiline function": { + "scope": "art", + "prefix": "if", + "body": [ + "if ${1:condition} [", + " $0", + "]" + ] + }, + + "import function": { + "scope": "art", + "prefix": "import", + "body": "import {${1:package}}" + }, + + "import local function": { + "scope": "art", + "prefix": "import.local", + "body": "import ./{${1:package}}" + }, + + "import.lean function": { + "scope": "art", + "prefix": "import.lean", + "body": "import.lean {${1:package}}" + }, + + "let function": { + "scope": "art", + "prefix": "let", + "body": "let ${1|'variable,\"variable\"|} $0" + }, + + "let sign": { + "scope": "art", + "prefix": "let", + "body": "${1|variable|}: $0" + }, + + "method function": { + "scope": "art", + "prefix": "method", + "body": [ + "method [${1:args}][", + " $0", + "]" + ] + }, + + "new function": { + "scope": "art", + "prefix": "method", + "body": "new $0" + }, + + "return function": { + "scope": "art", + "prefix": "method", + "body": "return $0" + }, + + "switch function": { + "scope": "art", + "prefix": "method", + "body": [ + "switch ${1:condition}", + " -> ${2:action}", + " -> ${3:alternative}" + ] + }, + + "switch multiline function": { + "scope": "art", + "prefix": "method", + "body": [ + "switch ${1:condition} [", + " ${2:action}", + " ][", + " ${3:alternative}", + "]" + ] + }, + + "unless function": { + "scope": "art", + "prefix": "unless", + "body": "unless ${1:condition} ${2|block,-> ,[]|}" + }, + + "unless multiline function": { + "scope": "art", + "prefix": "unless", + "body": [ + "unless ${1:condition} [", + " $0", + "]" + ] + }, + + "unstack function": { + "scope": "art", + "prefix": "unstack", + "body": "unstack ${1:number}" + }, + + "unstack.discard function": { + "scope": "art", + "prefix": "unstack.discard", + "body": "unstack.discard ${1:number}" + }, + + "until function": { + "scope": "art", + "prefix": "until", + "body": [ + "until [", + " $0", + "][${1:condition}]" + ] + }, + + "var function": { + "scope": "art", + "prefix": "var", + "body": "var '${1:symbol}" + }, + + "while function": { + "scope": "art", + "prefix": "while", + "body": [ + "while [${1:condition}][", + " $0", + "]" + ] + }, + + "with function": { + "scope": "art", + "prefix": "with", + "body": [ + "with ${1|embed,[],'embed|}[", + " $0", + "]" + ] + }, + + "if? function": { + "scope": "art", + "prefix": "if?", + "body": [ + "if? ${1:condition} -> ${2:action}}", + "else -> ${3:alternative}" + ] + }, + + "if? multiline function": { + "scope": "art", + "prefix": "if?", + "body": [ + "if? ${1:condition} [", + " ${2:action}", + "] else [", + " ${3:alternative}", + "]" + ] + }, + + "unless? function": { + "scope": "art", + "prefix": "unless?", + "body": [ + "unless? ${1:condition} -> ${2:action}}", + "else -> ${3:alternative}" + ] + }, + + "unless? multiline function": { + "scope": "art", + "prefix": "unless?", + "body": [ + "unless? ${1:condition} [", + " ${2:action}", + "] else [", + " ${3:alternative}", + "]" + ] + }, + + "when? function": { + "scope": "art", + "prefix": "when?", + "body": "when? [${1:condition}] -> $0" + }, + + "when? multiline function": { + "scope": "art", + "prefix": "when?", + "body": [ + "when? ${1:condition} [", + " $0", + "]" + ] + }, + + "null constant": { + "scope": "arturo", + "prefix": "null", + "body": "null" + }, + + "null sign": { + "scope": "art", + "prefix": "null", + "body": "∅" + } + +} \ No newline at end of file diff --git a/snippets/logic.json b/snippets/logic.json new file mode 100644 index 0000000..180f655 --- /dev/null +++ b/snippets/logic.json @@ -0,0 +1,117 @@ +{ + + "all? function": { + "scope": "art", + "prefix": "all?", + "body": "all? ${1|conditions,@[]}" + }, + + "and? function": { + "scope": "art", + "prefix": "and?", + "body": "and? $1 $2" + }, + + "and? sign": { + "scope": "art", + "prefix": "and?", + "body": "$1 ∧ $2" + }, + + "any? function": { + "scope": "art", + "prefix": "any?", + "body": "any? ${1|conditions,@[]}" + }, + + "false? function": { + "scope": "art", + "prefix": "false?", + "body": "false? $0" + }, + + "nand? function": { + "scope": "art", + "prefix": "nand?", + "body": "nand? $1 $2" + }, + + "nand? sign": { + "scope": "art", + "prefix": "nand?", + "body": "$1 ⊼ $2" + }, + + "nor? function": { + "scope": "art", + "prefix": "nor?", + "body": "nor? $1 $2" + }, + + "not? function": { + "scope": "art", + "prefix": "not?", + "body": "not? $0" + }, + + "not? sign": { + "scope": "art", + "prefix": "not?", + "body": "¬$0" + }, + + "or? function": { + "scope": "art", + "prefix": "or?", + "body": "or? $1 $2" + }, + + "or? sign": { + "scope": "art", + "prefix": "or?", + "body": "$1 ∨ $2" + }, + + "true? function": { + "scope": "art", + "prefix": "true?", + "body": "true? $0" + }, + + "xor? function": { + "scope": "art", + "prefix": "xor?", + "body": "xor? $1 $2" + }, + + "xor? sign": { + "scope": "art", + "prefix": "xor?", + "body": "$1 ⊻ $2" + }, + + "xnor? function": { + "scope": "art", + "prefix": "xnor?", + "body": "xnor? $1 $2" + }, + + "false constant": { + "scope": "art", + "prefix": "false", + "body": "false" + }, + + "true constant": { + "scope": "art", + "prefix": "true", + "body": "true" + }, + + "maybe constant": { + "scope": "art", + "prefix": "maybe", + "body": "maybe" + } + +} \ No newline at end of file diff --git a/snippets/numbers.json b/snippets/numbers.json new file mode 100644 index 0000000..ed3a3fa --- /dev/null +++ b/snippets/numbers.json @@ -0,0 +1,39 @@ +{ + + "product function": { + "scope": "art", + "prefix": "product", + "body": "product ${1|block,@[]}" + }, + + "product sign": { + "scope": "art", + "prefix": "product", + "body": "∏ ${1|block,@[]}" + }, + + "sum function": { + "scope": "art", + "prefix": "sum", + "body": "sum ${1|block,@[]}" + }, + + "sum sign": { + "scope": "art", + "prefix": "sum", + "body": "∑ ${1|block,@[]}" + }, + + "infinite constant": { + "scope": "art", + "prefix": "infinity", + "body": "infinity" + }, + + "infinite sign": { + "scope": "art", + "prefix": "infinity", + "body": "∞" + } + +} \ No newline at end of file diff --git a/snippets/sets.arturo.json b/snippets/sets.arturo.json new file mode 100644 index 0000000..c16d1c8 --- /dev/null +++ b/snippets/sets.arturo.json @@ -0,0 +1,87 @@ +{ + + "difference function": { + "scope": "art", + "prefix": "difference", + "body": "difference ${1|block,@[]} ${2|block,@[]}" + }, + + "intersection function": { + "scope": "art", + "prefix": "intersection", + "body": "intersection ${1|block,@[]} ${2|block,@[]}" + }, + + "intersection sign": { + "scope": "art", + "prefix": "intersection", + "body": "(${1|block,@[]}) ∩ (${2|block,@[]})" + }, + + "powerset function": { + "scope": "art", + "prefix": "powerset", + "body": "powerset ${1|block,@[]}" + }, + + "union function": { + "scope": "art", + "prefix": "union", + "body": "union ${1|block,@[]} ${2|block,@[]}" + }, + + "union sign": { + "scope": "art", + "prefix": "union", + "body": "(${1|block,@[]}) ∪ (${2|block,@[]})" + }, + + "disjoint? function": { + "scope": "art", + "prefix": "disjoint?", + "body": "disjoint? ${1|block,@[]} ${2|block,@[]}" + }, + + "intersect? function": { + "scope": "art", + "prefix": "intersect?", + "body": "intersect? ${1|block,@[]} ${2|block,@[]}" + }, + + "subset? function": { + "scope": "art", + "prefix": "subset?", + "body": "subset? ${1|block,@[]} ${2|block,@[]}" + }, + + "subset?.proper function": { + "scope": "art", + "prefix": "subset?.proper", + "body": "subset?.proper ${1|block,@[]} ${2|block,@[]}" + }, + + "subset? sign": { + "scope": "art", + "prefix": "subset?", + "body": "(${1|block,@[]}) ⊆ (${2|block,@[]})" + }, + + "superset? function": { + "scope": "art", + "prefix": "superset?", + "body": "superset? ${1|block,@[]} ${2|block,@[]}" + }, + + "superset?.proper function": { + "scope": "art", + "prefix": "superset?.proper", + "body": "superset?.proper ${1|block,@[]} ${2|block,@[]}" + }, + + "superset? sign": { + "scope": "art", + "prefix": "superset?", + "body": "(${1|block,@[]}) ⊃ (${2|block,@[]})" + } + +} \ No newline at end of file