Open daveyarwood opened 5 years ago
@daveyarwood Did you try to specify g:acid_alt_paths
like following?
let g:acid_alt_paths = ['src/backend', 'src/frontend']
After telling your paths to Acid, :AcidRequire
will work fine, I think.
However, I agree with your opinion that it is better to parse the ns
declarations. :laughing:
Parsing the file for the ns, when I wrote acid, was probably more complicated than figuring out with the paths. Take for example this top part of a clojure file:
;; TODO This file should be merged with sample.utils
(ns sample.tools)
Or this sample from eftest:
(ns ^:eftest/synchronized foo.core-test (:require [clojure.test :refer :all] [foo.core :refer :all]))
Or even a hypothetical poorly formatted file:
(
ns something)
None of those would reliably give me a ns unless I parse/interpret clojure, which is something that feels very hacky to do in Python.
I can give another shot. I won't remove the path-based ns finding since this is the most reliable way (obviously, when everything is configured), but I'm open to suggestions for the cases above.
Cheers
You can use nrepl to query for the classpath, and use that as your roots (after filtering out jars).
@rinx Specifying let g:acid_alt_paths = ['src/backend']
did the trick! Thanks, it wasn't obvious that there was a config option for that.
@hkupty I see your point about parsing the ns
form being complicated. Seems like there ought to be a better way. @SevereOverfl0w 's idea sounds promising!
@SevereOverfl0w Could you elaborate? I like the idea of outsourcing to the nrepl.
I think cider provides a classpath op, it will return a list which is the classpath. If you filter it to just directories, it should give you back a list like /home/dominic/project/src/backend
etc. it will also include test
, resources
and anything else.
You may have a few false-positives (e.g. /home/dominic/.gitlibs/edge/foo.bar) but they don't really matter for calculating the ns that should be used.
Amazing! I'll try that.
Since updating recently, I am no longer seeing evaluation results in the buffer. Running
:AcidRequire
and then usingcpp
to evaluate a form has no visible effect.I noticed that when I press
cqp
to get the prompt, the namespace is incorrect. In this particular project, I have afrontend
folder and abackend
folder, and acid appears to be incorrectly prefixing the namespace withbackend.
:From
/tmp/acid-log-handler.log
:I tried doing the same thing in another project with a "standard" Clojure folder hierarchy, and there is no problem, so this appears to be a bug where acid uses the file path to determine the namespace name. I think it should probably parse the
ns
declaration at the top of the file instead?