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
mauricio.szabo 2020-09-23T13:49:56.004100Z

Not really, there's an open issue for that... but I still didn't find a way to make it work reliably (one of the problems is that Atom only start up the package when you issue a command, or you can make the package start together with Atom, which is not ideal because makes startup slower)

2020-09-23T15:34:18.005900Z

Tangentially related beginners question - why can’t I use Chlorine commands without being connected? Seems like go to definition and things could work... ? 🙂

mauricio.szabo 2020-09-23T15:47:34.006300Z

Not really, @mattias504, all commands use the REPL in some way or the other

mauricio.szabo 2020-09-23T15:48:40.007600Z

Go to definition, for example, gets the meta, pick up the filename / row from there, and sometimes searches the files on the java classpath to get the full filename + directory

2020-09-23T15:57:58.011700Z

Ok, makes sense! Just my limited understanding playing tricks. Thanks!

mauricio.szabo 2020-09-23T16:04:37.011900Z

I'm studying some syntax analysis to go with Chlorine. The hard part is that I'm aiming for a "no external dependencies" approach. I've tried to port clojure-lsp to ClojureScript and use it internally, but it's quite hard. Tried other approaches like clindex, but it also depends on the JVM. Both of these libraries can be slow (the first time they run) and memory-hungry, so by porting to ClojureScript will make it even slower 😞

mauricio.szabo 2020-09-23T16:05:20.012600Z

(and it can also make Atom slow because JS runtime is single-threaded, so that's another problem too 😅)

seancorfield 2020-09-23T16:08:19.015100Z

@mattias504 Cursive (for IntelliJ) is the only Clojure editor that can do much without a REPL because it has a whole static analysis engine built-in -- but that's a lot of work since it has to duplicate a lot of what Clojure itself does to parse and figure out definitions etc. Clojure development is inherently REPL-driven so having a REPL should always be a given (I usually have two REPLs running -- one for my main work and one for "scratch" stuff such as helping beginners -- and my REPLs run for days, sometimes even weeks).

2020-09-23T16:19:43.016400Z

Thanks for the thoughtful explanations. I wanted to, but haven’t taken the time to dive into how the repl thing actually works behind the pretty slick scene 😀

seancorfield 2020-09-23T16:37:19.018400Z

I just start a REPL from the command-line, with an alias to start a Socket REPL. No magic. That could be just clj -A:test:socket with the right alias (from my dot-clojure repo). Then connect Chlorine to localhost/`50505` (the port is hardcoded in the alias in deps.edn). Everything is just code evaluation from that point on.

seancorfield 2020-09-23T16:38:21.019400Z

Clojure's REPL has everything needed for loading/finding definitions, getting completions, etc. Some editor integrations just build some smarts over the top of that.

fabrao 2020-09-23T17:06:22.019500Z

Can´t I create some atom.commands.add 'atom-text-editor', 'fabrao:start-repl', -> and interact with Chlorine? Like starting the repl connection?

fabrao 2020-09-23T17:10:25.020500Z

@seancorfield I created this

atom.commands.add 'atom-text-editor', 'fabrao:run-selection', ->
  editor = atom.workspace.getActiveTextEditor()
  caminhoArquivo = editor.getPath()
  texto = editor.getLastSelection().getText()
  projetos = atom.project.rootDirectories.filter (projeto) -> caminhoArquivo.indexOf(projeto.realPath) isnt -1
  if projetos.length
    comando_executar = '"cd ' + projetos[0].realPath + " ; " + texto
    spawn("powershell.exe", ["-Command", comando_executar], {shell: true, detached: true})
  else
    alert("Clojure Project not found")
and bind it to F8

fabrao 2020-09-23T17:13:15.021200Z

and if I want to run clj -A:dev, I select it and press F8

mauricio.szabo 2020-09-23T17:15:41.021300Z

Yes, you can create a command on init.coffee (or init.js). But then you'll have to run a Chlorine command - and that's not possible (yet?) because there's no way to run a command in a package that's no loaded. And the way to load Chlorine today is to run Connect Socket REPL command.

seancorfield 2020-09-23T17:15:57.021600Z

That's neat @fabrao!

mauricio.szabo 2020-09-23T17:17:12.021800Z

But, maybe there's a way. I just need to think a little bit on how to run this command and somehow pass a parameter to it

fabrao 2020-09-23T17:19:49.022Z

can´t you use Cl.ext.evaluate_and_present ?

fabrao 2020-09-23T17:20:14.022200Z

with something like chlorine:connect-socket-repl?