mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-02 16:13:27 +00:00
Some basic completion provider. Need to go through all the options and tweak them
This commit is contained in:
parent
63151eaa76
commit
a65a6c1bb3
9 changed files with 399 additions and 41 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -2,3 +2,6 @@
|
|||
node_modules
|
||||
.vscode-test/
|
||||
*.vsix
|
||||
client/server
|
||||
*.txt
|
||||
*.out
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -12,7 +12,7 @@
|
|||
"outFiles": [
|
||||
"${workspaceRoot}/client/out/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "compile"
|
||||
"preLaunchTask": "compile:client"
|
||||
},
|
||||
{
|
||||
"name": "Attach to Server",
|
||||
|
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -5,5 +5,6 @@
|
|||
},
|
||||
"search.exclude": {
|
||||
"out": true // set this to false to include "out" folder in search results
|
||||
}
|
||||
},
|
||||
"python.pythonPath": "/usr/bin/python3"
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitReturns": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
},
|
||||
"scripts": {
|
||||
"postinstall": "cd server && npm install && cd ../client && npm install && cd ..",
|
||||
"compile": "tsc -p client/tsconfig.json && cd server && npm run installServer && cd .. && tsc -p server/tsconfig.json",
|
||||
"compile": "npm run compile:client && npm run compile:server",
|
||||
"run": "concurrently \"npm run watch:client\" \"npm run watch:server\"",
|
||||
"compile:client": "tsc -p client/tsconfig.json",
|
||||
"watch:client": "tsc -w -p client/tsconfig.json",
|
||||
"compile:server": "cd server && npm run installServer && cd .. && tsc -p server/tsconfig.json",
|
||||
"watch:client": "tsc -w -p client/tsconfig.json",
|
||||
"watch:server": "cd server && npm run installServer && cd .. && tsc -w -p server/tsconfig.json",
|
||||
"lint": "cd server && npm run lint && cd ../client && npm run lint"
|
||||
},
|
||||
|
|
363
server/src/completionProvider.ts
Normal file
363
server/src/completionProvider.ts
Normal file
|
@ -0,0 +1,363 @@
|
|||
import { CompletionItem, CompletionItemKind } from 'vscode-languageserver'
|
||||
|
||||
const value = CompletionItemKind.Value
|
||||
|
||||
export const completions: CompletionItem[] = [
|
||||
{
|
||||
label: 'heldItemId',
|
||||
detail: '<int> held item ID (main hand)'
|
||||
},
|
||||
{
|
||||
label: 'heldBlockLightValue',
|
||||
detail: '<int> held item light value (main hand)'
|
||||
},
|
||||
{
|
||||
label: 'heldItemId2',
|
||||
detail: '<int> held item ID (off hand)'
|
||||
},
|
||||
{
|
||||
label: 'heldBlockLightValue2',
|
||||
detail: '<int> held item light value (off hand)'
|
||||
},
|
||||
{
|
||||
label: 'fogMode',
|
||||
detail: '<int> GL_LINEAR, GL_EXP or GL_EXP2'
|
||||
},
|
||||
{
|
||||
label: 'fogColor',
|
||||
detail: '<vec3> r, g, b'
|
||||
},
|
||||
{
|
||||
label: 'skyColor',
|
||||
detail: '<vec3> r, g, b'
|
||||
},
|
||||
{
|
||||
label: 'worldTime',
|
||||
detail: '<int> <ticks> = worldTicks % 24000'
|
||||
},
|
||||
{
|
||||
label: 'worldDay',
|
||||
detail: '<int> <days> = worldTicks / 24000'
|
||||
},
|
||||
{
|
||||
label: 'moonPhase',
|
||||
detail: '<int> 0-7'
|
||||
},
|
||||
{
|
||||
label: 'frameCounter',
|
||||
detail: '<int> Frame index (0 to 720719, then resets to 0)'
|
||||
},
|
||||
{
|
||||
label: 'frameTime',
|
||||
detail: '<float> last frame time, seconds'
|
||||
},
|
||||
{
|
||||
label: 'frameTimeCounter',
|
||||
detail: '<float> run time, seconds (resets to 0 after 3600s)'
|
||||
},
|
||||
{
|
||||
label: 'sunAngle',
|
||||
detail: '<float> 0.0-1.0'
|
||||
},
|
||||
{
|
||||
label: 'shadowAngle',
|
||||
detail: '<float> 0.0-1.0'
|
||||
},
|
||||
{
|
||||
label: 'rainStrength',
|
||||
detail: '<float> 0.0-1.0'
|
||||
},
|
||||
{
|
||||
label: 'aspectRatio',
|
||||
detail: '<float> viewWidth / viewHeight'
|
||||
},
|
||||
{
|
||||
label: 'viewWidth',
|
||||
detail: '<float> viewWidth'
|
||||
},
|
||||
{
|
||||
label: 'viewHeight',
|
||||
detail: '<float> viewHeight'
|
||||
},
|
||||
{
|
||||
label: 'near',
|
||||
detail: '<float> near viewing plane distance'
|
||||
},
|
||||
{
|
||||
label: 'far',
|
||||
detail: '<float> far viewing plane distance'
|
||||
},
|
||||
{
|
||||
label: 'sunPosition',
|
||||
detail: '<vec3> sun position in eye space'
|
||||
},
|
||||
{
|
||||
label: 'moonPosition',
|
||||
detail: '<vec3> moon position in eye space'
|
||||
},
|
||||
{
|
||||
label: 'shadowLightPosition',
|
||||
detail: '<vec3> shadow light (sun or moon) position in eye space'
|
||||
},
|
||||
{
|
||||
label: 'upPosition',
|
||||
detail: '<vec3> direction up'
|
||||
},
|
||||
{
|
||||
label: 'cameraPosition',
|
||||
detail: '<vec3> camera position in world space'
|
||||
},
|
||||
{
|
||||
label: 'previousCameraPosition',
|
||||
detail: '<vec3> last frame cameraPosition'
|
||||
},
|
||||
{
|
||||
label: 'gbufferModelView',
|
||||
detail: '<mat4> modelview matrix after setting up the camera transformations'
|
||||
},
|
||||
{
|
||||
label: 'gbufferModelViewInverse',
|
||||
detail: '<mat4> inverse gbufferModelView'
|
||||
},
|
||||
{
|
||||
label: 'gbufferPreviousModelView',
|
||||
detail: '<mat4> last frame gbufferModelView'
|
||||
},
|
||||
{
|
||||
label: 'gbufferProjection',
|
||||
detail: '<mat4> projection matrix when the gbuffers were generated'
|
||||
},
|
||||
{
|
||||
label: 'gbufferProjectionInverse',
|
||||
detail: '<mat4> inverse gbufferProjection'
|
||||
},
|
||||
{
|
||||
label: 'gbufferPreviousProjection',
|
||||
detail: '<mat4> last frame gbufferProjection'
|
||||
},
|
||||
{
|
||||
label: 'shadowProjection',
|
||||
detail: '<mat4> projection matrix when the shadow map was generated'
|
||||
},
|
||||
{
|
||||
label: 'shadowProjectionInverse',
|
||||
detail: '<mat4> inverse shadowProjection'
|
||||
},
|
||||
{
|
||||
label: 'shadowModelView',
|
||||
detail: '<mat4> modelview matrix when the shadow map was generated'
|
||||
},
|
||||
{
|
||||
label: 'shadowModelViewInverse',
|
||||
detail: '<mat4> inverse shadowModelView'
|
||||
},
|
||||
{
|
||||
label: 'wetness',
|
||||
detail: '<float> rainStrength smoothed with wetnessHalfLife or drynessHalfLife'
|
||||
},
|
||||
{
|
||||
label: 'eyeAltitude',
|
||||
detail: '<float> view entity Y position'
|
||||
},
|
||||
{
|
||||
label: 'eyeBrightness',
|
||||
detail: '<ivec2> x = block brightness, y = sky brightness, light 0-15 = brightness 0-240'
|
||||
},
|
||||
{
|
||||
label: 'eyeBrightnessSmooth',
|
||||
detail: '<ivec2> eyeBrightness smoothed with eyeBrightnessHalflife'
|
||||
},
|
||||
{
|
||||
label: 'terrainTextureSize',
|
||||
detail: '<ivec2> not used'
|
||||
},
|
||||
{
|
||||
label: 'terrainIconSize',
|
||||
detail: '<int> not used'
|
||||
},
|
||||
{
|
||||
label: 'isEyeInWater',
|
||||
detail: '<int> 1 = camera is in water, 2 = camera is in lava'
|
||||
},
|
||||
{
|
||||
label: 'nightVision',
|
||||
detail: '<float> night vision (0.0-1.0)'
|
||||
},
|
||||
{
|
||||
label: 'blindness',
|
||||
detail: '<float> blindness (0.0-1.0)'
|
||||
},
|
||||
{
|
||||
label: 'screenBrightness',
|
||||
detail: '<float> screen brightness (0.0-1.0)'
|
||||
},
|
||||
{
|
||||
label: 'hideGUI',
|
||||
detail: '<int> GUI is hidden'
|
||||
},
|
||||
{
|
||||
label: 'centerDepthSmooth',
|
||||
detail: '<float> centerDepth smoothed with centerDepthSmoothHalflife'
|
||||
},
|
||||
{
|
||||
label: 'atlasSize',
|
||||
detail: '<ivec2> texture atlas size (only set when the atlas texture is bound)'
|
||||
},
|
||||
{
|
||||
label: 'entityColor',
|
||||
detail: '<vec4> entity color multiplier (entity hurt, creeper flashing when exploding)'
|
||||
},
|
||||
{
|
||||
label: 'entityId',
|
||||
detail: '<int> entity ID'
|
||||
},
|
||||
{
|
||||
label: 'blockEntityId',
|
||||
detail: '<int> block entity ID (block ID for the tile entity)'
|
||||
},
|
||||
{
|
||||
label: 'blendFunc',
|
||||
detail: '<ivec4> blend function (srcRGB, dstRGB, srcAlpha, dstAlpha)'
|
||||
},
|
||||
{
|
||||
label: 'texture',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'lightmap',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'normals',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'specular',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'shadow',
|
||||
detail: '<sampler2D> waterShadowEnabled ? 5 : 4'
|
||||
},
|
||||
{
|
||||
label: 'watershadow',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'shadowtex0',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'shadowtex1',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'depthtex0',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'gaux1',
|
||||
detail: '<sampler2D> 7 <custom texture or output from deferred programs>'
|
||||
},
|
||||
{
|
||||
label: 'gaux2',
|
||||
detail: '<sampler2D> 8 <custom texture or output from deferred programs>'
|
||||
},
|
||||
{
|
||||
label: 'gaux3',
|
||||
detail: '<sampler2D> 9 <custom texture or output from deferred programs>'
|
||||
},
|
||||
{
|
||||
label: 'gaux4',
|
||||
detail: '<sampler2D> 10 <custom texture or output from deferred programs>'
|
||||
},
|
||||
{
|
||||
label: 'depthtex1',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'shadowcolor',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'shadowcolor0',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'shadowcolor1',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'noisetex',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'tex',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'gcolor',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'gdepth',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'gnormal',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'composite',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'colortex0',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'colortex1',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'colortex2',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'colortex3',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'colortex4',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'colortex5',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'colortex6',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'colortex7',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'gdepthtex',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'depthtex2',
|
||||
detail: '<sampler2D>'
|
||||
},
|
||||
{
|
||||
label: 'depthtex3',
|
||||
detail: '<type> depthBuffers = 4'
|
||||
}
|
||||
]
|
||||
|
||||
for (let i = 1; i < completions.length + 1; i++) {
|
||||
completions[i - 1].data = i
|
||||
completions[i - 1].kind = value
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import * as vsclang from 'vscode-languageserver'
|
||||
import { Config } from './config'
|
||||
import { completions } from './completionProvider';
|
||||
|
||||
const connection = vsclang.createConnection(new vsclang.IPCMessageReader(process), new vsclang.IPCMessageWriter(process));
|
||||
|
||||
|
@ -12,7 +13,7 @@ const conf = new Config('', '')
|
|||
connection.onInitialize((params): vsclang.InitializeResult => {
|
||||
return {
|
||||
capabilities: {
|
||||
textDocumentSync: vsclang.TextDocumentSyncKind.Incremental,
|
||||
textDocumentSync: documents.syncKind,
|
||||
completionProvider: {
|
||||
resolveProvider: true
|
||||
},
|
||||
|
@ -29,19 +30,7 @@ connection.onDidChangeConfiguration((change) => {
|
|||
documents.all().forEach(validateTextDocument);
|
||||
});
|
||||
|
||||
connection.onDidChangeTextDocument((param) => {
|
||||
console.log(param.contentChanges)
|
||||
})
|
||||
|
||||
connection.onDidOpenTextDocument((param) => {
|
||||
console.log(param)
|
||||
})
|
||||
|
||||
connection.onDidCloseTextDocument((param) => {
|
||||
console.log(param)
|
||||
})
|
||||
|
||||
function validateTextDocument(textDocument: vsclang.TextDocument) {
|
||||
function validateTextDocument(textDocument: vsclang.TextDocument): void {
|
||||
const diagnostics: vsclang.Diagnostic[] = [];
|
||||
const lines = textDocument.getText().split(/\r?\n/g);
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
|
@ -54,7 +43,7 @@ function validateTextDocument(textDocument: vsclang.TextDocument) {
|
|||
start: { line: i, character: index },
|
||||
end: { line: i, character: index + 10 }
|
||||
},
|
||||
message: `blah blah Todd Howard`,
|
||||
message: `bananas`,
|
||||
source: 'mcglsl'
|
||||
});
|
||||
}
|
||||
|
@ -64,27 +53,11 @@ function validateTextDocument(textDocument: vsclang.TextDocument) {
|
|||
}
|
||||
|
||||
connection.onCompletion((textDocumentPosition: vsclang.TextDocumentPositionParams): vsclang.CompletionItem[] => {
|
||||
return [
|
||||
{
|
||||
label: 'heldItemId',
|
||||
kind: vsclang.CompletionItemKind.Variable,
|
||||
data: 0,
|
||||
},{
|
||||
label: 'hot',
|
||||
kind: vsclang.CompletionItemKind.Property,
|
||||
data: 1
|
||||
}];
|
||||
return completions
|
||||
});
|
||||
|
||||
connection.onCompletionResolve((item: vsclang.CompletionItem): vsclang.CompletionItem => {
|
||||
if (item.data === 0) {
|
||||
item.documentation = 'blyat man'
|
||||
item.detail = 'Held item ID (main hand)'
|
||||
} else if (item.data === 1) {
|
||||
item.documentation = 'random'
|
||||
item.detail = 'something'
|
||||
}
|
||||
return item
|
||||
return completions[item.data - 1]
|
||||
});
|
||||
|
||||
connection.listen();
|
18
shaders.py
Normal file
18
shaders.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
with open('shaders.txt') as f:
|
||||
items = {}
|
||||
lines = filter(lambda s: s.startswith('uniform'), f.readlines())
|
||||
for line in lines:
|
||||
err = False
|
||||
try:
|
||||
detail = int(' '.join(line.split()[3:]))
|
||||
err = True
|
||||
except:
|
||||
pass
|
||||
type = line.split()[1].rstrip('>').lstrip('<')
|
||||
detail = ' '.join(line.split()[3:]) if not err else ''
|
||||
label = line.split()[2].rstrip(';')
|
||||
if label in items:
|
||||
continue
|
||||
items[label] = True
|
||||
detail = ' ' + detail if not detail == '' else ''
|
||||
print('{\n\tlabel: \'%s\',\n\tdetail: \'<%s>%s\'\n},' % (label, type, detail))
|
Loading…
Add table
Add a link
Reference in a new issue