-
-
Notifications
You must be signed in to change notification settings - Fork 50
feat: add workspace initialization command #374
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
9804a42
4dfff1a
d52af39
5554377
80d9db6
8bd3085
ebdb2a5
a104d79
8e7b0f3
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { ConfigurationTarget, Uri, workspace } from "vscode"; | ||
import { downloadBiome } from "./downloader"; | ||
import { restart, start, stop } from "./lifecycle"; | ||
import { info } from "./logger"; | ||
import { state } from "./state"; | ||
import { clearTemporaryBinaries } from "./utils"; | ||
|
||
/** | ||
* Starts the Biome extension | ||
* | ||
|
@@ -51,3 +51,51 @@ export const resetCommand = async () => { | |
info("Biome extension was reset"); | ||
await start(); | ||
}; | ||
|
||
export const initializeWorkspaceCommand = async (args: Uri) => { | ||
const subconfigs = [ | ||
"[javascript]", | ||
"[typescript]", | ||
"[typescriptreact]", | ||
"[javascriptreact]", | ||
"[json]", | ||
"[jsonc]", | ||
Comment on lines
+57
to
+62
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 should add 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. added it in as well 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. @ematipico If this means Biome will take precedence over the built-in extensions for vue/astro/svelte files, I'm not sure that's a great idea until support has progressed further and stabilized. I suspect anyone using these frameworks in earnest will prefer the official extensions at the moment, which means we'll need to document how to remove these lines from 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. that's a valid point, I left it generic in the beginning as I wasn't sure if I should add specific languages as well but yeah this is definitely something to think about from the maintainers side of view! 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. I think @colinhacks makes a good point here. We should only include languages for which we have full formatting support. This would mean removing |
||
"[vue]", | ||
"[astro]", | ||
"[svelte]", | ||
"[css]", | ||
"[graphql]", | ||
].join(""); | ||
nhedger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Scopes the config down to the current workspace folder | ||
const config = workspace.getConfiguration(undefined, Uri.parse(args.path)); | ||
try { | ||
const configsToUpdate = [ | ||
{ name: "biome.enabled", value: true }, | ||
{ | ||
name: "editor.codeActionsOnSave", | ||
value: { | ||
...config.get<object | undefined>( | ||
"editor.codeActionsOnSave", | ||
), | ||
"source.organizeImports.biome": "always", | ||
"quickfix.biome": "always", | ||
}, | ||
}, | ||
{ name: "editor.defaultFormatter", value: "biomejs.biome" }, | ||
{ | ||
name: `${subconfigs}`, | ||
value: { "editor.defaultFormatter": "biomejs.biome" }, | ||
}, | ||
]; | ||
for (const { name, value } of configsToUpdate) { | ||
await config.update( | ||
name, | ||
value, | ||
ConfigurationTarget.WorkspaceFolder, | ||
); | ||
} | ||
|
||
info("Workspace configuration updated"); | ||
} catch (e) {} | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.