Moved config back to lang server. Temp removed comment checking (it was bad anyways). Only adding in extension if it doesnt already exist. Fixed token replacer

This commit is contained in:
Noah Santschi-Cooney 2018-07-14 19:34:04 +01:00
parent f8edaa549c
commit db321c8566
No known key found for this signature in database
GPG key ID: 3B22282472C8AE48
9 changed files with 71 additions and 106 deletions

View file

@ -1,39 +0,0 @@
import * as vscode from 'vscode'
import { execSync } from 'child_process'
import * as vscodeLang from 'vscode-languageclient'
export class Config {
public readonly shaderpacksPath: string
public readonly glslangPath: string
constructor(shaderpacksPath: string, glslangPath: string) {
this.shaderpacksPath = shaderpacksPath
this.glslangPath = glslangPath || 'glslangValidator'
}
}
let conf = new Config('', '')
export async function configChangeHandler(langServer: vscodeLang.LanguageClient, event?: vscode.ConfigurationChangeEvent) {
if (event && !event.affectsConfiguration('mcglsl')) return
const temp = vscode.workspace.getConfiguration('mcglsl')
conf = new Config(temp.get('shaderpacksPath'), temp.get('glslangValidatorPath'))
try {
execSync(conf.glslangPath)
langServer.sendNotification(vscodeLang.DidChangeConfigurationNotification.type)
} catch (e) {
if (e.status !== 1) {
const selected = await vscode.window.showErrorMessage(
`[mc-glsl] glslangValidator not found at: '${conf.glslangPath}' or returned non-0 code`,
'Download',
'Cancel'
)
if (selected === 'Download') {
//TODO can i use the python script?
}
}
}
}

View file

@ -1,7 +1,6 @@
import * as vscode from 'vscode'
import * as vscodeLang from 'vscode-languageclient'
import * as path from 'path'
import { Config, configChangeHandler } from './config'
export function activate(context: vscode.ExtensionContext) {
const serverModule = context.asAbsolutePath(path.join('server', 'out', 'server.js'))
@ -20,17 +19,12 @@ export function activate(context: vscode.ExtensionContext) {
const clientOpts: vscodeLang.LanguageClientOptions = {
documentSelector: [{scheme: 'file', language: 'glsl'}],
synchronize: {
//configurationSection: 'mcglsl',
configurationSection: 'mcglsl',
fileEvents: vscode.workspace.createFileSystemWatcher('**/*.{fsh,gsh,vsh,glsl}')
}
}
const langServer = new vscodeLang.LanguageClient('vscode-mc-shader', serverOpts, clientOpts)
configChangeHandler(langServer)
vscode.workspace.onDidChangeConfiguration((e) => {
configChangeHandler(langServer, e)
})
context.subscriptions.push(langServer.start())
}