aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files/.vim/UltiSnips/python.snippets39
-rw-r--r--files/.vim/UltiSnips/sh.snippets2
2 files changed, 40 insertions, 1 deletions
diff --git a/files/.vim/UltiSnips/python.snippets b/files/.vim/UltiSnips/python.snippets
new file mode 100644
index 0000000..0f1c366
--- /dev/null
+++ b/files/.vim/UltiSnips/python.snippets
@@ -0,0 +1,39 @@
+# https://packaging.python.org/en/latest/specifications/inline-script-metadata/#inline-script-metadata
+# https://peps.python.org/pep-0723/
+snippet inline-script "Inline script metadata" b
+# /// script
+# requires-python = ">=3.11"
+# dependencies = [
+# "requests",
+# ]
+# ///
+endsnippet
+
+snippet #! "Run script with python3" b
+#!/usr/bin/env python3
+
+endsnippet
+
+snippet #!pipx "Run script with pipx" b
+#!/usr/bin/env -S pipx run --path
+
+# /// script
+# requires-python = ">=3.11"
+# dependencies = [
+# "requests",
+# ]
+# ///
+
+endsnippet
+
+snippet #!uv "Run script with uv" b
+#!/usr/bin/env -S uv run --script
+
+# /// script
+# requires-python = ">=3.11"
+# dependencies = [
+# "requests",
+# ]
+# ///
+
+endsnippet
diff --git a/files/.vim/UltiSnips/sh.snippets b/files/.vim/UltiSnips/sh.snippets
index d9087eb..4bc2ff3 100644
--- a/files/.vim/UltiSnips/sh.snippets
+++ b/files/.vim/UltiSnips/sh.snippets
@@ -87,5 +87,5 @@ main() {
$0
}
-eval "$(argc --argc-eval "$0" "$@")"
+eval "$(argc --argc-eval "\$0" "$@")"
endsnippet