-
Notifications
You must be signed in to change notification settings - Fork 175
/
nrepl.clj
21 lines (20 loc) · 1.05 KB
/
nrepl.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(ns cider.nrepl.middleware.util.nrepl
"Common utilities for interaction with the client."
(:require
[nrepl.middleware.interruptible-eval :refer [*msg*]]
[nrepl.misc :refer [response-for]]
[nrepl.transport :as transport]))
(defn notify-client
"Send user level notification to client as a response to request `msg`.
If transport is not provided use (:transport msg). If msg is not provided, use
current *msg* from interruptible-eval middleware. Type is a keyword or string
indicating type of the message (e.g. :message, :warning, :error etc). Type
defaults to :message. See `nrepl-notify` on the Emacs side."
([notification] (notify-client *msg* notification))
([msg notification] (notify-client (:transport msg) msg notification nil))
([msg notification type] (notify-client (:transport msg) msg notification type))
([tr msg notification type]
(transport/send tr (apply response-for msg
:status :notification
:msg notification
(when type [:type type])))))