Skip to content

Commit

Permalink
feat: ### Configuration improvements for customSnippets:
Browse files Browse the repository at this point in the history
    - make `type` of customSnippets typed. Previously it was a string, now it a string enum. Number support is preserved.
    - add `executeCommand` to allow running arbitrary commands on snippet accept
- ### improve builtin `useParam` snippet:
  1. Now it will appear on top with Event icon, similar to other builtin js snippets. Most importantly it now appear higher score than `useParams`
  2. Now it will expand to `const params = useParams() as { groupId: string }` instead of `const params = useParams<'groupId'>()`. You can look at the [react-router issue](remix-run/react-router#8498) for the motivation of this change. You can use `useParamMode` setting to switch to old behavior.
----
- allow to use captured group names from regexs of `when` in `body` of snippet
- ### Introduce New Type of Snippets!
- ### Typing Snippets
- More in readme
feat: ### New builtin snippets
  - `ed` -> `export default` (for js langs)
  - New snippets for markdown:
  - `ts` -> `` ```ts\n$1\n``` ``
  - `ts` -> `` ```ts\n$1\n``` ``
  - `codeblock` -> `` ```$1\n$2\n``` `` (fenced codeblock)
  - `dropdown` (fenced codeblock)
fix: Fix a rare case when the same snippet with multiple locations where included multiple times
fix: Allow to disable sortText applied by default snippet config
  • Loading branch information
zardoy committed Jan 16, 2022
1 parent 49b38b5 commit 3da6428
Show file tree
Hide file tree
Showing 10 changed files with 1,104 additions and 611 deletions.
25 changes: 24 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,30 @@ Also, web should be supported.

## Builtin Snippets

This extension comes with some [top-line builtin snippets](src/builtinSnippets.ts), they can be disabled.
This extension comes handy [top-line builtin snippets](src/builtinSnippets.ts) for JS and Markdown languages. They can be disabled.

## Typing Snippets

You can also define so called typing snippets. Some sequence of letter will be replaced with snippet, for example:

`cb ` -> `($1) => $2`

Configuration:

```json
"betterSnippets.typingSnippets": [
{
"sequence": "cb ",
"body":"($1) => $2"
}
],
```

Note that:

- some features from snippets such as `resolveImports` or `when` clause are supported
- any cursor movement (using arrows or mouse) will reset the typing sequence
- they don't work with multiple selections (when there are multiple cursor in editor)

## Experimental Snippets

Expand Down
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"scripts": {
"start": "vscode-framework start",
"start-web": "vscode-framework start --web",
"build": "vscode-framework build",
"build": "vscode-framework build && tsm prepare.ts",
"test": "echo not-implemented"
},
"pnpm": {
Expand All @@ -68,27 +68,32 @@
"@types/chai": "^4.3.0",
"@types/glob": "^7.2.0",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.17",
"@types/node": "^16.11.19",
"@types/vscode": "^1.63.1",
"@vscode/test-electron": "^2.0.1",
"@zardoy/tsconfig": "^1.2.2",
"@vscode/test-electron": "^2.1.0",
"@zardoy/tsconfig": "^1.3.1",
"char": "^1.0.2",
"cross-env": "^7.0.3",
"eslint": "^8.6.0",
"eslint-config-zardoy": "^0.2.5",
"delay": "^5.0.0",
"eslint": "^8.7.0",
"eslint-config-zardoy": "^0.2.8",
"glob": "^7.2.0",
"mocha": "^9.1.3",
"typescript": "^4.5.4"
"mocha": "^9.1.4",
"tsm": "^2.2.1",
"typescript": "^4.5.4",
"vscode-manifest": "^0.0.8"
},
"dependencies": {
"@types/path-browserify": "^1.0.0",
"@zardoy/utils": "^0.0.4",
"escape-string-regexp": "^5.0.0",
"got": "^11.8.3",
"modify-json-file": "^1.2.2",
"path-browserify": "^1.0.1",
"rambda": "^6.9.0",
"string-dedent": "^2.0.0",
"ts-essentials": "^9.1.2",
"type-fest": "^2.8.0",
"type-fest": "^2.9.0",
"vscode-framework": "^0.0.18",
"vscode-snippet-parser": "^0.0.5"
}
Expand Down
Loading

0 comments on commit 3da6428

Please sign in to comment.