rogual / neovim-dot-app

Mac OS X GUI for Neovim
1.13k stars 62 forks source link

Add preference to open files in new tabs #197

Closed rolandcrosby closed 6 months ago

rolandcrosby commented 8 years ago

Fixes #182. Adds a "MacSetOpenFilePreference" vim function, which sends a "neovim.app.setOpenFilePreference" message to the GUI. If the argument to the function is "new-tab", files dragged to the app/used via "open with" or gnvim will open in new tabs; if it's "new window", a new window will open and the files will be opened in tabs in that window.

rogual commented 8 years ago

Hi, thanks for this. It's a substantial PR so I'm going to give it some testing before merging.

Code all looks good — one thing I did notice is your use of NSUserDefaults. Is this necessary? (Haven't tested yet, so it might be). Usually these MacDoWhatever() functions which change app state only do so for the current session; to make the change permanent a user just puts the call in their .vimrc.

Right now in the code, user-defaults are only used for a couple of things:

These are both things that the app needs to be able to write to, and, for consistency, I'd prefer the tab preference not to use user-defaults unless it needs to. Happy to be convinced otherwise.

rolandcrosby commented 8 years ago

I don't have a preference either way about how to keep track of this kind of setting. Is there an existing application-level data store that would be better, or would you rather just use an instance variable in AppDelegate?

james2doyle commented 8 years ago

+1 for this feature

rogual commented 8 years ago

@rolandcrosby I'd rather have the instance variable if your code would still work, just for consistency because most app state is in instance vars right now (see view.mm) though of course this var would need to be app-level.

OskarSigvardsson commented 8 years ago

+1 for this feature as well, and a request: MacVim lets you add the file to the arglist and make it the current buffer. That would be my preference, I don't like having too many tabs open.

afshinm commented 7 years ago

Any updates on this?

rogual commented 7 years ago

It just needs that NSUserDefaults change and it can go in.