calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
2020-11-13T14:29:16.166900Z

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?

pez 2020-11-13T15:47:16.168400Z

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.

1👍
pez 2020-11-13T15:50:17.169200Z

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

2020-11-13T16:34:52.170500Z

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

2020-11-13T16:36:13.171400Z

created a new java file and got

package app.test;

public class Boom {
  
}

pez 2020-11-13T16:37:15.172Z

How did you create a new java file?

2020-11-13T16:38:29.172800Z

via command palette: new file

pez 2020-11-13T16:44:37.175200Z

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

2020-11-13T16:46:06.176900Z

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

1❤️
2020-11-13T16:46:37.177700Z

But first need to check out the java ext internals.

pez 2020-11-13T16:46:44.177900Z

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

pez 2020-11-13T16:47:35.178900Z

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

borkdude 2020-11-13T16:47:48.179200Z

To detect a new .clj file?

borkdude 2020-11-13T16:48:48.179600Z

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

pez 2020-11-13T16:54:09.182900Z

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.)

pez 2020-11-13T16:56:42.184600Z

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. 😃

1😆
pez 2020-11-13T16:57:33.185200Z

Let’s see wha @zelark digs up. 😃

chucklehead 2020-11-13T17:07:31.186300Z

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

1✔️
pez 2020-11-13T17:21:36.188100Z

Yeah, the Uri contains what we need at least.