Skip to content

Commit

Permalink
✨ Add gameVersion to vscode settings (#1506)
Browse files Browse the repository at this point in the history
  • Loading branch information
misode authored Jul 30, 2024
1 parent 956a6a3 commit f4d4588
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ connection.onInitialize(async (params) => {
'project#ready#bind',
]),
project: {
defaultConfig: core.ConfigService.merge(core.VanillaConfig, {
env: { gameVersion: initializationOptions?.gameVersion },
}),
cacheRoot: fileUtil.ensureEndingSlash(url.pathToFileURL(cacheRoot).toString()),
externals,
initializers: [mcdoc.initialize, je.initialize],
Expand Down
1 change: 1 addition & 0 deletions packages/language-server/src/util/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface CustomInitializationOptions {
inDevelopmentMode?: boolean
gameVersion?: string
}

export interface CustomServerCapabilities {
Expand Down
10 changes: 10 additions & 0 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@
"configuration": {
"title": "Spyglass",
"properties": {
"spyglassmc.env.gameVersion": {
"type": "string",
"enum": [
"Auto",
"Latest release",
"Latest snapshot"
],
"markdownDescription": "%spyglassmc.env.gameVersion%",
"default": "Auto"
},
"spyglassmc.trace.server": {
"type": "string",
"enum": [
Expand Down
1 change: 1 addition & 0 deletions packages/vscode-extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"spyglassmc.commands.showCacheRoot.title": "Open Cache Folder",
"spyglassmc.description": "Heavy language features for Minecraft: Java Edition data pack files",
"spyglassmc.displayName": "Datapack Helper Plus by Spyglass",
"spyglassmc.env.gameVersion": "The Minecraft version to use. When set to auto, the version is inferred from the `pack.mcmeta`. Other versions can be specified in a `spyglass.json` config file.",
"spyglassmc.trace.server": "Traces the communication between VS Code and the Spyglass Language Server."
}
3 changes: 3 additions & 0 deletions packages/vscode-extension/src/extension.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ export async function activate(context: vsc.ExtensionContext) {
{ language: 'json', pattern: '**/data/*/*/**/*.json' },
]

const gameVersion = vsc.workspace.getConfiguration('spyglassmc.env').get('gameVersion')

const initializationOptions: server.CustomInitializationOptions = {
inDevelopmentMode: context.extensionMode === vsc.ExtensionMode.Development,
gameVersion: typeof gameVersion === 'string' ? gameVersion : undefined,
}

// Options to control the language client
Expand Down

0 comments on commit f4d4588

Please sign in to comment.