mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-30 21:37:25 +00:00
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:
parent
f8edaa549c
commit
db321c8566
9 changed files with 71 additions and 106 deletions
|
@ -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?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue