diff --git a/README.md b/README.md index cfd071b..e9241b3 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ State is held in [websocket attributes](https://docs.basex.org/main/WebSocket_Fu |Name|Use| |----|---| +|client|the client initialize message| |initialized|set true after client sends initialized message| |files|A map whose keys are open uris, values are maps (doctype-> attribute name where doctype is stored| | |file-{uuid}|name of websocket attribute with textDocument| diff --git a/docs/explore.xqbk b/docs/explore.xqbk index 6e0cad2..12effb3 100644 --- a/docs/explore.xqbk +++ b/docs/explore.xqbk @@ -1 +1 @@ -{"cells":[{"kind":2,"language":"xquery","value":"(:<:)\r\n\r\nimport module namespace docs=\"lsp/docs\" at \"/srv/basex/webapp/lsp/docs.xqm\";"},{"kind":2,"language":"xquery","value":"2+2"},{"kind":2,"language":"xquery","value":"ws:ids()"},{"kind":2,"language":"xquery","value":"let $sock:=foot(ws:ids())\r\nlet $f:=docs:list($sock)\r\nlet $t:=docs:get($sock,$f,\"textDocument\")\r\nreturn $t?text"},{"kind":2,"language":"xquery","value":"let $sock:=foot(ws:ids())\r\nlet $f:=docs:list($sock)\r\nlet $t:=docs:get($sock,$f,\"parse\")\r\nreturn $t"},{"kind":2,"language":"xquery","value":"let $sock:=foot(ws:ids())\r\nlet $f:=docs:list($sock)\r\nlet $t:=docs:get($sock,$f,\"textDocument\")\r\nreturn $t"}]} \ No newline at end of file +{"cells":[{"kind":2,"language":"xquery","value":"(:<:)\r\n\r\nimport module namespace docs=\"lsp/docs\" at \"/srv/basex/webapp/lsp/docs.xqm\";\r\ndeclare variable $LAST:=foot(ws:ids());"},{"kind":2,"language":"xquery","value":"2+2"},{"kind":2,"language":"xquery","value":"ws:ids()"},{"kind":2,"language":"xquery","value":"let $sock:=foot(ws:ids())\r\nlet $f:=docs:list($sock)\r\nlet $t:=docs:get($sock,$f,\"textDocument\")\r\nreturn $t?text=>substring(1,100)"},{"kind":2,"language":"xquery","value":"let $sock:=foot(ws:ids())\r\nlet $f:=docs:list($sock)\r\nlet $t:=docs:get($sock,$f,\"parse\")\r\nreturn $t?text"},{"kind":2,"language":"xquery","value":"let $sock:=foot(ws:ids())\r\nlet $f:=docs:list($sock)\r\nlet $t:=docs:get($sock,$f,\"textDocument\")\r\nreturn $t"},{"kind":2,"language":"xquery","value":"(: client capabilities :)\r\nws:get($LAST,\"client\")"}]} \ No newline at end of file diff --git a/docs/wordat.xqbk b/docs/wordat.xqbk new file mode 100644 index 0000000..fa90a97 --- /dev/null +++ b/docs/wordat.xqbk @@ -0,0 +1 @@ +{"cells":[{"kind":1,"language":"markdown","value":"XPath name charactors"},{"kind":2,"language":"xquery","value":"let $s:=`[A-Z]\r\n | '_'\r\n | [a-z]\r\n | [#xC0-#xD6]\r\n | [#xD8-#xF6]\r\n | [#xF8-#x2FF]\r\n | [#x370-#x37D]\r\n | [#x37F-#x1FFF]\r\n | [#x200C-#x200D]\r\n | [#x2070-#x218F]\r\n | [#x2C00-#x2FEF]\r\n | [#x3001-#xD7FF]\r\n | [#xF900-#xFDCF]\r\n | [#xFDF0-#xFFFD]\r\n `\r\nlet $sreg:= normalize-space($s)\r\n =>tokenize(\"\\|\")\r\n =!>normalize-space()\r\n =!>replace(\"(#x[0-9A-F]+)\",fn($s,$m){\r\n convert:integer-from-base(substring($m,3),16)\r\n =>codepoints-to-string()\r\n })\r\n =!>translate(\"'\",\"\")\r\n =>string-join(\"|\")\r\nreturn $sreg"}]} \ No newline at end of file diff --git a/webapp/lsp/etc/capabilities.json b/webapp/lsp/etc/capabilities.json index ad358b8..2b4887f 100644 --- a/webapp/lsp/etc/capabilities.json +++ b/webapp/lsp/etc/capabilities.json @@ -13,7 +13,7 @@ } ] }, - "hoverProvider": {}, + "hoverProvider": true, "documentSymbolProvider": false, "documentRangeFormattingProvider": false, "colorProvider": false, diff --git a/webapp/lsp/jsonrpc.xqm b/webapp/lsp/jsonrpc.xqm index 1f1218e..e6df36f 100644 --- a/webapp/lsp/jsonrpc.xqm +++ b/webapp/lsp/jsonrpc.xqm @@ -57,6 +57,7 @@ declare function rpc:method-initialize($json as map(*)) as map(*) { + ws:set(ws:id(),"client", $json?params), rpc:result($json, json:doc("etc/capabilities.json",{"format":"w3"})) }; diff --git a/webapp/lsp/lsp-text.xqm b/webapp/lsp/lsp-text.xqm index e0757a9..995babc 100644 --- a/webapp/lsp/lsp-text.xqm +++ b/webapp/lsp/lsp-text.xqm @@ -24,9 +24,14 @@ declare function lsp-text:hover($json as map(*)) as map(*) { + let $pos:=$json?params?position + let $uri:= $json?params?textDocument?uri + let $word:="TODO" let $r:= [ -`At { pos:ln-col($json?params?position) }, uri: {$json?params?textDocument?uri}, -[path](https://quodatum.github.io/basex-xqparse/i-BaseX.xhtml#EQName)` +`At { pos:ln-col($pos) }, uri: {$uri}, +[path](https://quodatum.github.io/basex-xqparse/i-BaseX.xhtml#EQName) + +WordAt: {$word}` ] return rpc:result($json,{"contents":$r}) }; @@ -39,9 +44,11 @@ as map(*)? let $uri:=$json?params?textDocument?uri let $text:=docs:get(ws:id(), $uri, "textDocument")?text let $fr:=pos:full-range($text) + (: dummy data :) + let $nameRange:=$fr let $result:=map:for-each($lspt:SymbolKindMap, fn($k,$v){ - lspt:DocumentSymbol($k,$v,$fr,$fr,"todo") + lspt:DocumentSymbol($k,$v,$fr,$nameRange,"todo description") })=>array:build() return rpc:result($json,$result)=>trace("SSS") }; diff --git a/webapp/lsp/lsp-ws.xqm b/webapp/lsp/lsp-ws.xqm index 4d21206..ddf7389 100644 --- a/webapp/lsp/lsp-ws.xqm +++ b/webapp/lsp/lsp-ws.xqm @@ -34,7 +34,7 @@ function lsp-ws:message( $message as xs:string ) as empty-sequence() { - let $json := rpc:parse($message=>trace("MSG ")) + let $json := rpc:parse($message) return if(exists($json)) then rpc:reply($json) else message($message,"bad RPC: ") diff --git a/webapp/static/clients/codemirror/data.json b/webapp/static/clients/codemirror/data.json deleted file mode 100644 index 3722f88..0000000 --- a/webapp/static/clients/codemirror/data.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "name": "symbol 1", - "description": "This is the first item" - }, - { - "name": "symbol 2", - "description": "This is the second item" - }, - { - "name": "symbol 3", - "description": "This is the third item" - }, - { - "name": "symbol 4", - "description": "This is the third item" - }, - { - "name": "symbol 5", - "description": "This is the third item" - }, - { - "name": "symbol 6", - "description": "This is the third item" - } -] \ No newline at end of file diff --git a/webapp/static/clients/codemirror/deepseek.html b/webapp/static/clients/codemirror/deepseek.html deleted file mode 100644 index b156076..0000000 --- a/webapp/static/clients/codemirror/deepseek.html +++ /dev/null @@ -1,56 +0,0 @@ - - -
- - -