terrychou / iVim

A vim port to iOS.
596 stars 35 forks source link

Synchronizing iVim with MacVim on MacBook #231

Closed EricEWeir closed 2 years ago

EricEWeir commented 2 years ago

I gather that some (many?) iVim users have it set up so that files are synchronized with files generated by Vim running on a notebook or desktop. I assume that could be done via iCloud or Dropbox but don't have a very good idea how to go about it. I'll be exploring/experimenting but would appreciate any suggestions or pointers that folks here might be willing to give.

I am not a coder or developer. Just a writer and modestly sophisticated user. At one time I was an active user of MacVim with a configuration that I developed with a lot of help from the vim-use and mc-vim list serves. After retiring and starting to spend more time on my iPad than my MacBook my usage, and now my competence, declined precipitously.

Thanks in advance.

EricEWeir commented 2 years ago

Well, I see that from iVim I can open files in iCloud or Dropbox. But I sense that I can't write files to them. Unless there's a way I just haven't found.

EricEWeir commented 2 years ago

I think the share command provides a way to save files to iCloud and Dropbox. Uncertain if to the Files app.

majick commented 2 years ago

You probably want to explore the iexdir facility, which lets you mount (some but not all) Files.app providers to the local filesystem. I use this for SMB remote filesystems, iCloud, and OnMyiPad providers.

Check out :h iexdir to learn more. I highly recommend using the -o parameter to give external provider links a more useful name.

You can browse and access these file providers from inside netrw and generally access them as local files.

EricEWeir commented 2 years ago

Thanks, majick. I had seen reference to this but the contexts didn’t suggest it might be relevant to my interest.

I’ve studied the help on the command. I think I understand the basics, though some of the language is not absolutely clear. Experimentation will clarify things. If I run into any walls I’ll ask for help.

One question at the moment: The help says “you cannot create an external dir link in an external directory.” If I link to an external directory that has a subdirectory, will I be able to access the subdirectory from the link?

majick commented 2 years ago

Using iexdir effectively involves wrapping your head around a few concepts:

I hope this helps you work out how you want to use :iexdir. It's a fantastic feature that has made iVim one of the most powerful tools on my iPad.

EricEWeir commented 2 years ago

On May 10, 2022, at 6:26 PM, majick @.***> wrote:

Using iexdir effectively involves wrapping your head around a few concepts:

Thanks for the explanations and suggestions, majick. I’m surprised that this workaround of Apple’s sandboxing is possible. Terry certainly has done an amazing job with iVim.

I haven’t implemented my use of iexdir yet, but I’m ready to give it a try. I imagine it’s going to go through more smoothly on the iVim side than the Vim side. (I use MacVim.)

I’ve put my iVim directories in a directory on iCloud Drive. The Files app makes that easy. However I don’t know how to get to iCloud Drive from MacVim. It doesn’t show up in the directory list when I do merry.

While I’m at it, what is the root directory associated with iVim? Would that be ~/Documents?

Thanks again. ——————————— Eric Weir Atlanta, GA USA

“It has all been combustion.”

EricEWeir commented 2 years ago

Still seeking help with the macOS side of syncing iVim on iPad and MacVim on MacBook. MacVim doesn't appear in system preferences/icloud/icloud drive/options. iCloud Drive appears on the Finder sidebar, but not in the directory list. I can't cd into ~/icloud drive.

A respondent on Apple Support Communities suggested creating a "soft link" to files on iCloud Drive and suggested this code:

cd ~ /bin/ln -s $HOME/Library/Mobile Documents/com~apple~CloudDocs iDrive cp -a mydoc.zsh ~/iDrive vim ~/iDrive/mydoc.zsh

Which generated this error message:

ln: iDrive: No such file or directory cp: mydoc.zsh: No such file or directory Error detected while processing /Users/ericweir/.vimrc: line 6: E121: Undefined variable: xolox E116: Invalid arguments for function plug# line 7: E121: Undefined variable: xolox E116: Invalid arguments for function plug# line 8: E121: Undefined variable: xolox E116: Invalid arguments for function plug# line 9: E121: Undefined variable: davidoc E116: Invalid arguments for function plug# line 10: E121: Undefined variable: vimwiki E116: Invalid arguments for function plug# line 55: E518: Unknown option: ~/.vim/spell/en.utf-8.add.spl

I'm going to do trial-and-error to try to adapt this to the parameters of my setup. Puzzled why the reference to the plugins list in my .vimrc.

EricEWeir commented 2 years ago

Using iexdir effectively involves wrapping your head around a few concepts:

  • Each app has its own directory tree on the filesystem that, barring certain exceptions, no other app can access. This is one of the sandboxing restrictions.
  • Apps that offer a file service (iCloud Drive, Dropbox, etc.) may -- but do not always -- make those files available to other apps on the filesystem by direct reference. If they do, and the services are pinned to the sidebar in the Files.app, when you issue :iexdir add they will appear as possible selections.
  • When :iexdir add is successful, it puts a symbolic link in iVim's Documents/ directory. That symbolic link points to the thing you added. That's all it does. The cleverness is just in giving you a friendly system modal dialog that lets you pick the service, and letting it deal with the reference to where the service's files are.

Just wanted to thank you again, majick, for this explanation. I've finally gotten familiar with iexdir. Along with `iplug' and the extended keyboard, it really makes vim workable on Apple mobile devices.