chlorine-clover

About Chlorine for Atom and Clover for VS Code: https://atom.io/packages/chlorine and https://marketplace.visualstudio.com/items?itemName=mauricioszabo.clover
seancorfield 2020-11-10T01:46:34.243500Z

For anyone not in #news-and-articles: https://corfield.org/blog/2020/11/09/vscode-clover/

❤️ 1
jlmr 2020-11-10T09:19:19.244900Z

@seancorfield I’m trying out your vscode setup now (in VSCodium). Are you using Parinfer and if so how did you get it working?

mauricio.szabo 2020-11-10T12:36:42.245900Z

@jlmr when I tried VSCodium with vim-mode, parinfer and paredit, they kept conflicting with each other. I don't really know if parinfer works in this setup, I imagine it needs some tweaks.

mauricio.szabo 2020-11-10T12:37:04.246500Z

I was even seeing if I could port my parinfer-plus from Atom to VSCodium

jlmr 2020-11-10T12:48:23.248Z

So far I only tried parinfer and no other tools, but its not working correctly (ie parens not moved/added where you would expect them). Could be something with the parinfer package, I was hoping someone else had already found a solution

pez 2020-11-10T15:19:25.249100Z

Parinfer is not working all that well in VS Code. From what I’ve picked up in the #parinfer channel, Smartmode isn’t even possible.

mauricio.szabo 2020-11-10T15:22:25.251300Z

I'm trying to find a "hacky way" to make it work. But I'm not expecting that much, really... VSCode really limits the way you can adjust text after an edit (and not "any edit" but only the ones they allow you to intercept) For example, I haven't found a way to trigger a "reformat" when you press backspace

borkdude 2020-11-10T15:23:24.251700Z

@mauricio.szabo Do you also support the custom rendering using sci in vscode? ;)

mauricio.szabo 2020-11-10T15:24:14.252500Z

@borkdude Yes, I do! 🙂. The only limitation is that you can't use external JS libraries like you could in Atom

🎉 1
mauricio.szabo 2020-11-10T15:37:29.253Z

For example, this code works if you paste on the config file:

(defn create-a-counter []
  (p/let [pos (editor/get-block)
          code '{:html [:div [:button {:on-click '?inc}
                              "clicked " '?state " times"]]
                 :state 0
                 :fns {:inc '(fn [_ state] (inc state))}}]
    (editor/eval-interactive (assoc pos :text
                                    (pr-str code)))))

mauricio.szabo 2020-11-10T15:37:58.253600Z

It evaluates the inc function on the Clojure side, and everything else on sci

borkdude 2020-11-10T15:38:16.254200Z

excellent

mauricio.szabo 2020-11-10T15:42:26.256400Z

For example, this is the "custom command" that I use to run tests: https://gist.github.com/mauricioszabo/c2a756d5f5e363f6539cdad212815df1 It renders clickable stacktraces in case of exceptions, and makes it clear when something failed or not (instead of just printing on the console)

pez 2020-11-10T15:45:27.258200Z

@mauricio.szabo the way Calva does a reformat after backspace is to register backspace as a keyboard shortcut. Then make the command for it perform both the backspace and the reformat.

mauricio.szabo 2020-11-10T15:46:05.258600Z

Ah, right! That explains why it does not reformat when I use vim-mode 😄

pez 2020-11-10T15:46:27.258900Z

vim-mode binds backspace?

mauricio.szabo 2020-11-10T15:48:05.261200Z

Not really, but some commands do not trigger a backspace like "delete word". So while I was editing text, things were reformatting but when I changed to "command/normal mode" and tried to use vim commands, sometimes it did sometime didn't.

pez 2020-11-10T15:48:07.261400Z

Thinking about it, I think Calva does not reformat on backspace, but on many other paredit commands it does. Should probably add reformatting, there…

mauricio.szabo 2020-11-10T15:48:49.262100Z

I imagine that's when I triggered some "delete" commands on the vim side

seancorfield 2020-11-10T18:41:18.263300Z

Re: Parinfer -- I uninstalled it and now I miss what things it was doing, so I've installed it again!

mauricio.szabo 2020-11-11T13:00:01.266Z

@seancorfield I'm trying really :rolling_on_the_floor_laughing:. But the API is so limited and sometimes even buggy that my first experiments got me unpredictable results :(

sparkofreason 2020-11-11T15:53:12.266200Z

Which maybe goes back to my original thought. Is there some subset of effective parinfer features that is useful and more easily implemented?

mauricio.szabo 2020-11-11T17:23:33.266400Z

parinfer-rust is simply and easily implemented to be honest. You just have to get the state before the change and the state after the change, and then change the document with what parinfer-rust returns

sparkofreason 2020-11-11T20:52:39.266700Z

That sounds workable.

mauricio.szabo 2020-11-11T21:00:30.266900Z

Yes, but the problem is that VSCode API does not have 1. A way to capture the state before and after a change 2. A way to change current text 3. The only way to change text is by a FormattingEditProvider that only allows you to capture some changes - no backspace, for example, nor delete 4. onDidChangeTextDocument fires before the change is perceived by the TextEditor, so you can't know for example what's the current cursor position. Also, after FormattingEditProvider fires, if you issue changes to the document it'll fire "didChangeTextDocument" can fire again, so you have to catch this. 5. VSCode does not provide lots of APIs to, for example, by a "changes" object patch a text into another (also, there are at least 2 "changes" object, and they are incompatible between each other) These maybe are all workable in some way, but it's incredibly fragile. For example, you could hook onDidChange and run parinfer, accumulate the result, then apply then on edit provider, but there's still the case of multiple backspaces / deletions that will not fire the edit provider (and both smart-mode and paren-mode depends a lot on backspace)

2020-11-12T01:46:35.267100Z

(fwiw, iiuc, other folks who've worked on parinfer also discovered that various editors lacked apis. i think there was some discussion of this in: https://www.therepl.net/episodes/17/ )

sparkofreason 2020-11-12T15:05:54.267300Z

The tyranny of character streams. I wonder if there are any existing text editors that allow you to plug in at higher abstraction levels than individual keypresses.

mauricio.szabo 2020-11-12T15:08:10.267500Z

@dave.dixon what kind of abstraction do you have in mind?

sparkofreason 2020-11-12T19:10:15.267700Z

@mauricio.szabo It's an interesting question. I think the ideal for editing code is that the entity being edited is the AST or similar representation of the code, rather than the text representation. The textual representation would just be a transformation against that, perhaps combined with a bit of metadata around how the user wants to see it formatted (thus ending formatting wars in dev teams).

sparkofreason 2020-11-13T15:25:51.271700Z

In something like Clojure, this is "easy", in some sense, as you only need to type one or two characters to establish the AST node type to be inserted. For other languages, I think you'd need something more like "snippets".

sparkofreason 2020-11-10T20:08:01.263400Z

I starting to wonder if there isn't a place for a "parinfer light". I shut it off for awhile in Atom, found I mainly missed things like the maintenance of format when tabbing a form. I don't know that I actually use the "infer" part too much, and it usually seems to be the trouble-maker, often actively avoid it, such as when pasting in forms.

mauricio.szabo 2020-11-10T20:10:15.263900Z

Callbacks that say they will fire after an specific event are firing before, rows/cols that don't change, etc...

mauricio.szabo 2020-11-10T20:43:10.264100Z

@dave.dixon are you using parinfer on Atom, or parinfer-plus?

mauricio.szabo 2020-11-10T20:44:29.264300Z

(parinfer-plus should be considered less mature than parinfer, to be honest, but it addresses some of these issues)

sparkofreason 2020-11-10T21:29:58.264500Z

parinfer

sparkofreason 2020-11-10T21:36:24.264700Z

I'll try parinfer-plus.

mauricio.szabo 2020-11-10T21:36:54.264900Z

Please let me know if you find any issues with parinfer-plus 🙂.

1
pez 2020-11-10T21:53:06.265100Z

It's like I depicted it once 😃

pez 2020-11-10T21:54:00.265500Z

It helps regarding oneself as the hero, haha.