Add ocaml and dune snippets (#352)

This commit is contained in:
Jean-Michel Bea 2023-08-27 08:37:49 +01:00 committed by GitHub
parent 377d45475b
commit 90fc37677f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 161 additions and 0 deletions

View file

@ -483,6 +483,25 @@
{
"language": "reason",
"path": "./snippets/reason.json"
},
{
"language": [
"ocaml",
"ocamlinterface"
],
"path": "./snippets/ocaml/ocaml.json"
},
{
"language": "ocaml.ocamllex",
"path": "./snippets/ocaml/ocamllex.json"
},
{
"language": "dune-project",
"path": "./snippets/ocaml/dune-project.json"
},
{
"language": "dune",
"path": "./snippets/ocaml/dune.json"
}
]
}

View file

@ -0,0 +1,31 @@
{
"lang": {
"prefix": "lang",
"body": ["(lang $1 $2)"],
"description": "Snippet for a lang stanza"
},
"name": {
"prefix": "name",
"body": ["(name $1)"],
"description": "Snippet for a name stanza"
},
"using": {
"prefix": "using",
"body": ["(using $1 $2)"],
"description": "Snippet for an using stanza"
},
"info": {
"prefix": "info",
"body": [
"(license $1)\n(authors \"$2\")\n(maintainers \"$3\")\n(source (${4|uri,github|} $5))\n(bug_reports \"$6\")\n(homepage \"$7\")\n(documentation \"$8\")"
],
"description": "Snippet to add info related stanzas"
},
"package": {
"prefix": "package",
"body": [
"(package\n (name $1)\n (synopsis \"$2\")\n (description \"$3\")\n (depends $4))"
],
"description": "Snippet for a package stanza"
}
}

37
snippets/ocaml/dune.json Normal file
View file

@ -0,0 +1,37 @@
{
"env": {
"prefix": "env",
"body": ["(env\n ($1 $2))"],
"description": "Snippet for an env stanza"
},
"executable": {
"prefix": "executable",
"body": ["(executable\n (name $1)\n (public_name $2)\n (libraries $3))"],
"description": "Snippet for an executable stanza"
},
"executables": {
"prefix": "executables",
"body": ["(executables\n (names $1)\n (public_names $2)\n (libraries $3))"],
"description": "Snippet for an executables stanza"
},
"install": {
"prefix": "install",
"body": ["(install\n (section $1)\n (files ($2.exe as $3)))"],
"description": "Snippet for an install stanza"
},
"library": {
"prefix": "library",
"body": ["(library\n (name $1)\n (public_name $2)\n (libraries $3))"],
"description": "Snippet for a library stanza"
},
"rule": {
"prefix": "rule",
"body": ["(rule\n (alias $1)\n (deps $2)\n (targets $3)\n (action $4))"],
"description": "Snippet for a rule stanza"
},
"test": {
"prefix": "test",
"body": ["(test\n (name $1)\n (libraries $2))"],
"description": "Snippet for a test stanza"
}
}

67
snippets/ocaml/ocaml.json Normal file
View file

@ -0,0 +1,67 @@
{
"lambda": {
"prefix": "fun",
"body": ["fun (${1:pattern}) -> ${2:${1:pattern}}"],
"description": "Snippet for a lambda function definition"
},
"let .. in": {
"prefix": "let",
"body": ["let ${1:pattern} = ${2:()} in$0"],
"description": "Snippet for a let .. in binding"
},
"function": {
"prefix": "func",
"body": ["function\n| $0"],
"description": "Snippet for a match function definition"
},
"variant pattern": {
"prefix": "|",
"body": ["| ${1:_} -> $0"],
"description": "Snippet for a variant definition"
},
"let (toplevel)": {
"prefix": "let",
"body": ["let ${1:pattern} = $0"],
"description": "Snippet for a let definition"
},
"val": {
"prefix": "val",
"body": ["val ${1:name} : $0"],
"description": "Snippet for a value definition"
},
"sig": {
"prefix": "sig",
"body": ["sig\n ${1}\nend$0"],
"description": "Snippet for a signature block"
},
"struct": {
"prefix": "struct",
"body": ["struct\n ${1}\nend$0"],
"description": "Snippet for a struct block"
},
"module": {
"prefix": "module",
"body": ["module ${1:M} = struct\n ${2}\nend$0"],
"description": "Snippet for a module definition"
},
"module signature": {
"prefix": "module",
"body": ["module ${1:M} : sig\n ${2}\nend$0"],
"description": "Snippet for a module signature definition"
},
"module type": {
"prefix": "module",
"body": ["module type ${1:M} = sig\n ${2}\nend$0"],
"description": "Snippet for a module type definition"
},
"match": {
"prefix": "match",
"body": ["match ${1:scrutinee} with\n| ${2:pattern} -> ${3:${2:pattern}}"],
"description": "Snippet for a pattern match block definition"
},
"type declaration": {
"prefix": "type",
"body": ["type ${1:name} = $0"],
"description": "Snippet for a type declaration"
}
}

View file

@ -0,0 +1,7 @@
{
"rule": {
"prefix": "rule",
"body": ["rule ${1:pattern} = parse", "| $0"],
"description": "Snippet for a rule"
}
}