Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useful VS Code snippets #620

Open
JordanMartinez opened this issue Jan 23, 2024 · 0 comments
Open

Add useful VS Code snippets #620

JordanMartinez opened this issue Jan 23, 2024 · 0 comments

Comments

@JordanMartinez
Copy link
Owner

Context

Design Pattern
Enhancement = a new idea that can be documented/filed

Body

These are some snippets I've used over time:

purescript.json
{
	// Place your snippets for purescript here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	//
	// See https://github.com/microsoft/vscode/blob/main/src/vs/editor/contrib/snippet/browser/snippet.md
	// for syntax and transforms
	//
	// Example:
	// "Print to console": {
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"derive0EqOrdNewtypeGenericShow": {
		"prefix": "derive0EqOrdNewtypeGenericShow",
		"body": [
			"derive instance Eq $1",
			"derive instance Ord $1",
			"derive instance Newtype $1 _",
			"derive instance Generic $1 _",
			"instance Show $1 where",
			"  show x = genericShow x"
		],
		"description": "Derive common instances"
	},
	"derive1EqOrdNewtypeGenericShow": {
		"prefix": "derive1EqOrdNewtypeGenericShow",
		"body": [
			"derive instance Eq a => Eq ($1 a)",
			"derive instance Ord a => Ord ($1 a)",
			"derive instance Newtype ($1 a) _",
			"derive instance Generic ($1 a) _",
			"instance Show a => Show ($1 a) where",
			"  show x = genericShow x"
		],
		"description": "Derive common instances"
	},
	"deriveMonad": {
		"prefix": "deriveMonad",
		"body": [
			"derive instance Functor $1",
			"derive instance Apply $1",
			"derive instance Applicative $1",
			"derive instance Bind $1",
			"derive instance Monad $1",
			"instance Show a where",
			"  show x = genericShow x"
		],
		"description": "Derive monad instances"
	},
	"deriveFoldableTraversable": {
		"prefix": "deriveFoldableTraversable",
		"body": [
			"derive instance Functor $1",
			"derive instance Foldable $1",
			"derive instance Traversable $1"
		],
		"description": "Derive monad instances"
	},
	"EffectFn10": {
		"prefix": "effectfn10",
		"body": [
			"foreign import $1Impl :: EffectFn10 ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9) ($10) ($11) ($12)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $8 -> $9 -> $10 -> $11 -> Effect $12",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} ${10/(.+)/${1:/camelcase}/} ${11/(.+)/${1:/camelcase}/} =",
			"  runEffectFn10 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} ${10/(.+)/${1:/camelcase}/} ${11/(.+)/${1:/camelcase}/}"
		],
		"description": "EffectFn10 FFI"
	},
	"EffectFn9": {
		"prefix": "effectfn9",
		"body": [
			"foreign import $1Impl :: EffectFn9 ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9) ($10) ($11)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $8 -> $9 -> $10 -> Effect $11",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} ${10/(.+)/${1:/camelcase}/} =",
			"  runEffectFn9 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} ${10/(.+)/${1:/camelcase}/}"
		],
		"description": "EffectFn9 FFI"
	},
	"EffectFn8": {
		"prefix": "effectfn8",
		"body": [
			"foreign import $1Impl :: EffectFn8 ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9) ($10)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $8 -> $9 -> Effect $10",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} =",
			"  runEffectFn8 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} "
		],
		"description": "EffectFn8 FFI"
	},
	"EffectFn7": {
		"prefix": "effectfn7",
		"body": [
			"foreign import $1Impl :: EffectFn7 ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $8 -> Effect $9",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} =",
			"  runEffectFn7 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} "
		],
		"description": "EffectFn7 FFI"
	},
	"EffectFn6": {
		"prefix": "effectfn6",
		"body": [
			"foreign import $1Impl :: EffectFn6 ($2) ($3) ($4) ($5) ($6) ($7) ($8)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $Effect $8",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} =",
			"  runEffectFn6 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/}"
		],
		"description": "EffectFn6 FFI"
	},
	"EffectFn5": {
		"prefix": "effectfn5",
		"body": [
			"foreign import $1Impl :: EffectFn5 ($2) ($3) ($4) ($5) ($6) ($7)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> Effect $7",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} =",
			"  runEffectFn5 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/}"
		],
		"description": "EffectFn5 FFI"
	},
	"EffectFn4": {
		"prefix": "effectfn4",
		"body": [
			"foreign import $1Impl :: EffectFn4 ($2) ($3) ($4) ($5) ($6)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> Effect $6",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} =",
			"  runEffectFn4 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/}"
		],
		"description": "EffectFn4 FFI"
	},
	"EffectFn3": {
		"prefix": "effectfn3",
		"body": [
			"foreign import $1Impl :: EffectFn3 ($2) ($3) ($4) ($5)",
			"",
			"$1 :: $2 -> $3 -> $4 -> Effect $5",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} =",
			"  runEffectFn3 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/}"
		],
		"description": "EffectFn3 FFI"
	},
	"EffectFn2": {
		"prefix": "effectfn2",
		"body": [
			"foreign import $1Impl :: EffectFn2 ($2) ($3) ($4)",
			"",
			"$1 :: $2 -> $3 -> $4 -> Effect $5",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} =",
			"  runEffectFn2 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/}"
		],
		"description": "EffectFn2 FFI"
	},
	"EffectFn1": {
		"prefix": "effectfn1",
		"body": [
			"foreign import $1Impl :: EffectFn1 ($2) ($3)",
			"",
			"$1 :: $2 -> Effect $3",
			"$1 ${2/(.+)/${1:/camelcase}/} = runEffectFn1 $1Impl ${2/(.+)/${1:/camelcase}/}"
		],
		"description": "EffectFn1 FFI"
	},
	"Fn10": {
		"prefix": "fn10",
		"body": [
			"foreign import $1Impl :: Fn10 ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9) ($10) ($11) ($12)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $8 -> $9 -> $10 -> $11 ->  $12",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} ${10/(.+)/${1:/camelcase}/} ${11/(.+)/${1:/camelcase}/} =",
			"  runFn10 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} ${10/(.+)/${1:/camelcase}/} ${11/(.+)/${1:/camelcase}/}"
		],
		"description": "Fn10 FFI"
	},
	"Fn9": {
		"prefix": "fn9",
		"body": [
			"foreign import $1Impl :: Fn9 ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9) ($10) ($11)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $8 -> $9 -> $10 ->  $11",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} ${10/(.+)/${1:/camelcase}/} =",
			"  runFn9 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} ${10/(.+)/${1:/camelcase}/}"
		],
		"description": "Fn9 FFI"
	},
	"Fn8": {
		"prefix": "fn8",
		"body": [
			"foreign import $1Impl :: Fn8 ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9) ($10)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $8 -> $9 ->  $10",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} =",
			"  runFn8 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} ${9/(.+)/${1:/camelcase}/} "
		],
		"description": "Fn8 FFI"
	},
	"Fn7": {
		"prefix": "fn7",
		"body": [
			"foreign import $1Impl :: Fn7 ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $8 ->  $9",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} =",
			"  runFn7 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} ${8/(.+)/${1:/camelcase}/} "
		],
		"description": "Fn7 FFI"
	},
	"Fn6": {
		"prefix": "fn6",
		"body": [
			"foreign import $1Impl :: Fn6 ($2) ($3) ($4) ($5) ($6) ($7) ($8)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 -> $7 -> $ $8",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/} =",
			"  runFn6 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} ${7/(.+)/${1:/camelcase}/}"
		],
		"description": "Fn6 FFI"
	},
	"Fn5": {
		"prefix": "fn5",
		"body": [
			"foreign import $1Impl :: Fn5 ($2) ($3) ($4) ($5) ($6) ($7)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 -> $6 ->  $7",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/} =",
			"  runFn5 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} ${6/(.+)/${1:/camelcase}/}"
		],
		"description": "Fn5 FFI"
	},
	"Fn4": {
		"prefix": "fn4",
		"body": [
			"foreign import $1Impl :: Fn4 ($2) ($3) ($4) ($5) ($6)",
			"",
			"$1 :: $2 -> $3 -> $4 -> $5 ->  $6",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/} =",
			"  runFn4 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} ${5/(.+)/${1:/camelcase}/}"
		],
		"description": "Fn4 FFI"
	},
	"Fn3": {
		"prefix": "fn3",
		"body": [
			"foreign import $1Impl :: Fn3 ($2) ($3) ($4) ($5)",
			"",
			"$1 :: $2 -> $3 -> $4 ->  $5",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/} =",
			"  runFn3 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} ${4/(.+)/${1:/camelcase}/}"
		],
		"description": "Fn3 FFI"
	},
	"Fn2": {
		"prefix": "fn2",
		"body": [
			"foreign import $1Impl :: Fn2 ($2) ($3) ($4)",
			"",
			"$1 :: $2 -> $3 -> $4 ->  $5",
			"$1 ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/} =",
			"  runFn2 $1Impl ${2/(.+)/${1:/camelcase}/} ${3/(.+)/${1:/camelcase}/}"
		],
		"description": "Fn2 FFI"
	},
	"Fn1": {
		"prefix": "fn1",
		"body": [
			"foreign import $1Impl :: Fn1 ($2) ($3)",
			"",
			"$1 :: $2 ->  $3",
			"$1 ${2/(.+)/${1:/camelcase}/} = runFn1 $1Impl ${2/(.+)/${1:/camelcase}/}"
		],
		"description": "Fn1 FFI"
	},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant