Skip to content

Commit

Permalink
feat: Add elin.handler.navigate/cycle-source-and-test handler
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Feb 20, 2024
1 parent 1ff6ef4 commit e91d934
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion resources/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand Down
12 changes: 12 additions & 0 deletions src/elin/handler/navigate.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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])))

0 comments on commit e91d934

Please sign in to comment.