mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-07-19 09:15:54 +00:00
Shows error if glslangValidator not found. Also made script to download it
This commit is contained in:
parent
67e9c991a4
commit
44ee663d06
5 changed files with 47 additions and 7 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
node_modules
|
node_modules
|
||||||
out
|
out
|
||||||
*.out
|
*.out
|
||||||
*.txt
|
*.txt
|
||||||
|
glslangValidator
|
|
@ -4,10 +4,10 @@
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"author": "Noah Santschi-Cooney (Strum355)",
|
"author": "Noah Santschi-Cooney (Strum355)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Strum355/vscode-mc-shader"
|
"url": "https://github.com/Strum355/vscode-mc-shader"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "*"
|
"node": "*"
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,7 +68,7 @@ export function preprocess(document: TextDocument) {
|
||||||
}
|
}
|
||||||
if (i === lines.length - 1) lines.splice(0, 0, include)
|
if (i === lines.length - 1) lines.splice(0, 0, include)
|
||||||
}
|
}
|
||||||
console.log(lines.join('\n'))
|
//console.log(lines.join('\n'))
|
||||||
|
|
||||||
//const root = document.uri.replace(/^file:\/\//, '').replace(conf.minecraftPath, '').replace(path.basename(document.uri), '')
|
//const root = document.uri.replace(/^file:\/\//, '').replace(conf.minecraftPath, '').replace(path.basename(document.uri), '')
|
||||||
lint(lines.join('\n'), document.uri)
|
lint(lines.join('\n'), document.uri)
|
||||||
|
@ -76,6 +76,7 @@ export function preprocess(document: TextDocument) {
|
||||||
|
|
||||||
function lint(text: string, uri: string) {
|
function lint(text: string, uri: string) {
|
||||||
const child = exec(`${conf.glslangPath} --stdin -S frag`, (error, out, err) => {
|
const child = exec(`${conf.glslangPath} --stdin -S frag`, (error, out, err) => {
|
||||||
|
if (error) return
|
||||||
const diagnostics: Diagnostic[] = []
|
const diagnostics: Diagnostic[] = []
|
||||||
const matches = filterMatches(out) as RegExpMatchArray[]
|
const matches = filterMatches(out) as RegExpMatchArray[]
|
||||||
matches.forEach((match) => {
|
matches.forEach((match) => {
|
||||||
|
|
|
@ -2,11 +2,11 @@ import * as vsclang from 'vscode-languageserver'
|
||||||
import { Config } from './config'
|
import { Config } from './config'
|
||||||
import { completions } from './completionProvider';
|
import { completions } from './completionProvider';
|
||||||
import { preprocess } from './linter';
|
import { preprocess } from './linter';
|
||||||
|
import { stat } from 'fs';
|
||||||
|
|
||||||
export const connection = vsclang.createConnection(new vsclang.IPCMessageReader(process), new vsclang.IPCMessageWriter(process));
|
export const connection = vsclang.createConnection(new vsclang.IPCMessageReader(process), new vsclang.IPCMessageWriter(process));
|
||||||
|
|
||||||
export const documents = new vsclang.TextDocuments();
|
export const documents = new vsclang.TextDocuments();
|
||||||
|
|
||||||
documents.listen(connection);
|
documents.listen(connection);
|
||||||
|
|
||||||
export let conf = new Config('', '')
|
export let conf = new Config('', '')
|
||||||
|
@ -37,6 +37,11 @@ documents.onDidSave((event) => {
|
||||||
connection.onDidChangeConfiguration((change) => {
|
connection.onDidChangeConfiguration((change) => {
|
||||||
const temp = change.settings.mcglsl as Config
|
const temp = change.settings.mcglsl as Config
|
||||||
conf = new Config(temp.minecraftPath, temp.glslangPath)
|
conf = new Config(temp.minecraftPath, temp.glslangPath)
|
||||||
|
stat(conf.glslangPath, (error) => {
|
||||||
|
if (error) {
|
||||||
|
connection.window.showErrorMessage('glslangValidator not found')
|
||||||
|
}
|
||||||
|
})
|
||||||
documents.all().forEach(preprocess);
|
documents.all().forEach(preprocess);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
33
setup.py
Normal file
33
setup.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import urllib.request
|
||||||
|
import zipfile
|
||||||
|
from io import BytesIO
|
||||||
|
import shutil
|
||||||
|
import os as o
|
||||||
|
|
||||||
|
os = {
|
||||||
|
0: 'win',
|
||||||
|
1: 'linux',
|
||||||
|
2: 'osx'
|
||||||
|
}
|
||||||
|
|
||||||
|
url = {
|
||||||
|
0: 'https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip',
|
||||||
|
1: 'https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip',
|
||||||
|
2: 'https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-osx-Release.zip'
|
||||||
|
}
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os_choice = int(input('Choose your OS:\n - 0: Windows\n - 1: Linux\n - 2: OSX\n> '))
|
||||||
|
if os_choice not in os:
|
||||||
|
print('Invalid OS. Please only choose a value between 0 and 2')
|
||||||
|
|
||||||
|
with urllib.request.urlopen(url[os_choice]) as respone:
|
||||||
|
with BytesIO(respone.read()) as zipped:
|
||||||
|
with zipfile.ZipFile(zipped) as zip_file:
|
||||||
|
zip_file.extract('bin/glslangValidator')
|
||||||
|
o.rename('bin/glslangValidator', 'glslangValidator')
|
||||||
|
o.rmdir('bin')
|
||||||
|
print('glslangValidator downloaded. Set mclglsl')
|
||||||
|
return
|
||||||
|
print('There was an error :(')
|
||||||
|
main()
|
Loading…
Add table
Add a link
Reference in a new issue