urbit/pkg/arvo/lib
Philip Monk 76b917f426
dojo: add tab completion
This is initial support for type-aware tab completion.  When you hit tab, it tries to complete the word you're in the middle of using a face or arm in the subject at that point in the code.  It also shows all possible matches and their associated types.  It's nearly instantaneous.  Notes:

- It advances to the longest common prefix, so if you hit tab on `ab` and the only possible results are `abcde` and `abcdz`, then it'll write `abcd` and print both out (with their types).

- If there are fewer than ten matches, it prints the type along with the face.  Printing types is too slow to use all the time, but with 10 it's essentially instantaneous.

- The match closest in the subject to you (i.e. smallest axis number) is displayed lowest (closest to your focus).

Examples below, where `<TAB>` represents me hitting tab while my cursor is at that position (the line with the `<TAB>` is not preserved in the actual output).

```
~zod:dojo> eth<TAB>
-----
ethereum        #t/<11.qcl {<3.ltb 27.ipf 7.ecf 36.uek 92.bjk 247.ows 51.mvt 126.xjf 41.mac 1.ane $141> <21.yeb 27.ipf 7.ecf 36.uek 92.bjk 247.ows 51.mvt 126.xjf 41.mac 1.ane $141>}>
ethereum-types  #t/<3.ltb 27.ipf 7.ecf 36.uek 92.bjk 247.ows 51.mvt 126.xjf 41.mac 1.ane $141>
~zod:dojo> ethereum
~zod:dojo> |=  zong=@ud  z<TAB>
-----
zing  #t/<1.dqs {* <126.xjf 41.mac 1.ane $141>}>
zap   #t/<1.iot {tub/{p/{p/@ud q/@ud} q/""} <1.rff {daf/@t <247.ows 51.mvt 126.xjf 41.mac 1.ane $141>}>}>
zuse  #t/$309
zong  #t/@ud
~zod:dojo> |=  zong=@ud  zo<TAB>
-----
zong  #t/@ud
~zod:dojo> |=  zong=@ud  zong
~zod:dojo> <TAB>
hoon-version
trel
quip
pole
unit
qual
lone
... about 600 more lines ...
unity
html
zuse
eny
now
our
~zod:dojo>
```

Functionally, this is in a state where I'd be comfortable shipping it.  It doesn't interfere with anything if you don't press tab, and it's perfectly OTA-able.  I do think its output is a little verbose, but that can be tuned over time as people try it and determine what feels good in practice.

Additional notes:

- There are plenty of similar systems for other languages, but my most direct inspiration is Idris's editor tools.  This is implemented for the dojo, but I actually want it in my editor, which is why the meat is all defind in a library.  I've only tested on dojo one-liners, so I don't know the performance on large blocks of code.

- The default type printer isn't great for this use case.  In particular,
	- Cores should not print anything about their context
  - The `#t/` should go away
  - If it looks like a gate, we should print its return value
  - Maybe special handling for molds, but if the above is done, then for example `bone` is  `* -> @ud`.

- The worst part about our wing ordering is that it really screws up tab completion.  You want to do `point.owner-address` instead of `owner-address.point` because that lets you type `point.ow<TAB>`.  I weakly prefer reading it how we do it now, but it's really not great.  You could do an (dojo-specific?) alternate syntax of `point;owner-address`; this is a simple transformation.

- Regardless of the above, this should handle the case where we're in the middle of defining a wing; it doesn't right now.

- When a variable is shadowed, we show both of them.  We should probably show the shadowed one with a `^`.

- We probably shouldn't print out hundreds of results.  Maybe just the closest 50 with ellipses.

- This gets you any face in your subject, regardless of whether its type is reasonable.  We could limit that some by copying the `gol` logic in mint, so that if the pseudo-backward-inference engine happens to know what type it should be, you can filter the tab results according to if they nest in that type.  This would be "strongly type-aware".
2019-10-30 23:19:25 -07:00
..
bip39 Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
chat chat-cli: Cosmetic improvements 2019-10-08 23:00:46 +02:00
hood dojo: add tab completion 2019-10-30 23:19:25 -07:00
ph gall: unsubscribe after breach 2019-09-24 15:00:16 -07:00
test Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
async.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
auto.hoon dojo: add tab completion 2019-10-30 23:19:25 -07:00
base64.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
bip32.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
bip39.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
chat-json.hoon apps: added permission hook and chat-view %join action 2019-10-11 14:09:30 -07:00
chat.hoon chat: message processing time down to 60ms 2019-09-20 11:43:30 -02:30
cram.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
der.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
elem-to-react-json.hoon Replace (fall (~(get by calls with (~(gut by 2019-06-30 18:13:34 +02:00
eth-watcher.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
frontmatter.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
generators.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
group-json.hoon apps: added group/permission stores, hooks, marks 2019-09-30 14:46:07 -07:00
hall-json.hoon zuse: added path, tank, string utils to en/dejs 2019-09-30 01:31:46 +04:00
hall-legacy.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
hall.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
jose.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
keygen.hoon keygen: Add ownership-from-ticket function 2019-10-09 21:19:04 +02:00
number-to-words.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
old-phon.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
permission-json.hoon apps: added group/permission stores, hooks, marks 2019-09-30 14:46:07 -07:00
ph.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
pill.hoon dill, helm: add lite boot option with -l 2019-08-26 11:04:24 -07:00
pkcs.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
pprint.hoon hoon: moves new pretty-printer back into userspace 2019-10-17 17:52:45 -07:00
pretty-file.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
primitive-rsa.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
publish.hoon Move :publish app state type into app itself 2019-08-11 12:21:39 -07:00
rekey.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
ring.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
server.hoon Updated timer and chat app, server and eyre with latest 2019-07-12 11:04:47 -07:00
show-dir.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
sole.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
stdio.hoon add +scry to lib/stdio 2019-08-12 13:50:14 -07:00
tapp.hoon add +scry to lib/stdio 2019-08-12 13:50:14 -07:00
test.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
time-to-id.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
tree.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
urb-split.hoon Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8' 2019-06-28 12:48:05 +08:00
xray.hoon hoon: moves new pretty-printer back into userspace 2019-10-17 17:52:45 -07:00