Comments (2)
Yes, the transformations work with normal snippets. I'll use a smaller example (the React useState hook) to demonstrate some of the nuances I'm experiencing:
If I use this regular VSCode snippet...
{
"use state": {
"scope": "javascript,typescript,javascriptreact,typescriptreact",
"prefix": "usestate",
"body": ["const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState(${2});"],
"description": "useState"
}
}
... I can get the casing I want by first inserting the snippet, entering my text for variable $1
, and then hitting Tab to get to variable $2
. The capitalize
transform isn't applied until I hit Tab.
If I use this Cursorless snippet...
{
"useState": {
"definitions": [
{
"scope": {
"langIds": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
},
"body": [
"const [${name}, set${name/(.*)/${1:/capitalize}/}] = useState(${initialValue})"
],
"variables": {
"name": {
"formatter": "camelCase"
}
}
}
]
}
}
... I can add useState, useStateTest.name
to insertion_snippets_single_phrase.csv
and use the snippet without error, but the capitalize transform is not applied whether or not I include the initial phrase or not, so "snippet usestate hello world" will insert const [helloWorld, sethelloWorld] = useState()
, and if I use only "snippet usestate" and then enter $name
manually, the capitalize
transform will not be applied even after I use the Tab key. I also tested this without the formatter configured for $name
.
If I try making my Cursorless snippet this...
{
"useState": {
"definitions": [
{
"scope": {
"langIds": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
},
"body": [
"const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState(${initialValue})"
],
"variables": {
"1": {
"formatter": "camelCase"
}
}
}
]
}
}
... I cannot use the initial phrase for variable $1
, as it seems that entries such as useState, useState.1
or useState, useState[1]
, etc. do not work for insertion_snippets_single_phrase.csv
. However, I can simply use "snippet usestate" without a phrase and use the Tab key to get a successful capitalize
after manually entering $1
. This has been my current workaround in general for snippets where I need transformations, using numbered variables and not using the initial phrase (or using the initial phrase for a different variable that doesn't need transformation).
This is purely speculation, but perhaps the issue has to do with VSCode requiring the explicit Tab press to apply the transformation, and perhaps Cursorless cannot currently trigger this with the initial phrase. I'm not sure why in my second code block above, the Cursorless snippet using $name
, I cannot get the capitalize
even with manual entry of $name plus a Tab press, though.
from cursorless.
does this work with regular vscode snippets? we just vendored in their snippet parser
from cursorless.
Related Issues (20)
- Figure out why trailing newline gets added for scope test fixtures
- Allow more short versions for keyboard maps HOT 4
- Simplification to scope fixtures HOT 4
- Prompt to enable asking LLMs about Cursorless HOT 1
- "break" action doesn't use correct indentation HOT 3
- Diataxis initial tasks
- Python: `value` scope works for `return` statements, but not `yield` statements
- Keyboard Feature Idea: Fallthrough for unused keys
- Formatting Commands HOT 7
- Hat appearing on unicode characters HOT 2
- Add destinations to docs
- Create spoken form widget for use in docs
- Re-enable scroll position tests HOT 1
- Run better scroll tests when running tests locally
- Add support for reformat action to our custom api
- Add docs page for how to run cursorless-talon spoken form tests locally
- Uncaught exceptions from CustomSpokenForms.updateSpokenFormMaps? HOT 5
- Migrate to new VSCode test runner
- Support `"every row X past Y"`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cursorless.