-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Snippet wrap #296
Snippet wrap #296
Changes from 26 commits
8dd40cf
61fc7bc
357719e
180f374
cfa46fc
df99a07
a52473f
2a84b42
f411204
b9e1ac1
90d5a5b
8b86f10
7ccafc2
1df155c
6388499
b1a53e2
2e9f7b1
58c5b83
d741029
30b8163
36035c6
5722322
3da4762
541fd3f
07fdfcf
7205c61
1810d62
45e4f82
a0a190d
20a2717
f74bd50
bac3d38
7d716be
a8926a5
6adc0af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"ifElseStatement": { | ||
"definitions": [ | ||
{ | ||
"scope": { | ||
"langIds": [ | ||
"typescript", | ||
"typescriptreact", | ||
"javascript", | ||
"javascriptreact", | ||
"cpp", | ||
"c", | ||
"java", | ||
"csharp" | ||
] | ||
}, | ||
"body": [ | ||
"if ($condition) {", | ||
"\t$consequence", | ||
"} else {", | ||
"\t$alternative", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"scope": { | ||
"langIds": [ | ||
"python" | ||
] | ||
}, | ||
"body": [ | ||
"if $condition:", | ||
"\t$consequence", | ||
"else:", | ||
"\t$alternative" | ||
] | ||
} | ||
], | ||
"defaultScopeTypes": { | ||
"consequence": "statement", | ||
"alternative": "statement" | ||
}, | ||
"description": "If else statement" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"ifStatement": { | ||
"definitions": [ | ||
{ | ||
"scope": { | ||
"langIds": [ | ||
"typescript", | ||
"typescriptreact", | ||
"javascript", | ||
"javascriptreact", | ||
"cpp", | ||
"c", | ||
"java", | ||
"csharp" | ||
] | ||
}, | ||
"body": [ | ||
"if ($condition) {", | ||
"\t$consequence", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"scope": { | ||
"langIds": [ | ||
"python" | ||
] | ||
}, | ||
"body": [ | ||
"if $condition:", | ||
"\t$consequence" | ||
] | ||
} | ||
], | ||
"defaultScopeTypes": { | ||
"consequence": "statement" | ||
}, | ||
"description": "If statement" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"tryCatchStatement": { | ||
"definitions": [ | ||
{ | ||
"scope": { | ||
"langIds": [ | ||
"typescript", | ||
"typescriptreact", | ||
"javascript", | ||
"javascriptreact", | ||
"cpp", | ||
"c", | ||
"java", | ||
"csharp" | ||
] | ||
}, | ||
"body": [ | ||
"try {", | ||
"\t$body", | ||
"} catch ($error) {", | ||
"\t$exceptBody", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"scope": { | ||
"langIds": [ | ||
"python" | ||
] | ||
}, | ||
"body": [ | ||
"try:", | ||
"\t$body", | ||
"except $error:", | ||
"\t$exceptBody" | ||
] | ||
} | ||
], | ||
"defaultScopeTypes": { | ||
"body": "statement", | ||
"exceptBody": "statement" | ||
}, | ||
"description": "Try catch statement" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,9 +400,27 @@ | |
"verticalOffset": 0 | ||
} | ||
} | ||
}, | ||
"cursorless.experimental.snippetsDir": { | ||
"description": "Directory containing snippets for use in cursorless", | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"languages": [ | ||
{ | ||
"id": "json", | ||
"extensions": [ | ||
".cursorless-snippets" | ||
] | ||
} | ||
], | ||
"jsonValidation": [ | ||
{ | ||
"fileMatch": "*.cursorless-snippets", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This extension is a bit verbose; open to suggestions. Need some way to indicate that the file should be checked by the schema on the next line so that user gets autocomplete |
||
"url": "./schemas/cursorless-snippets.json" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "npm run -S esbuild-base -- --minify", | ||
|
@@ -420,7 +438,7 @@ | |
"@types/glob": "^7.1.3", | ||
"@types/js-yaml": "^4.0.2", | ||
"@types/mocha": "^8.0.4", | ||
"@types/node": "^12.11.7", | ||
"@types/node": "^16.11.3", | ||
"@types/sinon": "^10.0.2", | ||
"@types/vscode": "^1.53.0", | ||
"@typescript-eslint/eslint-plugin": "^4.9.0", | ||
|
@@ -432,12 +450,12 @@ | |
"js-yaml": "^4.1.0", | ||
"mocha": "^8.1.3", | ||
"sinon": "^11.1.1", | ||
"typescript": "^4.1.2", | ||
"typescript": "^4.4.4", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note the typescript version bump |
||
"vscode-test": "^1.4.1" | ||
}, | ||
"dependencies": { | ||
"@types/lodash": "^4.14.168", | ||
"immutability-helper": "^3.1.1", | ||
"lodash": "^4.17.21" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Snippets for use in cursorless", | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "object", | ||
"properties": { | ||
"definitions": { | ||
"type": "array", | ||
"descriptions": "List of possible definitions for this snippet", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"scope": { | ||
"type": "object", | ||
"description": "Scopes where this snippet is active", | ||
"properties": { | ||
"langIds": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"scopeType": { | ||
"$ref": "#/$defs/scopeType", | ||
"description": "Cursorless scopes in which this snippet is active. Allows, for example, to have different snippets to define a function if you're in a class or at global scope." | ||
} | ||
} | ||
}, | ||
"body": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"description": "Inline snippet text; entries joined by newline" | ||
} | ||
}, | ||
"required": [ | ||
"body" | ||
] | ||
} | ||
}, | ||
"defaultScopeTypes": { | ||
"type": "object", | ||
"description": "For each named variable in the snippet, uses the given scope type from this map when wrapping a target without scope type specified", | ||
"additionalProperties": { | ||
"$ref": "#/$defs/scopeType" | ||
} | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "Description of the snippet" | ||
} | ||
} | ||
}, | ||
"$defs": { | ||
"scopeType": { | ||
"type": "string", | ||
"enum": [ | ||
"argumentOrParameter", | ||
"anonymousFunction", | ||
"attribute", | ||
"class", | ||
"className", | ||
"collectionItem", | ||
"collectionKey", | ||
"comment", | ||
"functionCall", | ||
"functionName", | ||
"ifStatement", | ||
"list", | ||
"map", | ||
"name", | ||
"namedFunction", | ||
"regularExpression", | ||
"statement", | ||
"string", | ||
"type", | ||
"value", | ||
"xmlBothTags", | ||
"xmlElement", | ||
"xmlEndTag", | ||
"xmlStartTag" | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ interface MarkEntry { | |
} | ||
|
||
class BringMoveSwap implements Action { | ||
targetPreferences: ActionPreferences[] = [ | ||
getTargetPreferences: () => ActionPreferences[] = () => [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now have a function to give action a chance to see args |
||
{ insideOutsideType: null }, | ||
{ insideOutsideType: null }, | ||
]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy way to update snapshots