mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-07-19 17:26:13 +00:00
25 lines
No EOL
841 B
TypeScript
25 lines
No EOL
841 B
TypeScript
import { readFileSync } from 'fs';
|
|
import { conf } from './config';
|
|
import { serverLog } from './logging';
|
|
import { connection, documents } from './server';
|
|
|
|
export function postError(e: Error) {
|
|
connection.window.showErrorMessage(e.message)
|
|
serverLog.error(e.message, null)
|
|
console.log(e)
|
|
}
|
|
|
|
export function formatURI(uri: string): string {
|
|
const drive = uri[7]
|
|
uri = uri.replace(`file:///${drive.toUpperCase()}%3A`, `file://${drive}:`)
|
|
return uri.replace(/^file:\/\//, '').replace(/\\/g, '/')
|
|
}
|
|
|
|
export function getDocumentContents(uri: string): string {
|
|
if (documents.keys().includes('file://' + uri)) return documents.get('file://' + uri).getText()
|
|
else return readFileSync(uri).toString()
|
|
}
|
|
|
|
export function trimPath(path: string): string {
|
|
return path.replace(conf.shaderpacksPath, '')
|
|
} |