简体   繁体   中英

How do I add a new file to a Clojure project with Leinigen or Calva?

So I create a project with Lein: lein new app test

I open it in VSCode code test

I run Calva. I then test some simple functions in test.core. Works fine. Now I wanna have a new file with it's own namespace.

I create the file meat.clj inside: (ns test.meat) and try a simple function: (defn inc [a] (+ a 1))

I now run lein repl: lein repl then I navigate to the namespace (ns test.meat) => nil

Then try the function (inc 1) => Syntax error compiling at (C:\Users\felix\AppData\Local\Temp\form-init5552733050921187898.clj:1:1). Unable to resolve symbol: add in this context (inc 1) => Syntax error compiling at (C:\Users\felix\AppData\Local\Temp\form-init5552733050921187898.clj:1:1). Unable to resolve symbol: add in this context

Restarting the Calva server does not help, it can't find this new file.

I guess there maybe be some way to add a new file to Calvas build so it knows where to look? But I have no idea where to do this. Any ideas? The add function works in core but not in my custom namespace.

Couple possibilities:

If the namespace is test.meat , meat.clj needs to be in a directory named test .

Also you def 'da function called inc then you referred to it as add.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM