Fork me on GitHub
#conjure
<
2022-07-16
>
Martynas Maciulevičius09:07:05

Hey. There is no Conjure-hacking channel so I'll ask here (trying some Fennel+Aniseed+Conjure). How can I create a new Clojure buffer and connect it to Conjure? For instance I have this code (it's copied from conjure school from here: https://github.com/Olical/conjure/blob/2c42367fc301f3b38d1f25a68016eec59b834c1a/fnl/conjure/school.fnl#L49):

(defn set-clojure-mode! [buffer-name]
  (nvim.ex.augroup :conjure_school_filetype)
  (nvim.ex.autocmd_)
  (nvim.ex.autocmd (string.format "BufNewFile,BufRead %s setlocal filetype=clojure" buffer-name))
  (nvim.ex.augroup :END))

(defn start-buffer! []
  (set-clojure-mode! const.buf-name)
  (nvim.ex.edit const.buf-name))
(comment (start-buffer!))
It correctly assigns that Clojure file type and the highlighting is picked up. But what it doesn't do is it doesn't bind to a REPL. What I get is this in the log:
; eval (buf): /home/martin/.config/nvim/fnl/narrower/narrower1
; --------------------------------------------------------------------------------
; localhost:8794 (ECONNREFUSED): .nrepl-port
; --------------------------------------------------------------------------------
; localhost:8794 (disconnected): .nrepl-port
In all if my other Clojure projects this babashka REPL starts automatically even if I don't want it to start but here it doesn't start a REPL. What is the rule to start it? I tried creating .git and project.clj files in the fnl directory (trying to pretend this is a project). What I want to do is to start a new buffer, then put some code into it and evaluate in a REPL. But that REPL should be Clojure REPL from the current project and not Fennel REPL.

Martynas Maciulevičius09:07:12

It works if I'm in a project. But somehow it fails if I'm in fnl directory in my nvim config.

Martynas Maciulevičius09:07:29

Is it intended that Conjure doesn't pick up weirdly named buffers? I created this buffer out of thin air and set its mode to Clojure. Then REPL has bound itself to it but tests can't run when I click <localleader>tt. Weird. Is this a bug?

Martynas Maciulevičius10:07:57

Found it. If I run function ConjureCljRunCurrentNsTests manually then the tests are picked up.

Olical11:07:41

Conjure restricts some files types to extensions by default to avoid a bug with Scheme related stuff, I can't remember the specifics. More on it in :h g:conjure#filetype_suffixes#[filetype].

Olical11:07:16

That's only to separate Racked and Scheme though, there's no filtering for Clojure, only filetype I think.

Olical11:07:41

Did you evaluate the buffer first before running the tests?

Martynas Maciulevičius11:07:53

Well I think it's only the binding. In my previous comment I wrote that if I execute ConjureCljRunCurrentNsTests by hand then it loads the namespace. So probably this would be the same binding thing.