Closed tobiasandersen closed 6 years ago
Hello and welcome to the Oni repository! Thanks for opening your first issue here. To help us out, please make sure to include as much detail as possible - including screenshots and logs, if possible.
@tobiasandersen Awesome idea! These files/directories might be a good place to start:
browser/src/Editor/BufferManager.ts
browser/src/Services/Explorer/
At least from there you'll be able to see the wiring of the stuff that might directly relate to your goal.
@tobiasandersen I think this would be really cool functionality sort off like NERDTree's
focus file and the atom reveal you mention. In terms of how and where to look to implement this I'd initially point you towards this file which is where the logic for the Explorer lives.
Oni has an api for registering commands the link should give you an example. Haven't quite thought it all through but you could potentially create a function which takes in the current active buffer's file path (the editorManager
has access via editorManager.activeEditor.activeBuffer.filePath
and then pass it to the explorer which is in the same dir called ExplorerView
and have it focus the matching node. Might need to have a look around to figure exactly where to go from there but hopefully that gives you some idea.
Thanks so much for looking at this ^^ 👍 lemme know if you need any help or info.
👍 , this would be awesome!
Thanks guys, I'll look into it this week!
I think this can be closed now, due to https://github.com/onivim/oni/commit/b6bdb4bd68a41b4c751da02e74ddfb3512ebe758
Yep!
Thanks for the contribution @feltech, certainly something I've wished Oni had before!
It may be worth you and @Akin909 co-ordinating at some point to get this (and the other explorer features) into the Wiki. There is loads of cool functionality being added to it, but I think the documentation around the explorer currently is pretty barebones, and we don't want people to end up missing the cool bits!
There is shortcuts over at https://github.com/onivim/oni/wiki/Shortcuts, but they should probably be linked from the https://github.com/onivim/oni/wiki/Configuration page, plus add maybe a new section to highlight some of these useful features that people might want to bind in some way etc.
@CrossR yeah definitely a bit behind on documentation re new functionality will have a look this weekend at adding an explorer section to explain the different bits of functionality 👍
A couple of rough one-liners to extract commands as a markdown table...
For commands registered via new CallbackCommand
or new Command
$ ag -A5 -w registerCommand | grep -EA3 "new (Callback)?Command" | grep -Ev "new (Callback)?Command" | awk 'BEGIN{command=""; name=""; detail=""; print "|command|name|detail|\n|---|---|---|"} /^--/{print "| "command" | "name" | "detail"| "; command="";name="";detail=""; next} /".+"/{$0=gensub(".*\"(.+)\".*", "\\1", "g"); if (!command) {command=$0} else if (!name) { name=$0 } else if (!detail) { detail=$0 }; next } {if (!name) { name=" " } else if (!detail) { detail=" " }} END{print "| "command" | "name" | "detail" |"}'
and for commands registered directly
$ ag -A5 -w registerCommand | grep -E -w "(command|name|detail):" | awk 'BEGIN{command=""; name=""; detail=""; print "|command|name|detail|\n|---|---|---|"} /command: "/{print "| "command" | "name" | "detail" |"; command=gensub(".*\"(.*)\".*", "\\1", "g"); name=""; detail=""} /name: "/{name=gensub(".*\"(.*)\".*", "\\1", "g")} /detail: "/{detail=gensub(".*\"(.*)\".*", "\\1", "g")} END{print "| "command" | "name" | "detail" |"}'
Giving
command | name | detail |
---|---|---|
explorer.delete.persist | ||
explorer.delete | ||
explorer.yank | Explorer: Yank Selected Item | Select a file to move |
explorer.undo | Explorer: Undo Last Action | |
explorer.paste | Explorer: Move/Paste Selected Item | Paste the last yanked item |
explorer.refresh | Explorer: Refresh The Tree | Updates the explorer with the latest state on the file system |
explorer.create.file | Explorer: Create A New File | |
explorer.create.folder | Explorer: Create A New Directory | |
explorer.expand.directory | Explorer: Expand Selected Directory | |
explorer.collapse.directory | Explorer: Collapse Selected Directory | |
explorer.rename | Explorer: Rename Selected File/Folder | |
explorer.toggle | Explorer: Toggle Visibility | Toggles the explorer in the sidebar |
explorer.locate.buffer | Explorer: Locate Current Buffer | Locate current buffer in file tree |
preview.open | Preview: Open in Vertical Split | Open preview pane in a vertical split |
sneak.show | Sneak: Current Window | Show commands for current window |
sneak.hide | Sneak: Hide | Hide sneak view |
oni.themes.choose | Themes: Choose Theme | Choose your theme from the available bundled themes. |
select | ||
markdown.openPreview | Open Markdown Preview | Open the Markdown preview pane if it is not already opened |
markdown.closePreview | Close Markdown Preview | Close the Markdown preview pane if it is not already closed |
markdown.togglePreview | Toggle Markdown Preview | Open the Markdown preview pane if it is closed, otherwise open it |
and
command | name | detail |
---|---|---|
editor.split.horizontal | ||
editor.split.vertical | ||
plugins.toggle | Plugins: Toggle Visibility | Toggles the plugins pane in the sidebar |
browser.openUrl.verticalSplit | Browser: Open in Vertical Split | Open a browser window |
browser.openUrl.horizontalSplit | Browser: Open in Horizontal Split | Open a browser window |
browser.openUrl | ||
browser.debug | Browser: Open DevTools | Open the devtools pane for the current browser window. |
browser.goBack | Browser: Go back | |
browser.goForward | Browser: Go forward | |
browser.reload | Browser: Reload | |
browser.scrollDown | Browser: Scroll Down | |
browser.scrollUp | Browser: Scroll Up | |
browser.scrollLeft | Browser: Scroll Left | |
browser.scrollRight | Browser: Scroll Right | |
oni.config.openUserConfig | Configuration: Edit User Config | Edit user configuration file for Oni |
oni.config.openConfigJs | ||
oni.debug.openDevTools | Debug: Open Developer Tools | Debug Oni and any running plugins, using the Chromium developer tools |
oni.debug.reload | Debug: Reload Oni | Reloads the Oni instance. You will lose all unsaved changes! |
keyDisplayer.show | Input: Show key presses | Show typed keys in an overlay. |
keyDisplayer.hide | Input: Hide key presses | Turn off visible typing. |
achievements.show | Achievements: Open Trophy Case | Show accomplished and in-progress achievements |
experimental.tutorial.start | ||
debug.particles.test | ||
search.searchAllFiles | Search: All files | Search across files in the active workspace |
sidebar.increaseWidth | Sidebar: Increase Width | Increase the width of the sidebar pane |
sidebar.decreaseWidth | Sidebar: Decrease Width | Decrease the width of the sidebar pane |
sidebar.toggle | Sidebar: Toggle | Show / hide the contents of the sidebar pane. |
snippet.nextPlaceholder | ||
snippet.previousPlaceholder | ||
snippet.cancel | ||
userSnippets.editGlobal | Snippets: Edit User Snippets (global) | Edit user snippet definitions for all files. |
terminal.openInVerticalSplit | Terminal: Open Vertical | Open a terminal emulator in a vertical split |
terminal.openInHorizontalSplit | Terminal: Open Horizontal | Open a terminal emulator in a horizontal split |
vcs.sidebar.toggle | Fetch the selected branch | Open a menu with a list of all local branches |
vcs.commitAll | Version Control: Commit all | Commit all staged files |
vcs.openFile | ||
vcs.refresh | ||
vcs.unstage | ||
vcs.showHelp | ||
oni.quit | ||
autoformat.prettier | Autoformat with Prettier | |
quickOpen.searchFileByContent | ||
quickOpen.searchFileByPath | ||
quickOpen.show | ||
quickOpen.showBufferLines | ||
quickOpen.openFileNewTab | ||
quickOpen.openFileAlternative | ||
quickOpen.openFileVertical | ||
quickOpen.openFileHorizontal | ||
quickOpen.setToQuickFix | ||
ciTest.test | Test passing over args. | Opens a file. |
ciTest.test2 | Test passing over args. | Opens multiple files. |
buffer.delete | Delete Selected Buffer | |
buffer.split | Split Selected Buffer | |
buffer.vsplit | Vertical Split Selected Buffer | |
buffer.tabedit | Open Selected Buffer in a Tab | |
buffer.open | Open Bufferlist | Open A List of All Available Buffers |
buffer.toggle | Toggle Bufferlist | Toggle A List of All Available Buffers |
^ just a bit of lunch time fun that may be helpful for the wiki ;)
Is there any way to trigger this automatically, on every file opened? I generally use Denite, instead of Oni's built-in fuzzy-finder, to navigate files — or just plain :e
— and I'd love to keep the File Explorer open, as a general ‘visual overview’ of my project, but …
There's a command in Atom called
tree-view:reveal-active-file
that I think would be really cool to have in Oni as well. When invoked in Oni, I'd expect it to look at the currently active buffer and locate that buffer's file in the file explorer (sidebar) and give focus to it.I'm not familiar with the codebase, so it's a bit hard to tell how hard this would be to implement. But I'd love to give it a shot if you agree it's a feature worth adding.