@@ -79,15 +79,6 @@ local build_cmd = function(obj)
7979 table.insert (opts , obj .bind )
8080 end
8181
82- if obj .host ~= nil or obj .connect ~= nil then
83- table.insert (opts ," -c" )
84- end
85-
86- if obj .host ~= nil then
87- table.insert (opts ," -h" )
88- table.insert (opts , obj .host )
89- end
90-
9182 return opts
9283end
9384
@@ -102,17 +93,13 @@ nrepl.default_middlewares = {'nrepl/nrepl', 'cider/cider-nrepl', 'refactor-nrepl
10293-- @tparam [opt] string obj.pwd Path where the nrepl process will be started
10394-- @tparam [opt] table obj.middlewares List of middlewares.
10495-- @tparam [opt] string obj.alias aliases on the local deps.edn
105- -- @tparam [opt] string obj.connect -c parameter for the nrepl process
96+ -- @tparam [opt] int obj.port -p parameter for the nrepl process
10697-- @tparam [opt] string obj.bind -b parameter for the nrepl process
10798-- @tparam [opt] boolean obj.skip_autocmd don't fire an autocmd after starting this repl
10899-- @tparam [opt] boolean obj.disable_output_capture disables output capturing.
109100-- @treturn boolean Whether it was possible to spawn a nrepl process
110101nrepl .start = function (obj )
111- local pwd = obj .pwd or vim .api .nvim_call_function (" getcwd" , {})
112-
113- if not utils .ends_with (pwd , " /" ) then
114- pwd = pwd .. " /"
115- end
102+ local pwd = utils .ensure_path (obj .pwd or vim .api .nvim_call_function (" getcwd" , {}))
116103
117104 local selected = obj .middlewares or nrepl .default_middlewares
118105 local bind = obj .bind
@@ -121,8 +108,6 @@ nrepl.start = function(obj)
121108 port = obj .port ,
122109 alias = obj .alias ,
123110 bind = obj .bind ,
124- host = obj .host ,
125- connect = obj .connect ,
126111 deps_file = obj .deps_file
127112 }
128113
@@ -139,7 +124,7 @@ nrepl.start = function(obj)
139124
140125 if ret <= 0 then
141126 -- TODO log, inform..
142- return
127+ return false
143128 end
144129
145130 local conn = {bind , obj .port }
@@ -155,12 +140,49 @@ nrepl.start = function(obj)
155140 nrepl .cache [pwd ].id = conn_id
156141
157142 job_mapping [ret ] = {pwd = pwd , conn = conn_id , init = false }
158- if obj .disable_output_capture == false then
143+
144+ if not obj .disable_output_capture then
159145 output .buffer (conn_id )
160146 end
161147 return true
162148end
163149
150+ nrepl .bbnrepl = function (obj )
151+ local pwd = utils .ensure_path (obj .pwd or vim .api .nvim_call_function (" getcwd" , {}))
152+
153+ obj .port = obj .port or " 1667"
154+
155+ local cmd = {
156+ " bb" , " --nrepl-server" , obj .port
157+ }
158+
159+ local ret = nvim .nvim_call_function (' jobstart' , {
160+ cmd , {
161+ on_exit = " AcidJobCleanup" ,
162+ cwd = pwd
163+ }
164+ })
165+
166+ if ret <= 0 then
167+ -- TODO log, inform..
168+ return false
169+ end
170+
171+ local conn = {" 127.0.0.1" , obj .port }
172+
173+ nrepl .cache [pwd ] = {
174+ skip_autocmd = true ,
175+ job = ret ,
176+ addr = conn
177+ }
178+
179+ local conn_id = connections .add (conn )
180+ connections .select (obj .pwd , conn_id )
181+
182+ nrepl .cache [pwd ].id = conn_id
183+
184+ end
185+
164186--- Stops a nrepl process managed by acid
165187-- @tparam table obj Configuration for the nrepl process to be stopped
166188-- @tparam string obj.pwd Path where the nrepl process was started
0 commit comments