|
4 | 4 | [clojure.tools.logging :as log]
|
5 | 5 | [neovim-client.message :as message :refer [->request-msg]]
|
6 | 6 | [neovim-client.rpc :as rpc])
|
7 |
| - (:import (java.net Socket))) |
| 7 | + (:import (java.net Socket) |
| 8 | + (com.etsy.net UnixDomainSocketClient JUDS))) |
8 | 9 |
|
9 | 10 | (defmacro defvim
|
10 | 11 | [fn-name vim-command & args]
|
|
117 | 118 | (def stop rpc/stop)
|
118 | 119 |
|
119 | 120 | (defn new*
|
120 |
| - [input output debug] |
| 121 | + [input output update-nvim-channel?] |
121 | 122 | (let [component (rpc/new input output)]
|
122 |
| - ;; Each time you connect to the same nvim instance using a tcp socket, nvim |
| 123 | + ;; Each time you connect to the same nvim instance using a socket, nvim |
123 | 124 | ;; allocates a new channel.
|
124 |
| - (when debug |
125 |
| - (let [api-info (vim-get-api-info component)] |
126 |
| - (vim-command component (format "let g:nvim_tcp_plugin_channel = %s" |
127 |
| - (first api-info))))) |
| 125 | + (when update-nvim-channel? |
| 126 | + (async/thread |
| 127 | + (let [api-info (vim-get-api-info component)] |
| 128 | + (vim-command component (format "let g:nvim_tcp_plugin_channel = %s" |
| 129 | + (first api-info)))))) |
128 | 130 | component))
|
129 | 131 |
|
130 | 132 | (defn new
|
131 |
| - "Connect to msgpack-rpc channel via standard io or TCP socket." |
132 |
| - ([] (new* System/in System/out false)) |
| 133 | + "Connect to msgpack-rpc channel via standard io, TCP socket, Unix domain |
| 134 | + sockets." |
| 135 | + ([] (new* System/in System/out true)) |
| 136 | + ([uds-filepath] |
| 137 | + (let [socket (UnixDomainSocketClient. uds-filepath JUDS/SOCK_STREAM)] |
| 138 | + (new* (.getInputStream socket) (.getOutputStream socket) true))) |
133 | 139 | ([host port]
|
134 | 140 | (log/info "plugin host connecting to nvim at " host ":" port)
|
135 | 141 | (let [socket (java.net.Socket. host port)]
|
|
0 commit comments