-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
feat: add editor label and formatter configuration defaults #2330
base: master
Are you sure you want to change the base?
Conversation
I wonder if we could drop I also wonder if we could show |
I had this initially too but realised it could break if anyone changed the
Maybe something like this? Details"workbench.editor.customLabels.patterns": {
"src/routes/+[page|server]*": "/${filename}.${extname}",
"src/routes/*/+[page|server]*": "/${dirname}/${filename}.${extname}",
"src/routes/*/*/**/+[page|server]*": ".../${dirname}/${filename}.${extname}",
}, |
@@ -396,6 +396,16 @@ | |||
} | |||
} | |||
}, | |||
"configurationDefaults": { | |||
"[svelte]": { |
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.
I'm not 100% sure we want this because people can also use the prettier extension, if that ones installed I'd actually prefer that one was used assuming people have both prettier and the plugin installed.
The label thing is a super nice addition.
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.
Just curious, but what's the difference between the two? I've been using the svelte formatter set as the default although I have both installed. Mainly because setting prettier as the default formatter prompts me to change the default when I try to format a svelte file in a project that has no prettier installed or prettier config.
We could potentially duplicate the rules and remove the |
I'm not sure how to get the fallback rules to recognise the nesting level since without knowing the |
I tried exactly this in my configuration but removed it because:
|
This is what I came up with: "workbench.editor.customLabels.patterns": {
// Root
"**/routes/+layout.svelte": "/ [layout]",
"**/routes/+page.server.ts": "/ [server]",
"**/routes/+layout.server.ts": "/ [layout.server]",
"**/routes/+server.ts": "/ [endpoint]",
"**/routes/+page.svelte": "/ [page]",
// 1st level
"**/routes/*/+layout.svelte": "/${dirname} [layout]",
"**/routes/*/+page.server.ts": "/${dirname} [server]",
"**/routes/*/+layout.server.ts": "/${dirname} [layout.server]",
"**/routes/*/+server.ts": "/${dirname} [endpoint]",
"**/routes/*/+page.svelte": "/${dirname} [page]",
// Nested
"**/routes/*/*/**/+layout.svelte": "${dirname(1)}/${dirname} [layout]",
"**/routes/*/*/**/+page.server.ts": "${dirname(1)}/${dirname} [server]",
"**/routes/*/*/**/+layout.server.ts": "${dirname(1)}/${dirname} [layout.server]",
"**/routes/*/*/**/+server.ts": "${dirname(1)}/${dirname} [endpoint]",
"**/routes/*/*/**/+page.svelte": "${dirname(1)}/${dirname} [page]",
} Very convoluted but this makes things like |
@paoloricciuti I'm not sure you did try the same thing then. My suggestion was that @ottomated your setup can't differentiate between |
Co-authored-by: Ben McCann <[email protected]>
Good catch, here's a more comprehensive version: "workbench.editor.customLabels.patterns": {
// Root
"**/routes/+layout.svelte": "/ [layout]",
"**/routes/+layout.server.[jt]s": "/ [layout.server.load]",
"**/routes/+layout.[jt]s": "/ [layout.load]",
"**/routes/+page.svelte": "/ [page]",
"**/routes/+page.server.[jt]s": "/ [server.load]",
"**/routes/+page.[jt]s": "/ [load]",
"**/routes/+server.[jt]s": "/ [endpoint]",
// 1st level
"**/routes/*/+layout.svelte": "/${dirname} [layout]",
"**/routes/*/+layout.server.[jt]s": "/${dirname} [layout.server.load]",
"**/routes/*/+layout.[jt]s": "/${dirname} [layout.load]",
"**/routes/*/+page.svelte": "/${dirname} [page]",
"**/routes/*/+page.server.[jt]s": "/${dirname} [server.load]",
"**/routes/*/+page.[jt]s": "/${dirname} [load]",
"**/routes/*/+server.[jt]s": "/${dirname} [endpoint]",
// Nested
"**/routes/*/*/**/+layout.svelte": "${dirname(1)}/${dirname} [layout]",
"**/routes/*/*/**/+layout.server.[jt]s": "${dirname(1)}/${dirname} [layout.server.load]",
"**/routes/*/*/**/+layout.[jt]s": "${dirname(1)}/${dirname} [layout.load]",
"**/routes/*/*/**/+page.svelte": "${dirname(1)}/${dirname} [page]",
"**/routes/*/*/**/+page.server.[jt]s": "${dirname(1)}/${dirname} [server.load]",
"**/routes/*/*/**/+page.[jt]s": "${dirname(1)}/${dirname} [load]",
"**/routes/*/*/**/+server.[jt]s": "${dirname(1)}/${dirname} [endpoint]",
}, |
what about |
Uses the VS Code extension configuration defaults contribution point to:
Default
Label format
Custom labels