Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile Vim 7.3 with +clientserver feature on Mac OS X

How do I compile Vim with the clientserver feature on Mac OS X? I have the vim-7.3.tar.bz2 source

I understand that MacVim has this built in, but it only works when the GUI is running. I want to work with a CLI version, as my work is so much easier with the CLI (I can switch to the Terminal with ease, for example).

I compiled Vim 7.3 with the following ./configure options

./configure --enable-rubyinterp --enable-pythoninterp --with-features=huge

I have looked at this question on Unix & Linux, but it only takes care of the Ubuntu solution. Also, since I enabled the huge feature set, I should expect +clientserver, according to the vimdoc:

Thus if a feature is marked with "N", it is included in the normal, big and huge versions of Vim.

Update:

The server feature only works with GUI MacVim. To reproduce this:

$ Applications/MacVim.app/Contents/MacOS/Vim --servername VIM

The in another console:

$ vim --serverlist # does not output anything

Whereas if I'll fire up the GUI MacVim,

$ vim --serverlist
VIM1

But my requirement is to work in CLI Vim.

like image 591
Kit Avatar asked Apr 19 '12 15:04

Kit


4 Answers

You can now do this using HomeBrew as well:

brew install vim --with-client-server

It looks like this was added back in 2013, so I'm not sure why it's not mentioned more frequently.

Just in case you were doing this to start using Pterosaur like me, after installing vim with HomeBrew, you might have to force the symlink if you're using MacVim through HomeBrew as well.

brew link --overwrite macvim

Then, just set the extensions.pterosaur.vimbinary to /usr/local/bin/vim in the Firefox about:config page and it should work. I'm typing this using Pterosaur right now, though occasionally Python crashes.

like image 191
Anthony Naddeo Avatar answered Nov 18 '22 22:11

Anthony Naddeo


Using MacPorts:

$ sudo port install vim +huge +gtk2

In a new window:

$ /opt/local/bin/vim --servername FOO

And in another window:

$ /opt/local/bin/vim --serverlist
FOO

Quick. Easy.

EDIT

The +gtk2 is required to make it work, +huge is not enough. Actually, I think that it should work without +gtk2 as long as you have +x11. Unfortunatelly I'm not on my Mac anymore so I can't try. The whole thing takes about 3 minutes so you could try it.

ENDEDIT

like image 24
romainl Avatar answered Nov 18 '22 20:11

romainl


I got it to work by adding --enable-gui=gtk2

./configure --enable-rubyinterp --enable-pythoninterp --with-features=huge --enable-gui=gtk2

Then run from the console:

$ vim --servername FOOBAR_SERVER

From another console:

$ vim --serverlist
FOOBAR_SERVER

Or from within any Vim instance:

:echo serverlist()
FOOBAR_SERVER

Note that X11.app will also boot up as it is necessary for the Vim server to function.

like image 4
Kit Avatar answered Nov 18 '22 20:11

Kit


You could just run the CLI version of vim included in MacVim. With MacVim installed as /Applications/MacVim.app, the CLI version is:

/Applications/MacVim.app/Contents/MacOS/Vim

This is compiled with the clientserver feature. You can add a symlink to this to put it in your $PATH.

like image 3
larsks Avatar answered Nov 18 '22 22:11

larsks