Skip to content

Commit edde443

Browse files
authored
Port to lua (#31)
* Bump nrepl-python-client * Major overhaul This is still experimental, but simplifies handling so commands and handlers are implemented in lua instead of python * Proceed with lua hardwork * Implement some handlers in lua + better internal mechanisms * Allow a command to be supplied * Several corrections * Implement require feature * Enhancements to connections/nrepl * Add back require autocmd * Refactor handlers into middlewares So they can be composed better * Avoid connection errors * Allow clearing virtualtexts * Don't log 'changed-namespaces' * Fix getcwd * Add frontend functions * Make frontend fns available * Rename all files in sequence * Use line number instead of line index * Expose more features throguh viml functions/commands * Add configuration mechanism Now features and middlewares are indirectly bound throught configration. This also allows tight control over the behavior of individual middlewares, middleware composition and a lot of good stuff. * Don't expose 'extract' function * Rename var * Add import, add-require and sort-requires commands * Allow refactoring and other stuff * Improvements to virtualtext * Bump nrepl middlewares * Allow more options on built command * Use string.sub instead of str:sub This makes easier to spot when a non-string argument is supplied * Allow python counterpart to make use of lua connection state * Fix migration to obj * Saving state * General improvments * Better ns handling * Remove config and make middlewares simpler * Add eval function that insert the result into the buffer * Tweak path finding * Add docs * Add go to definition * Add doc generation * Cleanup on python side Also, expose a couple of old commands as revamped functions * Update docs * Cleanup and fixes on the provided functions * Change do_require so the API is kept * Document features * Update README.md
1 parent 1a91af6 commit edde443

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2055
-2141
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "deps/nrepl-python-client"]
22
path = deps/nrepl-python-client
33
url = https://github.com/clojure-vim/nrepl-python-client.git
4-
[submodule "deps/zen.nvim"]
5-
path = deps/zen.nvim
6-
url = https://github.com/hkupty/zen.nvim

API.md

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
# acid.connections
2+
low-level connection handler
3+
4+
## `add(this, addr)`
5+
Stores connection for reuse later
6+
7+
this **(table)**: Connections object.
8+
9+
addr **({string,string})**: Address tuple with ip and port.
10+
11+
12+
## `select(this, pwd, ix)`
13+
Elects selected connection as primary (thus default) for a certain address
14+
15+
this **(table)**: Connections object.
16+
17+
pwd **(string)**: path (usually project root).
18+
Assumed to be neovim's `pwd`.
19+
20+
ix **(int)**: index of the stored connection
21+
22+
23+
## `unselect(this, pwd)`
24+
Dissociates the connection for the given path
25+
26+
this **(table)**: Connections object.
27+
28+
pwd **(string)**: path (usually project root).
29+
30+
31+
## `get(this, pwd)`
32+
Return active connection for the given path
33+
34+
this **(table)**: Connections object.
35+
36+
pwd **(string)**: path (usually project root).
37+
38+
39+
**({string,string})** Connection tuple with ip and port.
40+
41+
42+
---
43+
44+
# acid.core
45+
low-level connection handler.
46+
47+
## `send([conn], obj, handler)`
48+
Forward messages to the nrepl and registers the handler.
49+
50+
*conn* **({string,string})**: Ip and Port tuple. Will try to get one if nil.
51+
52+
obj **(table)**: Payload to be sent to the nrepl.
53+
54+
handler **(function)**: Handler function to deal with the response.
55+
56+
57+
---
58+
59+
# acid.features
60+
User-facing features and runnable commands
61+
62+
## `eval_cmdline(code[, ns])`
63+
Evaluate the given code and insert the result at the cursor position
64+
65+
code **(string)**: Clojure s-expression to be evaluated on the nrepl
66+
67+
*ns* **(string)**: Namespace to be used when evaluating the code.
68+
Defaults to current file's ns.
69+
70+
71+
## `eval_expr([mode[, ns]])`
72+
Evaluate the current form or the given motion.
73+
74+
*mode* **(string)**: motion mode
75+
76+
*ns* **(string)**: Namespace to be used when evaluating the code.
77+
Defaults to current file's ns.
78+
79+
80+
## `do_require([ns[, ...]])`
81+
Sends a `(require '[...])` function to the nrepl.
82+
83+
*ns* **(string)**: Namespace to be used when evaluating the code.
84+
Defaults to current file's ns.
85+
86+
*...*: extra arguments to the require function
87+
88+
89+
## `do_import(java_ns, symbols)`
90+
Sends a `(import '[...])` function to the nrepl.
91+
92+
java_ns **(string)**: Namespace of the java symbols that are being imported.
93+
94+
symbols **({string,...})**: List of java symbols to be imported
95+
96+
97+
## `go_to([symbol[, ns]])`
98+
Navigates the the definition of the given symbol.
99+
100+
*symbol* **(string)**: Symbol to navigate to. Defaults to symbol under
101+
cursor.
102+
103+
*ns* **(string)**: Namespace to be used when evaluating the code.
104+
Defaults to current file's ns.
105+
106+
107+
## `docs([symbol[, ns]])`
108+
Shows the docstring of the given symbol.
109+
110+
*symbol* **(string)**: Symbol which docs will be shown. Defaults to symbol under cursor.
111+
112+
*ns* **(string)**: Namespace to be used when evaluating the code.
113+
Defaults to current file's ns.
114+
115+
116+
## `preload()`
117+
Inject some clojure files into the nrepl sesion.
118+
119+
120+
## `load_all_nss()`
121+
Load all namespaces in the current session.
122+
123+
124+
## `add_require(req)`
125+
Refactor the current file to include the given argument in the
126+
`(:requires ...)` section.
127+
128+
req **(string)**: require vector, such as `[clojure.string :as str]`.
129+
130+
131+
## `remove_require(req)`
132+
Refactor the current file to remove the given argument from the
133+
`(:requires ...)` section.
134+
135+
req **(string)**: require namespace, such as `clojure.string`.
136+
137+
138+
## `sort_requires()`
139+
Refactor the current file so the `(:require ...)` form is sorted.
140+
141+
142+
---
143+
144+
# acid.forms
145+
Forms extraction
146+
147+
## `get_form_boundaries()`
148+
Returns the coordinates for the boundaries of the current form
149+
150+
151+
**(table)** coordinates {from = {row,col}, to = {row,col}}
152+
153+
154+
## `form_under_cursor()`
155+
Extracts the innermost form under the cursor
156+
157+
158+
**(string)** symbol under cursor
159+
160+
**(table)** coordinates {from = {row,col}, to = {row,col}}
161+
162+
163+
## `symbol_under_cursor()`
164+
Extracts the symbol under the cursor
165+
166+
167+
**(string)** symbol under cursor
168+
169+
**(table)** coordinates {from = {row,col}, to = {row,col}}
170+
171+
172+
---
173+
174+
# acid
175+
Frontend module with most relevant functions
176+
177+
## `connected([pwd])`
178+
Checks whether a connection exists for supplied path or not.
179+
180+
*pwd* **(string)**: Path bound to connection.
181+
Will call `getcwd` on neovim if not supplied
182+
183+
184+
**(boolean)** Whether a connection exists or not.
185+
186+
187+
## `run(cmd, conn)`
188+
Façade to core.send
189+
190+
cmd: A command (op + payload + handler) to be executed.
191+
192+
conn: A connection where this command will be run.
193+
194+
195+
## `callback(session, ret)`
196+
Callback proxy for handling command responses
197+
198+
session: Session ID for matching response with request
199+
200+
ret: The response from nrepl
201+
202+
203+
---
204+
205+
# acid.nrepl
206+
nRepl connectivity
207+
208+
## `middlewares`
209+
List of supported middlewares and the wrappers to invoke when spawning a nrepl process.
210+
211+
Values:
212+
213+
* `[nrepl/nrepl]`
214+
215+
## `default_middlewares`
216+
Default middlewares that will be used by the nrepl server
217+
218+
Values:
219+
220+
* `nrepl/nrepl`
221+
* `cider/cider-nrepl`
222+
* `refactor-nrepl`
223+
224+
## `start(obj)`
225+
Starts a tools.deps nrepl server
226+
227+
obj **(table)**: Configuration for the nrepl process to be spawn
228+
229+
Parameters for table `obj` are:
230+
231+
* obj.pwd **(string)**: Path where the nrepl process will be started
232+
* *obj.middlewares* **(table)**: List of middlewares.
233+
* *obj.alias* **(string)**: alias on the local deps.edn
234+
* *obj.connect* **(string)**: -c parameter for the nrepl process
235+
* *obj.bind* **(string)**: -b parameter for the nrepl process
236+
237+
**(boolean)** Whether it was possible to spawn a nrepl process
238+
239+
240+
## `stop(obj)`
241+
Stops a nrepl process managed by acid
242+
243+
obj **(table)**: Configuration for the nrepl process to be stopped
244+
245+
Parameters for table `obj` are:
246+
247+
* obj.pwd **(string)**: Path where the nrepl process was started
248+
249+
## `show([ch])`
250+
Debugs nrepl connection by returning the captured output
251+
252+
*ch* **(int)**: Neovim's job id of given nrepl process. When not supplied return all.
253+
254+
255+
**(table)** table with the captured outputs for given (or all) nrepl process(es).
256+

DESIGN.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)