Fork me on GitHub
#chlorine-clover
<
2020-09-23
>
mauricio.szabo13:09:56

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)

fabrao17:09:22

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

mauricio.szabo17:09:41

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.

mauricio.szabo17:09:12

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

fabrao17:09:49

can´t you use Cl.ext.evaluate_and_present ?

fabrao17:09:14

with something like chlorine:connect-socket-repl?

Mattias15:09:18

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

mauricio.szabo15:09:34

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

mauricio.szabo15:09:40

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

Mattias15:09:58

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

mauricio.szabo16:09:37

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.szabo16:09:20

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

seancorfield16:09:19

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

Mattias16:09:43

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 😀

seancorfield16:09:19

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.

seancorfield16:09:21

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.

fabrao17:09:25

@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

fabrao17:09:15

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