Enable cross-repo navigation to project dependencies
SCIP Index / index (push) Successful in 1m30s

Previously external-ns? only included clojure.* and java.* namespaces,
missing project dependencies like tui.events. This prevented cross-repo
go-to-definition from working.

Changes:
- external-ns? now considers any non-internal namespace as external
- collect-external-symbols creates symbol entries even without runtime docs
- This enables hover and go-to-definition for dependency symbols

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 19:02:34 -05:00
parent 79ce17106a
commit 01883ffbe0
+16 -13
View File
@@ -206,13 +206,11 @@
:special-form true})) :special-form true}))
(defn external-ns? (defn external-ns?
"Check if a namespace is external (standard library or dependency)." "Check if a namespace is external (not defined in this project).
Any namespace not in internal-namespaces is considered external,
enabling cross-repo navigation to dependencies."
[ns-sym internal-namespaces] [ns-sym internal-namespaces]
(let [ns-str (str ns-sym)] (not (contains? internal-namespaces ns-sym)))
(and (not (contains? internal-namespaces ns-sym))
(or (str/starts-with? ns-str "clojure.")
(str/starts-with? ns-str "java.")
(contains? external-ns-prefixes ns-str)))))
(defn get-var-doc (defn get-var-doc
"Get documentation for a var. Returns a map with :doc, :arglists, :macro. "Get documentation for a var. Returns a map with :doc, :arglists, :macro.
@@ -236,7 +234,8 @@
(catch Exception _ nil)))) (catch Exception _ nil))))
(defn external-symbol->symbol-info (defn external-symbol->symbol-info
"Create SCIP SymbolInformation for an external symbol with documentation." "Create SCIP SymbolInformation for an external symbol.
Works with or without documentation - symbol entry is essential for cross-repo nav."
[{:keys [ns name doc arglists macro special-form]}] [{:keys [ns name doc arglists macro special-form]}]
(let [builder (Scip$SymbolInformation/newBuilder) (let [builder (Scip$SymbolInformation/newBuilder)
sig (str (cond special-form "special form " sig (str (cond special-form "special form "
@@ -246,25 +245,29 @@
(.setSymbol builder (make-symbol ns name)) (.setSymbol builder (make-symbol ns name))
;; Add signature as first doc line ;; Add signature as first doc line
(.addDocumentation builder (str "```clojure\n" sig "\n```")) (.addDocumentation builder (str "```clojure\n" sig "\n```"))
;; Add arglists ;; Add arglists if available
(when (seq arglists) (when (seq arglists)
(.addDocumentation builder (str "```clojure\n" (format-arglists arglists) "\n```"))) (.addDocumentation builder (str "```clojure\n" (format-arglists arglists) "\n```")))
;; Add docstring ;; Add docstring if available
(when doc (when doc
(.addDocumentation builder doc)) (.addDocumentation builder doc))
(.build builder))) (.build builder)))
(defn collect-external-symbols (defn collect-external-symbols
"Collect all unique external symbol references from analysis." "Collect all unique external symbol references from analysis.
Returns symbol info for all external symbols, with docs when available.
Essential for cross-repo navigation to dependencies."
[analysis internal-namespaces] [analysis internal-namespaces]
(->> (vals analysis) (->> (vals analysis)
(mapcat :var-usages) (mapcat :var-usages)
(filter #(external-ns? (:to %) internal-namespaces)) (filter #(external-ns? (:to %) internal-namespaces))
(map (fn [{:keys [to name]}] [to name])) (map (fn [{:keys [to name]}] [to name]))
(filter (fn [[ns-sym _]] ns-sym)) ; Filter out nil namespaces
(distinct) (distinct)
(keep (fn [[ns-sym var-name]] (map (fn [[ns-sym var-name]]
(get-var-doc ns-sym var-name))) ;; Try to get docs, but always return at minimum ns/name
(filter :doc))) ; Only include symbols with documentation (or (get-var-doc ns-sym var-name)
{:ns ns-sym :name var-name})))))
(defn uri->relative-path (defn uri->relative-path
"Convert file:// URI to relative path from project root." "Convert file:// URI to relative path from project root."