Comments (11)
I'll (try to) release 0.12.0 this week. It won't insert {} for attributes, only for directives.
Brace matching is still broken - IDK why, so it will need to wait for future release.
from svelte-intellij.
I agree to not auto-insert after defining an attribute, or auto-insert anything at all. It gets quite tiring having to remember backspace every time. It should however still auto close when braces or quotes when it is first opened.
from svelte-intellij.
Trying to guess the intention of the developer I think would be too overkill.
Linking back to my post above, I think it should be up to the developer to decide rather than trying to guess.
e.g. when I key in =
it should do nothing, when I key in {
after =
it should insert }
. When I key in "
after =
it should insert "
. Which effectively only auto-insert after it knows what the context of the attribute is. Hope this makes sense. I think most people would prefer 1 extra key then "click-backspace-backspace-etc-etc"
from svelte-intellij.
In the case when the js code within the braces has spaces, double quotes need to be used anyways.
What do you mean? Svelte 3 supported that always, this plugin supports that since 0.10.0. Compatibility with other tools?
I agree that option to auto-insert "{}"
could be preferred. For now let's see if this issue has wider community support.
from svelte-intellij.
As is, this this is an anti-feature, as I have to do 3 keystrokes to undo the auto braces. 90% of the time, I just want to have a plain old html attribute. And about 50% of the time I want the svelte curly braces, I want to use quotes.
That means, .9 * .5 = .045 or 4.5% of the time, the auto curly braces behavior is what I want. The other 95.5% of the time, I have to do 3 extra keystrokes to undo the behavior.
Note that 78.2% of the time, statistics are false.
from svelte-intellij.
And about 50% of the time I want the svelte curly braces, I want to use quotes.
@btakita you mean e.g. example="{something}"
right? Why is that? I can't think of any other reason besides compatibility with other tools.
Anyway curly braces were ported from React JSX, I'm trying to - at first - match Svelte plugin to known IntelliJ behavior.
Now I'm thinking that directives should always insert braces because otherwise it's invalid (correct me if I'm wrong), attributes could default to quotes, and component props could default to braces because you usually compose components in loops, pass variables from parent, context or stores etc.
On other thing, I wonder if attrs could be partitioned into 2 groups, ones that have usually static values and ones that have usually dynamic values - but that's a little too clever.
from svelte-intellij.
Yeah I understand what do you mean. That's pretty neat, yet I still think curly braces are more often preferred.
Something will be done about this, I'm not sure what yet. Some combination of changed defaults & intentions to wrap and unwrap {""} and "{}".
from svelte-intellij.
Cool, whichever is decided sounds like it will have a better experience with current behaviour.
The ="{}"
syntax is more for string interpolation, e.g. you can do something like this:
<script>
const display = true ? 'block' : 'none';
<script>
<div style="display: {display}"></div>
Which is more readable, rather than:
<div style={`display: ${display}`}></div>
Which is still valid but looks cumbersome.
from svelte-intellij.
looks cumbersome
Agreed. Still it's unusual so I wouldn't take it into account when talking about default.
from svelte-intellij.
@tomblachut Svelte used to have a compile error when there were spaces in a {}
block. It looks like this is no longer the behavior of Svelte. Given that, I'd rather there be no auto insert. Webstorm automatically closes a double quote or an open curly brace, which is 1 keystroke.
from svelte-intellij.
Migrating from GH. Please open fresh issue on YouTrack. if something is still required, although with differentiation between attribute/directive I'm not sure if something still needs to be done here.
from svelte-intellij.
Related Issues (20)
- Generated types dir is not recognized in Svelte compoenents HOT 6
- Update SvelteJSReferenceExpressionResolver for 223 intellij branch HOT 1
- Comment with Line Comment broken for <script> section of .svelte files HOT 3
- Support NPM Workspaces for "Go to Declaration" HOT 1
- Add support for `context="module"` HOT 2
- Add support for @const HOT 1
- delete is not highlighted as a keyword in "<script>" block HOT 3
- Support for "endpoints" tool window integration HOT 1
- Auto-import does not emit `import type` for types HOT 1
- "Rename" refactoring HOT 1
- destructed exports are not suggested HOT 1
- typescript declarations not working correctly for derived stores. HOT 1
- Unresolved variable for store when using TypeScript HOT 2
- No errors on missing 'type' imports HOT 2
- type errors not showing on component props HOT 2
- Exported functions from initialized components are "unresolved" HOT 4
- `typeof` not hinted/colored in Svelte files HOT 1
- Reference to `./$types` does not work in .svelte files but works in .ts files HOT 6
- Importing files with extension .js instead of .ts HOT 3
- Update on plugin release schedule HOT 4
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 svelte-intellij.