Chocolatey and Miniconda/Anaconda setup recipe for leointeg, a plugin to enable Visual Studio Code to use Leo Editor as an engine for working with outlines and nodes and clones.
Starting point: a Win10 admin command prompt with Chocolatey installer, Conda, and Git in PATH. I pinned python to 3.6 as that is Leo's current minimum python version. Adjust to suit your preference.
Admin prompt
:: Install Visual Studio Code & python support, Node.js
choco install vscode vscode-python nodejs
Normal command prompt:
:: Create anaconda environment for Leo & Leo-integ
conda create -n vscode-leo
conda activate vscode-leo
conda install python=3.6
:: Install Leo & dependencies
pushd code
pip install --editor .\leo-editor
:: Install Leointeg python dependencies
pip install websockets
:: Install Leointeg & Node.js dependencies
git clone https://github.com/boltex/leointeg
cd leointeg
npm install
npm audit fix
Run vscode
Open Folder >> path\to\leointeg
"This workspace has extension recommendations" >> Install All
Open command pallete [Ctrl-Shift-P]
c:\tools\miniconda3\envs\vscode-leo\python.exe
Run Extension
Vscode will open a new window in foreground. The background vscode window should have a highlighted bottom status bar and show the leointeg conda python environment.
The foreground window should be titled "Extension Development Host". From it Open Folder and point to your Leo stuff. A "Welcome to Leointeg" page opens.
Switch back to the original vscode window. Open a terminal in vscode [Ctrl-Shift-`] and start the leobridge server manually.
python leobridgeserver.py
Now switch to the dev host and in left hand menu >> Leo Integration >> [Connect to Server].
When connection is established an [Open Leo File] button should replace [Connect to Server].
….
When things don't work, look to the [Debug Console] panel in the original Vscode window.
What seems to be needed in every new vscode session:
I'm confident there's a way to automate this, somewhere.
Sources
> Switch back to the original vscode window. Open a terminal in vscode [Ctrl-Shift-`] and start the leobridge server manually.
python leobridgeserver.py
Interesting you should mention this. It shouldn't be necessary because (as you say) after running leoInteg you will see (by default) two buttons when you select the Leo icon on the left margin: "Connect to server" and "Start Server". Below those buttons you will see "View leoInteg's configuration settings."
On Linux, the "Start Server" button doesn't work, but starting leobridgeserver.py manually does work. A line containing an fstring fails, so presumably leoInteg is using python 2 instead of 3. This despite a configuration that says run "python", which on my machine does in fact run python 3.
Ok. I got things to work on Linux. The default python is supposed to be "python3" on Linux, but I had to enter "python3" explicitly.
Hold on a second. The configuration settings link brings up the configuration settings, but it appears that the settings page doesn't show the present settings!! For me, right now, the extension is acting properly and automatically starts the server and connects to it. So I see the "Open Leo File" button. But that's not what is showing in the configuration page!
Hold on another second. When I reload vs code I now do see the settings I entered.
Tentative Conclusion
Changing settings does work, but the configuration settings link won't show the updated settings under some circumstances. Maybe this also happens on Windows, but I've only seen this on Linux.
These problems would be very hard for
Félix to find, because everything works for him, so he's not changing settings.
> What seems to be needed in every new vscode session:
I just noticed you ran "npm audit fix" after running "npm install" so i'm not sure what dependency might have been raised to a version that might be problematic.
added 1034 packages from 542 contributors and audited 1104 packages in 47.144s
17 packages are looking for funding
run `npm fund` for details
found 11 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
Also, (as stated elsewhere), I also forgot to mention Leo's devel branch should be used with Leo, for multi-file support, until it's next release.
Many thanks again!
Leointeg's Python Command configuration set to python and Running the extension with the Server and Extension option are mutually exclusive: I have not explained those concepts clearly - and as I wanted to give more options for tester than less, it seems people are mix and matching those methods of starting the server in erroneous ways.
So to clarify: if you're running the extension with the "Server and Extension", then, the python command could be set to 'potato' it wouldn't matter because it's not used then. That would be using the debug profile in the .vscode/launch.json file. which I encourage you to open and see for yourself what those 3 debugging profiles are,. those will not exist at all when the extension is compiled and distributed as a real extension.
So this is important to distinguish: to simulate a real, finished extension, select 'run extension' only in the run/debug menu. this will force you to either :
1- set leoInteg option to start server automatically with the provided python command, both being in the leoInteg settings.
2- start a server by typing leobridgeserver.py in a terminal.
If you instead select "server AND extension" in the run/debug panel, then, vscode will run and debug the server by itself, as if vscode itself was considering the server program as it's main project. and will use whichever python debug setting vscode's debugger is set to. Not the leoInteg options!
So...Either configure a python command line setting in leo Integs settings, and use the 'run extension' only in the run/debugger dropdown. OR , don't start server automatically, and use the "start both server and extension" in the run/debuger dropdown instead. (ok to connect automatically though, doesn't matter how the server was started to connect to it automatically)
Again, sorry English is not my native language. (i guess i should capture myself as a screencast while explaining this)
--
Félix
Leointeg's Python Command configuration set to python and Running the extension with the Server and Extension option are mutually exclusive: I have not explained those concepts clearly - and as I wanted to give more options for tester than less, it seems people are mix and matching those methods of starting the server in erroneous ways.
So to clarify: if you're running the extension with the "Server and Extension", then, the python command could be set to 'potato' it wouldn't matter because it's not used then.