clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.54k stars 646 forks source link

Feature request: jump to project.clj / deps.edn file #2618

Closed yuhan0 closed 5 years ago

yuhan0 commented 5 years ago

It would be nice to have a command like cider-find-config which jumps directly to a buffer for the project-specific configuration file, whether it is deps.edn or project.clj or build.boot.

I'm not too familiar with Clojurescript but I believe the common setup is for there to be separate files for the clj and cljs side of things – this command would visit the appropriate one depending on the current file.

Is this information already contained somewhere in CIDER's environment? I could try to help implementing it with a pointer or two in the right direction :)

bbatsov commented 5 years ago

Something like this could be added to clojure-mode, as you don't really need a running REPL for it. As there are tools like Projectile and project.el that allow you to quickly jump to a file in project, I'm not sure that's something that we really need.

Malabarba commented 5 years ago

You could add this to your own config. :)

(defun me/find-dominating-file (f)
  (when-let ((dir (locate-dominating-file "./" f)))
    (expand-file-name f dir)))

(defun me/find-my-file ()
  (interactive)
  (let* ((files '("project.clj" "build.boot" "deps.edn" "Gemfile"))
         (file-found (car (delq nil (mapcar #'me/find-dominating-file files)))))
    (find-file (or file-found
                   (user-error "No relevant file found here")))))
yuhan0 commented 5 years ago

Thanks for the feedback - I assumed one needed a running REPL to determine which file to visit, eg. in the case of Clojurescript projects with multiple such files. The above snippet works well enough for my needs though, feel free to close this issue if it's not relevant to CIDER after all :)