1
0

test 0.12.1 config

This commit is contained in:
2026-04-08 19:19:43 +02:00
parent 0763449f80
commit 372f3a7720
43 changed files with 950 additions and 120 deletions

View File

@@ -0,0 +1,353 @@
-- Lua snippets
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
local rep = require("luasnip.extras").rep
-- Return a table of snippets for Bash
-- stylua: ignore start
return {
-- Shebang
s("shebang", {
t("#!/usr/bin/env bash"),
}),
-- Bash strict mode
s("strict", fmt([[
set -euo pipefail
IFS=$'\n\t'
]], {})),
-- Function definition
s("func", fmt([[
{}() {{
{}
}}
]], {
i(1, "function_name"),
i(2, "# function body"),
})),
-- If statement
s("if", fmt([[
if [ {} ]; then
{}
fi
]], {
i(1, "condition"),
i(2, "# code"),
})),
-- If-else statement
s("ifelse", fmt([[
if [ {} ]; then
{}
else
{}
fi
]], {
i(1, "condition"),
i(2, "# if code"),
i(3, "# else code"),
})),
-- If-elif-else statement
s("ifelif", fmt([[
if [ {} ]; then
{}
elif [ {} ]; then
{}
else
{}
fi
]], {
i(1, "condition1"),
i(2, "# if code"),
i(3, "condition2"),
i(4, "# elif code"),
i(5, "# else code"),
})),
-- For loop
s("for", fmt([[
for {} in {}; do
{}
done
]], {
i(1, "item"),
i(2, "items"),
i(3, "# loop body"),
})),
-- For loop with range
s("fori", fmt([[
for ((i={}; i<{}; i++)); do
{}
done
]], {
i(1, "0"),
i(2, "10"),
i(3, "# loop body"),
})),
-- While loop
s("while", fmt([[
while [ {} ]; do
{}
done
]], {
i(1, "condition"),
i(2, "# loop body"),
})),
-- Until loop
s("until", fmt([[
until [ {} ]; do
{}
done
]], {
i(1, "condition"),
i(2, "# loop body"),
})),
-- Case statement
s("case", fmt([[
case {} in
{})
{}
;;
{})
{}
;;
*)
{}
;;
esac
]], {
i(1, "variable"),
i(2, "pattern1"),
i(3, "# code for pattern1"),
i(4, "pattern2"),
i(5, "# code for pattern2"),
i(6, "# default code"),
})),
-- Read input
s("read", fmt([[
read -p "{}" {}
]], {
i(1, "Enter value: "),
i(2, "variable"),
})),
-- Command substitution
s("cmd", fmt([[
{}=$({}$)
]], {
i(1, "result"),
i(2, "command"),
})),
-- Variable declaration
s("var", fmt([[
{}="{}"
]], {
i(1, "variable"),
i(2, "value"),
})),
-- Array declaration
s("array", fmt([[
{}=({})
]], {
i(1, "array"),
i(2, "item1 item2 item3"),
})),
-- Check if command exists
s("cmdexists", fmt([[
if command -v {} &> /dev/null; then
{}
else
{}
fi
]], {
i(1, "command"),
i(2, "# command exists"),
i(3, "# command does not exist"),
})),
-- Check if file exists
s("fileexists", fmt([[
if [ -f {} ]; then
{}
else
{}
fi
]], {
i(1, "file"),
i(2, "# file exists"),
i(3, "# file does not exist"),
})),
-- Check if directory exists
s("direxists", fmt([[
if [ -d {} ]; then
{}
else
{}
fi
]], {
i(1, "directory"),
i(2, "# directory exists"),
i(3, "# directory does not exist"),
})),
-- Check if variable is empty
s("isempty", fmt([[
if [ -z "${{{}}}" ]; then
{}
else
{}
fi
]], {
i(1, "variable"),
i(2, "# variable is empty"),
i(3, "# variable is not empty"),
})),
-- Check if variable is not empty
s("isnotempty", fmt([[
if [ -n "${{{}}}" ]; then
{}
else
{}
fi
]], {
i(1, "variable"),
i(2, "# variable is not empty"),
i(3, "# variable is empty"),
})),
-- Error handling
s("error", fmt([[
error() {{
echo "[ERROR] $1" >&2
exit 1
}}
]], {})),
-- Parse command line arguments
s("getopts", fmt([[
while getopts ":{}:" opt; do
case $opt in
{})
{}
;;
{})
{}
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift $((OPTIND-1))
]], {
i(1, "ab:c:"),
i(2, "a"),
i(3, "# handle option a"),
i(4, "b"),
i(5, "# handle option b with value in $OPTARG"),
})),
-- Trap signals
s("trap", fmt([[
trap '{}' {}
]], {
i(1, "echo 'Caught signal, cleaning up...; exit 1'"),
i(2, "SIGINT SIGTERM"),
})),
-- Cleanup function with trap
s("cleanup", fmt([[
cleanup() {{
{}
}}
trap cleanup EXIT
]], {
i(1, "# cleanup code here"),
})),
-- Redirect stdout and stderr to file
s("redirect", fmt([[
{} > {} 2>&1
]], {
i(1, "command"),
i(2, "logfile.log"),
})),
-- Check exit status
s("checkstatus", fmt([[
if [ $? -eq 0 ]; then
{}
else
{}
fi
]], {
i(1, "# success"),
i(2, "# failure"),
})),
-- Here document
s("heredoc", fmt([[
cat << EOF > {}
{}
EOF
]], {
i(1, "output.txt"),
i(2, "content goes here"),
})),
-- Here string
s("herestring", fmt([[
{} <<< "{}"
]], {
i(1, "command"),
i(2, "string"),
})),
-- Script usage/help
s("usage", fmt([[
usage() {{
cat << EOF
Usage: $(basename $0) [options] <arguments>
Options:
-h, --help Show this help message and exit
-v, --verbose Enable verbose output
{}
Examples:
$(basename $0) {}
EOF
exit ${1:-0}
}}
]], {
i(1, "-o, --option Description of option"),
i(2, "example_argument"),
})),
}
-- stylua: ignore end

View File

@@ -0,0 +1,79 @@
-- Lua snippets
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
local rep = require("luasnip.extras").rep
-- Return a table of snippets for Lua
-- stylua: ignore start
return {
-- Basic print statement
s("pr", {
t('print("'),
i(1, "text"),
t('")'),
}),
-- Function definition
s("fn", fmt([[
local function {}({})
{}
end
]], {
i(1, "name"),
i(2, ""),
i(3, "-- TODO: implement"),
})),
-- Module pattern
s("mod", fmt([[
local {} = {{}}
function {}:new(o)
o = o or {{}}
setmetatable(o, self)
self.__index = self
return o
end
{}
return {}
]], {
i(1, "ModuleName"),
rep(1),
i(2, "-- TODO: add methods"),
rep(1),
})),
-- For loop
s("for", fmt([[
for {} = {}, {} do
{}
end
]], {
i(1, "i"),
i(2, "1"),
i(3, "10"),
i(4, "-- TODO: loop body"),
})),
-- For pairs loop
s("forp", fmt([[
for {}, {} in pairs({}) do
{}
end
]], {
i(1, "k"),
i(2, "v"),
i(3, "table"),
i(4, "-- TODO: loop body"),
})),
}
-- stylua: ignore end

View File

@@ -0,0 +1,75 @@
-- Python snippets
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
local rep = require("luasnip.extras").rep
-- Return a table of snippets for Python
-- stylua: ignore start
return {
-- Print statement
s("pr", {
t("print("),
i(1, "text"),
t(")"),
}),
-- Function definition
s("def", fmt([[
def {}({}):
{}
]], {
i(1, "function_name"),
i(2, ""),
i(3, "pass"),
})),
-- Class definition
s("class", fmt([[
class {}:
def __init__(self, {}):
{}
]], {
i(1, "ClassName"),
i(2, ""),
i(3, "pass"),
})),
-- For loop
s("for", fmt([[
for {} in {}:
{}
]], {
i(1, "item"),
i(2, "iterable"),
i(3, "pass"),
})),
-- If statement
s("if", fmt([[
if {}:
{}
]], {
i(1, "condition"),
i(2, "pass"),
})),
-- Try/except
s("try", fmt([[
try:
{}
except {}:
{}
]], {
i(1, "# code"),
i(2, "Exception"),
i(3, "pass"),
})),
}
-- stylua: ignore end

View File

@@ -0,0 +1,340 @@
-- Lua snippets
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
local rep = require("luasnip.extras").rep
-- Return a table of snippets for Rust
-- stylua: ignore start
return {
-- Basic main function
s("main", fmt([[
fn main() {{
{}
}}
]], {
i(1, "// Your code here"),
})),
-- Function definition
s("fn", fmt([[
fn {}({}) {} {{
{}
}}
]], {
i(1, "function_name"),
i(2, ""),
c(3, {
t(""),
t("-> ()"),
sn(nil, {t("-> "), i(1, "ReturnType")}),
}),
i(4, "// Function body"),
})),
-- Public function
s("pfn", fmt([[
pub fn {}({}) {} {{
{}
}}
]], {
i(1, "function_name"),
i(2, ""),
c(3, {
t(""),
t("-> ()"),
sn(nil, {t("-> "), i(1, "ReturnType")}),
}),
i(4, "// Function body"),
})),
-- Struct definition
s("struct", fmt([[
struct {} {{
{}
}}
]], {
i(1, "StructName"),
i(2, "// fields"),
})),
-- Public struct
s("pstruct", fmt([[
pub struct {} {{
{}
}}
]], {
i(1, "StructName"),
i(2, "// fields"),
})),
-- Struct implementation
s("impl", fmt([[
impl {} {{
{}
}}
]], {
i(1, "StructName"),
i(2, "// methods"),
})),
-- Trait implementation
s("implfor", fmt([[
impl {} for {} {{
{}
}}
]], {
i(1, "Trait"),
i(2, "Type"),
i(3, "// trait implementation"),
})),
-- Trait definition
s("trait", fmt([[
trait {} {{
{}
}}
]], {
i(1, "TraitName"),
i(2, "// trait methods"),
})),
-- Public trait
s("ptrait", fmt([[
pub trait {} {{
{}
}}
]], {
i(1, "TraitName"),
i(2, "// trait methods"),
})),
-- Enum definition
s("enum", fmt([[
enum {} {{
{},
}}
]], {
i(1, "EnumName"),
i(2, "// variants"),
})),
-- Public enum
s("penum", fmt([[
pub enum {} {{
{},
}}
]], {
i(1, "EnumName"),
i(2, "// variants"),
})),
-- Match expression
s("match", fmt([[
match {} {{
{} => {},
_ => {},
}}
]], {
i(1, "expression"),
i(2, "pattern"),
i(3, "result"),
i(4, "default_result"),
})),
-- If let expression
s("iflet", fmt([[
if let {} = {} {{
{}
}}
]], {
i(1, "pattern"),
i(2, "expression"),
i(3, "// code"),
})),
-- While let loop
s("whilelet", fmt([[
while let {} = {} {{
{}
}}
]], {
i(1, "pattern"),
i(2, "expression"),
i(3, "// loop body"),
})),
-- For loop
s("for", fmt([[
for {} in {} {{
{}
}}
]], {
i(1, "item"),
i(2, "iterator"),
i(3, "// loop body"),
})),
-- Loop
s("loop", fmt([[
loop {{
{}
{}
}}
]], {
i(1, "// loop body"),
i(2, "break;"),
})),
-- Closure
s("closure", fmt([[
|{}| {} {{
{}
}}
]], {
i(1, "args"),
c(2, {
t(""),
sn(nil, {t("-> "), i(1, "ReturnType")}),
}),
i(3, "// closure body"),
})),
-- Derive attribute
s("derive", fmt([[
#[derive({})]
]], {
i(1, "Debug, Clone"),
})),
-- Module
s("mod", fmt([[
mod {} {{
{}
}}
]], {
i(1, "module_name"),
i(2, "// module contents"),
})),
-- Public module
s("pmod", fmt([[
pub mod {} {{
{}
}}
]], {
i(1, "module_name"),
i(2, "// module contents"),
})),
-- Use statement
s("use", fmt([[
use {};
]], {
i(1, "path::to::module"),
})),
-- Test module
s("testmod", fmt([[
#[cfg(test)]
mod tests {{
use super::*;
#[test]
fn {}() {{
{}
}}
}}
]], {
i(1, "test_name"),
i(2, "// test code"),
})),
-- Test function
s("test", fmt([[
#[test]
fn {}() {{
{}
}}
]], {
i(1, "test_name"),
i(2, "// test code"),
})),
-- Async function
s("async", fmt([[
async fn {}({}) {} {{
{}
}}
]], {
i(1, "function_name"),
i(2, ""),
c(3, {
t(""),
t("-> ()"),
sn(nil, {t("-> "), i(1, "ReturnType")}),
}),
i(4, "// async function body"),
})),
-- Result type
s("result", fmt([[
Result<{}, {}>
]], {
i(1, "T"),
i(2, "Error"),
})),
-- Option type
s("option", fmt([[
Option<{}>
]], {
i(1, "T"),
})),
-- Unwrap with error message
s("expect", fmt([[
.expect("{}")
]], {
i(1, "Failed to unwrap value"),
})),
-- Print debug
s("dbg", fmt([[
dbg!({});
]], {
i(1, "expression"),
})),
-- Print
s("print", fmt([[
println!("{}", {});
]], {
i(1, "{}"),
i(2, "expression"),
})),
-- Let statement
s("let", fmt([[
let {} = {};
]], {
i(1, "variable"),
i(2, "value"),
})),
-- Let mut statement
s("letmut", fmt([[
let mut {} = {};
]], {
i(1, "variable"),
i(2, "value"),
})),
}
-- stylua: ignore end

View File

@@ -0,0 +1,297 @@
-- Terraform snippets
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
local rep = require("luasnip.extras").rep
-- Return a table of snippets for Terraform
-- stylua: ignore start
return {
-- Terraform block
s("terraform", fmt([[
terraform {{
required_version = ">= {}"
required_providers {{
{}
}}
{}
}}
]], {
i(1, "1.0.0"),
i(2, 'aws = {\n source = "hashicorp/aws"\n version = "~> 4.0"\n }'),
i(3, ""),
})),
-- Provider block
s("provider", fmt([[
provider "{}" {{
{}
}}
]], {
i(1, "aws"),
i(2, 'region = "us-west-2"'),
})),
-- AWS Provider with profile
s("aws", fmt([[
provider "aws" {{
region = "{}"
profile = "{}"
}}
]], {
i(1, "us-west-2"),
i(2, "default"),
})),
-- Resource block
s("resource", fmt([[
resource "{}" "{}" {{
{}
}}
]], {
i(1, "aws_s3_bucket"),
i(2, "example"),
i(3, ""),
})),
-- Data source block
s("data", fmt([[
data "{}" "{}" {{
{}
}}
]], {
i(1, "aws_ami"),
i(2, "example"),
i(3, 'owners = ["amazon"]'),
})),
-- Variable block
s("variable", fmt([[
variable "{}" {{
description = "{}"
type = {}
default = {}
{}
}}
]], {
i(1, "example"),
i(2, "Example variable"),
c(3, {
t("string"),
t("number"),
t("bool"),
t("list(string)"),
t("map(string)"),
t("object({})"),
sn(nil, {t("list(object({"), i(1, "name = string, value = string"), t("}))")}),
}),
c(4, {
t('null'),
sn(nil, {t('"'), i(1, "default_value"), t('"')}),
sn(nil, {t('true')}),
sn(nil, {t('false')}),
sn(nil, {t('123')}),
sn(nil, {t('['), i(1, '"item1", "item2"'), t(']')}),
sn(nil, {t('{'), i(1, 'key = "value"'), t('}')}),
}),
i(5, ""),
})),
-- Output block
s("output", fmt([[
output "{}" {{
description = "{}"
value = {}
{}
}}
]], {
i(1, "example"),
i(2, "Example output"),
i(3, "aws_instance.example.id"),
c(4, {
t(""),
t("sensitive = true"),
}),
})),
-- Local block
s("locals", fmt([[
locals {{
{} = {}
}}
]], {
i(1, "example"),
i(2, '"value"'),
})),
-- Module block
s("module", fmt([[
module "{}" {{
source = "{}"
{}
}}
]], {
i(1, "example"),
i(2, "./modules/example"),
i(3, "# Module inputs"),
})),
-- Backend block
s("backend", fmt([[
backend "{}" {{
{}
}}
]], {
i(1, "s3"),
i(2, 'bucket = "terraform-state"\nkey = "path/to/state.tfstate"\nregion = "us-west-2"'),
})),
-- Conditional expression
s("condition", fmt([[
{} ? {} : {}
]], {
i(1, "var.environment == \"prod\""),
i(2, "\"production\""),
i(3, "\"development\""),
})),
-- For expression
s("for", fmt([[
[for {} in {} : {}]
]], {
i(1, "item"),
i(2, "var.list"),
i(3, "item.name"),
})),
-- For expression with index
s("fori", fmt([[
[for {}, {} in {} : {}]
]], {
i(1, "index"),
i(2, "item"),
i(3, "var.list"),
i(4, "\"${index}-${item.name}\""),
})),
-- For expression with map
s("formap", fmt([[
{{for {} in {} : {} => {}}}
]], {
i(1, "item"),
i(2, "var.list"),
i(3, "item.key"),
i(4, "item.value"),
})),
-- Count parameter
s("count", fmt([[
count = {}
{}[count.index]
]], {
i(1, "var.create_resource ? 1 : 0"),
i(2, "# Reference this resource elsewhere using aws_instance.example"),
})),
-- For each parameter
s("foreach", fmt([[
for_each = {}
{}
]], {
c(1, {
sn(nil, {t("toset(["), i(1, "\"item1\", \"item2\""), t("])")}),
sn(nil, {t("{"), i(1, "key1 = \"value1\", key2 = \"value2\""), t("}")}),
sn(nil, {t("var."), i(1, "map_variable")}),
}),
i(2, "# Reference this resource elsewhere using aws_instance.example[each.key]"),
})),
-- Dynamic block
s("dynamic", fmt([[
dynamic "{}" {{
for_each = {}
content {{
{}
}}
}}
]], {
i(1, "ingress"),
i(2, "var.ingress_rules"),
i(3, "from_port = ingress.value.from_port\n to_port = ingress.value.to_port\n protocol = ingress.value.protocol\n cidr_blocks = ingress.value.cidr_blocks"),
})),
-- Lifecycle block
s("lifecycle", fmt([[
lifecycle {{
{}
}}
]], {
c(1, {
t("create_before_destroy = true"),
t("prevent_destroy = true"),
t("ignore_changes = [tags]"),
sn(nil, {t("ignore_changes = ["), i(1, "attribute"), t("]")}),
t("create_before_destroy = true\n prevent_destroy = true\n ignore_changes = [tags]"),
}),
})),
-- Terraform workspace
s("workspace", fmt([[
terraform.workspace
]], {})),
-- Depends on
s("depends", fmt([[
depends_on = [
{},
]
]], {
i(1, "aws_iam_role_policy.example"),
})),
-- Provisioner
s("provisioner", fmt([[
provisioner "{}" {{
{}
}}
]], {
c(1, {
t("local-exec"),
t("remote-exec"),
t("file"),
}),
c(2, {
sn(nil, {t('command = "'), i(1, "echo hello"), t('"')}),
sn(nil, {t('inline = [\n "'), i(1, "echo hello"), t('",\n ]')}),
sn(nil, {t('source = "'), i(1, "scripts/setup.sh"), t('"\n destination = "'), i(2, "/tmp/setup.sh"), t('"')}),
}),
})),
-- Null resource
s("null", fmt([[
resource "null_resource" "{}" {{
triggers = {{
{} = {}
}}
{}
}}
]], {
i(1, "example"),
i(2, "trigger"),
i(3, "uuid()"),
i(4, "# Provisioners or depends_on go here"),
})),
}
-- stylua: ignore end