generated from itdominator/Python-With-Gtk-Template
Added lsp-manager js file; updated lsp config
This commit is contained in:
parent
02ce50cb76
commit
7bec522a31
@ -55,6 +55,37 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- LSP modal -->
|
||||
<div class="modal" id="lsp-modal" tabindex="-1" role="dialog" data-bs-theme="dark">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3>LSPs:</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body margin-bottom-neg-200">
|
||||
<div class="row">
|
||||
<div class="col max-height-600 noselect">
|
||||
<ul id="lsp-selection" class="list-group scroller">
|
||||
</ul>
|
||||
<button onclick="loadPythonLSPFromBlobURLs()">Load LSP Client</button>
|
||||
<input id="lsp-search" class="form-control mr-sm-2" type="search" placeholder="Search..." aria-label="Search" />
|
||||
</div>
|
||||
<div class="col max-height-800">
|
||||
<pre id="preview-editor"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<script nomodule>
|
||||
console.info(`Your browser doesn't support native JavaScript modules.`);
|
||||
</script>
|
||||
@ -74,6 +105,7 @@
|
||||
<script src="resources/js/libs/ace_editor/ext-language_tools.js"></script>
|
||||
|
||||
<!-- 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/service-manager.js"></script>
|
||||
<script src="resources/js/libs/ace_editor/lsp/language-client.js"></script>
|
||||
|
@ -101,8 +101,7 @@ const importJavaScriptFileFromBlobURL = async (objectURL) => {
|
||||
|
||||
// Add a listener to revoke the object URL when the script has loaded.
|
||||
scriptElement.addEventListener("load", () => {
|
||||
console.log("Loaded script...");
|
||||
// URL.revokeObjectURL(objectURL);
|
||||
URL.revokeObjectURL(objectURL);
|
||||
});
|
||||
|
||||
// Append the script element to the document to execute the JavaScript code.
|
||||
|
@ -15,6 +15,7 @@ window.onload = (eve) => {
|
||||
const loadLSPClientJSFiles = () => {
|
||||
const baseLink = `${window.location.href}resources/js/libs/ace_editor/lsp`;
|
||||
|
||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/../lsp_servers_config.json`, content = "");
|
||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/ace-linters.js`, content = "");
|
||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/base-service.js`, content = "");
|
||||
sendMessage(topic = "load_javascript", ftype = "", fhash = "", fpath = `${baseLink}/service-manager.js`, content = "");
|
||||
|
@ -18,6 +18,9 @@ const editorOpts = {
|
||||
}
|
||||
|
||||
const scriptBlobURLs = {};
|
||||
const baseLSPLink = "http://0.0.0.0:4880";
|
||||
let lspProvider = null;
|
||||
|
||||
|
||||
let editor = null;
|
||||
let previewEditor = null;
|
||||
|
@ -17,6 +17,14 @@ const editorCommands = [
|
||||
editor.showKeyboardShortcuts();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}, {
|
||||
name: "showLSPManager",
|
||||
bindKey: {win: "ctrl-m", mac: "command-m"},
|
||||
exec: function(editor) {
|
||||
$('#lsp-modal').modal("toggle");
|
||||
}
|
||||
}, {
|
||||
name: "search",
|
||||
bindKey: {win: "ctrl-f", mac: "ctrl-f"},
|
||||
|
@ -0,0 +1,117 @@
|
||||
/* Works but isn't websocket */
|
||||
// manager.registerService("python", {
|
||||
// module: () => {
|
||||
// importScripts( "${ scriptBlobURLs["python-service.js"] }" );
|
||||
// return {PythonService};
|
||||
// },
|
||||
// className: "PythonService",
|
||||
// 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 = () => {
|
||||
importJavaScriptFileFromBlobURL( scriptBlobURLs["ace-linters.js"] ).then(
|
||||
async () => {
|
||||
let workerString = `
|
||||
!function () {
|
||||
importScripts( "${ scriptBlobURLs["service-manager.js"] }" );
|
||||
let manager = new ServiceManager(self);
|
||||
|
||||
/* Works and is websocket */
|
||||
manager.registerServer("python", {
|
||||
module: () => {
|
||||
importScripts( "${ scriptBlobURLs["language-client.js"] }" );
|
||||
return {LanguageClient};
|
||||
},
|
||||
modes: "python|python3",
|
||||
type: "socket", // "socket|worker"
|
||||
socket: new WebSocket("ws://127.0.0.1:3030/python"),
|
||||
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/lsp_bridge-venv/venv/lib/python3.10/site-packages/gi-stubs"
|
||||
]
|
||||
}
|
||||
});
|
||||
}()
|
||||
`;
|
||||
|
||||
let worker = new Worker(
|
||||
createBlobURL(
|
||||
createScriptBlob(workerString)
|
||||
)
|
||||
);
|
||||
|
||||
lspProvider = LanguageProvider.create(worker);
|
||||
lspProvider.registerEditor(editor);
|
||||
}
|
||||
).catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
const loadPythonLSPFromNetwork = () => {
|
||||
importJavaScriptFile(baseLSPLink + "/ace-linters.js").then(
|
||||
async () => {
|
||||
let workerString = `
|
||||
!function () {
|
||||
importScripts("${await importScriptFromNetwork(baseLSPLink + "/service-manager.js")}");
|
||||
let manager = new ServiceManager(self);
|
||||
|
||||
/* Works and is websocket */
|
||||
manager.registerServer("python", {
|
||||
module: () => {
|
||||
importScripts("${await importScriptFromNetwork(baseLSPLink + "/language-client.js")}");
|
||||
return {LanguageClient};
|
||||
},
|
||||
modes: "python|python3",
|
||||
type: "socket", // "socket|worker"
|
||||
socket: new WebSocket("ws://127.0.0.1:3030/python"),
|
||||
initializationOptions: {
|
||||
"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"
|
||||
]
|
||||
}
|
||||
});
|
||||
}()
|
||||
`;
|
||||
|
||||
let worker = new Worker(
|
||||
createBlobURL(
|
||||
createScriptBlob(workerString)
|
||||
)
|
||||
);
|
||||
|
||||
lspProvider = LanguageProvider.create(worker);
|
||||
lspProvider.registerEditor(editor);
|
||||
}
|
||||
).catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
}
|
@ -28,6 +28,7 @@ const loadEditor = () => {
|
||||
editor.addEventListener("click", (eve) => {
|
||||
setLabels();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
const loadInitialSession = () => {
|
||||
@ -64,66 +65,6 @@ const setSession = async (ftype, fhash, session) => {
|
||||
|
||||
if (ftype !== "buffer") {
|
||||
editor.session.setMode("ace/mode/" + ftype);
|
||||
|
||||
if (ftype === "python") {
|
||||
// const baseLink = "http://0.0.0.0:4880";
|
||||
|
||||
// importJavaScriptFile(baseLink + "/ace-linters.js").then(
|
||||
importJavaScriptFileFromBlobURL( scriptBlobURLs["ace-linters.js"] ).then(
|
||||
async () => {
|
||||
/* Works but isn't websocket */
|
||||
// manager.registerService("python", {
|
||||
// module: () => {
|
||||
// importScripts( "${ scriptBlobURLs["python-service.js"] }" );
|
||||
// return {PythonService};
|
||||
// },
|
||||
// className: "PythonService",
|
||||
// modes: "python|python3",
|
||||
// });
|
||||
|
||||
// importScripts("${await importScriptFromNetwork(baseLink + "/service-manager.js")}");
|
||||
// importScripts("${await importScriptFromNetwork(baseLink + "/python-service.js")}");
|
||||
// importScripts("${await importScriptFromNetwork(baseLink + "/language-client.js")}");
|
||||
let workerString = `
|
||||
!function () {
|
||||
importScripts( "${ scriptBlobURLs["service-manager.js"] }" );
|
||||
let manager = new ServiceManager(self);
|
||||
|
||||
/* Works and is websocket */
|
||||
manager.registerServer("python", {
|
||||
module: () => {
|
||||
importScripts( "${ scriptBlobURLs["language-client.js"] }" );
|
||||
return {LanguageClient};
|
||||
},
|
||||
modes: "python|python3",
|
||||
type: "socket", // "socket|worker"
|
||||
socket: new WebSocket("ws://127.0.0.1:3030/python"),
|
||||
initializationOptions: {
|
||||
"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"
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
}()
|
||||
`;
|
||||
|
||||
let worker = new Worker(
|
||||
createBlobURL(
|
||||
createScriptBlob(workerString)
|
||||
)
|
||||
);
|
||||
|
||||
let provider = LanguageProvider.create(worker);
|
||||
provider.registerEditor(editor);
|
||||
|
||||
}
|
||||
).catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
setLabels();
|
||||
@ -168,6 +109,7 @@ const loadFile = (ftype, fname, fpath, content, line = 0) => {
|
||||
aceSessions[fhash] = {"ftype": ftype, "fname": fname, "fpath": fpath, "session": session};
|
||||
|
||||
setSession(ftype, fhash, session);
|
||||
|
||||
sendMessage("load_file", ftype, fhash, fpath, fname);
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,22 @@
|
||||
},
|
||||
"python": {
|
||||
"info": "https://github.com/python-lsp/python-lsp-server",
|
||||
"command": ["pylsp"],
|
||||
"initialization_options": {}
|
||||
"command": "pylsp --ws --port 3030",
|
||||
"socket": "ws://127.0.0.1:3030/python",
|
||||
"initialization_options": {
|
||||
"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/lsp_bridge-venv/venv/lib/python3.10/site-packages/gi-stubs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"python3": {
|
||||
"info": "https://pypi.org/project/jedi-language-server/",
|
||||
"command": ["jedi-language-server"],
|
||||
"command": "jedi-language-server",
|
||||
"socket": "ws://127.0.0.1:3030/python",
|
||||
"initialization_options": {
|
||||
"jediSettings": {
|
||||
"autoImportModules": [],
|
||||
@ -25,8 +35,8 @@
|
||||
},
|
||||
"markupKindPreferred": "markdown",
|
||||
"workspace": {
|
||||
"extraPaths": [],
|
||||
"environmentPath": "/path/to/venv/bin/python",
|
||||
"extraPaths": ["/home/abaddon/Portable_Apps/py-venvs/gtk-apps-venv/venv/lib/python3.10/site-packages/gi"],
|
||||
"environmentPath": "/home/abaddon/Portable_Apps/py-venvs/gtk-apps-venv/venv/bin/python",
|
||||
"symbols": {
|
||||
"ignoreFolders": [".nox", ".tox", ".venv", "__pycache__", "venv"],
|
||||
"maxSymbols": 20
|
||||
|
Loading…
Reference in New Issue
Block a user