[fix] working editor
This commit is contained in:
parent
f31520b45c
commit
16c0a1c8c4
7 changed files with 203 additions and 50 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
data/
|
11
README.md
11
README.md
|
@ -1,3 +1,14 @@
|
|||
An attempt to write a language protocol server using BaseX features...
|
||||
|
||||
* `webapp/lsp` A BaseX LSP application with a WebSocket Jsonrpc API
|
||||
* `webapp/static/ace` A html page using an Ace editor that connects to a BaseX LSP instance
|
||||
|
||||
## Uses
|
||||
* https://github.com/mkslanc/ace-linters https://mkslanc.github.io/ace-linters/
|
||||
|
||||
* I needed `set NODE_OPTIONS=--max_old_space_size=8192` for build to complete
|
||||
## notes
|
||||
|
||||
Using https://github.com/mkslanc/ace-linters https://mkslanc.github.io/ace-linters/
|
||||
|
||||
Make a websocket server for lsp on port 3000
|
||||
|
|
|
@ -28,3 +28,124 @@
|
|||
13:59:11.369 SERVER admin TRACE CONNECT: "websocket2"
|
||||
14:03:40.821 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
14:03:40.829 SERVER admin TRACE CONNECT: "websocket3"
|
||||
14:52:02.807 SERVER admin OK Server was started (port: 1984).
|
||||
14:52:02.852 SERVER admin OK HTTP Server was started (port: 8080).
|
||||
14:54:26.641 172.19.0.1:46432 admin REQUEST [GET] /favicon.ico
|
||||
14:54:28.835 172.19.0.1:46432 admin 404 Service not found. 2195.32 ms
|
||||
14:59:48.126 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
14:59:48.159 SERVER admin TRACE CONNECT: "websocket0"
|
||||
15:03:35.640 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:03:35.655 SERVER admin TRACE CONNECT: "websocket1"
|
||||
15:03:35.846 172.19.0.1:49788 admin REQUEST [GET] /favicon.ico
|
||||
15:03:35.847 172.19.0.1:49788 admin 404 Service not found. 1.8 ms
|
||||
15:08:19.471 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:08:19.484 SERVER admin TRACE CONNECT: "websocket2"
|
||||
15:10:06.561 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:10:06.573 SERVER admin TRACE CONNECT: "websocket3"
|
||||
15:10:52.549 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:10:52.559 SERVER admin TRACE CONNECT: "websocket4"
|
||||
15:11:06.125 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:11:06.134 SERVER admin TRACE CONNECT: "websocket5"
|
||||
15:11:06.211 172.19.0.1:49234 admin REQUEST [GET] /favicon.ico
|
||||
15:11:06.212 172.19.0.1:49234 admin 404 Service not found. 1.32 ms
|
||||
15:12:53.901 172.19.0.1:38688 admin REQUEST [GET] /exampleServer
|
||||
15:12:53.922 172.19.0.1:38688 admin 404 Service not found. 24.36 ms
|
||||
15:14:19.235 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:14:19.247 SERVER admin TRACE CONNECT: "websocket6"
|
||||
15:18:53.916 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:18:53.932 SERVER admin TRACE CONNECT: "websocket7"
|
||||
15:21:07.983 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:21:07.993 SERVER admin TRACE CONNECT: "websocket8"
|
||||
15:23:42.106 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:23:42.116 SERVER admin TRACE CONNECT: "websocket9"
|
||||
15:34:19.447 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:34:19.464 SERVER admin TRACE CONNECT: "websocket10"
|
||||
15:54:25.526 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
15:54:25.549 SERVER admin TRACE CONNECT: "websocket11"
|
||||
16:20:28.642 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
16:20:28.671 SERVER admin TRACE CONNECT: "websocket12"
|
||||
16:20:28.945 172.19.0.1:51002 admin REQUEST [GET] /favicon.ico
|
||||
16:20:28.948 172.19.0.1:51002 admin 404 Service not found. 3.59 ms
|
||||
16:28:00.399 172.19.0.1:43084 admin REQUEST [GET] /favicon.ico
|
||||
16:28:00.412 172.19.0.1:43084 admin 404 Service not found. 13.71 ms
|
||||
16:31:26.564 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
16:31:26.582 SERVER admin TRACE CONNECT: "websocket13"
|
||||
16:36:32.978 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
16:36:32.999 SERVER admin TRACE CONNECT: "websocket14"
|
||||
16:51:00.861 172.19.0.1:51754 admin REQUEST [GET] /favicon.ico
|
||||
16:51:00.877 172.19.0.1:51754 admin 404 Service not found. 16.12 ms
|
||||
16:51:52.441 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
16:51:52.456 SERVER admin TRACE CONNECT: "websocket15"
|
||||
16:53:31.048 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
16:53:31.065 SERVER admin TRACE CONNECT: "websocket16"
|
||||
16:55:51.056 172.19.0.1:38764 admin REQUEST [GET] /exampleServer
|
||||
16:55:51.073 172.19.0.1:38764 admin 404 Service not found. 16.8 ms
|
||||
16:58:22.121 172.19.0.1:52126 admin REQUEST [GET] /favicon.ico
|
||||
16:58:22.135 172.19.0.1:52126 admin 404 Service not found. 14.19 ms
|
||||
17:03:25.464 172.19.0.1:46446 admin REQUEST [GET] /favicon.ico
|
||||
17:03:25.479 172.19.0.1:46446 admin 404 Service not found. 15.21 ms
|
||||
17:05:15.288 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
17:05:15.305 SERVER admin TRACE CONNECT: "websocket17"
|
||||
19:55:27.736 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
19:55:27.789 SERVER admin TRACE CONNECT: "websocket18"
|
||||
19:55:27.841 172.19.0.1:37328 admin REQUEST [GET] /favicon.ico
|
||||
19:55:27.843 172.19.0.1:37328 admin 404 Service not found. 2.82 ms
|
||||
20:21:49.709 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
20:21:49.741 SERVER admin TRACE CONNECT: "websocket19"
|
||||
20:21:49.837 172.19.0.1:50254 admin REQUEST [GET] /favicon.ico
|
||||
20:21:49.839 172.19.0.1:50254 admin 404 Service not found. 2.69 ms
|
||||
20:24:33.730 172.19.0.1:58644 admin REQUEST [GET] /dba/logs?input=
|
||||
20:24:33.907 172.19.0.1:58644 admin 302 Location: login?input=&_page=logs 176.8 ms
|
||||
20:24:33.919 172.19.0.1:58644 admin REQUEST [GET] /dba/login?input=&_page=logs
|
||||
20:24:34.022 172.19.0.1:58644 public 200 104.28 ms
|
||||
20:24:34.083 172.19.0.1:58644 admin REQUEST [GET] /dba/static/style.css
|
||||
20:24:34.091 172.19.0.1:58646 admin REQUEST [GET] /dba/static/codemirror/codemirror.css
|
||||
20:24:34.093 172.19.0.1:58654 admin REQUEST [GET] /dba/static/codemirror/codemirror.js
|
||||
20:24:34.093 172.19.0.1:58668 admin REQUEST [GET] /dba/static/js.js
|
||||
20:24:34.095 172.19.0.1:58660 admin REQUEST [GET] /dba/static/editor.js
|
||||
20:24:34.096 172.19.0.1:58674 admin REQUEST [GET] /dba/static/codemirror/xquery.js
|
||||
20:24:34.203 172.19.0.1:58646 public 200 112.16 ms
|
||||
20:24:34.204 172.19.0.1:58668 public 200 110.64 ms
|
||||
20:24:34.204 172.19.0.1:58654 public 200 112.02 ms
|
||||
20:24:34.205 172.19.0.1:58644 public 200 121.63 ms
|
||||
20:24:34.205 172.19.0.1:58660 public 200 111.5 ms
|
||||
20:24:34.211 172.19.0.1:58674 public 200 114.72 ms
|
||||
20:24:34.211 172.19.0.1:58644 admin REQUEST [GET] /dba/static/codemirror/xml.js
|
||||
20:24:34.270 172.19.0.1:58644 public 200 59.21 ms
|
||||
20:24:34.276 172.19.0.1:58654 admin REQUEST [GET] /dba/static/basex.svg
|
||||
20:24:34.334 172.19.0.1:58654 public 200 58.07 ms
|
||||
20:24:36.041 172.19.0.1:58654 admin REQUEST [POST] /dba/login
|
||||
20:24:36.091 172.19.0.1:58654 public DBA Login: admin
|
||||
20:24:36.092 172.19.0.1:58654 public 302 Location: logs?input= 50.85 ms
|
||||
20:24:36.099 172.19.0.1:58654 admin REQUEST [GET] /dba/logs?input=
|
||||
20:24:36.206 172.19.0.1:58654 admin 200 108.58 ms
|
||||
20:24:36.275 172.19.0.1:58654 admin REQUEST [POST] /dba/logs?date=2025-07-17&page=1
|
||||
20:24:36.377 172.19.0.1:58674 admin REQUEST [GET] /dba/static/basex.svg
|
||||
20:24:36.415 172.19.0.1:58674 public 200 38.1 ms
|
||||
20:24:36.439 172.19.0.1:58654 admin 200 164.58 ms
|
||||
20:25:53.749 172.19.0.1:38538 admin REQUEST [GET] /dba/editor
|
||||
20:25:53.814 172.19.0.1:38538 admin 200 65.59 ms
|
||||
20:25:57.907 172.19.0.1:38538 admin REQUEST [GET] /dba/files
|
||||
20:25:57.994 172.19.0.1:38538 admin 200 87.0 ms
|
||||
20:26:03.620 172.19.0.1:38538 admin REQUEST [GET] /dba/sessions
|
||||
20:26:03.668 172.19.0.1:38538 admin 200 48.32 ms
|
||||
20:26:05.752 172.19.0.1:38538 admin REQUEST [GET] /dba/settings
|
||||
20:26:05.795 172.19.0.1:38538 admin 200 43.28 ms
|
||||
20:26:09.100 172.19.0.1:38538 admin REQUEST [GET] /dba/jobs
|
||||
20:26:09.165 172.19.0.1:38538 admin 200 65.06 ms
|
||||
20:26:13.623 172.19.0.1:38538 admin REQUEST [GET] /dba/editor
|
||||
20:26:13.659 172.19.0.1:38538 admin 200 36.22 ms
|
||||
20:26:18.147 172.19.0.1:38538 admin REQUEST [GET] /dba/databases
|
||||
20:26:18.211 172.19.0.1:38538 admin 200 64.37 ms
|
||||
20:45:26.245 172.19.0.1:51432 admin REQUEST [GET] /dba/logs
|
||||
20:45:26.319 172.19.0.1:51432 admin 200 74.87 ms
|
||||
20:45:26.407 172.19.0.1:51432 admin REQUEST [POST] /dba/logs?date=2025-07-17&page=1
|
||||
20:45:26.496 172.19.0.1:51432 admin 200 89.92 ms
|
||||
20:46:15.411 172.19.0.1:51432 admin REQUEST [GET] /lsp
|
||||
20:46:15.426 172.19.0.1:51432 admin 404 Service not found. 14.85 ms
|
||||
20:46:42.266 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
20:46:42.278 SERVER admin TRACE CONNECT: "websocket20"
|
||||
20:47:31.865 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp
|
||||
20:47:31.879 SERVER admin TRACE CONNECT: "websocket21"
|
||||
21:05:38.659 172.19.0.1:43870 admin REQUEST [GET] /exampleServer
|
||||
21:05:38.677 172.19.0.1:43870 admin 404 Service not found. 17.6 ms
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
module: () => import("ace-linters/build/language-client"),
|
||||
modes: "astro",
|
||||
type: "socket",
|
||||
socket: new WebSocket("ws://127.0.0.1:8080/ws/lsp"),
|
||||
socket: new WebSocket("ws://127.0.0.1:8080/ws/lsp"
|
||||
//"ws://127.0.0.1:3000/exampleserver"
|
||||
),
|
||||
}
|
||||
];
|
||||
let languageProvider = AceLanguageClient.for(servers);
|
||||
|
|
|
@ -2,58 +2,27 @@
|
|||
<html lang="en-US">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>BaseX LSP</title>
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"ace": "https://esm.sh/ace-builds@latest",
|
||||
"ace-linters/": "https://esm.sh/ace-linters@latest"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <script type="module" src="acego.js"></script> -->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height" />
|
||||
<title>BaseX LSP Demo WIP</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ace.js"></script>
|
||||
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-language_tools.js"></script>
|
||||
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
|
||||
<script src="https://www.unpkg.com/ace-linters@latest/build/service-manager.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>something<button onclick="foo()">send</button><a href="/dba/logs" target="_blank">dba</a></div>
|
||||
<div id="editor" style="height: 100px">some text</div>
|
||||
<script type="module">
|
||||
import ace from 'ace';
|
||||
import AceLanguageClient from "https://esm.sh/ace-linters@latest/build/ace-language-client";
|
||||
|
||||
ace.config.set('basePath', 'https://esm.sh/ace-builds@latest/src-noconflict');
|
||||
const ed = ace.edit("editor", {
|
||||
mode: "ace/mode/json",
|
||||
theme: "ace/theme/github"
|
||||
});
|
||||
|
||||
|
||||
var servers = [
|
||||
{
|
||||
module: () => import("https://esm.sh/ace-linters@latest/build/language-client"),
|
||||
modes: "json",
|
||||
type: "socket",
|
||||
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"),
|
||||
}
|
||||
];
|
||||
let languageProvider = AceLanguageClient.for(servers);
|
||||
|
||||
ace.require("ace/ext/language_tools"); //To allow autocompletion
|
||||
var editor = ace.edit("editor", {
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: true,
|
||||
mode: "json"
|
||||
});
|
||||
|
||||
languageProvider.registerEditor(editor);
|
||||
// editor.session.setMode("astro"); // mode now contains "ace/mode/javascript".
|
||||
function foo(){
|
||||
servers[0].socket.send("TTTTT")
|
||||
alert("hi")
|
||||
}
|
||||
</script>
|
||||
<header>something
|
||||
<button onclick="opts(editor)">console</button>
|
||||
<button onclick="editor.showSettingsMenu();">Settings</button>
|
||||
<a href="/dba/logs" target="_blank">dba</a>
|
||||
</header>
|
||||
<div>
|
||||
<div id="settings" style="height: 100px">sett</div>
|
||||
<div id="editor" style="height: 100px">some text</div>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
|
|
42
webapp/static/ace/script.js
Normal file
42
webapp/static/ace/script.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
ace.require("ace/ext/language_tools"); //To allow autocompletion
|
||||
var editor = ace.edit("editor", {
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: true,
|
||||
theme: "ace/theme/chrome",
|
||||
mode: "ace/mode/html",
|
||||
fontSize: "14px",
|
||||
showPrintMargin: false,
|
||||
useWorker: false // Disable web worker for this simple demo
|
||||
});
|
||||
|
||||
//ace.require('ace/ext/settings_menu');
|
||||
editor.setTheme("ace/theme/github");
|
||||
//editor.session.setMode("ace/mode/html");
|
||||
editor.commands.addCommands([
|
||||
{
|
||||
name: "showSettingsMenu",
|
||||
bindKey: {
|
||||
win: "Ctrl-q",
|
||||
mac: "Ctrl-q"
|
||||
},
|
||||
exec: function (editor) {
|
||||
editor.showSettingsMenu();
|
||||
},
|
||||
readOnly: true
|
||||
}
|
||||
]);
|
||||
var provider = LanguageProvider.fromCdn("https://www.unpkg.com/ace-linters@latest/build/");
|
||||
provider.registerEditor(editor);
|
||||
|
||||
const serverData = {
|
||||
module: () => import("https://www.unpkg.com/ace-linters@latest/build/language-client"),
|
||||
modes: "json|json5",
|
||||
type: "socket",
|
||||
socket: new WebSocket("ws://127.0.0.1:3000/exampleServer"), // your websocket server address
|
||||
}
|
||||
|
||||
function opts(editor) {
|
||||
const modes=editor.session.$modes;
|
||||
console.log(editor.session.$modeId);
|
||||
console.log(Object.keys(modes));
|
||||
}
|
7
webapp/static/ace/styles.css
Normal file
7
webapp/static/ace/styles.css
Normal file
|
@ -0,0 +1,7 @@
|
|||
header {
|
||||
background-color: aqua;
|
||||
}
|
||||
.box {
|
||||
border: 2px dotted rgb(96 139 168);
|
||||
display: flex;
|
||||
}
|
Loading…
Add table
Reference in a new issue