mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-14 17:41:33 +03:00
language-server: add function signature on hover
Add function signature on hover. Fixes bug around autocomplete not working properly when the cursor was mid-word.
This commit is contained in:
parent
26c4c6c7e4
commit
b0c5b7b0fe
@ -23,6 +23,7 @@
|
||||
$% [%sync changes=(list change)]
|
||||
[%completion position]
|
||||
[%commit @ud]
|
||||
[%hover position]
|
||||
==
|
||||
==
|
||||
::
|
||||
@ -74,6 +75,7 @@
|
||||
:~ sync+sync
|
||||
completion+position
|
||||
commit+ni
|
||||
hover+position
|
||||
==
|
||||
~
|
||||
==
|
||||
@ -132,6 +134,7 @@
|
||||
%sync (handle-sync buf +>.lsp-req)
|
||||
%completion (handle-completion buf +>.lsp-req)
|
||||
%commit (handle-commit buf uri.lsp-req)
|
||||
%hover (handle-hover buf +>.lsp-req)
|
||||
==
|
||||
=. bufs
|
||||
(~(put by bufs) uri.lsp-req buf)
|
||||
@ -183,6 +186,30 @@
|
||||
|
|
||||
==
|
||||
::
|
||||
++ 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]
|
||||
=/ match/(unit [=term =type])
|
||||
(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 ~]
|
||||
::
|
||||
++ handle-sync
|
||||
|= [buf=wall changes=(list change)]
|
||||
:- (json-response *json)
|
||||
@ -254,16 +281,7 @@
|
||||
=, enjs:format
|
||||
%- json-response
|
||||
?: ?=(%| -.tl)
|
||||
%- pairs
|
||||
:~ good+b+|
|
||||
:+ %diagnostics %a :_ ~
|
||||
=/ loc (pairs line+(numb (dec row.p.tl)) character+(numb col.p.tl) ~)
|
||||
%- pairs
|
||||
:~ range+(pairs start+loc end+loc ~)
|
||||
severity+n+'1'
|
||||
message+s+'syntax error'
|
||||
==
|
||||
==
|
||||
(format-diagnostic p.tl)
|
||||
?~ p.tl
|
||||
*json
|
||||
%- pairs
|
||||
|
@ -68,6 +68,17 @@
|
||||
[%hold *] $(ty ~(repo ut ty))
|
||||
==
|
||||
::
|
||||
++ search-exact
|
||||
|= [sid=term ids=(list [term type])]
|
||||
^- (unit [term type])
|
||||
=/ match/(list [term type])
|
||||
%+ skim ids
|
||||
|= [id=term ty=type]
|
||||
=(sid id)
|
||||
?~ match
|
||||
~
|
||||
[~ i.match]
|
||||
::
|
||||
:: Get all the identifiers that start with sid.
|
||||
::
|
||||
++ search-prefix
|
||||
@ -234,18 +245,14 @@
|
||||
^- (unit [term type])
|
||||
~
|
||||
::
|
||||
:: Insert magic marker in hoon source at the given position.
|
||||
::
|
||||
++ insert-magic
|
||||
++ get-id
|
||||
|= [pos=@ud txt=tape]
|
||||
^- [back-pos=@ud fore-pos=@ud txt=tape]
|
||||
:: Find beg-pos by searching backward to where the current term
|
||||
:: begins
|
||||
::
|
||||
^- [forward=(unit term) backward=(unit term) id=(unit term)]
|
||||
=/ forward=(unit term)
|
||||
%+ scan `tape`(slag pos txt)
|
||||
;~(sfix (punt sym) (star ;~(pose prn (just `@`10))))
|
||||
=/ backward=(unit term)
|
||||
%- (lift |=(t=@tas (crip (flop (trip t)))))
|
||||
%+ scan `tape`(flop (scag pos txt))
|
||||
;~(sfix (punt sym) (star ;~(pose prn (just `@`10))))
|
||||
=/ id=(unit term)
|
||||
@ -256,6 +263,16 @@
|
||||
?~ backward
|
||||
`u.forward
|
||||
`(cat 3 u.backward u.forward)
|
||||
[forward backward id]
|
||||
::
|
||||
:: Insert magic marker in hoon source at the given position.
|
||||
::
|
||||
++ insert-magic
|
||||
|= [pos=@ud txt=tape]
|
||||
^- [back-pos=@ud fore-pos=@ud txt=tape]
|
||||
:: Find beg-pos by searching backward to where the current term
|
||||
:: begins
|
||||
=+ (get-id pos txt)
|
||||
=/ back-pos
|
||||
?~ backward
|
||||
pos
|
||||
|
Loading…
Reference in New Issue
Block a user