I have an idea for a new plugin which works much like parinfer (and maybe can piggieback on it) for keeping one’s namespace form correct and clean. I’m curious what people think of the idea and opinions on how to execute it. Here’s what I’ve got so far:
- It knows how to find Clojure source files, which means a minimal bit of reading project.clj to find source directories, including :test and such.
- It parses all source files into a database that includes what namespaces are included with which aliases, which symbols are :refer’d in other files in your project, and so forth.
- As you type, if you type, s/def, for example, it would find that clojure.spec.alpha is aliased as s/ in another namespace, and add a :require form for it with an alias at the top of your file.
- If you type, deftest, for example, it would see that this is :refer’d from clojure.test elsewhere in your project, and so it would add it to the :refer for this namespace in this file.
- It would keep things sorted, of course.
- It would remove :refer symbols when they are deleted from the file.
- It would remove a namespace when it has no more used refer symbols or alias prefix.
- Except, if a namespace never had an alias or refer clause, it is kept (for defmethod and implementations).
What do you think?