Fork me on GitHub
#calva
<
2018-12-12
>
pez10:12:52

Friends of Calva. I need some help testing this build of Calva Formatter. It should be about exactly the same as the currently released one, but it is built in a quite different manner. The formatting library is published as an NPM module and then required by the TS code. The idea is that all Calva extensions should be able to share the same library. From what I can see this version of Calva Formatter works fine, but I had all sorts of problem getting it there so I'd like some help in testing it.

mseddon12:12:22

12/12/2018 12:15:45 - Microsoft VSIX Installer
12/12/2018 12:15:45 - -------------------------------------------
12/12/2018 12:15:45 - vsixinstaller.exe version:
12/12/2018 12:15:45 - 15.5.99+g87f89a485e
12/12/2018 12:15:45 - -------------------------------------------
12/12/2018 12:15:45 - Command line parameters:
12/12/2018 12:15:45 - C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\VSIXInstaller.exe,C:\Users\Me\Downloads\calva-fmt-0.0.30-calva-lib.vsix
12/12/2018 12:15:45 - -------------------------------------------
12/12/2018 12:15:45 - Microsoft VSIX Installer
12/12/2018 12:15:45 - -------------------------------------------
12/12/2018 12:15:46 - Initializing Install...
12/12/2018 12:15:46 - Microsoft.VisualStudio.ExtensionManager.InvalidExtensionManifestException: Element 'Identity' has invalid value for attribute 'Version' ---> System.FormatException: Input string was not in a correct format.
   at System.Version.VersionResult.SetFailure(ParseFailureKind failure, String argument)
   at System.Version.TryParseComponent(String component, String componentName, VersionResult& result, Int32& parsedComponent)
   at System.Version.TryParseVersion(String version, VersionResult& result)
   at System.Version.Parse(String input)
   at System.Version..ctor(String version)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionImpl.<>c.<ExtractManifestData>b__64_1(String s)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionImpl.VerifyStringValue[T](String value, ErrorInfo info, Func`2 selector, Boolean isRequired, Int32 maxLength, T defaultValue)
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.ExtensionManager.ExtensionImpl.VerifyStringValue[T](String value, ErrorInfo info, Func`2 selector, Boolean isRequired, Int32 maxLength, T defaultValue)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionImpl.ExtractManifestData(PackageManifest manifest)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionImpl.ReadPackageManifest(XmlReader reader)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionImpl.ReadManifest(Stream manifestStream)
   at Microsoft.VisualStudio.ExtensionManager.InstallableExtensionImpl.ReadVSIXManifestFromPackage(Stream stream, CultureInfo preferredCulture)
   at Microsoft.VisualStudio.ExtensionManager.InstallableExtensionImpl..ctor(String path, CultureInfo preferredCulture)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionEngineImpl.CreateInstallableExtension(String extensionPath, CultureInfo preferredCulture)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionEngineImpl.CreateInstallableExtension(String extensionPath)
   at VSIXInstaller.App.GetInstallableData(String vsixPath, Boolean isRepairSupported, IEnumerable`1& skuData)
   at VSIXInstaller.App.Initialize(Boolean isRepairSupported)
   at VSIXInstaller.App.Initialize()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

mseddon12:12:21

I may be doing this wrong, first time I've installed something outside of the store... πŸ™‚

pez12:12:57

I'm happy you tried! πŸ˜ƒ Did you do it from the command line?

mseddon12:12:19

I didn't, I just double clicked on it like a n00b in windows πŸ˜‰

mseddon12:12:44

ah, also... huh. that is visual studio trying to install it. derp

mseddon12:12:50

that probably won't work out πŸ˜„

pez12:12:07

Ah, yes, they have the same extension probably. Install it from within VS Code's extensions panel. There's a metballs-menu at the top with the option to install VSIX packages.

mseddon12:12:51

I'm doing code --install-extension atm

mseddon12:12:06

nothing is happening yet but hey, maybe no news is good news? πŸ™‚

mseddon12:12:12

it was successfully installed

mseddon12:12:39

it seems to mostly work? there seem to be some toplevel forms that it sticks the silly indent on newline after when it should be at column 0

pez12:12:48

Cool. Let me know how it fares. I do think this branch has come a tad out of sync with the main one so might be some new things that are missing.

mseddon12:12:49

also I have switch CRLF to LF for now... since yeah.

pez12:12:14

Yeah, that one. My attempts to fix it have failed.

pez12:12:02

My code is a bit too complicated. I think it will be easier to fix if I can manage to simplify it some.

mseddon12:12:34

hmm, yeah definitely getting some funky indents at the end of anything but very simple forms..

pez12:12:09

With the -calva-lib version?

mseddon12:12:35

yeah, 0.0.30-calva-lib

mseddon12:12:41

paredit 0.1.21

mseddon12:12:49

calva 1.3.58

mseddon12:12:07

I've been in emacs mostly for the past week or so, so perhaps i don't have the latest updates, let me check

pez12:12:27

Those are the latest.

pez12:12:03

Give me an example of funky indents.

mseddon12:12:22

trying to get a repro on it atm

mseddon12:12:33

also is it me or does cond format a bit weird?

mseddon12:12:46

last line seems to indent 2 chars in from the (

pez12:12:41

I think that is probably compatitble with the non-calva-lib version. πŸ˜ƒ

mseddon12:12:30

so long as it's not new πŸ˜‰

pez12:12:30

Yeah, I have tried not to change anything.

mseddon12:12:53

pressing tab fixes the cond, but incremental seems to make a bit of a mess

pez12:12:04

Incremental?

mseddon12:12:09

oh, the incremental formatting

pez12:12:21

I see. That doesn't sound good at all.

mseddon12:12:30

so e.g. if I write

(defn foo []
  (cond (= x 5)
        (println "Hello")
        (= y 6)
        (println "hi")))

mseddon12:12:56

just pressing enter, not tab etc, I get

mseddon12:12:00

(defn foo []
  (cond (= x 5)
        (println "Hello")
        (= y 6)
    (println "hi")))

mseddon12:12:15

if I press tab within the cond form, or at the defn level it all fixes itself

mseddon12:12:08

again this is under wind0wz so there may be some fun here, are you running linux or macos?

pez12:12:08

So where is the cursor when you press enter?

mseddon12:12:27

(println "hi")*))

mseddon12:12:38

oh, no, sorry. lol

mseddon12:12:43

let me figure that out and check again πŸ™‚

mseddon12:12:01

I haven't started the println form yet

mseddon12:12:23

when it is at (= x 5)* i get the same thing for the (println "Hello")

pez12:12:25

I see it now. I think this might be a newly introduced bug in cljfmt.

mseddon12:12:50

but that fixes itself as I add new lines, presumably because you call cljfmt and it fixes up the previous bits

pez12:12:00

The particular bug here is that it indents

(println "h")\n))
differently than
(println "h")\nfoo))
.

mseddon12:12:34

oh- because yeah, in a regular file I guess that makes sense

pez12:12:37

Again, I think that is bug compatible with v0.0.29.

mseddon12:12:54

the problem is the incremental application of cljfmt perhaps?

mseddon12:12:19

because yeah, it would make sense to dedent that )) if cljfmt was looking at a complete text file

pez12:12:39

It's a bug. I think this PR might have introduced it: https://github.com/weavejester/cljfmt/pull/156

pez12:12:25

It really should indent those trailing parens the same as if there was a symbol on the line before them.

mseddon12:12:30

huh, well I just skimmed basically the whole code for cljfmt! that's nice.

mseddon12:12:42

perhaps bugfixing these things is not so horrible

mseddon12:12:10

so can you point me briefly at all the bits where you invoke cljfmt in calva?

mseddon12:12:26

christmas is coming, and that includes a bit of time I hope πŸ™‚

pez12:12:03

I'll be filing an issue on cljfmt about this.

mseddon12:12:27

does clojureVSCode use cljfmt incrementally, or does it just expose it as a 'reformat file' feature?

pez12:12:28

I only invoke cljfmt directly in one place. But indirectly at a few more places, of course.

mseddon12:12:46

yeah I need to spend a bit of time learning about where vscode event hooks take place

pez12:12:49

I don't know how clojureVSCode does formatting.

mseddon12:12:46

just looked in his codebase- it's just a "reformat file" and "reformat on save" feature

mseddon12:12:17

oh- do you develop this plugin with a repl into a debug vscode instance btw?

pez12:12:56

Debugging does not really work with the cljs stuff.

pez12:12:24

The -calva-lib version has a bit of a special dev setup. Where the calva-lib library is it's own project, cljs-only.

pez12:12:26

It builds an npm module that extension code (TypeScript) requires from the npmjs repository.

pez12:12:24

The currently released extension is built a bit differently.

pez12:12:34

There I can have the repl attached to the running extension. Which is good. With the new dev setup I lose that. I do have a repl, but can't attach it to the running extension.

pez12:12:29

But with the current dev setup it is hard to share the code, or at least I didn't find a good way to do it.

mseddon12:12:35

ah right. hm.

mseddon12:12:05

and it definitely needs to be packaged as 3 extensions?

pez12:12:15

Maybe we can find a better way of doing it that lets us keep the attach feature.

mseddon12:12:20

(again, totally unaware how vscode organises things)

pez12:12:10

That has less to do with vscode than that I don't want to force Calva on people who need a formatter or paredit.

pez12:12:18

Another thing with the current dev process is that it makes the API to the library a bit funny and also a bit hard to maintain.

mseddon12:12:49

hmm. yeah okay. I wonder if there is a way to build a monolithic calva extension, but also publish paredit and cljfmt separately from the same codebase.

mseddon12:12:17

(and if that would even help...)

pez12:12:31

I think it would.

pez13:12:24

Or at least have the same codebase and build the three extensions from it.

pez13:12:05

That is partly what I try to do today, but if I understand your idea correctly it would be more like one vscode-extension project where the extensions can share code much more directly.

mseddon13:12:08

yeah, it would sort of be like a multi lein project, sharing the code directly

mseddon13:12:25

but then two other projects including just what they need and some extension specific other stuff

pez13:12:42

I think I must try it. Even though it has taken me two weeks to get this calva-lib thing done…

mseddon13:12:12

i need to actually take shadow-cljs out for a spin, and work with vscode extensions for a week

mseddon13:12:37

I've only recently returned to clojure so I am all oldschool leiningen and emacs for the most part...

pez13:12:46

There is still that thing with the library API getting a bit strange, that would increase with this setup. But having the repl attached to the running extension is a really good thing.

mseddon13:12:09

I can't imagine clojure development without a repl 😞

pez13:12:23

But I do have a repl.

pez13:12:39

Just not attached to the running app.

pez13:12:35

I would never had gone for a dev process without a repl. Believe me. πŸ˜ƒ

mseddon13:12:51

πŸ˜„ quite. I thought you were extremely brave for a moment there

pez13:12:30

I am a brave type of guy, but Clojure is not fun w/o a repl.

mseddon13:12:48

nope. it kinda misses the point of lisp.

mseddon13:12:17

I doubt everyone at MIT and BBN etc would have put up with gc's that took 10 minutes without one...

mseddon13:12:13

but okay, I will try to get a dumb typescript plugin running connected to the repl over the next week or so...

pez13:12:54

@pedrorgirardi likes to build them in pure ClojureScript.

mseddon13:12:19

Yeah see, that sounds fun πŸ˜‰

mseddon13:12:25

that said I really don't mind typescript at all

pez13:12:07

Me neither. My reason for using both is that I like to be able to use the debugger at the integration level with VS Code. It also helps my thinking to keep the object oriented stuff in TS so that I can use data structures an functions more purely in the CLJS end of things.

mseddon13:12:27

btw- for keyword highlighting out of the box, couldn't you override the default configurations with https://code.visualstudio.com/docs/extensionAPI/extension-points#_contributesconfigurationdefaults?

pez13:12:48

I think I can provide a new grammar. But I have found no way of contributing the keyword highlighting. Would be happy if that was just me.

mseddon13:12:26

fair enough. I am just peeking at the plugin api over lunch. this is very armchair πŸ™‚

pez13:12:32

I have a PR rotting against the Atom Clojure grammar, because that is what VS Code uses and they track the Atom repo for it.

mseddon13:12:12

now microsoft control both vscode and atom, it may die down there πŸ˜‰

mseddon13:12:00

yeah it looks like it's rarely looked at

pez13:12:54

Here's the issue you found for me, @mseddon: https://github.com/weavejester/cljfmt/issues/159

pez13:12:28

Please feel free to try fix it. πŸ˜ƒ

mseddon13:12:37

πŸ˜„ I shall have a go

pez16:12:15

Welcome @jeff!

jeff.bachtel16:12:47

thanks! I just installed your extension in vscode, as the previous extension was no longer working (was dabbling at a project that I last touched a year ago)

jeff.bachtel16:12:22

and now I'm yak shaving to figure out why my lein repl command line is throwing an assertion πŸ˜‰

pez16:12:46

Which extension were you using?

jeff.bachtel16:12:21

which, I'm not sure based off your doc comment, was that what you forked originally?

jeff.bachtel16:12:38

it used to work well but the author isn't doing Clojure anymore and well you know how that goes

jeff.bachtel16:12:47

okay I've got repl going. Does Calva yet support the Debug interface in vscode? if so, is there a launch.json config I should use?

jeff.bachtel17:12:14

looking closely at the Calva readme it seems it doesn't support Debug yet. It's probably a huge lift, but that is something I'd find to be awesome in the future (but for now nREPL will work just fine, and thanks again for the extension)

pez18:12:04

Calva took off from visual:clojure. Maybe we should talk to the Clojure Debug creator about porting the debug things to Calva?