boltex / leointeg Goto Github PK
View Code? Open in Web Editor NEWLeo Editor Integration with VS Code
License: MIT License
Leo Editor Integration with VS Code
License: MIT License
An idea that has come up several times over the years on Leo's mailing list is the possibility to have a combined view of the outline and node bodies, with the body of each node rendered inline, and both headlines and node bodies being editable inside this unified tree.
A major advantage compared to the current situation is that this would make it possible to see the contents of the preceding and following nodes while working on a particular node's body. This would significantly reduce the need to keep track in your mind of what's what, and also allow you to scroll through a large document as with regular editors (while keeping Leo's advantages of organizing with nodes, clones, etc.).
Is this something that could be done in leointeg / VSCode?
Some commands to select, expand and contract outline nodes could be implemented
(such as Alt-Home (goto-first-visible-node), Alt-End (goto-last-visible-node), Alt-arrow keys, ...)
See http://leoeditor.com/commands.html#selecting-outline-nodes
Convert commands definitions in package.json to split from commands called while focus in text editor vs outline tree.
See https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts
and
https://stackoverflow.com/questions/57038025/vscode-keep-focus-in-folders-panel-after-selecting-a-file for example of detecting and differenciating location of focus for commands.
Along with "prev", "next" controls, etc.
Save and restore selection, along with cursor position, from selection state saved in each node (or gnx array)
Addendum: Once implemented, this can be tested by trying to run the 'execute script' command on a text selection via leo's minibuffer (alt+x) instead of (ctrl+b) or the command palette (ctrl+shift+p).
Can clise this issue after removing the internal ctrl+b execute script to use leo's own command directly like the rest of normal commands.
Suggested by @ar-jan as an unrelated idea to an other issue #32 : #32 (comment)
Could this be mimicked? ...In Leo, if arrow keys are used in the outline, the node selection is reflected instantly in the body pane. In vscode, an outline has a cursor
Q&A below:
Q: It's already the case when using the keyboard to expand/contract nodes so why not making it so too when moving the outline "cursor" ?
A: expanding and collapsing nodes have an associated event, although moving the cursor in the tree is detectable, the selection cursor is unkown as far as I know as opposed to a collapse/expand event.
Try to refresh the outline somehow when the interface-related settings are changed.
Related : Add to documentation / readme the details about the debounced auso-save after 0.5 seconds
Currently all directives are colored appropriately (unless missed) but the @languages directives should trigger color-grammar insertions.
(until end of outline section or other @language directive)
Should be easy, vscode has pre-made tui components for that sort of thing.
1-make a command in leobridge server to fetch list of commands to propose for a given string, (get_auto_complete)
2- open an auto complete prompt on alt-x feed it with the previous output from get_auto_complete, fetch get_auto_complete while staying open if the user adds to string.
3-Enter calls a 'run command by name' with the given string name as parameter to leobridge.
Watchout! command ran this way might summon null-GUI
calls and stuff!
'Full refresh' is not 'full' enough! ๐
'Move Right' gets inside its parent node as expected from this operation, but the parent node stays collapsed so a 'reveal' call would be required it seems.
This can be fixed by altering only leobridgeserver.py (from editing its leo file: leoInteg.leo)
UNDO operation works with outline changes such as move node commands, but some others (insert node, rename node and maybe others..) seem to need to set an 'undo' restore point when being executed.
See class Undoer in leoUndo.py from Leo's sources for relevant methods to be called for this fix.
Implement and offer option to show line numbers for a body pane editor relative to a derived file
Replace icons and functionality of vscode'S collapse all treeview default button/functionality with Leo's own functions. (via leoBridge actions)
Tested on both windows and linux (ubuntu 18.04) : broken in 6.2 but works when Leo reverted to 6.1 final.
Grab the color syntax that would be applied to leo's body pane and apply it to the document editor.
Nope! too much work because no gui is running and no color-syntaxing was applied in the first place when running in leoBridge!
Instead define the same syntax as Leo to be applied to "body panes"
(Suggestion) For apearance of breadcrumbs:
Change the filesystem filename current method of using the GNX by a new method, to decorate the body pane tab with custom breadcrunbs.
Try to add an entry in the regular explorer (right-click) files context menu if a file has extension ".leo"
(Idea given after reading Brad's comment on the google group forum about having more 'seamless' integration.)
Note: The user must have had set his leoInteg settings correctly to automatically "start server" and "connect to server" and optionally 'python command' launch string at minimum for any of the smooth integration to even make sense in the first place.
Add a command 'stack' in the front end side of vscode's to support rapidly chaining commands because of nodes being sent as parameters being not valid if taken before previous commands finishes.
Commands that use the 'marked' property of nodes:
Outline seems to refresh (slight flash of side lines of expanded parent nodes), in a slugish manner twice, or even thrice, when coming back from an automatic change of outline-node selection caused by using a different body pane. (a body pane from a node of a different gnx).
It is also the case when refreshing the tree because of a change in active leo outline treeviews in vscode's workspace (switching between file explorer and standalone outline).
On the other hand, it seems to refresh perfectly when coming back from a node operation like move, insert and other outline edition commands! So it's probably the order and chaining of operations performed when trying to refresn in those instances, and/or the node parameter chosen as target of the 'reveal' function call(s).
Leo has tabs to offer choice between multiple opened Leo files, it would be useful to offer a way to have the same capability. (through someting other than tabs)
Maybe a menu openable through the status bar indicator or other items in the dropdown in the outline's titlebar.
As of now only the answers from commands initiated by the user are acted upon. Handle asynchronous messages initiated by leo.
Needed for feeding the log pane and asking permission to update derived files.
Note: React to file changes and other events, see
leo-editor/leo-editor#1281 (comment)
The new way of browsing the tree may have vscode ask for any body pane stats and contents before it was actually selected in the tree.
Commands that move clones of all nodes matching the search pattern under a single organizer node, created as the last top-level node:
'Clone-marked' commands that move clones of all marked nodes under an organizer node:
Replace documents icons with color icons and cleanup/minify svg files
Pass p.v.u in archived positions, discard it on reception as to not have this weight in 'apJson' that is used on the way back when ap's are sent back as parameters in Leo commands.
i,e, when right clicking on a particular node to issue a command and not use the 'currently selected node'.
Convert documentation comments to tsDoc standard: See https://github.com/microsoft/tsdoc
Use 'Menu enablers' ("c.Menu Enablers" in leoCommands.py) to get states and availability of various interface items.
Make saving more natural by binding ctrl+s to the leo save instead/on top of the vscode's regular save of the edited document into it's filesystem scheme.
Status bar flag for leo keybinds should offer configurable text, color, placement etc.
On the dev branch, commit 6288f23 Makes the color (hex) and string customizable. Up to 8 character long.
Configuration for left/right placement would be nice.
Color chooser instead of a text input for the hex string color would be nice too!
In leo the shortcut is Alt+-
Handle text selection / cursor position. Also useful for sending to leo and to restore back when selecting other nodes.
This will make it possible to get some useful parameters for commands such as 'Extract' and 'Extract Name'.
"Execute Script" should also use selection instead of outline if any.
Should be easy to do but are they a regular command(s)? or are they @buttons?
Offer command icons to perform leointeg's actions in more views and context menus (Currently only The View title menu - view/title and The View item menu - view/item/context are used so far):
Also offer settings to hide/show them individually.
Such as those three common ones ("when" clause : filesystem-scheme is 'leo' to limit to leo bodies):
see https://code.visualstudio.com/api/references/contribution-points#contributes.menus for complete list of menus into which to place command-buttons/icons.
Hi, it looks like you've been making great and steady progress over the last several months. Awesome! I just tried out the dev branch and I'v run into a problem loading the extension. I've installed all dependencies etc as described. Actually the first time I ran F5 to run the extension a welcome screen with Leo icon did appear, but I'd already clicked a VSCode message about window loading taking longer than 10 seconds, and trying a reload. Now I don't see the Leo welcome anymore.
When I click the "Connect to Leo Bridge server" icon in the Leo tab, I get Leo Bridge Connection Failed
.
The terminal in the original window says this:
Executing task: npm run webpack <
[email protected] webpack C:\Programs\leointeg
webpack --mode developmentStarting type checking service...
Using 1 worker with 2048MB memory limit
Child
Hash: f72f38eb55e39ace8f04
Version: webpack 4.41.2
Time: 3915ms
Built at: 01/12/2020 16:35:25
Asset Size Chunks Chunk Names
extension.js 271 KiB main [emitted] main
extension.js.map 357 KiB main [emitted] [dev] main
Entrypoint main = extension.js extension.js.map
[./src/constants.ts] 1.12 KiB {main} [built]
[./src/eamodioEditorManager/activeEditorTracker.ts] 3.56 KiB {main} [built]
[./src/eamodioEditorManager/comparers.ts] 1.6 KiB {main} [built]
[./src/eamodioEditorManager/documentManager.ts] 10.3 KiB {main} [built]
[./src/extension.ts] 12.1 KiB {main} [built]
[./src/leoBody.ts] 9.48 KiB {main} [built]
[./src/leoBridge.ts] 5.09 KiB {main} [built]
[./src/leoFiles.ts] 2.13 KiB {main} [built]
[./src/leoIntegration.ts] 53.2 KiB {main} [built]
[./src/leoNode.ts] 2.26 KiB {main} [built]
[./src/leoOutline.ts] 2.24 KiB {main} [built]
[./src/serverService.ts] 3.2 KiB {main} [built]
[./src/webviews/leoSettingsWebview.ts] 4.18 KiB {main} [built]
[path] external "path" 42 bytes {main} [built]
[vscode] external "vscode" 42 bytes {main} [built]
+ 27 hidden modulesWARNING in ./node_modules/ws/lib/buffer-util.js Module not found: Error: Can't resolve 'bufferutil' in 'C:\Programs\leointeg\node_modules\ws\lib' @ ./node_modules/ws/lib/buffer-util.js @ ./node_modules/ws/lib/receiver.js @ ./node_modules/ws/index.js @ ./src/leoBridge.ts @ ./src/leoIntegration.ts @ ./src/extension.ts WARNING in ./node_modules/ws/lib/validation.js Module not found: Error: Can't resolve 'utf-8-validate' in 'C:\Programs\leointeg\node_modules\ws\lib' @ ./node_modules/ws/lib/validation.js @ ./node_modules/ws/lib/receiver.js @ ./node_modules/ws/index.js @ ./src/leoBridge.ts @ ./src/leoIntegration.ts @ ./src/extension.ts
Child
Time: 3904ms
Built at: 01/12/2020 16:35:25
Asset Size Chunks Chunk Names
main-styles.css 27.9 KiB main-styles [emitted] main-styles
main-styles.js 4.48 KiB main-styles [emitted] main-styles
settings.html 14.7 KiB [emitted]
settings.js 59.9 KiB settings [emitted] settingsTerminal will be reused by tasks, press any key to close it.
And the debug console says:
(node:11832) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
warning.js:27
(node:11832) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
warning.js:27
Launch with default command : py -3 c:\Programs\leointeg/leobridgeserver.py
extension.js:7226
leoInteg startup launched in 6 ms
extension.js:5532
websocket error: connect ECONNREFUSED 127.0.0.1:32125
extension.js:5921
websocket closed, code: 1006
extension.js:5925
websocket error: connect ECONNREFUSED 127.0.0.1:32125
extension.js:5921
websocket closed, code: 1006
I do have websockets
installed in my default Python environment (which is an Anaconda env, Python 3.7.3). Any way to check if leointeg is using the correct Python environment? Also npm install
from within VSCode terminal says all packages are installed. echo %PYTHONPATH%
gives C:\Programs\Leo
(correct). I'm on Windows 10. Leo is at version 6.0-final.
Any ideas to debug this further?
While having only one opened Leo file at a time, it would be nice to be able to start 'new' leo files, and / or save with a new name.
Also being able to 'close' and (re)open another Leo file would be desired.
This is different than supporting multiple opened Leo files.
Indicator stays 'on' when the last editor is closed and focus falls in the 'empty' zone.
Offer more options based on context, such as 'start server', 'open settings', and more informative content based on context with messages such as "Connecting..." and other messages reflecting the current state.
See https://code.visualstudio.com/api/extension-guides/tree-view#welcome-content for exact details and implementation examples.
It is not possible in vscode, to properly 'reveal' a node that is hidden (child of collapsed node are, by definition, not visible) when his siblings have the exact same headline label, or are clones.
The first one of the repeated headline label will be selected regardeless. This otherwise works fine if the node is already 'visible'. (This is because if it's visible it has been created as a specific node instance of the treeview. vscode seems then to be able to handle this because it can somehow be pointed to specifically when revealing)
So to counter this, change the behavior to mimic exactly Leo: Colapsing or expanging a node should also select it. So that it is impossible to have a selected node that is invisible (hidden inside its collapsed parent).
Most importantly, modify the 'open aside' feature, so that it selects the chosen node first, then opens it. So only ONE body pane is opened at a time, altough still "duplicatable" in many panels so that "split view" will still be possible. This change will remove the "more than one body opened at the same time".
This simplification will ultimately help a lot in the short and middle terms. It will also help with other problematic features such as closing opened bodies of 'expired gnxs' (e.g. after deletion of tree branches), 'hoist/dehoist' commands and many other.
Have a flat or state that resets after stacks of commands resolve : its useage would be to set a limit / cap what to refresh more precisely
(Prevent refreshing for documents panel and @button panel)
Add three commands to cover all cases:
Only makes sense of muliple opened files support is implemented: Could be merged with #13
For multiple file support : Show the currently opened files in a list under the leo outline in Leo's view panel.
Selecting one should switch to that document.
Offer 'Real Clipboard' operations, instead of leo's 'internal' clipboard behavior
Use globals.gui.clipboard and the real clipboard with g.app.gui.getTextFromClipboard()
For pasting, use g.app.gui.replaceClipboardWith(p_realClipboard)
See the 'execute script' command as an example on how to get the selection when a command is issued in order to implement the 'Extract' and 'Extract Name' commands.
Whem detecting body changes, debounce, still offer quick 'first modif' reaction of icon apearance, also maybe keep in a temp body variable, but only send to leo before acting on someting else (starting another action, or command) rather than on 500ms timer.
In welcome/settings webview: similar to hover commands interface preview. When the config changes, have the text be previewed over the png background of the statusbar, along with switching to the appropriate color.
(Does not seem to affect rendering / usage )
Providers for treeview, and provider for body pane filesystem should handle transitions from a document to the next, or hoisting/dehoisting without generating warnings/errors in vscode's debug console.
Try to cleanup last opened-gnx transition to a new one. Also try to cleanup the tree-refresh cycle after de-hoisting/changeing leo file.
Make leoBridge server 'persist' through disconnects and accept multiple connections from the same user/ip for multiple vscode windows instances.
This is not 'multi-user' or 'multi-edition', instead it multi-connection for the same user at the same 'editing point' so that if leoInteg is installed in vscode for a given machine, and it's started (connected to a leobridge server) all of vscode's windows will show the same tree, body simultaneously in a synchronised manner.
(Leobridges would just run in a single 'user' & single selected 'commander' as usual, but it gives a copy of its 'json answers' on all connected websockets at once.)
This implies new functionality, such as:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.