macvim icon indicating copy to clipboard operation
macvim copied to clipboard

Gui file explorer feature?

Open rickalex21 opened this issue 3 years ago • 11 comments

Thanks to everyone for their contributions to this project. Are there any plans of including a feature like a gui file explorer on the side like visual studio code workspace folders?

I understand that this is vim but this is the 'gui' version of vim. There are text based file explorers out there but when it comes to web development I find myself going back to visual studio code every time. I'm not new to vim, I've created lots of personal vim plugins. I just find it easier in vscode to go in and out of folders, drag and drop folders/images/files etc.. Once everything is set, I go back to vim.

You could have an option to hide or show the folder workspace if people want to use it.

rickalex21 avatar Mar 20 '21 19:03 rickalex21

Hey, do you mean you want to add something like NerdTree plugin?

I'm asking because of:

  1. I like the idea :)
  2. VSCode has very vague definition of "project" (but there's a project file though)
  3. MacVim currently is just a special terminal with some additional keybindings
  4. Such idea is generally good for Vim as a whole to integrate (with this it's better to go to the upstream, and in my opinion make sense)
  5. I don't understand how to properly implement this without breaking "pure Vim" experience as MacVim currently has
  6. What's about opening files from the same project from terminal? What's about other corner cases?

eirnym avatar Mar 20 '21 23:03 eirnym

Yes, something like that but a gui version since this is Macvim. This is what I'm talking about.

I don't really use the project files '.vscode' but I'm sure others find them useful. Ya I agree with you on '2', that's why I was suggesting this feature.

I don't understand how to properly implement this without breaking "pure Vim" experience as MacVim currently has

I'm sure there will be changes that would have to be made but I don't know to what extent. I would imagine that this would need to be separated from vim to prevent things from breaking and have an intermediate module to reflect changes in vim windows. For example, if a user clicks on a file then it should be shown in the vim window. This is not much different from File -> open.

What's about opening files from the same project from terminal? What's about other corner cases?

I think opening workspace folders from the menu on macvim is fine. The main idea is the ability to drag and drop stuff into folders just like you can in visual studio code.

rickalex21 avatar Mar 21 '21 04:03 rickalex21

OK, while generally agree with this idea and willing to have this in MacVim implemented, I have questions before we start implementation to be on the same page and not to make a thing won't be totally needed by others

let's imagine, we have this feature implemented. Where is the root directory? or / is the root directory and we show tree as NerdTree? How we can define workspace? what would be saved there?

There's sessions in Vim, as an already implemented feature, and we theoretically can extend it by adding something used only by MacVim (some work could be required in the upstream, but it's ok)

eirnym avatar Mar 21 '21 09:03 eirnym

Where is the root directory? or / is the root directory and we show tree as NerdTree?

Make it work the same way vscode works. I'm not a big fan of terminal file explorers when it comes to web development so I can't comment much on nerd tree, netrw, or any other file explorer.

How we can define workspace? what would be saved there?

By saving the workspace, I mean just save what files and folders I have open. I know mksession does this but it does not have gui folders. As you can see in the image above I have two folders pandoc and wiki along with a makefile. That was all restored from a workspace save. Which basically is just a json file, another method of saving would need to be used by macvim.

{
	"folders": [
		{
			"path": "../../pandoc"
		},
		{
			"path": "../../hugo/wiki"
		}
	],
	"settings": {
		"liveServer.settings.multiRootWorkspaceName": "pandoc"
	}
}

Only implement the basic stuff first. You can always add features later on like ability to save workspace or mksession. For now just the basics.

  • Open folders into side view file explorer
  • Open Files from side file explore into vim terminal
  • Drag and drop files, move folders etc..

It would look like this, you would click on a file and it would show up in the terminal. Nerdtree and other file explores do this but it's not as fluid like in a gui where you can drag and drop.

rickalex21 avatar Mar 21 '21 16:03 rickalex21

Sweet, I like the idea more and more.

There's my thoughts on how to integrate this feature as smooth as possible to MacVim without breaking "pure vim" experience. (this could lead to PRs in Vim)

On file format for sessions/workspace, I'd extend existing Vim mechanism (see notes below)

Top folder

let's imagine following scenarios: prerequisites:

  • I create a session and specify a top folder
  • I create files/folders by working in this MacVim window

I have scenarios, multiplied by how I open files. How MacVim should behave?

  • I edit file test.py from folder inside written in session file as the base
  • I edit file test.c from folder outside written in session file as the base

Let's multiply this by:

  • I open via menu File -> New window
  • I open via menu File -> New tab
  • I open via $ vim filename, and have setting enable "open in new window"
  • I open via $ vim filename, and have setting enable "open in current window"

What user actions will change session file? how these actions could be customized?

Foot Notes

I see following constraints and integrations points to introduce it as smooth as possible by inviting as many users as possible without creating a monster with "Mac"-specific UI

Sessions:

  • Creating a session should be a separate configurable action turned off by default - to continue to have the pure Vim experience for those who wants, but could be enabled by default for those who wants it for daily work
  • Session parameters should be editable by commands and UI - could be done in later versions if it's not done already
  • Session file should be compatible with file from Vim. - This could lead to PR for upstream, but it's workable

File Tree:

  • File Tree should be an optional GUI interface defined in Vim Core - this is the best option to make other work with it
  • File Tree interface should be hookable and customizable - there'll be people who'd want to customize it (e.g. icons, sorting, actions per file, actions per cursor position changes and much more!)
  • File Tree interface should be fully accessible by keyboard - it's the main idea of ViM and I'd prefer to keep it this way
  • File Tree should have basic settings customizable in vimrc. ideally - every aspect.

PS: These constrains doesn't neglect drag&drop fluidness and other features you mentioned. I try to involve to this as many people as possible, not only MacVim community, but whole Vim community!

eirnym avatar Mar 21 '21 19:03 eirnym

These constrains doesn't neglect drag&drop fluidness and other features you mentioned. I try to involve to this as many people as possible, not only MacVim community, but whole Vim community!

Yes I agree with you it should be feature rich and something that everyone would want to use :) . As far as the technical details go, I wouldn't be much help since I'm not familiar with developing for Mac, swift, or the macvim code. The developers in macvim would know more about how to do this. As long as it has a similar file explorer to visual studio code I'm fine with it. I just want to drag and drop files, move folders around etc... You can download visual studio code or vscodium if you would like to check it out.

rickalex21 avatar Mar 22 '21 01:03 rickalex21

So now you want this? Try keyword: fern  🌿🌿 (my keyboard shortcut is <Tab>)

image

nyngwang avatar Mar 29 '21 10:03 nyngwang

@nyngwang great tool, thanks, I'll give it a try

eirnym avatar Mar 29 '21 12:03 eirnym

The only thing it doesn't satisfy is drag-n-drop feature inside MacVim, from and out :) This is why I'd like to have a standardized GUI drawer, not the text-only.

PS: this won't make such plugins obsolete as text-only UI for Vim is widely used and I'd prefer to have them around

eirnym avatar Mar 29 '21 12:03 eirnym

The only thing it doesn't satisfy is drag-n-drop feature inside MacVim, from and out :) This is why I'd like to have a standardized GUI drawer, not the text-only.

PS: this won't make such plugins obsolete as text-only UI for Vim is widely used and I'd prefer to have them around

@eirnym What do you mean drag-n-drop feature? In my case the vertical bar can be adjusted like this without trouble, the following is done in sequence, it looks like Vim but I'm actually using MacVim, the trick is that I set the titlebar of MacVim Hidden:

  1. Adjust left:

  2. Move bottom up:

  3. Adjust right:

  4. Move bottom down:

nyngwang avatar Mar 29 '21 13:03 nyngwang

@nyngwang

What do you mean drag-n-drop feature?

The ability to easily move images, files, etc... in and out of folders with the mouse. I wouldn't suggest it on vim but since this is MacVim a 'gui' version of vim, it would be a nice feature to have.

rickalex21 avatar Apr 07 '21 22:04 rickalex21