Make the fun snippet work in more contexts

`fun` expands to a simple function definition in JavaScript, but there 
are certain contexts where that syntax is invalid, making the snippet 
much less useful.

Now that we're scoping the insides of class bodies and object literals, 
though, we can define more specific snippets for those contexts that use 
the correct syntax.

The class-instance-method snippet and the inside-an-object-literal 
snippet are identical, except that the latter has a trailing comma.
This commit is contained in:
Andrew Dupont 2023-08-16 09:36:44 -07:00
parent 5c8f6abd94
commit 37a81ccb82

View File

@ -128,3 +128,18 @@
'return':
'prefix': 'ret'
'body': 'return $1;$0'
'.source.js .meta.block.function.js':
'Function':
'prefix': 'fun'
'body': 'function ${1:functionName}($2) {\n\t$0\n}'
'.source.js .meta.block.class.js':
'Function':
'prefix': 'fun'
'body': '${1:functionName}($2) {\n\t$0\n}'
'.source.js .meta.object.js':
'Function':
'prefix': 'fun'
'body': '${1:functionName}($2) {\n\t$0\n},'