mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-04 00:49:17 +00:00
Made GLSLProvider have a constructor instead, added config interface and init function and now gonna start away on symlinking and linting
This commit is contained in:
parent
61e460650c
commit
7c282e7471
6 changed files with 97 additions and 38 deletions
33
package-lock.json
generated
33
package-lock.json
generated
|
@ -410,6 +410,16 @@
|
|||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
|
||||
"dev": true
|
||||
},
|
||||
"create-symlink": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/create-symlink/-/create-symlink-1.0.0.tgz",
|
||||
"integrity": "sha1-QNOKcRdnMiNFdi+Q+NBs8nJiAdc=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.11",
|
||||
"inspect-with-kind": "^1.0.0",
|
||||
"is-plain-obj": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"cryptiles": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz",
|
||||
|
@ -895,8 +905,7 @@
|
|||
"graceful-fs": {
|
||||
"version": "4.1.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
|
||||
"dev": true
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
|
||||
},
|
||||
"growl": {
|
||||
"version": "1.10.3",
|
||||
|
@ -1304,6 +1313,21 @@
|
|||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||
"dev": true
|
||||
},
|
||||
"inspect-with-kind": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inspect-with-kind/-/inspect-with-kind-1.0.4.tgz",
|
||||
"integrity": "sha512-KN8VFSf62Ig4hyXtXODkWF6PIatrCIJF32KY8tQUwwLtgfNsr+3ZIpd+epM+pRbC86nJZycBPjWwziDvn/+6YQ==",
|
||||
"requires": {
|
||||
"kind-of": "^6.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"kind-of": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
|
||||
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"is": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is/-/is-3.2.1.tgz",
|
||||
|
@ -1378,6 +1402,11 @@
|
|||
"integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
|
||||
"dev": true
|
||||
},
|
||||
"is-plain-obj": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
|
||||
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4="
|
||||
},
|
||||
"is-posix-bracket": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz",
|
||||
|
|
34
package.json
34
package.json
|
@ -4,6 +4,10 @@
|
|||
"description": "A Visual Studio Code extension for linting/etc Minecraft GLSL Shaders",
|
||||
"version": "0.0.1",
|
||||
"publisher": "Strum355",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "https://github.com/Strum355/vscode-mc-shader"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.23.0"
|
||||
},
|
||||
|
@ -19,14 +23,16 @@
|
|||
],
|
||||
"main": "./out/extension",
|
||||
"contributes": {
|
||||
"languages": [{
|
||||
"id": "glsl",
|
||||
"extensions": [
|
||||
".fsh",
|
||||
".vsh",
|
||||
".glsl"
|
||||
]
|
||||
}],
|
||||
"languages": [
|
||||
{
|
||||
"id": "glsl",
|
||||
"extensions": [
|
||||
".fsh",
|
||||
".vsh",
|
||||
".glsl"
|
||||
]
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
"title": "Minecraft GLSL configurations",
|
||||
"properties": {
|
||||
|
@ -46,10 +52,14 @@
|
|||
"test": "npm run compile && node ./node_modules/vscode/bin/test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^2.6.1",
|
||||
"vscode": "^1.1.6",
|
||||
"tslint": "^5.8.0",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/node": "^7.0.43",
|
||||
"@types/mocha": "^2.2.42"
|
||||
"@types/create-symlink": "./node_modules/@types/create-symlink",
|
||||
"tslint": "^5.8.0",
|
||||
"typescript": "^2.6.1",
|
||||
"vscode": "^1.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"create-symlink": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
'use strict';
|
||||
// The module 'vscode' contains the VS Code extensibility API
|
||||
// Import the module and reference it with the alias vscode in your code below
|
||||
import * as vscode from 'vscode';
|
||||
import GLSLProvider from './linter/glslProvider';
|
||||
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
import * as vscode from 'vscode'
|
||||
import GLSLProvider from './linter/glslProvider'
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
let linter = new GLSLProvider()
|
||||
linter.activate()
|
||||
vscode.languages.registerCodeActionsProvider('glsl', linter)
|
||||
vscode.languages.registerCodeActionsProvider('glsl', new GLSLProvider(context.subscriptions))
|
||||
}
|
||||
|
||||
// this method is called when your extension is deactivated
|
||||
export function deactivate() {
|
||||
}
|
|
@ -1,12 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode'
|
||||
import * as os from 'os'
|
||||
import * as cp from 'child_process'
|
||||
import * as sym from 'create-symlink'
|
||||
import * as fs from 'fs'
|
||||
|
||||
interface config {
|
||||
glslangPath: string
|
||||
tmpdir: string
|
||||
}
|
||||
|
||||
export default class GLSLProvider implements vscode.CodeActionProvider {
|
||||
private diagnosticCollection?: vscode.DiagnosticCollection
|
||||
private diagnosticCollection: vscode.DiagnosticCollection
|
||||
private config: config
|
||||
|
||||
public activate() {
|
||||
constructor(subs: vscode.Disposable[]) {
|
||||
this.diagnosticCollection = vscode.languages.createDiagnosticCollection()
|
||||
|
||||
subs.push(this)
|
||||
this.config = this.initConfig()
|
||||
|
||||
vscode.workspace.onDidOpenTextDocument(this.lint, this)
|
||||
vscode.workspace.onDidSaveTextDocument(this.lint, this)
|
||||
|
@ -15,21 +28,32 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
|||
|
||||
vscode.workspace.onDidChangeConfiguration(this.configChange, this)
|
||||
|
||||
vscode.workspace.textDocuments.forEach(this.lint, this)
|
||||
vscode.workspace.onDidCloseTextDocument((document: vscode.TextDocument) => {
|
||||
this.diagnosticCollection.delete(document.uri)
|
||||
}, null, subs)
|
||||
}
|
||||
|
||||
console.log(vscode.workspace.textDocuments)
|
||||
private initConfig(): config {
|
||||
const c = vscode.workspace.getConfiguration('mcglsl')
|
||||
|
||||
console.log('glslangValidatorPath set to', c.get('glslangValidatorPath'))
|
||||
console.log('temp dir set to', os.tmpdir())
|
||||
|
||||
return {
|
||||
glslangPath: c.get('glslangValidatorPath') as string,
|
||||
tmpdir: os.tmpdir()
|
||||
}
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
if(this.diagnosticCollection != null) {
|
||||
this.diagnosticCollection.clear()
|
||||
this.diagnosticCollection.dispose()
|
||||
}
|
||||
this.diagnosticCollection.clear()
|
||||
this.diagnosticCollection.dispose()
|
||||
}
|
||||
|
||||
private configChange(e: vscode.ConfigurationChangeEvent) {
|
||||
if (e.affectsConfiguration('mcglsl')) {
|
||||
|
||||
console.log('config changed')
|
||||
this.config = this.initConfig()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,10 +61,14 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
|||
this.lint(e.document)
|
||||
}
|
||||
|
||||
private lint(document: vscode.TextDocument) {
|
||||
private async lint(document: vscode.TextDocument) {
|
||||
if(document.languageId !== 'glsl') {
|
||||
return
|
||||
}
|
||||
|
||||
fs.mkdirSync(`${this.config.tmpdir}/shaders`)
|
||||
sym(`${vscode.workspace.rootPath}/shaders/composite.frag`, `${this.config.tmpdir}/shaders/composite.banana`)
|
||||
.catch((err) => {console.log(err)})
|
||||
}
|
||||
|
||||
public provideCodeActions(document: vscode.TextDocument,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"target": "esnext",
|
||||
"outDir": "out",
|
||||
"lib": [
|
||||
"es6"
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
"curly": true,
|
||||
"class-name": true,
|
||||
"semicolon": [
|
||||
true,
|
||||
"always"
|
||||
false,
|
||||
],
|
||||
"triple-equals": true
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue