65 lines
1.5 KiB
Lua
65 lines
1.5 KiB
Lua
local ls = require('luasnip')
|
|
local s = ls.snippet
|
|
local i = ls.insert_node
|
|
local f = ls.function_node
|
|
local fmt = require('luasnip.extras.fmt').fmt
|
|
|
|
------------------------------
|
|
-- YAML
|
|
------------------------------
|
|
local yaml_schema_snippet = s(
|
|
{ name = 'yaml_schema', trig = 'yaml_schema' },
|
|
fmt([[
|
|
{comment} yaml-language-server: $schema={path}
|
|
]],
|
|
{
|
|
path = i(1, 'path'),
|
|
comment = f(com_string, {}, { user_args = { false } }),
|
|
}
|
|
)
|
|
)
|
|
|
|
ls.add_snippets('yaml', { yaml_schema_snippet })
|
|
ls.add_snippets('helm', { yaml_schema_snippet })
|
|
|
|
local flux_cd_kustomization = s(
|
|
{ name = 'fluxcd_kustomization', trig = 'fluxkust' },
|
|
fmt([[
|
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
|
kind: Kustomization
|
|
metadata:
|
|
name: {name}
|
|
namespace: {namespace}
|
|
spec:
|
|
interval: {interval}
|
|
path: {path}
|
|
prune: true
|
|
sourceRef:
|
|
kind: GitRepository
|
|
name: {repository_name}
|
|
]],
|
|
{
|
|
name = i(1, 'name'),
|
|
namespace = i(2, 'flux-system'),
|
|
interval = i(3, '5m'),
|
|
path = i(4, 'path'),
|
|
repository_name = i(5, 'repository_name'),
|
|
}
|
|
)
|
|
)
|
|
|
|
ls.add_snippets('yaml', { flux_cd_kustomization })
|
|
|
|
local sleep_command = s(
|
|
{ name = 'sleep_command', trig = 'sleep' },
|
|
fmt([[
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- while true; do sleep 3600; done
|
|
]], {})
|
|
)
|
|
|
|
ls.add_snippets('yaml', { sleep_command })
|
|
|