Skip to content

Commit

Permalink
fixes #219 #211 get rid of lazy loading deps - what was I thinking
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Hauman committed Jan 21, 2025
1 parent 9773dab commit 124e5e9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 43 deletions.
7 changes: 4 additions & 3 deletions rebel-readline/deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{:deps {org.clojure/clojure {:mvn/version "1.8.0"}
{:deps {org.clojure/clojure {:mvn/version "1.10.0" }
org.jline/jline-reader {:mvn/version "3.5.1"}
org.jline/jline-terminal {:mvn/version "3.5.1"}
org.jline/jline-terminal-jansi {:mvn/version "3.5.1"}
cljfmt {:mvn/version "0.5.7"} ;; depends on tools reader
compliment {:mvn/version "0.3.6"}}}
dev.weavejester/cljfmt {:mvn/version "0.13.0"} ;; depends on tools reader
compliment/compliment {:mvn/version "0.6.0"}}
:aliases {:rebel {:main-opts ["-m" "rebel-readline.main"]}}}
6 changes: 3 additions & 3 deletions rebel-readline/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
:url "https://github.com/bhauman/rebel-readline"
:dir ".."}

:dependencies [[org.clojure/clojure "1.8.0"]
:dependencies [[org.clojure/clojure "1.10.0"]
[org.jline/jline-reader "3.5.1"]
[org.jline/jline-terminal "3.5.1"]
[org.jline/jline-terminal-jansi "3.5.1"]
[cljfmt "0.5.7"] ;; depends on tools reader
[compliment "0.3.6"]]
[dev.weavejester/cljfmt "0.13.0"] ;; depends on tools reader
[compliment/compliment "0.6.0"]]

:profiles {:dev {:source-paths ["src" "dev"]
:main rebel-dev.main}})
29 changes: 13 additions & 16 deletions rebel-readline/src/rebel_readline/clojure/line_reader.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
[rebel-readline.clojure.sexp :as sexp]
[rebel-readline.tools :as tools :refer [color service-dispatch]]
[rebel-readline.utils :as utils :refer [log]]
;; lazy-load
#_[cljfmt.core :refer [reformat-string]]
[cljfmt.core :refer [reformat-string]]
[clojure.string :as string]
[clojure.java.io :as io]
[clojure.main])
Expand Down Expand Up @@ -441,20 +440,18 @@
(if (zero? cursor)
0
(if-let [prx (indent-proxy-str s cursor)]
;; lazy-load for faster start up
(let [reformat-string (utils/require-resolve-var 'cljfmt.core/reformat-string)]
(try (->>
(reformat-string prx {:remove-trailing-whitespace? false
:insert-missing-whitespace? false
:remove-surrounding-whitespace? false
:remove-consecutive-blank-lines? false})
string/split-lines
last
sexp/count-leading-white-space)
(catch clojure.lang.ExceptionInfo e
(if (-> e ex-data :type (= :reader-exception))
(+ 2 (sexp/count-leading-white-space prx))
(throw e)))))
(try (->>
(reformat-string prx {:remove-trailing-whitespace? false
:insert-missing-whitespace? false
:remove-surrounding-whitespace? false
:remove-consecutive-blank-lines? false})
string/split-lines
last
sexp/count-leading-white-space)
(catch clojure.lang.ExceptionInfo e
(if (-> e ex-data :type (= :reader-exception))
(+ 2 (sexp/count-leading-white-space prx))
(throw e))))
0)))

(def indent-line-widget
Expand Down
21 changes: 8 additions & 13 deletions rebel-readline/src/rebel_readline/clojure/service/local.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
[rebel-readline.clojure.utils :as clj-utils]
[rebel-readline.tools :as tools]
[rebel-readline.utils :as utils]
;; lazy-load
#_[compliment.core :as compliment]
[compliment.core :as compliment]
[clojure.repl]))

;; taken from replicant
Expand Down Expand Up @@ -68,11 +67,9 @@
(resolve-meta var-str))

(defmethod clj-reader/-complete ::service [_ word options]
;; lazy-load for faster startup
(when-let [completions (utils/require-resolve-var 'compliment.core/completions)]
(if options
(completions word options)
(completions word))))
(if options
(compliment/completions word options)
(compliment/completions word)))

(defmethod clj-reader/-current-ns ::service [_]
(some-> *ns* str))
Expand All @@ -86,12 +83,10 @@

(defmethod clj-reader/-doc ::service [self var-str]
(when-let [{:keys [ns name]} (clj-reader/-resolve-meta self var-str)]
;; lazy-load for faster startup
(when-let [documentation (utils/require-resolve-var 'compliment.core/documentation)]
(when-let [doc (documentation var-str)]
(let [url (clj-utils/url-for (str ns) (str name))]
(cond-> {:doc doc}
url (assoc :url url)))))))
(when-let [doc (compliment/documentation var-str)]
(let [url (clj-utils/url-for (str ns) (str name))]
(cond-> {:doc doc}
url (assoc :url url))))))

(defmethod clj-reader/-eval ::service [self form]
(let [res (call-with-timeout
Expand Down
1 change: 0 additions & 1 deletion rebel-readline/src/rebel_readline/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
:prompt (fn []))))"
[line-reader & body]
`(ensure-terminal
(rebel-readline.utils/load-slow-deps!)
(binding [rebel-readline.jline-api/*line-reader* ~line-reader]
~@body)))

Expand Down
7 changes: 0 additions & 7 deletions rebel-readline/src/rebel_readline/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,3 @@
(when (try (require (symbol ns)) true (catch Throwable t false))
(when-let [var (resolve var-sym)]
var))))))

(defn load-slow-deps! []
(.start
(Thread.
#(do
(require 'cljfmt.core)
(require 'compliment.core)))))

0 comments on commit 124e5e9

Please sign in to comment.