From e91d9341d3bd1fb6aca07e4383ec59ae384114f8 Mon Sep 17 00:00:00 2001 From: liquidz Date: Tue, 20 Feb 2024 21:44:18 +0900 Subject: [PATCH] feat: Add elin.handler.navigate/cycle-source-and-test handler --- resources/config.edn | 3 ++- src/elin/handler/navigate.clj | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/resources/config.edn b/resources/config.edn index 4db33da4..836d156d 100644 --- a/resources/config.edn +++ b/resources/config.edn @@ -21,7 +21,8 @@ elin.handler.internal/initialize elin.handler.internal/intercept elin.handler.lookup/lookup - elin.handler.navigate/jump-to-definition] + elin.handler.navigate/jump-to-definition + elin.handler.navigate/cycle-source-and-test] :config-map {elin.handler.evaluate/evaluate {:interceptor {:includes [elin.interceptor.nrepl/output-eval-result-to-cmdline-interceptor]}} elin.handler.evaluate/evaluate-current-expr {:interceptor #ref [:interceptor :preset :evaluation]} diff --git a/src/elin/handler/navigate.clj b/src/elin/handler/navigate.clj index 3bdb96ac..f543751c 100644 --- a/src/elin/handler/navigate.clj +++ b/src/elin/handler/navigate.clj @@ -2,6 +2,8 @@ (:require [elin.error :as e] [elin.function.nrepl :as e.f.nrepl] + [elin.function.nrepl.namespace :as e.f.n.namespace] + [elin.function.nrepl.system :as e.f.n.system] [elin.function.vim :as e.f.vim] [elin.function.vim.sexp :as e.f.v.sexp] [elin.schema.handler :as e.s.handler] @@ -18,3 +20,13 @@ (when (and file line) (e.f.vim/jump!! host file line (or column 1))) true)) + +(m/=> cycle-source-and-test [:=> [:cat e.s.handler/?Elin] any?]) +(defn cycle-source-and-test + [{:component/keys [host nrepl]}] + (let [ns-path (e.f.vim/get-current-file-path!! host) + ns-str (e.f.v.sexp/get-namespace!! host) + file-sep (e.f.n.system/get-file-separator nrepl) + cycled-path (e.f.n.namespace/get-cycled-namespace-path + {:ns ns-str :path ns-path :file-separator file-sep})] + (e.f.vim/notify host "elin#internal#open_file" [cycled-path])))