hsimpson / vscode-glsllint

VSCode extension to lint GLSL shading language files
MIT License
80 stars 13 forks source link

Feature request for better automatic handling of file-relative `#include` #16

Closed kayru closed 4 years ago

kayru commented 4 years ago

It is not uncommon for #include directives to use paths relative to the current file. However, as glsllint provides input source code to glslangValidator via stdin and sets cwd to vscode.workspace.rootPath, file-relative includes do not work.

It is possible to work around the issue by using project-specific glsllint.glslangValidatorArgs with -I<rootPath-relative-directory> flag, however this does not work in larger projects with multiple directories that may contain shader files.

It would be very welcome if #include "<relative-path>" worked out-of-the-box with this extension. Perhaps as an opt-in via settings, off by default.

hsimpson commented 4 years ago

Good thing. What do you think about enabling the current path of the file to lint as an include path. Maybe as an opt-in setting?

kayru commented 4 years ago

Adding the current file path to include path list will likely do the trick, though I don't know how exactly glslangValidator searches for includes. Worth a try.

hsimpson commented 4 years ago

I will try to implement it will it be possible to attach some example shader files with includes?

kayru commented 4 years ago

Sure. Trivial example: https://gist.github.com/kayru/f619234dc40fedb077f2f60730961c48

hsimpson commented 4 years ago

Next version (0.0.13) will have 2 new options, both are enabled by default: