[add] start symbols

This commit is contained in:
Andy Bunce 2025-09-20 22:18:15 +01:00
parent 00aed821e1
commit aede6dab36
3 changed files with 28 additions and 7 deletions

View file

@ -14,7 +14,8 @@ declare variable $lsp-text:methods:=map{
"textDocument/hover": lsp-text:hover#1,
"textDocument/completion": lsp-text:completion#1,
"textDocument/formatting" : lsp-text:format#1
"textDocument/formatting" : lsp-text:format#1,
"textDocument/documentSymbol" : lsp-text:symbols#1
};
(:~ hover :)
@ -29,6 +30,18 @@ as map(*)
return rpc:result({"contents":$r},$json)
};
(:~ symbols :)
declare
function lsp-text:symbols($json as map(*))
as map(*)?
{
let $doc:=$json?params?textDocument?uri
return map{
"jsonrpc": "2.0",
"id": $json?id,
"result":()
}
};
declare
function lsp-text:completion($json as map(*))

View file

@ -80,7 +80,7 @@
<button id="wordAt" type="button" class="btn btn-light" title="word at">
<i class="bi bi-1-square"></i></button>
<button id="unused2" type="button" class="btn btn-light" title="unused2">
<button id="symbols2" type="button" class="btn btn-light" title="symbols">
<i class="bi bi-2-square"></i></button>
<button id="unused3" type="button" class="btn btn-light" title="unused3">

View file

@ -38,17 +38,25 @@ $("search").onclick = e => lsp.openSearchPanel(view);
$("fullscreen").onclick = e => $("editor").requestFullscreen();
$("wordAt").onclick = e => {
let pos=view.state.selection.main.head;
let w= view.state.wordAt(pos);
alert("wordAt " + JSON.stringify(w) );
let pos = view.state.selection.main.head;
let w = view.state.wordAt(pos);
alert("wordAt " + JSON.stringify(w));
};
$("symbols2").onclick = e => {
client.sync();
client.request("textDocument/documentSymbol", { "textDocument": { "uri": $("iFile").value} })
.then (r => {
alert("symbols " + "TODO");
});
};
$("cmd").onclick = e => {
let cmds = lsp.listCommands(view);
[...cmds.keys()].forEach(key => {
console.log(`${key} ${cmds.get(key).key}` )
console.log(`${key} ${cmds.get(key).key}`)
});
};
$("lint").onclick = async e => {