Fork me on GitHub
#calva
<
2020-11-13
>
alekszelark14:11:16

Hi! In Cursive there is a feuture, when you create a new file, its ns form will be automatically created. For example if I created src/app/core.clj I would get (ns app.core) in the file. I wonder is there something similar in Calva or VSCode?

pez15:11:16

There isn’t. Please check if there is an issue for it. If not, please file one. It’s easy enough to type that, but still I would love the convenience.

👍 3
pez15:11:17

If there is some prior art from some other VS Code extension, that would help to know about for anyone picking up the issue.

alekszelark16:11:52

Haven’t found an issue, also checked that Java Extension supports that. https://marketplace.visualstudio.com/items?itemName=redhat.java

alekszelark16:11:13

created a new java file and got

package app.test;

public class Boom {
  
}

pez16:11:15

How did you create a new java file?

alekszelark16:11:29

via command palette: new file

pez16:11:37

Please create an issue. Include the info about the Java extension. And add a step-by-step description about how it is done there.

alekszelark16:11:06

Ok, I’ll create. If you don’t mind I’d like to implement it.

❤️ 3
alekszelark16:11:37

But first need to check out the java ext internals.

pez16:11:44

Super awesome. Of course I don’t mind. I was about to suggest it, even. 😃

pez16:11:35

I’m thinking there might be an explicit API for it. Some provider we need to implement.

borkdude16:11:48

To detect a new .clj file?

borkdude16:11:48

btw emacs also has this, I think clojure-mode does it

pez16:11:09

A lot of VS Code API:s are about implementing Provider*s . So here they might have a *NewFileProvider that is called when a clojure file is created with some arguments and we should respond with some contents. (I’m purely speculating here, but it does seems like a common enough thing for a code editor to be asked for that there is a specific API for it. Especially in VS Code where we are often limited by these specific API:s.)

pez16:11:42

The good thing with this is that things behave very consistently across VS Code extensions. The bad thing is that some things that the VS Code team does not find important enough for users to do is either not possible to implement or just hard to implement. Most of Calva is in the last catagory there. 😃

😆 3
pez16:11:33

Let’s see wha @zelark digs up. 😃

chucklehead17:11:31

you should be able to add a handler for workspace.onDidCreateFiles https://code.visualstudio.com/api/references/vscode-api#workspace

✔️ 3
pez17:11:36

Yeah, the Uri contains what we need at least.