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?
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.
If there is some prior art from some other VS Code extension, that would help to know about for anyone picking up the issue.
Haven’t found an issue, also checked that Java Extension supports that. https://marketplace.visualstudio.com/items?itemName=redhat.java
created a new java file and got
package app.test;
public class Boom {
}
How did you create a new java file?
via command palette: new file
Please create an issue. Include the info about the Java extension. And add a step-by-step description about how it is done there.
Ok, I’ll create. If you don’t mind I’d like to implement it.
But first need to check out the java ext internals.
Super awesome. Of course I don’t mind. I was about to suggest it, even. 😃
I’m thinking there might be an explicit API for it. Some provider we need to implement.
To detect a new .clj file?
btw emacs also has this, I think clojure-mode does it
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.)
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. 😃
Let’s see wha @zelark digs up. 😃
you should be able to add a handler for workspace.onDidCreateFiles https://code.visualstudio.com/api/references/vscode-api#workspace
Yeah, the Uri contains what we need at least.