stef-levesque / vscode-shader Goto Github PK
View Code? Open in Web Editor NEWShader languages support for VS Code
License: MIT License
Shader languages support for VS Code
License: MIT License
Hello from the VS Code team 👋
We're doing some housekeeping that involves renaming some of our internal packages. Namely, vscode-ripgrep
will be renamed to @vscode/ripgrep
, which affects its location in VS Code's node_modules
folder. It looks like this extension depends on vscode-ripgrep
in a way that will break when this rename happens.
We suggest either:
vscode-ripgrep
and retrieve the binary path from there. We will alias the require
statement, so that the renamed package is always resolved correctly, and vscode-ripgrep
exports the binary path. For example:function getCoreNodeModule(moduleName) {
try {
return require(`${vscode.env.appRoot}/node_modules.asar/${moduleName}`);
} catch (err) {
try {
return require(`${vscode.env.appRoot}/node_modules/${moduleName}`);
} catch (err) {
return undefined;
}
}
}
const { rgPath } = getCoreNodeModule('vscode-ripgrep');
// then child_process.spawn(rgPath, [...
Note that if you're building your extension with Webpack, you will want to use __non_webpack_require__
instead of require
, otherwise webpack will try to (incorrectly) resolve the request by itself.
Add .fsh
, .gsh
and .vsh
file extensions for GLSL
Hi ,
Great extension. Was just wondering if there could be added support for non standard file name extensions. At the moment it's probably .cg .hlsl .shader , etc , but we use a proprietary extension at work. Thanks
it was removed in 2016
euler0/sublime-glsl@23054fe#diff-3a38e14c624455a039b9d07762299d7c
Without this inclusion it is now correctly highlight syntax embedded in .js
( https://github.com/boyswan/vscode-glsl-literal )
Is it possible to highlight shader code inside C++11 raw strings?
For example, highlight this.
R"(
#version 420 core
void main(void)
{
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}
)"
With the new "Show Running Extensions" feature I noticed that this extension has an abnormally high start-up time. Most extensions start in 30-100ms, this one in 700+ (tested it multiple times).
Is there an easy way to fix this?
We have written the needed data into your clipboard. Please paste:
{
"activationTimes": {
"startup": false,
"codeLoadingTime": 731,
"activateCallTime": 0,
"activateResolvedTime": 12,
"activationEvent": "onLanguage:glsl"
}
}
When formatting HLSL code the resulting format ignores the .clang-format
file that's present in the Workspace, if present. I didn't test other languages, but it seems like the extension still doesn't support formatting for shader languages that are not HLSL
.clang-format
file that changes the behaviour of the default C++ formatter options set in VSCodeI tried to look around the code and I think I understood that to format an HLSL file the code creates a temporary copy of the file in the system's temp folder, appends .cpp
to it and then calls the standard VSCode format call on it. When using clang-formatter as a formatter provider and with file
as a default format style VSCode looks for a .clang-format
file by traversing the parent folders of the file (or so I understood from the documentation). Since we go in another root altogether the .clang-format
file is not found.
When I press format document it's just do nothing. Currently I'm using last version of VSCode 1.74.3. I was trying to debug extension but I cannot fix it. It creates cpp file successfully but this line just return undefined (extension.ts, line 24)
return vscode.commands.executeCommand<vscode.TextEdit[]>('vscode.executeFormatDocumentProvider', doc.uri, options) .then(r => (tmpFile.removeCallback(), r));
I tried to copy my hlsl code to cpp file and format and it works. But I do not why extension seems can't do it action 'vscode.executeFormatDocumentProvider' return undefined. I checked doc.uri and options it also seems correct I do not know where is the problem.
Performance
shader
1.1.4
Windows_NT x64 10.0.17134
1.33.1
C:\Users\Victor\slevesque.shader-unresponsive.cpuprofile.txt
Find more details here: https://github.com/Microsoft/vscode/wiki/Explain:-extension-causes-high-cpu-load
In a complex project, maybe include some other .hlsl file, and hope this extension detect include file automatically.
In markdown code blocks can be highlighted in VSCode. Example text
# Markdown
Some text here with *italics* and **bold**
and [links](#foo).
Some JavaScript
```js
console.log('hello world');
```
Some **C#**
```csharp
class Foo {
void process() {
System.Console.WriteLine("Hello World!");
}
}
```
Some **C++**
```cpp
#include <stdio.h>
int main(int argc, const char** argv) {
printf("hello world\n");
return 0;
}
```
Some **GLSL**
```glsl
in vec4 position;
uniform mat4 matrix;
void main() {
gl_Position = matrix * position;
}
```
And the result in my VSCode looks like this
You can see above JavaScript, C++, C# are all syntax highlighted but not GLSL
Note that if I make a .glsl file then the syntax is highlighted
Any idea how to get VS code to use GLSL highlighting for GLSL blocks in markdown?
some projects are using these extensions for shader files (e.g gfx-rs)
Bug
shader
1.1.5
Windows_NT x64 10.0.19042
1.55.2
I get a warning notification every time i start vscode with this extension installed.
Hey @Argmaster let's discuss here if you're interested
In Visual Studio, you can usually double click a variable name and all instances of that variable will be highlighted. Afterwards, if you press Ctrl + R + R, you can rename all the symbols at once. Is there something like this for this extension?
It would be really cool to have the same features when writing in ShaderLab.
Adding new keywords introduced by Vulkan to the syntax highlighter is the easy part but there is a problem.
At the moment, vscode-shader's syntax highlighter contains some archaic GLSL constructs that don't quite align with Vulkan. One example is the keyword texture2D. At the very beginning texture2D was a function (GLSL 1.10), then it got deprecated and finally it got reintroduced in Vulkan as a type. At the moment the syntax highlighter thinks texture2D is a function.
I'm not sure what is the best course of action here. texture2D and co are functions in WebGL but types in Vulkan. Any idea how to solve this issue? Maybe have a config option to control this?
Hi there,
I love your Shader Languages package for VSC!
I work in game development and our shaders often come with game-engine specific file extensions, though the code within is still HLSL, GLSL, or CG.
Would it be possible for you to add a place where I can add custom file extensions to be handled by your highlighting package?
Thanks for the time and effort - it makes life much better!
~Alex
Per document
"Formatting Code (Experimental) Require MS CppTools to be installed"
How does this work?
I installed MS CppTools but I still get
"There is no document formatter for 'glsl'-files installed."
I want to reformat some glsl code. But it tell me that I did not install format file.
When I change associate file to HLSL it work.
Is there something wrong?
Bug
shader
1.1.5
Windows_NT x64 10.0.19043
1.57.0
Extension has caused the extension host to freeze. And it takes 8441ms to activate.
Normally, while typing, any words that exist in the current document are suggested, for example, when editing C code:
But this does not work when editing HLSL code. It only suggests names of built-ins:
Using slevesque.shader last released 2021-02-08, 07:12:56.
This plugin disables syntax highlighting, autocompletion etc for Ionide-fsharp
Bug
shader
1.1.5
Windows_NT x64 10.0.19044
1.69.2
In the README.md, it's said that there is the feature "Find References and Definition".
But it doesn't work for me when I pressing F12 for a variable in a glsl file.
Also for a glsl file, it only says "No definition found for xxx".
The "Finding Definition" feature works for other languages like c++ in my Vscode.
in ES 2015 there is a concept of template literals. More about that here
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
In short: we can write something like this in js/ts
export const mySnippets = {
foo: glsl`
# some glsl source code to highlight
`
}
where glsl
is a tagged template
I would love to see syntax highlighting enabled for tagged templates like glsl
and hlsl
inside js/ts files. This is only about syntax highlighting, there is no need to provide these template functions.
Here is an example extension that does exactly that but with html templates
Bug
shader
1.1.5
Windows_NT x64 6.2.9200
1.69.2
I've been using WEBGPU lately and noticed there was no extension that supported proper highlight and/or completion. Would it be possible to add WSGL support?
Would love to get the same code completion, signature and help/documentation for GLSL as it's already there for HLSL.
In WebGL we can specify shaders in separate files or embedded in an HTML file like this:
<html>
<script id="vertex-shader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
</html>
VSCode already has highlighting for embedded JS in an HTML file so I think this should be possible, although I'm not sure if it's within the realm of this extension or would require a change in the way VS Code parses HTML. The shader is identifiable as the text inside any <script> tag with the type
property set to x-shader/x-vertex
or x-shader/x-fragment
. Syntax should be the same as OpenGL ES 2.0.
I could potentially have a look into implementing this is you think it's a worthwhile addition but don't have any experience in writing VS Code extensions so any help or ideas would be great. What do you reckon?
Hi,
When using unreal hlsl code is using the extention .usf
and .ush
. a simple modification in package.json with the 2 new files extensions had done the trick for me. Would be awesome if it's there by default so unreal shader code would work out of the box.
I see on the details page some shots for Completion Proposals and Help With Function and Method Signatures. But non of that works in glsl files?
Im on version 1.1.3
Hi, I'm on the VS Code team. I noticed that your extension uses the vscode.previewHtml
command which is deprecated and which we are actively working to remove: microsoft/vscode#62630
We've developed a webview API that provides a much better developer experience and offers a number of important security and compatibility benefits over previewHtml
. We cannot fix previewHtml
without breaking backwards compatibility, and have instead opted to remove it.
To ensure that your extension continues to work properly in VS Code, please try upgrading to use the new Webview API. You can find documentation on the API usage here. Let me know if you have any questions or concerns about this migration
Hi,
new shader file types are introduced in VK_NV_ray_tracing:
.rgen = ray generation
.rint = ray intersection
.rahit = ray any hit
.rchit = ray closest hit
.rmiss = ray miss
.rcall = ray callable
(See: KhronosGroup/glslang@b50c02e)
Any chance those can be added to the list of supported shader files?
Hey, I was trying to get #43 running in VS Code but my embedded shaders weren't highlighted.
Then I noticed the merge happend on Feb 14 and https://marketplace.visualstudio.com/items?itemName=slevesque.shader says "Last updated | 2/8/2021".
If anyone else is looking for this – you can manually install the git version:
git clone https://github.com/stef-levesque/vscode-shader.git
cd vscode-shader && npm install
WGSL is the upcoming shader language for WebGPU graphics API. The spec is still in progress and being worked on, but nonetheless it would be amazing to have at least some initial support for this language.
It would be very comfortable to switch between vertex shader and fragment shader of the same name with this shortcut, like you can switch between .h and .cpp files in C++ with this shortcut
These are the extensions used by Khronos group in glslang respectively for: tessellation control, tessellation evaluation and compute shader.
Hi, I used to use your extension in VSCode,
I now use gitpod and vscodium, I have to install it using the vsix file.
But there is a much better solution Eclipse foundation started a fully open source vscode extension registry name OpenVSX,
I would love it if you took a look at registering the extension there, so it can appear in non Microsoft VSCode alternatives.
Note that Microsoft is prohibiting the direct use of their marketplace by any non-Microsoft software, even though most extensions are actually open source and not developed or maintained by Microsoft. quoted from GitPod docs
unity uses hlsl shaders but it uses ".shader" files your extension does not pick up on these being shader files.
The Unity engine has their own special shader format, known as ShaderLab, which I use to write shaders. It would be awesome if this extension supported it as well!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.