Fork me on GitHub
#cursive
<
2024-05-21
>
Marcel Krcah13:05:57

What's the way to change the namespace name so that the changes are propagated everywhere the namespace is used? In Scala, for example, a common refactoring pattern is to select a directory of a package, hit "Refactor" and that would change the package name everywhere the package is used. Is something like this available in Cursive, where one can change the directory name or move a file around, and IDE would automatically update the namespace name and the corresponding requires as well, etc? Thanks!

Leo E13:05:15

Refactor -> Rename and other available in Idea refactor action works for me. You mean some special case or just regular variables renaming?

andre.richards13:05:35

In my experience if you rename the leaf of the namespace, i.e. a *.clj file, Cursive updates all namespaces referencing that namespace. However if you change the name of a directory containing namespace files and/or subdirectories, Cursive does not update everything. You either have to go and edit all namespaces manually, or do text find/replace.

Marcel Krcah13:05:21

Thanks for the replies and, sorry, I should have probably ask the question better. I made this short Loom with the minimal demonstration of what I meant: https://www.loom.com/share/e08b376dfb254ddc8f6a8e9c50a2bcaa

Leo E14:05:31

Yes, indeed, I checked and such problems exist. I'm afraid, as in some other cases, such as following a protocol implementation, refactoring or editing library files, you will have to combine several editors. In the video you can see that the vs code do well with the task you described. Because it use ClojureLSP(which cursive don't) server to do this, i guess. But vscode will not help you if you have a combined project with Java or Kotlin, also it doesn't support multimonitor. There is also emacs+cider, but it has a high learning curve. In general, I get out of this situation by combining tools.

Marcel Krcah19:05:23

@U04V57E4PUZ Thanks a lot for sharing that tip and also for reproducing the use-cases in vs code. The approach of using multiple editors didn't occurred to me, I will give it a try. @U0567Q30W Are these use-cases feasible/planned in the upcoming future or better to use two editors for now? Thx

Leo E20:05:12

If you really need to combine the functionality provided by different editors, then I can also recommend the https://plugins.jetbrains.com/plugin/22710-open-in-vs-code, which I use to quickly move between the same project in two editors. Unfortunately, I have not yet found a plugin that works in the opposite direction.

🙌 1
cfleming23:05:34

Yes, unfortunately Cursive doesn’t do this yet. However, it’s something that’s on my short-term roadmap, and I’ve been fixing the ns manipulation code required to support this recently. I need to fix it for CLJC since that needs to be reliable for refactoring, and then I can implement it.

🚀 3
Marcel Krcah13:05:44

Thanks for the tips and the update 👍