While trying to dig into this a bit more I found an open issue over on the JuliaFormatter repo in which some stricken-through text suggested “Function Naming (not possible)”. There wasn’t much information about why it wasn’t possible – and of course: even though nobody has chimed in here yet, absence of evidence is hardly evidence of absence.
I still suspect that I’m just missing something, and that some tool that uses an LSP or that directly performs a semantic analysis of the Julia code probably does this. But in the absence of that, I thought I would clean up and share the glued-together implementation I mentioned above.
It’s an (imperfect) implementation that uses treesitter to parse the code. Obviously this syntactic-rather-than-semantic approach has limitations / sometimes flags things incorrectly, but so far I find it to work surprisingly well (the task of catching definitions is a pretty restricted version of a more general problem, so syntax alone can get us most of the way there for most code).
The plugin – along with more information, and a few demo videos showing how it behaves when applied to existing packages like ForwardDiff.jl and JuMP.jl – can be found over here: https://github.com/DanielMSussman/simpleJuliaTreesitterTools.nvim.
Obviously this is a bit niche, but since I find it helpful to help clean up after my old naming habits I thought it might help others, too. Feedback is welcome, and if someone wants to take the ideas from this plugin generalize them away from neovim’s treesitter integration (or just implement the semantic analysis version) – even better!