Closed francisdb closed 7 years ago
Thanks for feedback. Can you give me more information about this syntax? Is embedding external language code a standard feature of Elm compiler? What languages can you embed into Elm? Where can I find some documentation about it?
No idea, all I know is that code between [glsl|
and |]
should be excluded. Maybe @w0rm can shed some light on this?
[glsl| |]
is a valid Elm code, that is supported by the Elm compiler, it should be syntax highlighted as the glsl language.
Is it possible to embed one language into another? I've opened a similar issue for the atom plugin here.
@w0rm is this a generic thing where [javascript| ... |]
could also be implemented by some library?
@francisdb no, it's not generic. The Elm compiler has the glsl parser baked in for the WebGL stuff.
thanks @w0rm , @durkiewicz do you know enough with this answer?
Ok, so now I know that I can use GLSL code as expressions in Elm code. Are there some restrictions to that? Can I, for example, write:
f x =
case x of
A -> 1
B -> [glsl| ... |] + 5
Or is it limited to defining the whole body of a function? Can I use GLSL code as a non-expression code? If so, can you give me a complete list of allowed usages?
IntelliJ has a feature of language injection: https://www.jetbrains.com/help/idea/2016.3/using-language-injections.html
So if I make sure that the content of [glsl| ... |]
is parsed as a string in Elm plugin then you should probably be able to use the feature of language injection in order to use GLSL tooling.
Just tried some things:
let
foo =
[glsl|
attribute vec3 position;
|]
bar =
foo + 1
defining foo works, of course adding 1 fails
The left argument of (+) is causing a type mismatch.
149| foo + 1
^^^
(+) is expecting the left argument to be a:
number
But the left argument is:
Shader { a | position : Vec3 } b {}
Thanks for taking care of this @durkiewicz ! 🙌
First of all thanks for this great plugin!
It seems that the plugin can't handle shader code between
[glsl|
and|]
. Marking everything with errors.I guess it would not be too much work to ignore those blocks. Even better would be to enable https://plugins.jetbrains.com/idea/plugin/6993-glsl-support if installed? But I guess that will not be a simple undertaking?