Merge branch 'liam-fitzgerald/tab-complete-chat' (#1995)

* liam-fitzgerald/tab-complete-chat:
  chat-cli: update tab-complete to static gall
  chat-cli: autocomplete on empty command
  chat-cli: use tall-form cencab
  chat-cli: clarify tab completion suggestions
  chat-cli: address style issues
  chat-cli: add tab autocomplete
  language-server: genericise searching gates

Signed-off-by: Jared Tobin <jared@tlon.io>
This commit is contained in:
Jared Tobin 2019-12-05 16:43:37 +08:00
commit 834cd78a1b
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4
3 changed files with 83 additions and 18 deletions

View File

@ -12,7 +12,8 @@
/- *chat-store, *chat-view, *chat-hook,
*permission-store, *group-store, *invite-store,
sole-sur=sole
/+ sole-lib=sole, chat-eval, default-agent, verb
/+ sole-lib=sole, chat-eval, default-agent, verb,
auto=language-server-complete
::
|%
+$ card card:agent:gall
@ -350,7 +351,62 @@
%det (edit +.dat.act)
%clr [~ all-state]
%ret obey
%tab [~ all-state]
%tab (tab +.dat.act)
==
:: +tab-list: static list of autocomplete entries
++ tab-list
^- (list (option:auto tank))
:~
[%join leaf+";join ~ship/chat-name (glyph)"]
[%leave leaf+";leave ~ship/chat-name"]
::
[%create leaf+";create [type] /chat-name (glyph)"]
[%delete leaf+";delete /chat-name"]
[%invite leaf+";invite [rw | r | w] /chat-name ~ships"]
[%banish leaf+";banish [rw | r | w] /chat-name ~ships"]
::
[%bind leaf+";bind [glyph] ~ship/chat-name"]
[%unbind leaf+";unbind [glyph]"]
[%what leaf+";what (~ship/chat-name) (glyph)"]
::
[%settings leaf+";settings"]
[%set leaf+";set key (value)"]
[%unset leaf+";unset key"]
::
[%chats leaf+";chats"]
[%help leaf+";help"]
==
++ tab
|= pos=@ud
^- (quip card state)
?. =(';' (snag 0 buf.state.cli))
[~ all-state]
=+ (get-id:auto pos (tufa buf.state.cli))
=/ needle=term
(fall id '')
?: &(!=(pos 1) =(0 (met 3 needle)))
[~ all-state] :: autocomplete empty command iff user at start of command
=/ options=(list (option:auto tank))
(search-prefix:auto needle tab-list)
=/ advance=term
(longest-match:auto options)
=/ to-send=tape
(trip (rsh 3 (met 3 needle) advance))
=/ send-pos
(add pos (met 3 (fall forward '')))
=| moves=(list card)
=? moves ?=(^ options)
[(tab:sh-out options) moves]
=| fxs=(list sole-effect:sole-sur)
|-
?~ to-send
[(flop moves) all-state]
=^ char state.cli
(~(transmit sole-lib state.cli) [%ins send-pos `@c`i.to-send])
%_ $
moves [(effect:sh-out %det char) moves]
send-pos +(send-pos)
to-send t.to-send
==
:: +edit: apply sole edit
::
@ -982,6 +1038,12 @@
^- card
::TODO don't hard-code session id 'drum' here
[%give %fact `/sole/drum %sole-effect !>(fec)]
:: +tab: print tab-complete list
::
++ tab
|= options=(list [cord tank])
^- card
(effect %tab options)
:: +print: puts some text into the cli as-is
::
++ print

View File

@ -212,7 +212,7 @@
=+ (get-id:auto (get-pos buf row col) txt)
?~ id
[(json-response eyre-id *json) buf]
=/ match=(unit [=term =type])
=/ match=(unit (option:auto type))
(search-exact:auto u.id (get-identifiers:auto -:!>(..zuse)))
?~ match
[(json-response eyre-id *json) buf]
@ -220,7 +220,7 @@
%- crip
;: weld
"`"
~(ram re ~(duck easy-print type.u.match))
~(ram re ~(duck easy-print detail.u.match))
"`"
==
:_ buf

View File

@ -3,7 +3,8 @@
::
=/ debug |
|%
+$ ids (list [=term =type])
+* option [item]
[=term detail=item]
::
:: Like +rose except also produces line number
::
@ -21,7 +22,7 @@
++ get-identifiers
|= ty=type
%- flop
|- ^- ids
|- ^- (list (option type))
?- ty
%noun ~
%void ~
@ -36,7 +37,7 @@
:_ ?. ?=(%gold r.p.q.ty)
~
$(ty p.ty)
^- (list (pair term type))
^- (list (option type))
%- zing
%+ turn ~(tap by q.r.q.ty)
|= [term =tome]
@ -69,11 +70,10 @@
==
::
++ search-exact
|= [sid=term ids=(list [term type])]
^- (unit [term type])
=/ match=(list [term type])
%+ skim ids
|= [id=term ty=type]
|* [sid=term options=(list (option))]
=/ match
%+ skim options
|= [id=term *]
=(sid id)
?~ match
~
@ -82,16 +82,16 @@
:: Get all the identifiers that start with sid.
::
++ search-prefix
|= [sid=term =ids]
^- (list [term type])
|* [sid=term ids=(list (option))]
^+ ids
%+ skim ids
|= [id=term ty=type]
|= [id=term *]
=(sid (end 3 (met 3 sid) id))
::
:: Get the longest prefix of a list of identifiers.
::
++ longest-match
|= matches=(list [=term =type])
|= matches=(list (option))
^- term
?~ matches
''
@ -307,7 +307,9 @@
|= [sut=type gen=hoon]
%+ bind (find-type-mule sut gen)
|= [id=term typ=type]
(longest-match (search-prefix id (get-identifiers typ)))
=/ matches=(list (option type))
(search-prefix id (get-identifiers typ))
(longest-match matches)
::
:: Same as +advance-hoon, but takes a position and text directly.
::
@ -322,6 +324,7 @@
::
++ tab-list-hoon
|= [sut=type gen=hoon]
^- (unit (list (option type)))
%+ bind (find-type-mule sut gen)
|= [id=term typ=type]
(search-prefix id (get-identifiers typ))
@ -330,7 +333,7 @@
::
++ tab-list-tape
|= [sut=type pos=@ud code=tape]
^- (each (unit ids) [row=@ col=@])
^- (each (unit (list (option type))) [row=@ col=@])
~? > debug %start-magick
=/ magicked txt:(insert-magic pos code)
~? > debug %start-parsing