summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-07-06 11:13:43 +0800
committereltrac <hi@eltr.ac>2026-07-06 11:13:43 +0800
commitd6fbd70a771ec1200f6e6b781df3368f1ff8380f (patch)
treee657503a40b12def523789da7b19fe276c10db12
parent6e7eee1afd93b7f1089119c56f30131d81dd60d9 (diff)
support local config
-rw-r--r--config.edn1
-rw-r--r--vimulti.clj39
-rw-r--r--vimulti.edn5
3 files changed, 34 insertions, 11 deletions
diff --git a/config.edn b/config.edn
deleted file mode 100644
index b096e69..0000000
--- a/config.edn
+++ /dev/null
@@ -1 +0,0 @@
-{:editor-command "nvim"}
diff --git a/vimulti.clj b/vimulti.clj
index 4775f11..38c87c6 100644
--- a/vimulti.clj
+++ b/vimulti.clj
@@ -5,11 +5,30 @@
'[clojure.edn :as edn]
'[clojure.string :as str])
-(def default-config
- {:editor-command "nvim"})
+(def default-config
+ {:editor-command "nvim"
+ :default-target "nvim:"
+ :aliases []})
;; configuration helpers
-(defn- config-path []
+(defn- deep-merge [v & vs]
+ (letfn [(rec-merge [v1 v2]
+ (if (and (map? v1) (map? v2))
+ (merge-with deep-merge v1 v2)
+ v2))]
+ (if (some identity vs)
+ (reduce #(rec-merge %1 %2) v vs)
+ (last vs))))
+
+(defn- init-config [path]
+ (when-not (fs/exists? path)
+ (fs/create-dirs (fs/parent path))
+ (fs/create-file path)
+ (spit path default-config))
+ path)
+
+;;; global config
+(defn- global-config-path []
(let [env-vimnulti-config (System/getenv "VIMULTI_CONFIG")
env-xdg-config-home (System/getenv "XDG_CONFIG_HOME")
config-filename "config.edn"]
@@ -18,14 +37,14 @@
(str env-xdg-config-home "/vimulti/" config-filename)
config-filename))))
-(defn- init-config [path]
- (when-not (fs/exists? path)
- (fs/create-dirs (fs/parent path))
- (fs/create-file path)
- (spit path default-config))
- path)
+(def global-config (-> (global-config-path)
+ init-config
+ slurp
+ edn/read-string))
-(def config (-> (config-path) init-config slurp edn/read-string))
+;;; load local config
+(def config (cond-> global-config
+ (fs/exists? "vimulti.edn") (deep-merge (-> "vimulti.edn" slurp edn/read-string))))
;; git helpers
(defn- get-current-branch [dir]
diff --git a/vimulti.edn b/vimulti.edn
new file mode 100644
index 0000000..1d3baca
--- /dev/null
+++ b/vimulti.edn
@@ -0,0 +1,5 @@
+{:editor-command "nvim"
+ :default-target "nvim:"
+ :aliases [:lazy {:app-name "nvim-lazy"
+ :branch "main"
+ :repo "/Users/eltrac/.config/nvim-lazy/"}]}