mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-01 07:33:09 +00:00
Added download prompt to download glslangValdiator
This commit is contained in:
parent
db321c8566
commit
c5fc9ffedd
7 changed files with 342 additions and 32 deletions
|
@ -5,14 +5,16 @@ import { completions } from './completionProvider'
|
|||
import { preprocess, ext, formatURI } from './linter'
|
||||
import { exec, execSync } from 'child_process'
|
||||
import { extname } from 'path'
|
||||
import fetch from 'node-fetch'
|
||||
import { platform } from 'os'
|
||||
import { createWriteStream, chmodSync, createReadStream, unlinkSync } from 'fs'
|
||||
import * as unzip from 'unzip'
|
||||
|
||||
export const connection = vsclang.createConnection(new vsclang.IPCMessageReader(process), new vsclang.IPCMessageWriter(process))
|
||||
|
||||
export const documents = new vsclang.TextDocuments()
|
||||
documents.listen(connection)
|
||||
|
||||
export let conf = new Config('', '')
|
||||
|
||||
connection.onInitialize((params): vsclang.InitializeResult => {
|
||||
return {
|
||||
capabilities: {
|
||||
|
@ -32,7 +34,7 @@ documents.onDidSave((event) => onEvent(event.document))
|
|||
|
||||
//documents.onDidChangeContent(onEvent)
|
||||
|
||||
function onEvent(document: vsclangproto.TextDocument) {
|
||||
export function onEvent(document: vsclangproto.TextDocument) {
|
||||
if (!ext.has(extname(document.uri))) return
|
||||
try {
|
||||
preprocess(document.getText().split('\n'), formatURI(document.uri))
|
||||
|
@ -41,24 +43,6 @@ function onEvent(document: vsclangproto.TextDocument) {
|
|||
}
|
||||
}
|
||||
|
||||
connection.onDidChangeConfiguration(async (change) => {
|
||||
const temp = change.settings.mcglsl as Config
|
||||
conf = new Config(temp['shaderpacksPath'], temp['glslangValidatorPath'])
|
||||
try {
|
||||
execSync(conf.glslangPath)
|
||||
documents.all().forEach(document => onEvent)
|
||||
} catch (e) {
|
||||
if (e.status !== 1) {
|
||||
const chosen = await connection.window.showErrorMessage(
|
||||
`[mc-glsl] glslangValidator not found at: '${conf.glslangPath}' or returned non-0 code`,
|
||||
{title: 'Download'},
|
||||
{title: 'Cancel'}
|
||||
)
|
||||
console.log(chosen.title)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
connection.onCompletion((textDocumentPosition: vsclang.TextDocumentPositionParams) => completions)
|
||||
|
||||
connection.onCompletionResolve((item: vsclang.CompletionItem): vsclang.CompletionItem => completions[item.data - 1])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue