Fork me on GitHub
#calva
<
2024-01-05
>
Namit Shah04:01:41

I have this configured in the cljfmt.clj file,

{:indents {sql/select [[:inner 2]]
           sql/insert [[:inner 2]]
           sql/update [[:inner 2]]
           sql/delete [[:inner 2]]
           sql/on-conflict [[:inner 2]]}}
I am currently using the 2.0.375 and the formatting works as expected. I tried updating to the latest version and change the cljfmt.clj file to use :extra-indents instead of :indents which looks like,
{:extra-indents {sql/select [[:inner 2]]
                 sql/insert [[:inner 2]]
                 sql/update [[:inner 2]]
                 sql/delete [[:inner 2]]
                 sql/on-conflict [[:inner 2]]}}
But for some reason, the formatting is not working now. Any idea what can be going wrong here or what else do I need to change?

pez07:01:19

It looks right. I don’t think 375 supported :extra-indents though. Can you try with latest Calva?

Namit Shah14:01:27

Yes. In 2.0.375, the :indents configuration is working. But when I updated Calva to latest version and tried using :extra-indents it is not working.

pez15:01:54

Ah, I’m sorry, missed that you had indeed tried with latest Calva. Is it indenting (what happens when you hit return) or formatting (what happens when you hit tab) that is not working, or both?

Namit Shah15:01:22

Not working for either.

pez16:01:35

Thanks. Very strange… Can you check if it works with the cljfmt command line tool?

Umar Mahmud23:01:48

I have a file called alternate-strings.clj in src/leetcode_clojure in the merge-strings-alternately folder. When the namespace is set to (ns leetcode-clojure.merge-strings-alternately.alternate-strings) I am getting an error - "Namespace does not match file name: leetcode-clojure.merge-strings-alternately.alternate-strings". This is a lein project. Any ideas on this?

dpsutton23:01:59

can you put the full path of alternate-strings namespace and the classpath roots from your project.clj file?

dpsutton23:01:08

fundamentally that’s all it is.

dpsutton23:01:35

but my guess is that you put merge-strings-alternately with hyphens but those should be underscores in the filesystem

dpsutton23:01:13

leetcode-clojure.merge-strings-alternately.alternate-strings would expect to find this at src/leetcode_clojure/merge_strings_alternately/alternate_strings.clj

Umar Mahmud23:01:12

Sorry I am new to Clojure. Is "classpath root" what immediately follows "defproject" in my project.clj file? In that case, it is "leetcode-clojure".

Umar Mahmud23:01:03

Are you saying I should replace hyphens with underscore?

dpsutton23:01:33

it would be the vector that is the value for :src-paths in project.clj

dpsutton23:01:53

and yes. need to use underscores in filenames and hyphens in namespace names

👍 1
dpsutton23:01:20

src/a/b/c_d.clj is (ns a.b.c-d)

Umar Mahmud23:01:49

I don't see any :src-paths key in my project.cli file.

dpsutton23:01:16

then it’s probably the default of just using “src”. But i’m not sure

Umar Mahmud23:01:20

Ok, changing filenames to use underscores resolved it. Thanks for your help!

👍 2