[fix] size linewrap

This commit is contained in:
Andy Bunce 2025-08-05 23:02:56 +01:00
parent f1fecbdee8
commit 5b311838ba
13 changed files with 196 additions and 5480 deletions

View file

@ -6,11 +6,12 @@
module namespace docs="lsp/docs";
import module namespace p="xq4" at "xq4.xqm";
(:~
@param line Line position in a document (zero-based).
@param character Character offset on a line in a document (zero-based).
:)
declare record docs:Position(
(: Line position in a document (zero-based). :)
line as xs:integer,
(: Character offset on a line in a document (zero-based). :)
character as xs:integer
);
@ -34,23 +35,25 @@ declare function docs:get(
(: save $textDocument data as session $socket properties :)
declare function docs:save(
$socket as xs:string,
$textDocument as map(*)
$params as map(*)
)
{
let $text as xs:string:=$textDocument?text
let $uri:=$textDocument?uri
let $text as xs:string:=$params?textDocument?text
let $uri:=$params?textDocument?uri
let $files:=ws:get($socket,"files",{})
let $files:=if(map:contains($files,$uri))
then $files
else map:put($files,$uri,{
"textDocument":random:uuid(),
"parse":random:uuid() })
else
let $uuid:=random:uuid()
return map:put($files,$uri,{
"textDocument": "file-" || $uuid,
"parse": "parse-" || $uuid })
let $keys:=$files($uri)
let $xml:=p:parse-Module($text)
let $xml:=prof:time(p:parse-Module($text),"⏱️ p:parse-Module ")
return (
ws:set($socket,"files",$files),
ws:set($socket,$keys?textDocument,$textDocument),
ws:set($socket,$keys?textDocument,$params?textDocument),
ws:set($socket,$keys?parse,$xml)
)
};

View file

@ -18,19 +18,19 @@ declare variable $lsp-text:methods:=map{
:)
declare
function lsp-text:hover($json as map(*))
as map(*)?
as map(*)
{
let $doc:=$json?params?textDocument?uri
return map{
map{
"jsonrpc": "2.0",
"id": $json?id,
"result":{
"contents": [
`markdown: this is **bold**
a [link](http://google.com)
The last line.`
`markdown here, this is **bold**.
A [link](http://google.com)
The last line.`
,
"plaintext: A hover for " || json:serialize($json?params?position)
`A hover for { json:serialize($json?params?position) }
uri: {$json?params?textDocument?uri} `
]
}
}
@ -53,9 +53,9 @@ declare
function lsp-text:didOpen($json as map(*))
as empty-sequence()
{
let $textDoc:=$json?params?textDocument
let $x:=job:eval(xs:anyURI("parse.xq"),
{"textDocument":$textDoc,"webSocket":ws:id()},
{"params" : $json?params,
"webSocket":ws:id()},
{ 'cache': true() }
)
@ -67,9 +67,9 @@ declare
function lsp-text:didChange($json as map(*))
as map(*)?
{
let $textDoc:=$json?params?textDocument
let $x:=job:eval(xs:anyURI("parse.xq"),
{"textDocument":$textDoc,"webSocket":ws:id()},
{"params": $json?params,"webSocket":ws:id()},
{ 'cache': true() }
)

View file

@ -1,13 +1,14 @@
(: Save an XQuery doc and it's parse :)
import module namespace docs="lsp/docs" at "docs.xqm";
declare variable $textDocument external;
(:~ from LSP didOpen or didChange msg:)
declare variable $params as map(*) external;
declare variable $webSocket as xs:string external;
docs:save(
prof:time(docs:save(
$webSocket,
$textDocument
),
$params
),"⏱️ doc:save "),
ws:send(
{"jsonrpc": "2.0",