Fork me on GitHub
#emacs
<
2023-12-06
>
Andrey Subbotin05:12:17

How does one find what inserts the (ns some.name) template into a new visited .clj file to change the template? I use eglot, clojure-lsp, cider, and yasnippet. But I seem to be unable to locate the bit that does insert the template. yasnippet has a snippet that inserts exactly that, but editing the snippet and calling yas-reload-all doesn't change what's inserted. For clojure-lsp I have {:auto-add-ns-to-new-files? false} in .clojure-lsp/config.edn, removing which leads to the ns form being inserted twice in the same file, so the flag actually has an effect, and it seems to be not clojure-lsp inserting the original ns form. eglot shouldn't do that on its own I believe, as it's merely an LSP client. And cider... I couldn't find anything related to new file templates in its docs, and thus am not sure if it's ever involved. Still, the question remains, how do I figure out where the ns form comes from?

magnars05:12:57

Do you also use clj-refactor? Then take a look at the cljr-add-ns-to-blank-clj-files custom. What do you want to change the declaration to?

Andrey Subbotin06:12:23

Oh yeah. That's it. I have cljr-add-ns-to-blank-clj-files set to t in .clj files... setting it to nil stops the form being added to new files

Andrey Subbotin06:12:55

Thank you so much

Andrey Subbotin06:12:47

I'd like to add some more forms added as default on the current project and wanted to disable the simple ns one, but couldn't figure out how.

Andrey Subbotin06:12:22

I somehow have forgotten clj-refactor was doing this... even though I believe I knew it at some point... huh.