mirror of
https://github.com/urbit/shrub.git
synced 2025-01-05 11:09:30 +03:00
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:
commit
834cd78a1b
@ -12,7 +12,8 @@
|
|||||||
/- *chat-store, *chat-view, *chat-hook,
|
/- *chat-store, *chat-view, *chat-hook,
|
||||||
*permission-store, *group-store, *invite-store,
|
*permission-store, *group-store, *invite-store,
|
||||||
sole-sur=sole
|
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
|
+$ card card:agent:gall
|
||||||
@ -350,7 +351,62 @@
|
|||||||
%det (edit +.dat.act)
|
%det (edit +.dat.act)
|
||||||
%clr [~ all-state]
|
%clr [~ all-state]
|
||||||
%ret obey
|
%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
|
:: +edit: apply sole edit
|
||||||
::
|
::
|
||||||
@ -982,6 +1038,12 @@
|
|||||||
^- card
|
^- card
|
||||||
::TODO don't hard-code session id 'drum' here
|
::TODO don't hard-code session id 'drum' here
|
||||||
[%give %fact `/sole/drum %sole-effect !>(fec)]
|
[%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: puts some text into the cli as-is
|
||||||
::
|
::
|
||||||
++ print
|
++ print
|
||||||
|
@ -212,7 +212,7 @@
|
|||||||
=+ (get-id:auto (get-pos buf row col) txt)
|
=+ (get-id:auto (get-pos buf row col) txt)
|
||||||
?~ id
|
?~ id
|
||||||
[(json-response eyre-id *json) buf]
|
[(json-response eyre-id *json) buf]
|
||||||
=/ match=(unit [=term =type])
|
=/ match=(unit (option:auto type))
|
||||||
(search-exact:auto u.id (get-identifiers:auto -:!>(..zuse)))
|
(search-exact:auto u.id (get-identifiers:auto -:!>(..zuse)))
|
||||||
?~ match
|
?~ match
|
||||||
[(json-response eyre-id *json) buf]
|
[(json-response eyre-id *json) buf]
|
||||||
@ -220,7 +220,7 @@
|
|||||||
%- crip
|
%- crip
|
||||||
;: weld
|
;: weld
|
||||||
"`"
|
"`"
|
||||||
~(ram re ~(duck easy-print type.u.match))
|
~(ram re ~(duck easy-print detail.u.match))
|
||||||
"`"
|
"`"
|
||||||
==
|
==
|
||||||
:_ buf
|
:_ buf
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
::
|
::
|
||||||
=/ debug |
|
=/ debug |
|
||||||
|%
|
|%
|
||||||
+$ ids (list [=term =type])
|
+* option [item]
|
||||||
|
[=term detail=item]
|
||||||
::
|
::
|
||||||
:: Like +rose except also produces line number
|
:: Like +rose except also produces line number
|
||||||
::
|
::
|
||||||
@ -21,7 +22,7 @@
|
|||||||
++ get-identifiers
|
++ get-identifiers
|
||||||
|= ty=type
|
|= ty=type
|
||||||
%- flop
|
%- flop
|
||||||
|- ^- ids
|
|- ^- (list (option type))
|
||||||
?- ty
|
?- ty
|
||||||
%noun ~
|
%noun ~
|
||||||
%void ~
|
%void ~
|
||||||
@ -36,7 +37,7 @@
|
|||||||
:_ ?. ?=(%gold r.p.q.ty)
|
:_ ?. ?=(%gold r.p.q.ty)
|
||||||
~
|
~
|
||||||
$(ty p.ty)
|
$(ty p.ty)
|
||||||
^- (list (pair term type))
|
^- (list (option type))
|
||||||
%- zing
|
%- zing
|
||||||
%+ turn ~(tap by q.r.q.ty)
|
%+ turn ~(tap by q.r.q.ty)
|
||||||
|= [term =tome]
|
|= [term =tome]
|
||||||
@ -69,11 +70,10 @@
|
|||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ search-exact
|
++ search-exact
|
||||||
|= [sid=term ids=(list [term type])]
|
|* [sid=term options=(list (option))]
|
||||||
^- (unit [term type])
|
=/ match
|
||||||
=/ match=(list [term type])
|
%+ skim options
|
||||||
%+ skim ids
|
|= [id=term *]
|
||||||
|= [id=term ty=type]
|
|
||||||
=(sid id)
|
=(sid id)
|
||||||
?~ match
|
?~ match
|
||||||
~
|
~
|
||||||
@ -82,16 +82,16 @@
|
|||||||
:: Get all the identifiers that start with sid.
|
:: Get all the identifiers that start with sid.
|
||||||
::
|
::
|
||||||
++ search-prefix
|
++ search-prefix
|
||||||
|= [sid=term =ids]
|
|* [sid=term ids=(list (option))]
|
||||||
^- (list [term type])
|
^+ ids
|
||||||
%+ skim ids
|
%+ skim ids
|
||||||
|= [id=term ty=type]
|
|= [id=term *]
|
||||||
=(sid (end 3 (met 3 sid) id))
|
=(sid (end 3 (met 3 sid) id))
|
||||||
::
|
::
|
||||||
:: Get the longest prefix of a list of identifiers.
|
:: Get the longest prefix of a list of identifiers.
|
||||||
::
|
::
|
||||||
++ longest-match
|
++ longest-match
|
||||||
|= matches=(list [=term =type])
|
|= matches=(list (option))
|
||||||
^- term
|
^- term
|
||||||
?~ matches
|
?~ matches
|
||||||
''
|
''
|
||||||
@ -307,7 +307,9 @@
|
|||||||
|= [sut=type gen=hoon]
|
|= [sut=type gen=hoon]
|
||||||
%+ bind (find-type-mule sut gen)
|
%+ bind (find-type-mule sut gen)
|
||||||
|= [id=term typ=type]
|
|= [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.
|
:: Same as +advance-hoon, but takes a position and text directly.
|
||||||
::
|
::
|
||||||
@ -322,6 +324,7 @@
|
|||||||
::
|
::
|
||||||
++ tab-list-hoon
|
++ tab-list-hoon
|
||||||
|= [sut=type gen=hoon]
|
|= [sut=type gen=hoon]
|
||||||
|
^- (unit (list (option type)))
|
||||||
%+ bind (find-type-mule sut gen)
|
%+ bind (find-type-mule sut gen)
|
||||||
|= [id=term typ=type]
|
|= [id=term typ=type]
|
||||||
(search-prefix id (get-identifiers typ))
|
(search-prefix id (get-identifiers typ))
|
||||||
@ -330,7 +333,7 @@
|
|||||||
::
|
::
|
||||||
++ tab-list-tape
|
++ tab-list-tape
|
||||||
|= [sut=type pos=@ud code=tape]
|
|= [sut=type pos=@ud code=tape]
|
||||||
^- (each (unit ids) [row=@ col=@])
|
^- (each (unit (list (option type))) [row=@ col=@])
|
||||||
~? > debug %start-magick
|
~? > debug %start-magick
|
||||||
=/ magicked txt:(insert-magic pos code)
|
=/ magicked txt:(insert-magic pos code)
|
||||||
~? > debug %start-parsing
|
~? > debug %start-parsing
|
||||||
|
Loading…
Reference in New Issue
Block a user