[mod] tidy

This commit is contained in:
Andy Bunce 2025-09-23 17:39:28 +01:00
parent 28b4799ee0
commit eaebbd12aa
10 changed files with 19 additions and 89 deletions

View file

@ -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|

View file

@ -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"}]}
{"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\")"}]}

1
docs/wordat.xqbk Normal file
View file

@ -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"}]}

View file

@ -13,7 +13,7 @@
}
]
},
"hoverProvider": {},
"hoverProvider": true,
"documentSymbolProvider": false,
"documentRangeFormattingProvider": false,
"colorProvider": false,

View file

@ -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"}))
};

View file

@ -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")
};

View file

@ -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: ")

View file

@ -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"
}
]

View file

@ -1,56 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Holy Grail Layout with BeerCSS</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style>
body {
margin: 0;
font-family: 'Roboto', sans-serif;
}
.container {
display: grid;
grid-template-rows: auto 1fr auto;
min-height: 100vh;
}
.main-layout {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
padding: 1rem;
}
@media (min-width: 768px) {
.main-layout {
grid-template-columns: 1fr 1fr;
}
}
@media (min-width: 1024px) {
.main-layout {
grid-template-columns: 200px 1fr 200px;
}
}
@media (max-width: 767px) {
.main-layout {
grid-template-areas:
"main"
"left-sidebar"
"right-sidebar";
}
}
</style>
</head>
<body>
<div class="container">
<header class="primary padding large">Header</header>
<div class="main-layout">
<nav class="left-sidebar surface padding">Left Sidebar</nav>
<main class="padding">Main Content</main>
<aside class="right-sidebar surface padding">Right Sidebar</aside>
</div>
<footer class="primary padding large">Footer</footer>
</div>
</body>
</html>

View file

@ -113,7 +113,9 @@
<option
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">
lsp-text.xqm</option>
<option
value="../../../lsp/lsp-text.xqm">
lsp-text.xqm</option>
</optgroup>
<optgroup label="xpath">
<option