Import snippets from VSCode
This commit is contained in:
parent
af524c2630
commit
a3d7d30bcd
12
configs/Code/User/snippets/json.json
Normal file
12
configs/Code/User/snippets/json.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"Vector3": {
|
||||
"prefix": "vector3",
|
||||
"body": [
|
||||
"{",
|
||||
"\t\"x\": $1,",
|
||||
"\t\"y\": $2,",
|
||||
"\t\"z\": $3",
|
||||
"}",
|
||||
]
|
||||
}
|
||||
}
|
70
configs/Code/User/snippets/python.json
Normal file
70
configs/Code/User/snippets/python.json
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"CLI App Skeleton": {
|
||||
"prefix": "cli_app",
|
||||
"body": [
|
||||
"import argparse",
|
||||
"import sys",
|
||||
"import logging",
|
||||
"",
|
||||
"logger = logging.getLogger(__name__)",
|
||||
"",
|
||||
"def main() -> int:",
|
||||
"\t# Handle program arguments",
|
||||
"\tap = argparse.ArgumentParser(prog='$1', description='$2')",
|
||||
"\t$3",
|
||||
"\tap.add_argument('-v', '--verbose', help='Enable verbose logging', action='store_true')"
|
||||
"\targs = ap.parse_args()",
|
||||
"",
|
||||
"\t# Configure logging",
|
||||
"\tlogging.basicConfig(",
|
||||
"\t\tlevel=logging.DEBUG if args.verbose else logging.INFO,",
|
||||
"\t\tformat='%(levelname)s:\t%(message)s',",
|
||||
"\t)",
|
||||
"",
|
||||
"\treturn 0",
|
||||
"",
|
||||
"if __name__ == \"__main__\":",
|
||||
"\tsys.exit(main())"
|
||||
]
|
||||
},
|
||||
"Request error handler": {
|
||||
"prefix": "rerror",
|
||||
"body": [
|
||||
"if int($1.status_code / 100) != 2:",
|
||||
"\treturn $2"
|
||||
]
|
||||
},
|
||||
"Path to the current file": {
|
||||
"prefix": "__filepath__",
|
||||
"body": "Path(__file__)"
|
||||
},
|
||||
"Path to the current file's parent directory": {
|
||||
"prefix": "__filedir__",
|
||||
"body": "Path(__file__).parent"
|
||||
},
|
||||
"Disable formatting for block": {
|
||||
"prefix": "nofmt",
|
||||
"body": [
|
||||
"# fmt: off",
|
||||
"$1",
|
||||
"# fmt: on",
|
||||
"$2"
|
||||
]
|
||||
},
|
||||
"Import Path from pathlib": {
|
||||
"prefix": "impath",
|
||||
"body": "from pathlib import Path"
|
||||
},
|
||||
"Get a logger instance": {
|
||||
"prefix": "getlogger",
|
||||
"body": "logger = logging.getLogger(__name__)"
|
||||
},
|
||||
"Import dataclass": {
|
||||
"prefix":"impdataclass",
|
||||
"body": "from dataclasses import dataclass, field"
|
||||
},
|
||||
"Import enums": {
|
||||
"prefix":"impenum",
|
||||
"body": "from enum import Enum, auto"
|
||||
}
|
||||
}
|
31
configs/Code/User/snippets/rust.json
Normal file
31
configs/Code/User/snippets/rust.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"Constructor": {
|
||||
"prefix": "new",
|
||||
"body": [
|
||||
"/// Construct a new $1",
|
||||
"pub fn new($2) -> Self {",
|
||||
"\tSelf {",
|
||||
"\t\t$3",
|
||||
"\t}",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
"Derive Macro": {
|
||||
"prefix": "derive",
|
||||
"body": "#[derive(Debug, $1)]$2"
|
||||
},
|
||||
"Unit Tests": {
|
||||
"prefix": "cfg: test",
|
||||
"body": [
|
||||
"#[cfg(test)]",
|
||||
"mod tests {",
|
||||
"\tuse super::*;",
|
||||
"\t",
|
||||
"\t#[test]",
|
||||
"\tfn test_$1() {",
|
||||
"\t\t$2",
|
||||
"\t}",
|
||||
"}"
|
||||
]
|
||||
}
|
||||
}
|
15
configs/Code/User/snippets/toml.json
Normal file
15
configs/Code/User/snippets/toml.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"Inculde: Serde": {
|
||||
"prefix": "serde",
|
||||
"body": [
|
||||
"serde = { version = \"^1.0\", features = [\"derive\"] }",
|
||||
"serde_json = \"^1.0\""
|
||||
]
|
||||
},
|
||||
"Include: Tokio": {
|
||||
"prefix": "tokio",
|
||||
"body": [
|
||||
"tokio = { version = \"$1\", features = [\"macros\", \"rt-multi-thread\"] }$2"
|
||||
]
|
||||
},
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user