language-server: magic-spoon hover, autocomplete

Uses magic-spoon to properly trace the subject to the cursor position.
This commit is contained in:
Liam Fitzgerald 2020-01-31 14:21:17 +10:00
parent 07d66413b2
commit 8428f0ab14

View File

@ -161,12 +161,14 @@
(get-pos buf row.com col.com) (get-pos buf row.com col.com)
=/ rune (rune-snippet (swag [(safe-sub pos 2) 2] txt)) =/ rune (rune-snippet (swag [(safe-sub pos 2) 2] txt))
?^ rune rune ?^ rune rune
=+ (get-id:auto pos txt) =/ tab-list
?~ id ~ %^ tab-list-tape:auto
=/ matches=(list (option:auto type)) (~(gut by preludes) uri.com -:!>(..zuse))
(search-prefix:auto u.id (get-identifiers:auto (get-subject uri.com))) pos txt
?~ matches ~ ?: ?=(%| -.tab-list) ~
(turn matches make-completion-item) ?~ p.tab-list ~
?~ u.p.tab-list ~
(turn u.p.tab-list make-completion-item)
:: ::
++ make-completion-item ++ make-completion-item
|= [name=term =type] |= [name=term =type]
@ -339,26 +341,27 @@
++ handle-hover ++ handle-hover
|= hov=text-document--hover:request:lsp-sur |= hov=text-document--hover:request:lsp-sur
^- (quip card _state) ^- (quip card _state)
:_ state
%^ give-rpc-response %text-document--hover id.hov
=/ buf=wall =/ buf=wall
(~(got by bufs) uri.hov) (~(got by bufs) uri.hov)
=/ txt =/ txt
(zing (join "\0a" buf)) (zing (join "\0a" buf))
=+ (get-id:auto (get-pos buf row.hov col.hov) txt) =/ tab-list
?~ id %^ tab-list-tape:auto
[(give-rpc-response [%text-document--hover id.hov ~]) state] (~(gut by preludes) uri.hov -:!>(..zuse))
=/ match=(unit (option:auto type)) (get-pos buf row.hov col.hov)
(search-exact:auto u.id (get-identifiers:auto (get-subject uri.hov))) txt
?~ match ?: ?=(%| -.tab-list) ~
[(give-rpc-response [%text-document--hover id.hov ~]) state] ?~ p.tab-list ~
=/ contents ?~ u.p.tab-list ~
:- ~
%- crip %- crip
;: weld ;: weld
"`" "`"
~(ram re ~(duck easy-print detail.u.match)) ~(ram re ~(duck easy-print detail.i.u.p.tab-list))
"`" "`"
== ==
:_ state
(give-rpc-response [%text-document--hover id.hov `contents])
:: ::
++ sync-buf ++ sync-buf
|= [buf=wall changes=(list change:lsp-sur)] |= [buf=wall changes=(list change:lsp-sur)]