|
11 | 11 | seq-replace-var windows?]] |
12 | 12 | [taoensso.timbre :as log])) |
13 | 13 |
|
14 | | -(defn- find-project-root-from-file [file] |
15 | | - (loop [current-dir (fs/parent (fs/path file))] |
16 | | - (if-not current-dir |
17 | | - (throw (ex-info (str "Could not determine Defold project from path: " file) {})) |
18 | | - (let [target (fs/path current-dir "game.project")] |
19 | | - (if (fs/exists? target) |
20 | | - (str current-dir) |
21 | | - (recur (fs/parent current-dir))))))) |
22 | | - |
23 | | -; TODO: #33 this is not a good solution, but it works for most use cases presumably |
24 | | -(defn- find-project-root-from-file-or-use-old-one [file] |
25 | | - (let [path (cache-dir "defold.nvim") |
26 | | - last-used (str (fs/path path ".last-used-project-root"))] |
27 | | - (fs/create-dirs path) |
28 | | - (try |
29 | | - (let [project-root (find-project-root-from-file file)] |
30 | | - (spit last-used project-root) |
31 | | - project-root) |
32 | | - (catch Throwable t |
33 | | - (log/error (ex-message t)) |
34 | | - (assert (fs/exists? last-used)) |
35 | | - (slurp last-used))))) |
36 | | - |
37 | 14 | (defn- runtime-dir [project-root] |
38 | 15 | (let [p (cache-dir "defold.nvim" "runtime" (project-id project-root))] |
39 | 16 | (fs/create-dirs p) |
|
172 | 149 | "terminal" (create-terminal-launcher cfg neovim) |
173 | 150 | (throw (ex-info (format "Unknown launcher type: %s" (cfg "type")) {:launcher-config cfg})))) |
174 | 151 |
|
175 | | -(defn run [launcher-config file-name line] |
| 152 | +(defn run [launcher-config root-dir file-name line] |
176 | 153 | (let [neovim (str (fs/which "nvim")) |
177 | 154 | launcher (create-launcher launcher-config neovim) |
178 | 155 | line (when line (Integer/parseInt line)) |
179 | | - root-dir (find-project-root-from-file-or-use-old-one file-name) |
180 | 156 | class-name (format base-class-name (project-id root-dir)) |
181 | 157 | edit-cmd (make-neovim-edit-command file-name line)] |
182 | 158 | (when (or (nil? (:cmd launcher)) (not (command-exists? (:cmd launcher)))) |
|
0 commit comments