Fork me on GitHub
#cursive
<
2018-11-28
>
cfleming00:11:51

@tony.kay The action is Code-&gt;Generate…, you can check the key it’s bound to in the menu.

polymeris01:11:29

Is there any way to enable language injections in cursive?

cfleming01:11:01

@polymeris Only by me doing it, sadly. Is there one in particular you’re interested in?

polymeris01:11:37

graphql and glsl

polymeris01:11:51

but it's not urgent, just a nice to have

cfleming01:11:15

Are there IntelliJ languages for those?

polymeris01:11:01

I don't think they are official

cfleming01:11:10

Probably, I have no idea if they exist.

polymeris01:11:24

but they exist, yes

cfleming01:11:04

The other issue is that presumably you want these replaced at certain points in function/macro calls - that part would have to be extensible too.

cfleming01:11:25

I assume you have those inside strings?

cfleming01:11:06

Actually, are they functions or macros? That might be important.

polymeris01:11:48

currently they are just stuff like

(def fragment-shader-source
  "
  void main() {
     gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
  }")

polymeris01:11:37

I don't understand the question, tbh

polymeris01:11:43

they are just strings

cfleming01:11:44

Hmm, I see - that’s tricky because it’s hard to attach to anything, i.e. there’s no way for Cursive to know that that string is GLSL.

cfleming01:11:16

A simple workaround would be to use something like (deffragment my-fragment "<GLSL code>")

cfleming01:11:44

Then Cursive could be taught that deffragment calls always take GLSL as an arg.

polymeris01:11:07

Java intellij shows you an intention for any string, is that not possible?

polymeris01:11:16

Or you can tag strings with comments

polymeris01:11:31

It's a bit more work for the developer, but more flexible

cfleming01:11:32

Right, something like that should be possible, I’m not sure how Java does it.

polymeris01:11:42

class Scratch {
    public static void main(String[] args) {
        //language=GLSL
        String foo = "void main() { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); }";
    }
}
Like this

cfleming01:11:04

If you use the intention, is that what it adds?

polymeris01:11:56

It allows you to choose to either just inject the language (I suppose it stores it in .idea somewhere) or to add the comment

cfleming01:11:38

Hmm, I wonder how that works. The problem is that I don’t know how it identifies an individual string in the source code without the comment.

cfleming01:11:22

Oh right, so it’s transient unless you annotate it - that makes sense.

polymeris01:11:16

The (deffragment .... idea would be cool as well (since it doesn't contaminate the code with cursive-specific comments), but the annotation might be more flexible

cfleming01:11:32

Sure, I think it should support both.

polymeris01:11:00

In fact I think idea comes with some predefined functions for some languages where it will guess the injected lang

cfleming01:11:01

Language injection is pretty complicated, I’ve looked into it from time to time for regexes and other things, but never got as far as implementing it.

polymeris01:11:16

what if I add defragment there :thinking_face: ?

polymeris01:11:10

nvm, can't add clojure "names"

cfleming01:11:49

Yeah, I assume that view is pluggable.