Compile Vim 7.3 with +clientserver feature on Mac OS X
Asked Answered
U

6

15

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.

Unconquerable answered 19/4, 2012 at 15:15 Comment(3)
Does vim --version actually include +clientserver? Also what is the output of which vim?Peisch
@AndrewMarshall, my vim is aliased to the path where my compiled Vim is located. --version only has -clientserverUnconquerable
Since I am using YCM, I'd like to keep using CLI macvim --- Is there a way to allow server running even in terminal? Thanks,Ashly
U
4

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.

Unconquerable answered 20/4, 2012 at 6:42 Comment(2)
What was the full path to configure? I see you just have it listed as ./configure. I'm running into this exact same issue.Mays
@bigtunacan, sorry for the very late response. Whenever you want to compile from a source tarball, the configure script is usually in the parent of src. In other words, it is in the same level as src.Unconquerable
I
11

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.

Inconsonant answered 12/2, 2015 at 15:16 Comment(6)
brew install macvim --with-client-server worked for me, not the vim one. Hope it helpsPredictory
Can be looked up at github.com/Homebrew/homebrew-core/blob/… There are all possible options in combination with homebrew.Garcon
It's working well with vim without having to using macvim. The thing is you have to launch XQuartz once after installation. And you have to restart or logout/login your mac.Alkanet
it said invalid option :(Toughen
Error: invalid option: --with-client-serverToughen
Unfortunately, this solution no longer works as the option has been removed. See github.com/Homebrew/homebrew-core/issues/….Naaman
A
9

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

Antisocial answered 19/4, 2012 at 15:50 Comment(1)
+huge +x11 did it for me. I didn't need gtk2.Sundries
U
4

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.

Unconquerable answered 20/4, 2012 at 6:42 Comment(2)
What was the full path to configure? I see you just have it listed as ./configure. I'm running into this exact same issue.Mays
@bigtunacan, sorry for the very late response. Whenever you want to compile from a source tarball, the configure script is usually in the parent of src. In other words, it is in the same level as src.Unconquerable
E
3

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.

Evangelista answered 19/4, 2012 at 15:19 Comment(1)
I did mention in the question details that the server only works with the GUI. It's also mentioned in the MacVim caveats that you'll find in :help remoteUnconquerable
A
2

Even after reading all these answers, I had to spend several hours for making things work, so I would like to give some clear steps for someone like me.

Given that almost all of the Mac users are using Homebrew, my solution is using Homebrew for installtion.

  1. brew cask install xquartz
  2. Launch XQuartz. You might need to update it.
  3. Logout and login, or restart your Mac.
  4. brew install vim --with-client-server

Now if you launch vim, XQuartz will be launched as well. And if you run vim with --servername <name> argument, you will be able to see the server using --serverlist option.

But after this, you have to launch XQuartz with vim and also you have to do some work for making clipboard thing work again. I found a blog post and followed it but failed to make it work correctly regarding the clipboard.

Alkanet answered 27/12, 2016 at 21:9 Comment(0)
M
1

You should get a command line executable with MacVim.

Micronutrient answered 19/4, 2012 at 15:18 Comment(3)
Simply linking to another question is an indication that you should be voting to close as a duplicate, not posting an answer. That question also doesn't answer this one anyway.Peisch
My point is that if you want a CLI version, then you get one with a precompiled MacVim. Does that not do what you require?Micronutrient
How does that question answer that at all? mvim is not CLI Vim, it's a script to open GVim. Very different.Peisch

© 2022 - 2024 — McMap. All rights reserved.