Merge pull request #4347 from urbit/lf/moar-lsp

language-server: fixes & improvements
This commit is contained in:
matildepark 2021-03-03 14:51:40 -05:00 committed by GitHub
commit c16815b003
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 16 deletions

View File

@ -5,7 +5,7 @@
easy-print=language-server-easy-print, easy-print=language-server-easy-print,
rune-snippet=language-server-rune-snippet, rune-snippet=language-server-rune-snippet,
build=language-server-build, build=language-server-build,
default-agent default-agent, verb
|% |%
+$ card card:agent:gall +$ card card:agent:gall
+$ lsp-req +$ lsp-req
@ -44,6 +44,7 @@
== ==
-- --
^- agent:gall ^- agent:gall
%+ verb |
=| state-zero =| state-zero
=* state - =* state -
=< =<
@ -69,7 +70,7 @@
|= old-state=vase |= old-state=vase
^- (quip card _this) ^- (quip card _this)
~& > %lsp-upgrade ~& > %lsp-upgrade
[~ this(state *state-zero)] [~ this(state !<(state-zero old-state))]
:: ::
++ on-poke ++ on-poke
^+ on-poke:*agent:gall ^+ on-poke:*agent:gall
@ -275,12 +276,14 @@
++ handle-did-open ++ handle-did-open
|= item=text-document-item:lsp-sur |= item=text-document-item:lsp-sur
^- (quip card _state) ^- (quip card _state)
=/ =path
(uri-to-path:build uri.item)
?: ?=(%sys -.path)
`state
=/ buf=wall =/ buf=wall
(to-wall (trip text.item)) (to-wall (trip text.item))
=. bufs =. bufs
(~(put by bufs) uri.item buf) (~(put by bufs) uri.item buf)
=/ =path
(uri-to-path:build uri.item)
:_ state :_ state
%+ weld %+ weld
(give-rpc-notification (get-diagnostics uri.item)) (give-rpc-notification (get-diagnostics uri.item))
@ -318,12 +321,12 @@
?~ p.tab-list ~ ?~ p.tab-list ~
?~ u.p.tab-list ~ ?~ u.p.tab-list ~
:- ~ :- ~
%- crip =- (crip :(weld "```hoon\0a" tape "\0a```"))
;: weld ^- =tape
"`" %- zing
~(ram re ~(duck easy-print detail.i.u.p.tab-list)) %+ join "\0a"
"`" %+ scag 40
== (~(win re ~(duck easy-print detail.i.u.p.tab-list)) 0 140)
:: ::
++ sync-buf ++ sync-buf
|= [buf=wall changes=(list change:lsp-sur)] |= [buf=wall changes=(list change:lsp-sur)]

View File

@ -185,6 +185,7 @@
[%zpmc *] (both p.gen q.gen) [%zpmc *] (both p.gen q.gen)
[%zpts *] loop(gen p.gen) [%zpts *] loop(gen p.gen)
[%zppt *] (both q.gen r.gen) [%zppt *] (both q.gen r.gen)
[%zpgl *] (spec-and-hoon p.gen q.gen)
[%zpzp *] ~ [%zpzp *] ~
* *
=+ doz=~(open ap gen) =+ doz=~(open ap gen)
@ -245,15 +246,25 @@
^- (unit [term type]) ^- (unit [term type])
~ ~
:: ::
++ get-id ++ get-id-sym
|= [pos=@ud txt=tape] |= [pos=@ud =tape]
^- [forward=(unit @t) backward=(unit @t) id=(unit @t)] %^ get-id pos tape
=/ seek ^- $-(nail (like (unit @t)))
;~(sfix (punt sym) (star ;~(pose prn (just `@`10))))
::
++ get-id-cord
|= [pos=@ud =tape]
%^ get-id pos tape
^- $-(nail (like (unit @t)))
;~(sfix (punt (cook crip (star prn))) (star ;~(pose prn (just `@`10)))) ;~(sfix (punt (cook crip (star prn))) (star ;~(pose prn (just `@`10))))
::
++ get-id
|= [pos=@ud txt=tape seek=$-(nail (like (unit @t)))]
^- [forward=(unit @t) backward=(unit @t) id=(unit @t)]
=/ forward=(unit @t) =/ forward=(unit @t)
(scan (slag pos txt) seek) (scan (slag pos txt) seek)
=/ backward=(unit @t) =/ backward=(unit @t)
%- (lift |=(t=@tas (swp 3 t))) %- (lift |=(t=@t (swp 3 t)))
(scan (flop (scag pos txt)) seek) (scan (flop (scag pos txt)) seek)
=/ id=(unit @t) =/ id=(unit @t)
?~ forward ?~ forward
@ -272,7 +283,7 @@
^- [back-pos=@ud fore-pos=@ud txt=tape] ^- [back-pos=@ud fore-pos=@ud txt=tape]
:: Find beg-pos by searching backward to where the current term :: Find beg-pos by searching backward to where the current term
:: begins :: begins
=+ (get-id pos txt) =+ (get-id-sym pos txt)
=/ back-pos =/ back-pos
?~ backward ?~ backward
pos pos

View File

@ -291,7 +291,7 @@
++ tab ++ tab
|= pos=@ud |= pos=@ud
^- (quip card _cli-state) ^- (quip card _cli-state)
=+ (get-id:auto pos (tufa buf.cli-state)) =+ (get-id-cord:auto pos (tufa buf.cli-state))
=/ needle=term =/ needle=term
(fall id %$) (fall id %$)
:: autocomplete empty command iff user at start of command :: autocomplete empty command iff user at start of command