mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-04 09:00:18 +00:00
Added "Show flattened file" command to display a fully flattened top-level file in vscode virtual doc
execute_command now returns content to the client on success, any valid json value
This commit is contained in:
parent
49324cfb04
commit
26c855f016
8 changed files with 224 additions and 109 deletions
|
@ -1,7 +1,6 @@
|
|||
import * as vscode from 'vscode'
|
||||
import * as lsp from 'vscode-languageclient'
|
||||
import { Extension } from './extension'
|
||||
import { tryInstallExecutable } from './glslangValidator'
|
||||
import { log } from './log'
|
||||
|
||||
export type Command = (...args: any[]) => unknown
|
||||
|
@ -23,8 +22,31 @@ export function restartExtension(e: Extension): Command {
|
|||
}
|
||||
}
|
||||
|
||||
export function downloadValidator(e: Extension): Command {
|
||||
export function virtualMergedDocument(e: Extension): Command {
|
||||
const getVirtualDocument = async (path: string): Promise<string> => {
|
||||
const content = await e.lspClient.sendRequest<string>(lsp.ExecuteCommandRequest.type.method, {
|
||||
command: 'virtualMerge',
|
||||
arguments: [path]
|
||||
})
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
const docProvider = new class implements vscode.TextDocumentContentProvider {
|
||||
onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>();
|
||||
onDidChange = this.onDidChangeEmitter.event;
|
||||
|
||||
provideTextDocumentContent(uri: vscode.Uri, __: vscode.CancellationToken): vscode.ProviderResult<string> {
|
||||
return getVirtualDocument(uri.path)
|
||||
}
|
||||
}
|
||||
|
||||
e.context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider('mcglsl', docProvider))
|
||||
|
||||
return async () => {
|
||||
await tryInstallExecutable(e)
|
||||
const uri = vscode.window.activeTextEditor.document.uri
|
||||
const path = vscode.Uri.parse('mcglsl:' + uri.path)
|
||||
const doc = await vscode.workspace.openTextDocument(path)
|
||||
await vscode.window.showTextDocument(doc, {preview: true})
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import * as vscode from 'vscode'
|
||||
import * as lsp from 'vscode-languageclient'
|
||||
import * as commands from './commands'
|
||||
import { bootstrapGLSLangValidator } from './glslangValidator'
|
||||
import { log } from './log'
|
||||
import { LanguageClient } from './lspClient'
|
||||
|
||||
|
@ -23,10 +22,8 @@ export class Extension {
|
|||
|
||||
this.registerCommand('graphDot', commands.generateGraphDot)
|
||||
this.registerCommand('restart', commands.restartExtension)
|
||||
this.registerCommand('downlaod', commands.downloadValidator)
|
||||
this.registerCommand('virtualMerge', commands.virtualMergedDocument)
|
||||
|
||||
if(!await bootstrapGLSLangValidator(this)) return
|
||||
|
||||
log.info('starting language server...')
|
||||
|
||||
this.client = await new LanguageClient(this).startServer()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue