Fork me on GitHub

hi there folks. I'm looking for a mechanism to switch buffers/files by namespace rather than file. I use doom with ivy+projectile and use the projectile-find-file to hop around the codebase. But I'd much rather browse at the namespace level than the file. Any idea if there's some combo of cider/lsp that can make this happen? Or maybe let me open the question more: how do you browse around namespaces ?


maybe you can use consult-lsp-symbols ?


there is no such feature that return only namespaces though AFAIK


This isn’t quite what you are looking for, but I have a snippet that sets the names of Clojure buffers to the namespace, rather than the file:

(defun tc/rename-buffer-to-ns ()
  (when (buffer-file-name)
    (let ((ns (clojure-expected-ns)))
      (when (not (string= "" ns))
        (rename-buffer ns)))))

(add-hook 'clojure-mode-hook 'tc/rename-buffer-to-ns)


Handy for navigating buffers once they’re open, but doesn’t really address the problem of finding files


helm-lsp-workspace-symbol looks very useful, lists namespaces and symbols in those namespaces (I assume this is similar to consult-lsp-symbols) Otherwise, I either jump to definition if the namespace or function is used in the current buffer (and easy to jump the cursor too) Mostly I use projectile find file - fuzzy matching of the pattern means _ characters can be skipped (as can most of the name), so narrowing by namespace name would be the same pattern as use with filenames anyway. cider-browse-ns could be used, although I believe it only lists loaded namespaces and requires navigating through a document popup that contains a link to the namespace file. Much more fiddly.


oh, and there is cider-find-ns which lists all loaded (evaluated) namespaces in the current project. This seems to be what the original ask was (assuming the namespaces are all loaded in the running REPL)


consult-lsp-symbols is only available in doom when using vertico. But I'm using ivy.


cider-find-ns is nice! But it doesn't prioritize "project" ns over ns from dependencies


I'll play some more with these