[mod] additions
This commit is contained in:
parent
c59edb71a2
commit
2f54b3370e
19 changed files with 40083 additions and 16 deletions
|
|
@ -3,14 +3,17 @@
|
|||
: @author andy bunce
|
||||
:)
|
||||
module namespace lsprpc = 'lsprpc';
|
||||
import module namespace lsp-text = 'lsp-text' at "lsp-text.xqm";
|
||||
|
||||
declare variable $lsprpc:methods:=map{
|
||||
(: map methods to functions :)
|
||||
declare variable $lsprpc:methods:=map:merge((
|
||||
map{
|
||||
"initialize" : lsprpc:method-initialize#1,
|
||||
"initialized" : lsprpc:method-unknown#1,
|
||||
"workspace/didChangeConfiguration" :lsprpc:method-unknown#1,
|
||||
"textDocument/didOpen": lsprpc:method-unknown#1,
|
||||
"textDocument/didClose" : lsprpc:method-unknown#1
|
||||
};
|
||||
"workspace/didChangeConfiguration" :lsprpc:method-unknown#1
|
||||
},
|
||||
$lsp-text:methods
|
||||
));
|
||||
|
||||
(:~ return map if $msg is jsonrpc else empty :)
|
||||
declare
|
||||
|
|
@ -41,11 +44,28 @@ as empty-sequence() {
|
|||
(:~ canned initialize response :)
|
||||
declare
|
||||
function lsprpc:method-initialize($json as map(*))
|
||||
as map(*)?
|
||||
as map(*)
|
||||
{
|
||||
``[{"jsonrpc":"2.0","id":0,
|
||||
"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"resolveProvider":false,"triggerCharacters":["\"",":"]},"hoverProvider":true,"documentSymbolProvider":true,"documentRangeFormattingProvider":false,"colorProvider":{},"foldingRangeProvider":true,"selectionRangeProvider":true,"documentLinkProvider":{}}}}]``
|
||||
=>parse-json()
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": $json?id,
|
||||
"result": {
|
||||
"capabilities": {
|
||||
"textDocumentSync": 2,
|
||||
"completionProvider": {
|
||||
"resolveProvider": false(),
|
||||
"triggerCharacters": [ """", ":" ]
|
||||
},
|
||||
"hoverProvider": true(),
|
||||
"documentSymbolProvider": true(),
|
||||
"documentRangeFormattingProvider": false(),
|
||||
"colorProvider": {},
|
||||
"foldingRangeProvider": true(),
|
||||
"selectionRangeProvider": true(),
|
||||
"documentLinkProvider": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
(:~ unknown method response :)
|
||||
|
|
|
|||
71
webapp/lsp/lsp-text.xqm
Normal file
71
webapp/lsp/lsp-text.xqm
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
(:~ handle text messages
|
||||
: @author andy bunce
|
||||
:)
|
||||
module namespace lsp-text = 'lsp-text';
|
||||
import module namespace p="xq4" at "xq4.xqm";
|
||||
|
||||
declare variable $lsp-text:methods:=map{
|
||||
"textDocument/didOpen": lsp-text:didOpen#1,
|
||||
"textDocument/didClose" : lsp-text:method-unknown#1,
|
||||
"textDocument/didChange": lsp-text:method-unknown#1,
|
||||
"textDocument/hover": lsp-text:hover#1,
|
||||
"textDocument/completion": lsp-text:completion#1
|
||||
};
|
||||
(:~ hover
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 2,
|
||||
"method": "textDocument/hover",
|
||||
"params": {
|
||||
"textDocument": {
|
||||
"uri": "file:///session1.json"
|
||||
},
|
||||
"position": {
|
||||
"line": 2,
|
||||
"character": 22
|
||||
}
|
||||
}
|
||||
}
|
||||
:)
|
||||
declare
|
||||
function lsp-text:hover($json as map(*))
|
||||
as map(*)?
|
||||
{
|
||||
let $doc:=$json?params?textDocument?uri
|
||||
return map{
|
||||
"jsonrpc": "2.0",
|
||||
"id": $json?id,
|
||||
"value":"uri: " || $doc
|
||||
}
|
||||
};
|
||||
|
||||
declare
|
||||
function lsp-text:completion($json as map(*))
|
||||
as map(*)?
|
||||
{
|
||||
let $doc:=$json?params?textDocument?uri
|
||||
return map{
|
||||
"jsonrpc": "2.0",
|
||||
"id": $json?id,
|
||||
"result":()
|
||||
}
|
||||
};
|
||||
|
||||
(:~ didOpen method response :)
|
||||
declare
|
||||
function lsp-text:didOpen($json as map(*))
|
||||
as map(*)?
|
||||
{
|
||||
let $textDoc:=$json?params?textDocument
|
||||
let $text:=$textDoc?text=>trace("TXT")
|
||||
return ()
|
||||
};
|
||||
|
||||
(:~ unknown method response :)
|
||||
declare
|
||||
function lsp-text:method-unknown($json as map(*))
|
||||
as map(*)?
|
||||
{
|
||||
let $_:=trace($json?method,"unknown")
|
||||
return ()
|
||||
};
|
||||
|
|
@ -19,9 +19,13 @@ function lsp-ws:error($error) {
|
|||
declare
|
||||
%ws:connect('/lsp')
|
||||
function lsp-ws:connect() as empty-sequence() {
|
||||
|
||||
ws:set(ws:id()=>trace("CONNECT: "), $chat-util:id, "session:get($chat-util:id)")
|
||||
(: ,chat-util:users() :)
|
||||
let $id:=ws:id()=>trace("CONNECT: ")
|
||||
return (
|
||||
ws:set($id, "id", $id),
|
||||
store:clear(),
|
||||
store:put("id",$id),
|
||||
store:write("lsp-store")
|
||||
)
|
||||
};
|
||||
|
||||
(:~
|
||||
|
|
|
|||
6570
webapp/lsp/xq4.xqm
Normal file
6570
webapp/lsp/xq4.xqm
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue