2019-11-04 08:54:04 +03:00
|
|
|
/+ *server,
|
|
|
|
auto=language-server-complete,
|
2019-11-12 14:46:09 +03:00
|
|
|
lsp-parser=language-server-parser,
|
2019-11-04 08:54:04 +03:00
|
|
|
easy-print=language-server-easy-print,
|
|
|
|
rune-snippet=language-server-rune-snippet
|
2019-11-04 06:18:40 +03:00
|
|
|
|%
|
|
|
|
:: +move: output effect
|
|
|
|
::
|
|
|
|
+$ move [bone card]
|
|
|
|
:: +card: output effect payload
|
|
|
|
::
|
|
|
|
+$ card
|
|
|
|
$% [%connect wire binding:eyre term]
|
|
|
|
[%disconnect wire binding:eyre]
|
|
|
|
[%http-response =http-event:http]
|
2019-11-12 14:46:09 +03:00
|
|
|
[%poke wire dock out-pokes]
|
2019-11-04 06:18:40 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-12 14:46:09 +03:00
|
|
|
+$ out-pokes [%kiln-commit term _|]
|
|
|
|
::
|
2019-11-04 06:18:40 +03:00
|
|
|
+$ lsp-req
|
2019-11-05 05:12:23 +03:00
|
|
|
$: uri=@t
|
|
|
|
$% [%sync changes=(list change)]
|
|
|
|
[%completion position]
|
2019-11-12 14:46:09 +03:00
|
|
|
[%commit @ud]
|
2019-11-12 18:57:01 +03:00
|
|
|
[%hover position]
|
2019-11-05 05:12:23 +03:00
|
|
|
==
|
2019-11-04 06:18:40 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-04 08:32:42 +03:00
|
|
|
+$ change
|
|
|
|
$: range=(unit range)
|
|
|
|
range-length=(unit @ud)
|
|
|
|
text=@t
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ range
|
|
|
|
$: start=position
|
|
|
|
end=position
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ position
|
|
|
|
[row=@ud col=@ud]
|
|
|
|
::
|
2019-11-05 05:12:23 +03:00
|
|
|
+$ state bufs=(map uri=@t buf=wall)
|
2019-11-04 06:18:40 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
|_ [bow=bowl:gall state]
|
|
|
|
::
|
|
|
|
++ this .
|
|
|
|
++ prep
|
|
|
|
|= old=(unit state)
|
|
|
|
^- (quip move _this)
|
|
|
|
~& > %lsp-prep
|
|
|
|
?~ old
|
|
|
|
:_ this
|
|
|
|
[ost.bow %connect / [~ /'~language-server-protocol'] %language-server]~
|
2019-11-05 05:12:23 +03:00
|
|
|
[~ this(bufs u.old)]
|
2019-11-04 06:18:40 +03:00
|
|
|
::
|
|
|
|
:: alerts us that we were bound.
|
|
|
|
::
|
|
|
|
++ bound
|
|
|
|
|= [wir=wire success=? binding=binding:eyre]
|
|
|
|
^- (quip move _this)
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
:: +poke-handle-http-request: received on a new connection established
|
|
|
|
::
|
2019-11-04 08:32:42 +03:00
|
|
|
++ parser
|
|
|
|
=, dejs:format
|
|
|
|
|^
|
2019-11-05 05:12:23 +03:00
|
|
|
%: ot
|
|
|
|
uri+so
|
|
|
|
:- %data
|
|
|
|
%- of
|
|
|
|
:~ sync+sync
|
|
|
|
completion+position
|
2019-11-12 14:46:09 +03:00
|
|
|
commit+ni
|
2019-11-12 18:57:01 +03:00
|
|
|
hover+position
|
2019-11-05 05:12:23 +03:00
|
|
|
==
|
|
|
|
~
|
2019-11-04 08:32:42 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ sync
|
|
|
|
%- ar
|
|
|
|
%: ou
|
|
|
|
range+(uf ~ (pe ~ range))
|
|
|
|
'rangeLength'^(uf ~ (pe ~ ni))
|
|
|
|
text+(un so)
|
|
|
|
~
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ range
|
|
|
|
%: ot
|
|
|
|
start+position
|
|
|
|
end+position
|
|
|
|
~
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ position
|
|
|
|
%: ot
|
|
|
|
line+ni
|
|
|
|
character+ni
|
|
|
|
~
|
|
|
|
==
|
|
|
|
--
|
2019-11-12 14:46:09 +03:00
|
|
|
::
|
|
|
|
++ json-response
|
|
|
|
|= jon=json
|
|
|
|
^- (list move)
|
|
|
|
:_ ~
|
|
|
|
:*
|
|
|
|
ost.bow
|
|
|
|
%http-response
|
|
|
|
(json-response:app (json-to-octs jon))
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ coup
|
|
|
|
|= [=wire saw=(unit tang)]
|
|
|
|
^- (quip move _this)
|
|
|
|
:_ this
|
|
|
|
~
|
|
|
|
::
|
2019-11-04 06:18:40 +03:00
|
|
|
++ poke-handle-http-request
|
|
|
|
%- (require-authorization:app ost.bow move this)
|
|
|
|
|= =inbound-request:eyre
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(^ body.request.inbound-request)
|
|
|
|
=/ =lsp-req
|
2019-11-04 08:32:42 +03:00
|
|
|
%- parser
|
|
|
|
(need (de-json:html q.u.body.request.inbound-request))
|
2019-11-05 05:12:23 +03:00
|
|
|
=/ buf (~(gut by bufs) uri.lsp-req *wall)
|
2019-11-12 14:46:09 +03:00
|
|
|
=^ moves buf
|
2019-11-05 05:12:23 +03:00
|
|
|
?- +<.lsp-req
|
|
|
|
%sync (handle-sync buf +>.lsp-req)
|
|
|
|
%completion (handle-completion buf +>.lsp-req)
|
2019-11-12 14:46:09 +03:00
|
|
|
%commit (handle-commit buf uri.lsp-req)
|
2019-11-12 18:57:01 +03:00
|
|
|
%hover (handle-hover buf +>.lsp-req)
|
2019-11-04 06:18:40 +03:00
|
|
|
==
|
2019-11-05 05:12:23 +03:00
|
|
|
=. bufs
|
|
|
|
(~(put by bufs) uri.lsp-req buf)
|
2019-11-12 14:46:09 +03:00
|
|
|
[moves this]
|
|
|
|
::
|
|
|
|
++ regen-diagnostics
|
|
|
|
|= buf=wall
|
|
|
|
^- json
|
|
|
|
=/ t=tape
|
|
|
|
(zing (join "\0a" buf))
|
|
|
|
=/ parse
|
|
|
|
(lily:auto t (lsp-parser *beam))
|
|
|
|
?: ?=(%| -.parse)
|
|
|
|
(format-diagnostic p.parse)
|
|
|
|
=, enjs:format
|
|
|
|
%- pairs
|
|
|
|
:~ good+b+&
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ format-diagnostic
|
|
|
|
|= [row=@ col=@]
|
|
|
|
^- json
|
|
|
|
=, enjs:format
|
|
|
|
%- pairs
|
|
|
|
:~ good+b+|
|
|
|
|
:+ %diagnostics %a :_ ~
|
|
|
|
=/ loc (pairs line+(numb (dec row)) character+(numb col) ~)
|
|
|
|
%- pairs
|
|
|
|
:~ range+(pairs start+loc end+loc ~)
|
|
|
|
severity+n+'1'
|
|
|
|
message+s+'syntax error'
|
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-commit
|
|
|
|
|= [buf=wall uri=@t]
|
|
|
|
^- [(list move) wall]
|
|
|
|
:_ buf
|
|
|
|
=/ jon
|
|
|
|
(regen-diagnostics buf)
|
|
|
|
:_ (json-response jon)
|
|
|
|
:*
|
|
|
|
ost.bow
|
|
|
|
%poke
|
|
|
|
/commit
|
|
|
|
[our.bow %hood]
|
|
|
|
%kiln-commit
|
|
|
|
q.byk.bow
|
|
|
|
|
|
|
|
|
==
|
2019-11-04 06:18:40 +03:00
|
|
|
::
|
2019-11-12 18:57:01 +03:00
|
|
|
++ handle-hover
|
|
|
|
|= [buf=wall row=@ud col=@ud]
|
|
|
|
^- [(list move) wall]
|
|
|
|
=/ txt
|
|
|
|
(zing (join "\0a" buf))
|
|
|
|
=+ (get-id:auto (get-pos buf row col) txt)
|
|
|
|
?~ id
|
|
|
|
[(json-response *json) buf]
|
2019-11-16 04:46:17 +03:00
|
|
|
=/ match=(unit [=term =type])
|
2019-11-12 18:57:01 +03:00
|
|
|
(search-exact:auto u.id (get-identifiers:auto -:!>(..zuse)))
|
|
|
|
?~ match
|
|
|
|
[(json-response *json) buf]
|
|
|
|
=/ contents
|
|
|
|
%- crip
|
|
|
|
;: weld
|
|
|
|
"`"
|
|
|
|
~(ram re ~(duck easy-print type.u.match))
|
|
|
|
"`"
|
|
|
|
==
|
|
|
|
:_ buf
|
|
|
|
%- json-response
|
|
|
|
%- pairs:enjs:format
|
|
|
|
[contents+s+contents ~]
|
|
|
|
::
|
2019-11-04 06:18:40 +03:00
|
|
|
++ handle-sync
|
2019-11-05 05:12:23 +03:00
|
|
|
|= [buf=wall changes=(list change)]
|
2019-11-12 14:46:09 +03:00
|
|
|
:- (json-response *json)
|
2019-11-04 08:32:42 +03:00
|
|
|
|- ^- wall
|
|
|
|
?~ changes
|
|
|
|
buf
|
|
|
|
?: ?|(?=(~ range.i.changes) ?=(~ range-length.i.changes))
|
|
|
|
=/ =wain (to-wain:format text.i.changes)
|
|
|
|
=. buf (turn wain trip)
|
|
|
|
$(changes t.changes)
|
|
|
|
=/ =tape (zing (join "\0a" buf))
|
2019-11-05 05:12:23 +03:00
|
|
|
=/ start-pos (get-pos buf start.u.range.i.changes)
|
|
|
|
=/ end-pos (get-pos buf end.u.range.i.changes)
|
2019-11-04 08:32:42 +03:00
|
|
|
=. tape
|
|
|
|
;: weld
|
|
|
|
(scag start-pos tape)
|
|
|
|
(trip text.i.changes)
|
|
|
|
(slag end-pos tape)
|
|
|
|
==
|
|
|
|
=. buf (to-wall tape)
|
|
|
|
$(changes t.changes)
|
|
|
|
::
|
|
|
|
++ to-wall
|
|
|
|
|= =tape
|
|
|
|
^- wall
|
|
|
|
%+ roll (flop tape)
|
|
|
|
|= [char=@tD =wall]
|
2019-11-04 06:18:40 +03:00
|
|
|
?~ wall
|
2019-11-04 08:32:42 +03:00
|
|
|
[[char ~] ~]
|
|
|
|
?: =('\0a' char)
|
|
|
|
[~ wall]
|
|
|
|
[[char i.wall] t.wall]
|
|
|
|
::
|
|
|
|
++ get-pos
|
2019-11-05 05:12:23 +03:00
|
|
|
|= [buf=wall position]
|
2019-11-04 08:32:42 +03:00
|
|
|
^- @ud
|
|
|
|
?~ buf
|
|
|
|
0
|
|
|
|
?: =(0 row)
|
|
|
|
col
|
|
|
|
%+ add +((lent i.buf)) :: +1 because newline
|
|
|
|
$(row (dec row), buf t.buf)
|
2019-11-04 06:18:40 +03:00
|
|
|
::
|
|
|
|
++ safe-sub
|
|
|
|
|= [a=@ b=@]
|
|
|
|
?: (gth b a)
|
|
|
|
0
|
|
|
|
(sub a b)
|
|
|
|
::
|
|
|
|
++ handle-completion
|
2019-11-05 05:12:23 +03:00
|
|
|
|= [buf=wall row=@ud col=@ud]
|
2019-11-12 14:46:09 +03:00
|
|
|
^- [(list move) wall]
|
2019-11-04 08:32:42 +03:00
|
|
|
=/ =tape (zing (join "\0a" buf))
|
2019-11-05 05:12:23 +03:00
|
|
|
=/ pos (get-pos buf row col)
|
2019-11-04 08:32:42 +03:00
|
|
|
:_ buf
|
|
|
|
:: Check if we're on a rune
|
|
|
|
::
|
2019-11-04 06:18:40 +03:00
|
|
|
=/ rune (swag [(safe-sub pos 2) 2] tape)
|
|
|
|
?: (~(has by runes:rune-snippet) rune)
|
2019-11-12 14:46:09 +03:00
|
|
|
(json-response (rune-snippet rune))
|
2019-11-04 08:32:42 +03:00
|
|
|
:: Don't run on large files because it's slow
|
|
|
|
::
|
|
|
|
?: (gth (lent buf) 1.000)
|
|
|
|
=, enjs:format
|
2019-11-12 14:46:09 +03:00
|
|
|
(json-response (pairs good+b+& result+~ ~))
|
2019-11-04 06:18:40 +03:00
|
|
|
::
|
|
|
|
=/ tl
|
2019-11-04 08:32:42 +03:00
|
|
|
(tab-list-tape:auto -:!>(..zuse) pos tape)
|
2019-11-04 06:18:40 +03:00
|
|
|
=, enjs:format
|
2019-11-12 14:46:09 +03:00
|
|
|
%- json-response
|
2019-11-04 06:18:40 +03:00
|
|
|
?: ?=(%| -.tl)
|
2019-11-12 18:57:01 +03:00
|
|
|
(format-diagnostic p.tl)
|
2019-11-04 06:18:40 +03:00
|
|
|
?~ p.tl
|
|
|
|
*json
|
|
|
|
%- pairs
|
|
|
|
:~ good+b+&
|
|
|
|
::
|
|
|
|
:- %result
|
|
|
|
%- pairs
|
|
|
|
:~ 'isIncomplete'^b+&
|
|
|
|
::
|
|
|
|
:- %items
|
|
|
|
:- %a
|
|
|
|
=/ lots (gth (lent u.p.tl) 10)
|
|
|
|
%- flop
|
|
|
|
%+ turn (scag 50 u.p.tl)
|
|
|
|
|= [=term =type]
|
|
|
|
?: lots
|
|
|
|
(frond label+s+term)
|
|
|
|
=/ detail (crip ~(ram re ~(duck easy-print type)))
|
|
|
|
(pairs label+s+term detail+s+detail ~)
|
|
|
|
==
|
|
|
|
==
|
|
|
|
--
|