generated from itdominator/Python-With-Gtk-Template
Capped const variables; loading config and socket from config
This commit is contained in:
parent
7bec522a31
commit
c268a7ef1a
@ -105,13 +105,13 @@
|
|||||||
<script src="resources/js/libs/ace_editor/ext-language_tools.js"></script>
|
<script src="resources/js/libs/ace_editor/ext-language_tools.js"></script>
|
||||||
|
|
||||||
<!-- For ACE LSP... -->
|
<!-- For ACE LSP... -->
|
||||||
<script src="resources/js/newton/lsp-manager.js"></script>
|
|
||||||
<script src="resources/js/libs/ace_editor/lsp/ace-linters.js"></script>
|
<script src="resources/js/libs/ace_editor/lsp/ace-linters.js"></script>
|
||||||
<script src="resources/js/libs/ace_editor/lsp/service-manager.js"></script>
|
<script src="resources/js/libs/ace_editor/lsp/service-manager.js"></script>
|
||||||
<script src="resources/js/libs/ace_editor/lsp/language-client.js"></script>
|
<script src="resources/js/libs/ace_editor/lsp/language-client.js"></script>
|
||||||
|
|
||||||
<!-- For Application... -->
|
<!-- For Application... -->
|
||||||
<script src="resources/js/newton/globals.js"></script>
|
<script src="resources/js/newton/globals.js"></script>
|
||||||
|
<script src="resources/js/newton/lsp-manager.js"></script>
|
||||||
<script src="resources/js/newton/utils.js"></script>
|
<script src="resources/js/newton/utils.js"></script>
|
||||||
<script src="resources/js/newton/post-ajax.js"></script>
|
<script src="resources/js/newton/post-ajax.js"></script>
|
||||||
<script src="resources/js/newton/ajax.js"></script>
|
<script src="resources/js/newton/ajax.js"></script>
|
||||||
|
@ -31,9 +31,9 @@ const doAjax = (actionPath, data, action) => {
|
|||||||
const formatURL = (basePath) => {
|
const formatURL = (basePath) => {
|
||||||
url = window.location.href;
|
url = window.location.href;
|
||||||
if ( url.endsWith('/') )
|
if ( url.endsWith('/') )
|
||||||
return url + basePath;
|
return `${url}${basePath}`;
|
||||||
else
|
else
|
||||||
return url + '/' + basePath;
|
return `${url}/${basePath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchData = async (url) => {
|
const fetchData = async (url) => {
|
||||||
@ -117,6 +117,10 @@ const importScriptFromScriptStr = async (scriptStr) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const importScriptFromBackendResponse = async (scriptName, dataStr) => {
|
const importScriptFromBackendResponse = async (scriptName, dataStr) => {
|
||||||
backendResponse = atob(dataStr);
|
scriptStr = atob(dataStr);
|
||||||
scriptBlobURLs[scriptName] = await importScriptFromScriptStr(backendResponse);
|
SCRIPT_BLOB_URLs[scriptName] = await importScriptFromScriptStr(scriptStr);
|
||||||
|
|
||||||
|
if (scriptName === "lsp_servers_config.json") {
|
||||||
|
lspServersConfig = JSON.parse(scriptStr);
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,16 +13,14 @@ window.onload = (eve) => {
|
|||||||
|
|
||||||
|
|
||||||
const loadLSPClientJSFiles = () => {
|
const loadLSPClientJSFiles = () => {
|
||||||
const baseLink = `${window.location.href}resources/js/libs/ace_editor/lsp`;
|
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = LSP_SERVER_CONFG, content = "");
|
||||||
|
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${BASE_LINK}/ace-linters.js`, content = "");
|
||||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/../lsp_servers_config.json`, content = "");
|
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${BASE_LINK}/base-service.js`, content = "");
|
||||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/ace-linters.js`, content = "");
|
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${BASE_LINK}/service-manager.js`, content = "");
|
||||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/base-service.js`, content = "");
|
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${BASE_LINK}/language-client.js`, content = "");
|
||||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/service-manager.js`, content = "");
|
|
||||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/language-client.js`, content = "");
|
|
||||||
|
|
||||||
// Note: If using builtin services tghan connecting to a socket.
|
// Note: If using builtin services tghan connecting to a socket.
|
||||||
// sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/python-service.js`, content = "");
|
// sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${BASE_LINK}/python-service.js`, content = "");
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onerror = function(msg, url, line, col, error) {
|
window.onerror = function(msg, url, line, col, error) {
|
||||||
|
@ -2,7 +2,7 @@ const messenger = (window.webkit) ? window.webkit.messageHandlers : (message) =
|
|||||||
console.log("Message: " + message);
|
console.log("Message: " + message);
|
||||||
};
|
};
|
||||||
|
|
||||||
const editorOpts = {
|
const EDITOR_OPTS = {
|
||||||
printMarginColumn: 80,
|
printMarginColumn: 80,
|
||||||
enableBasicAutocompletion: true,
|
enableBasicAutocompletion: true,
|
||||||
enableInlineAutocompletion: true,
|
enableInlineAutocompletion: true,
|
||||||
@ -17,9 +17,13 @@ const editorOpts = {
|
|||||||
mergeUndoDeltas: false
|
mergeUndoDeltas: false
|
||||||
}
|
}
|
||||||
|
|
||||||
const scriptBlobURLs = {};
|
const BASE_LINK = `${window.location.href}resources/js/libs/ace_editor/lsp`;
|
||||||
const baseLSPLink = "http://0.0.0.0:4880";
|
const LSP_SERVER_CONFG = `${window.location.href}../lsp_servers_config.json`;
|
||||||
|
const BASE_LSP_LINK = "http://0.0.0.0:4880";
|
||||||
|
|
||||||
|
const SCRIPT_BLOB_URLs = {};
|
||||||
let lspProvider = null;
|
let lspProvider = null;
|
||||||
|
let lspServersConfig = null;
|
||||||
|
|
||||||
|
|
||||||
let editor = null;
|
let editor = null;
|
||||||
|
@ -1,60 +1,36 @@
|
|||||||
/* Works but isn't websocket */
|
/* Works but isn't websocket */
|
||||||
// manager.registerService("python", {
|
// manager.registerService("python", {
|
||||||
// module: () => {
|
// module: () => {
|
||||||
// importScripts( "${ scriptBlobURLs["python-service.js"] }" );
|
// importScripts( "${ SCRIPT_BLOB_URLs["python-service.js"] }" );
|
||||||
// return {PythonService};
|
// return {PythonService};
|
||||||
// },
|
// },
|
||||||
// className: "PythonService",
|
// className: "PythonService",
|
||||||
// modes: "python|python3",
|
// modes: "python|python3",
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// importScripts("${await importScriptFromNetwork(baseLink + "/service-manager.js")}");
|
|
||||||
// importScripts("${await importScriptFromNetwork(baseLink + "/python-service.js")}");
|
|
||||||
// importScripts("${await importScriptFromNetwork(baseLink + "/language-client.js")}");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// initializationOptions: {
|
|
||||||
// "pylsp.plugins.rope_autoimport.enabled": true,
|
|
||||||
// "pylsp.plugins.rope_completion.enabled": true,
|
|
||||||
// "pylsp.plugins.rope_completion.eager": true,
|
|
||||||
// "pylsp.plugins.jedi_completion.fuzzy": true,
|
|
||||||
// "pylsp.plugins.jedi.extra_paths": [
|
|
||||||
// "/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/lib/python3.10/site-packages",
|
|
||||||
// "/home/abaddon/Portable_Apps/py-venvs/gtk-apps-venv/venv/lib/python3.10/site-packages/gi"
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
|
|
||||||
// "/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/lib/python3.10/site-packages"
|
|
||||||
|
|
||||||
|
|
||||||
const loadPythonLSPFromBlobURLs = () => {
|
const loadPythonLSPFromBlobURLs = () => {
|
||||||
importJavaScriptFileFromBlobURL( scriptBlobURLs["ace-linters.js"] ).then(
|
importJavaScriptFileFromBlobURL( SCRIPT_BLOB_URLs["ace-linters.js"] ).then(
|
||||||
async () => {
|
async () => {
|
||||||
let workerString = `
|
let workerString = `
|
||||||
!function () {
|
!function () {
|
||||||
importScripts( "${ scriptBlobURLs["service-manager.js"] }" );
|
importScripts( "${ SCRIPT_BLOB_URLs["service-manager.js"] }" );
|
||||||
let manager = new ServiceManager(self);
|
let manager = new ServiceManager(self);
|
||||||
|
|
||||||
/* Works and is websocket */
|
/* Works and is websocket */
|
||||||
manager.registerServer("python", {
|
manager.registerServer(
|
||||||
module: () => {
|
"python", {
|
||||||
importScripts( "${ scriptBlobURLs["language-client.js"] }" );
|
module: () => {
|
||||||
return {LanguageClient};
|
importScripts( "${ SCRIPT_BLOB_URLs["language-client.js"] }" );
|
||||||
},
|
return {LanguageClient};
|
||||||
modes: "python|python3",
|
},
|
||||||
type: "socket", // "socket|worker"
|
modes: "python|python3",
|
||||||
socket: new WebSocket("ws://127.0.0.1:3030/python"),
|
type: "socket", // "socket|worker"
|
||||||
initializationOptions: {
|
socket: new WebSocket( "${ lspServersConfig['python']['socket'] }" ),
|
||||||
"pylsp.plugins.rope_autoimport.enabled": true,
|
initializationOptions: ${ JSON.stringify( lspServersConfig['python']['initialization_options'] ) }
|
||||||
"pylsp.plugins.rope_completion.enabled": true,
|
|
||||||
"pylsp.plugins.rope_completion.eager": true,
|
|
||||||
"pylsp.plugins.jedi_completion.fuzzy": true,
|
|
||||||
"pylsp.plugins.jedi.extra_paths": [
|
|
||||||
"/home/abaddon/Portable_Apps/py-venvs/lsp_bridge-venv/venv/lib/python3.10/site-packages/gi-stubs"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}()
|
}()
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -75,28 +51,23 @@ const loadPythonLSPFromBlobURLs = () => {
|
|||||||
|
|
||||||
|
|
||||||
const loadPythonLSPFromNetwork = () => {
|
const loadPythonLSPFromNetwork = () => {
|
||||||
importJavaScriptFile(baseLSPLink + "/ace-linters.js").then(
|
importJavaScriptFile(BASE_LSP_LINK + "/ace-linters.js").then(
|
||||||
async () => {
|
async () => {
|
||||||
let workerString = `
|
let workerString = `
|
||||||
!function () {
|
!function () {
|
||||||
importScripts("${await importScriptFromNetwork(baseLSPLink + "/service-manager.js")}");
|
importScripts("${await importScriptFromNetwork(BASE_LSP_LINK + "/service-manager.js")}");
|
||||||
let manager = new ServiceManager(self);
|
let manager = new ServiceManager(self);
|
||||||
|
|
||||||
/* Works and is websocket */
|
/* Works and is websocket */
|
||||||
manager.registerServer("python", {
|
manager.registerServer("python", {
|
||||||
module: () => {
|
module: () => {
|
||||||
importScripts("${await importScriptFromNetwork(baseLSPLink + "/language-client.js")}");
|
importScripts("${await importScriptFromNetwork(BASE_LSP_LINK + "/language-client.js")}");
|
||||||
return {LanguageClient};
|
return {LanguageClient};
|
||||||
},
|
},
|
||||||
modes: "python|python3",
|
modes: "python|python3",
|
||||||
type: "socket", // "socket|worker"
|
type: "socket", // "socket|worker"
|
||||||
socket: new WebSocket("ws://127.0.0.1:3030/python"),
|
socket: new WebSocket( "${ lspServersConfig['python']['socket'] }" ),
|
||||||
initializationOptions: {
|
initializationOptions: ${ JSON.stringify( lspServersConfig['python']['initialization_options'] ) }
|
||||||
"pylsp.plugins.jedi.extra_paths": [
|
|
||||||
"/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/lib/python3.10/site-packages",
|
|
||||||
"/home/abaddon/Portable_Apps/py-venvs/gtk-apps-venv/venv/lib/python3.10/site-packages/gi"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}()
|
}()
|
||||||
`;
|
`;
|
||||||
|
@ -3,7 +3,7 @@ const loadPreviewEditor = () => {
|
|||||||
|
|
||||||
previewEditor = ace.edit("preview-editor");
|
previewEditor = ace.edit("preview-editor");
|
||||||
// Note: https://github.com/ajaxorg/ace/wiki/Configuring-Ace
|
// Note: https://github.com/ajaxorg/ace/wiki/Configuring-Ace
|
||||||
previewEditor.setOptions(editorOpts);
|
previewEditor.setOptions(EDITOR_OPTS);
|
||||||
|
|
||||||
// Note: https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts
|
// Note: https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts
|
||||||
previewEditor.commands.addCommands(editorCommands);
|
previewEditor.commands.addCommands(editorCommands);
|
||||||
@ -18,7 +18,7 @@ const loadEditor = () => {
|
|||||||
|
|
||||||
editor = ace.edit("editor");
|
editor = ace.edit("editor");
|
||||||
// Note: https://github.com/ajaxorg/ace/wiki/Configuring-Ace
|
// Note: https://github.com/ajaxorg/ace/wiki/Configuring-Ace
|
||||||
editor.setOptions(editorOpts);
|
editor.setOptions(EDITOR_OPTS);
|
||||||
|
|
||||||
// Note: https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts
|
// Note: https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts
|
||||||
editor.commands.addCommands(editorCommands);
|
editor.commands.addCommands(editorCommands);
|
||||||
|
Loading…
Reference in New Issue
Block a user