2020-01-03 15:04:53 +03:00
|
|
|
/- lsp-sur=language-server
|
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,
|
2019-11-05 10:42:59 +03:00
|
|
|
rune-snippet=language-server-rune-snippet,
|
2020-01-08 03:41:29 +03:00
|
|
|
build=language-server-build,
|
2019-11-05 10:42:59 +03:00
|
|
|
default-agent
|
2019-11-04 06:18:40 +03:00
|
|
|
|%
|
2019-11-19 07:36:21 +03:00
|
|
|
+$ card card:agent:gall
|
2019-11-05 10:42:59 +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]
|
|
|
|
::
|
2020-01-13 08:27:42 +03:00
|
|
|
+$ state-zero
|
|
|
|
$: %0
|
|
|
|
bufs=(map uri=@t buf=wall)
|
|
|
|
builds=(map uri=@t =vase)
|
|
|
|
ford-diagnostics=(map uri=@t (list diagnostic:lsp-sur))
|
2020-01-31 06:19:19 +03:00
|
|
|
preludes=(map uri=@t type)
|
2020-01-13 08:27:42 +03:00
|
|
|
==
|
2020-01-08 03:41:29 +03:00
|
|
|
+$ versioned-state
|
|
|
|
$%
|
|
|
|
state-zero
|
|
|
|
==
|
2019-11-04 06:18:40 +03:00
|
|
|
--
|
2019-11-19 07:36:21 +03:00
|
|
|
^- agent:gall
|
2020-01-08 03:41:29 +03:00
|
|
|
=| state-zero
|
2019-11-07 09:19:32 +03:00
|
|
|
=* state -
|
|
|
|
=<
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2019-11-07 09:19:32 +03:00
|
|
|
+* this .
|
|
|
|
lsp-core +>
|
|
|
|
lsp ~(. lsp-core bowl)
|
2019-11-09 00:56:35 +03:00
|
|
|
def ~(. (default-agent this %|) bowl)
|
2019-11-05 10:42:59 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-init
|
2019-11-19 07:36:21 +03:00
|
|
|
^+ on-init:*agent:gall
|
2019-11-05 10:42:59 +03:00
|
|
|
^- (quip card _this)
|
|
|
|
~& > %lsp-init
|
|
|
|
:_ this :_ ~
|
|
|
|
:* %pass /connect
|
|
|
|
%arvo %e
|
|
|
|
%connect [~ /'~language-server-protocol'] %language-server
|
|
|
|
==
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
2019-11-19 07:36:21 +03:00
|
|
|
^+ on-load:*agent:gall
|
2019-11-05 10:42:59 +03:00
|
|
|
|= old-state=vase
|
|
|
|
^- (quip card _this)
|
|
|
|
~& > %lsp-upgrade
|
2020-01-20 06:20:04 +03:00
|
|
|
[~ this(state *state-zero)]
|
2019-11-05 10:42:59 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-poke
|
2019-11-19 07:36:21 +03:00
|
|
|
^+ on-poke:*agent:gall
|
2019-11-05 10:42:59 +03:00
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ mark (on-poke:def mark vase)
|
2020-01-13 08:27:42 +03:00
|
|
|
%language-server-rpc-notification
|
|
|
|
(on-notification:lsp !<(all:notification:lsp-sur vase))
|
2020-01-03 15:04:53 +03:00
|
|
|
%language-server-rpc-request
|
2020-01-13 08:27:42 +03:00
|
|
|
(on-request:lsp !<(all:request:lsp-sur vase))
|
2019-11-05 10:42:59 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2019-11-24 10:41:46 +03:00
|
|
|
++ on-watch
|
|
|
|
|= =path
|
2020-01-03 09:19:16 +03:00
|
|
|
?: ?=([%primary ~] path)
|
2020-01-27 05:18:48 +03:00
|
|
|
`this
|
2019-11-24 10:41:46 +03:00
|
|
|
?. ?=([%http-response @ ~] path)
|
|
|
|
(on-watch:def path)
|
|
|
|
`this
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-leave on-leave:def
|
2020-01-20 06:19:08 +03:00
|
|
|
++ on-peek on-peek:def
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-arvo
|
2019-11-19 07:36:21 +03:00
|
|
|
^+ on-arvo:*agent:gall
|
2019-11-05 10:42:59 +03:00
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
2020-01-08 03:41:29 +03:00
|
|
|
?+ sign-arvo (on-arvo:def wire sign-arvo)
|
|
|
|
[%e %bound *] `state
|
2020-05-14 09:26:52 +03:00
|
|
|
[%c *] (handle-build:lsp wire +.sign-arvo)
|
2019-11-05 10:42:59 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-fail on-fail:def
|
2019-11-05 10:42:59 +03:00
|
|
|
--
|
2019-11-04 06:18:40 +03:00
|
|
|
::
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ bow=bowl:gall
|
2019-11-04 06:18:40 +03:00
|
|
|
::
|
2019-11-12 14:46:09 +03:00
|
|
|
++ json-response
|
2019-11-24 10:41:46 +03:00
|
|
|
|= [eyre-id=@ta jon=json]
|
|
|
|
^- (list card)
|
2020-08-27 17:18:10 +03:00
|
|
|
(give-simple-payload:app eyre-id (json-response:gen jon))
|
2019-11-12 14:46:09 +03:00
|
|
|
::
|
2020-01-08 03:41:29 +03:00
|
|
|
++ give-rpc-notification
|
2020-01-13 08:27:42 +03:00
|
|
|
|= res=out:notification:lsp-sur
|
2020-01-03 15:04:53 +03:00
|
|
|
^- (list card)
|
|
|
|
:_ ~
|
2020-01-27 05:18:48 +03:00
|
|
|
[%give %fact ~[/primary] %language-server-rpc-notification !>(res)]
|
2020-01-03 15:04:53 +03:00
|
|
|
::
|
2020-01-13 08:27:42 +03:00
|
|
|
++ on-notification
|
|
|
|
|= not=all:notification:lsp-sur
|
2020-01-03 09:19:16 +03:00
|
|
|
^- (quip card _state)
|
2020-01-03 15:04:53 +03:00
|
|
|
=^ cards state
|
2020-01-13 08:27:42 +03:00
|
|
|
?+ -.not [~ state]
|
2020-01-28 02:23:27 +03:00
|
|
|
%text-document--did-open (handle-did-open +.not)
|
2020-01-27 05:18:48 +03:00
|
|
|
%text-document--did-change (handle-did-change +.not)
|
2020-01-28 02:23:27 +03:00
|
|
|
%text-document--did-save (handle-did-save +.not)
|
|
|
|
%text-document--did-close (handle-did-close +.not)
|
|
|
|
%exit handle-exit
|
2020-01-03 15:04:53 +03:00
|
|
|
==
|
|
|
|
[cards state]
|
2020-01-13 08:27:42 +03:00
|
|
|
++ on-request
|
|
|
|
|= req=all:request:lsp-sur
|
|
|
|
^- (quip card _state)
|
|
|
|
=^ cards state
|
|
|
|
?+ -.req [~ state]
|
2020-01-28 05:24:39 +03:00
|
|
|
%text-document--hover (handle-hover req)
|
|
|
|
%text-document--completion (handle-completion req)
|
2020-01-13 08:27:42 +03:00
|
|
|
==
|
|
|
|
[cards state]
|
|
|
|
::
|
2020-01-29 03:29:50 +03:00
|
|
|
++ get-subject
|
|
|
|
|= uri=@t
|
|
|
|
^- type
|
2020-01-31 06:19:19 +03:00
|
|
|
(~(gut by preludes) uri -:!>(..zuse))
|
2020-01-29 03:29:50 +03:00
|
|
|
::
|
2020-01-28 05:24:39 +03:00
|
|
|
++ handle-completion
|
|
|
|
|= com=text-document--completion:request:lsp-sur
|
|
|
|
^- (quip card _state)
|
|
|
|
:_ state
|
|
|
|
%^ give-rpc-response %text-document--completion id.com
|
|
|
|
=/ buf=wall
|
|
|
|
(~(got by bufs) uri.com)
|
|
|
|
=/ txt=tape
|
|
|
|
(zing (join "\0a" buf))
|
|
|
|
=/ pos
|
|
|
|
(get-pos buf row.com col.com)
|
|
|
|
=/ rune (rune-snippet (swag [(safe-sub pos 2) 2] txt))
|
|
|
|
?^ rune rune
|
2020-01-31 07:21:17 +03:00
|
|
|
=/ tab-list
|
|
|
|
%^ tab-list-tape:auto
|
|
|
|
(~(gut by preludes) uri.com -:!>(..zuse))
|
|
|
|
pos txt
|
|
|
|
?: ?=(%| -.tab-list) ~
|
|
|
|
?~ p.tab-list ~
|
|
|
|
?~ u.p.tab-list ~
|
|
|
|
(turn u.p.tab-list make-completion-item)
|
2020-01-28 05:24:39 +03:00
|
|
|
::
|
|
|
|
++ make-completion-item
|
|
|
|
|= [name=term =type]
|
|
|
|
^- completion-item:lsp-sur
|
|
|
|
=/ doc
|
|
|
|
%- crip
|
|
|
|
;: weld
|
|
|
|
"`"
|
|
|
|
~(ram re ~(duck easy-print type))
|
|
|
|
"`"
|
|
|
|
==
|
|
|
|
[name 1 doc '' name 1]
|
|
|
|
::
|
2020-01-13 08:27:42 +03:00
|
|
|
++ give-rpc-response
|
|
|
|
|= res=all:response:lsp-sur
|
|
|
|
^- (list card)
|
|
|
|
:_ ~
|
2020-01-27 05:18:48 +03:00
|
|
|
[%give %fact ~[/primary] %language-server-rpc-response !>(res)]
|
2020-01-08 03:41:29 +03:00
|
|
|
::
|
|
|
|
++ handle-exit
|
|
|
|
^- (quip card _state)
|
|
|
|
~& > %lsp-shutdown
|
|
|
|
:_ *state-zero
|
|
|
|
%+ turn
|
|
|
|
~(tap in ~(key by builds))
|
|
|
|
|= uri=@t
|
2020-05-14 10:22:39 +03:00
|
|
|
[%pass /ford/[uri] %arvo %c %warp our.bow %home ~]
|
2020-01-08 03:41:29 +03:00
|
|
|
::
|
|
|
|
++ handle-did-close
|
2020-01-13 08:27:42 +03:00
|
|
|
|= [uri=@t version=(unit @)]
|
2020-01-08 03:41:29 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
=. bufs
|
|
|
|
(~(del by bufs) uri)
|
2020-01-13 08:27:42 +03:00
|
|
|
=. ford-diagnostics
|
|
|
|
(~(del by ford-diagnostics) uri)
|
2020-01-08 03:41:29 +03:00
|
|
|
=. builds
|
|
|
|
(~(del by builds) uri)
|
|
|
|
:_ state
|
2020-05-14 10:22:39 +03:00
|
|
|
[%pass /ford/[uri] %arvo %c %warp our.bow %home ~]~
|
2020-01-08 03:41:29 +03:00
|
|
|
::
|
|
|
|
++ handle-did-save
|
2020-01-13 08:27:42 +03:00
|
|
|
|= [uri=@t version=(unit @)]
|
2020-01-08 03:41:29 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
:_ state
|
2020-01-13 08:27:42 +03:00
|
|
|
:_ (give-rpc-notification (get-diagnostics uri))
|
2020-01-08 03:41:29 +03:00
|
|
|
:*
|
|
|
|
%pass
|
|
|
|
/commit
|
|
|
|
%agent
|
|
|
|
[our.bow %hood]
|
|
|
|
%poke
|
|
|
|
%kiln-commit
|
|
|
|
!>([q.byk.bow |])
|
|
|
|
==
|
2020-01-03 15:04:53 +03:00
|
|
|
::
|
|
|
|
++ handle-did-change
|
|
|
|
|= [document=versioned-doc-id:lsp-sur changes=(list change:lsp-sur)]
|
|
|
|
^- (quip card _state)
|
|
|
|
=/ updated=wall
|
|
|
|
(sync-buf (~(got by bufs) uri.document) changes)
|
|
|
|
=. bufs
|
|
|
|
(~(put by bufs) uri.document updated)
|
|
|
|
`state
|
|
|
|
::
|
2020-01-08 03:41:29 +03:00
|
|
|
++ handle-build
|
2020-05-14 09:26:52 +03:00
|
|
|
|= [=path =gift:able:clay]
|
2020-01-08 03:41:29 +03:00
|
|
|
^- (quip card _state)
|
2020-05-14 09:26:52 +03:00
|
|
|
?> ?=([%writ *] gift)
|
2020-01-08 03:41:29 +03:00
|
|
|
=/ uri=@t
|
|
|
|
(snag 1 path)
|
2020-05-14 09:26:52 +03:00
|
|
|
=; res=(quip card _state)
|
|
|
|
[(snoc -.res (build-file | uri path)) +.res]
|
|
|
|
?~ p.gift
|
2020-01-31 06:19:19 +03:00
|
|
|
[~ state]
|
2020-05-14 09:26:52 +03:00
|
|
|
=. builds
|
|
|
|
(~(put by builds) uri q.r.u.p.gift)
|
|
|
|
=. ford-diagnostics
|
|
|
|
(~(del by ford-diagnostics) uri)
|
|
|
|
=+ .^(=open:clay %cs /(scot %p our.bow)/home/(scot %da now.bow)/open)
|
|
|
|
=/ =type -:(open (uri-to-path:build uri))
|
|
|
|
=. preludes
|
|
|
|
(~(put by preludes) uri type)
|
|
|
|
:_ state
|
|
|
|
(give-rpc-notification (get-diagnostics uri))
|
2020-01-08 03:41:29 +03:00
|
|
|
::
|
2020-01-13 08:27:42 +03:00
|
|
|
++ get-diagnostics
|
|
|
|
|= uri=@t
|
|
|
|
^- out:notification:lsp-sur
|
2020-01-08 03:41:29 +03:00
|
|
|
:+ %text-document--publish-diagnostics
|
|
|
|
uri
|
2020-01-13 08:27:42 +03:00
|
|
|
%+ weld
|
|
|
|
(~(gut by ford-diagnostics) uri ~)
|
|
|
|
(get-parser-diagnostics uri)
|
2020-01-08 03:41:29 +03:00
|
|
|
::
|
2020-05-14 09:26:52 +03:00
|
|
|
++ build-file
|
|
|
|
|= [eager=? uri=@t =path]
|
|
|
|
^- card
|
|
|
|
=/ =rave:clay
|
|
|
|
?: eager
|
|
|
|
[%sing %a da+now.bow path]
|
|
|
|
[%next %a da+now.bow path]
|
|
|
|
[%pass /ford/[uri] %arvo %c %warp our.bow %home `rave]
|
2020-01-31 06:19:19 +03:00
|
|
|
::
|
2020-01-03 15:04:53 +03:00
|
|
|
++ handle-did-open
|
|
|
|
|= item=text-document-item:lsp-sur
|
|
|
|
^- (quip card _state)
|
2020-01-31 06:19:19 +03:00
|
|
|
=/ buf=wall
|
|
|
|
(to-wall (trip text.item))
|
2020-01-03 15:04:53 +03:00
|
|
|
=. bufs
|
2020-01-31 06:19:19 +03:00
|
|
|
(~(put by bufs) uri.item buf)
|
2020-01-08 03:41:29 +03:00
|
|
|
=/ =path
|
|
|
|
(uri-to-path:build uri.item)
|
|
|
|
:_ state
|
2020-01-31 06:19:19 +03:00
|
|
|
%+ weld
|
|
|
|
(give-rpc-notification (get-diagnostics uri.item))
|
2020-05-14 09:26:52 +03:00
|
|
|
[(build-file & uri.item path) ~]
|
2020-01-03 09:19:16 +03:00
|
|
|
::
|
2020-01-08 03:41:29 +03:00
|
|
|
++ get-parser-diagnostics
|
|
|
|
|= uri=@t
|
2020-01-13 08:27:42 +03:00
|
|
|
^- (list diagnostic:lsp-sur)
|
2019-11-12 14:46:09 +03:00
|
|
|
=/ t=tape
|
2020-01-08 03:41:29 +03:00
|
|
|
(zing (join "\0a" `wall`(~(got by bufs) uri)))
|
2019-11-12 14:46:09 +03:00
|
|
|
=/ parse
|
2020-05-14 09:26:52 +03:00
|
|
|
(lily:auto t (lsp-parser (uri-to-path:build uri)))
|
2020-01-08 03:41:29 +03:00
|
|
|
?. ?=(%| -.parse)
|
|
|
|
~
|
|
|
|
=/ loc=position:lsp-sur
|
|
|
|
[(dec -.p.parse) +.p.parse]
|
|
|
|
:_ ~
|
|
|
|
[[loc loc] 1 'Syntax Error']
|
2019-11-04 06:18:40 +03:00
|
|
|
::
|
2020-01-13 08:27:42 +03:00
|
|
|
++ handle-hover
|
|
|
|
|= hov=text-document--hover:request:lsp-sur
|
|
|
|
^- (quip card _state)
|
2020-01-31 07:21:17 +03:00
|
|
|
:_ state
|
|
|
|
%^ give-rpc-response %text-document--hover id.hov
|
2020-01-13 08:27:42 +03:00
|
|
|
=/ buf=wall
|
|
|
|
(~(got by bufs) uri.hov)
|
|
|
|
=/ txt
|
|
|
|
(zing (join "\0a" buf))
|
2020-01-31 07:21:17 +03:00
|
|
|
=/ tab-list
|
|
|
|
%^ tab-list-tape:auto
|
|
|
|
(~(gut by preludes) uri.hov -:!>(..zuse))
|
|
|
|
(get-pos buf row.hov col.hov)
|
|
|
|
txt
|
|
|
|
?: ?=(%| -.tab-list) ~
|
|
|
|
?~ p.tab-list ~
|
|
|
|
?~ u.p.tab-list ~
|
|
|
|
:- ~
|
|
|
|
%- crip
|
|
|
|
;: weld
|
|
|
|
"`"
|
|
|
|
~(ram re ~(duck easy-print detail.i.u.p.tab-list))
|
|
|
|
"`"
|
|
|
|
==
|
2019-11-12 18:57:01 +03:00
|
|
|
::
|
2020-01-03 15:04:53 +03:00
|
|
|
++ sync-buf
|
|
|
|
|= [buf=wall changes=(list change:lsp-sur)]
|
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)
|
2020-01-03 15:04:53 +03:00
|
|
|
::
|
2019-11-04 08:32:42 +03:00
|
|
|
++ 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)
|
|
|
|
::
|
|
|
|
--
|