Macvim: Client Server mode does not work in non-GUI macvim

Created on 23 Mar 2018  路  10Comments  路  Source: macvim-dev/macvim

If I startup MacVim in GUI mode with: mvim --remote
The first time, I get a message:
E247: no registered server named "VIM": Send failed. Trying to execute locally
This is expected, as MacVim wasn't running yet.

Now with MacVim (GUI) running, from a terminal I can do: mvim --serverlist
and I see: VIM as a VIM server that is available.

If I do the same thing, but instead of running the GUI MacVim, I run it in a terminal window I get:
E247: no registered server named "VIM": Send failed. Trying to execute locally
Which again is expected. But apparently no server is actually started.
When I do: vim --serverlist
There is no server found, it just exits without printing anything.
If, from that same terminal I try to do: vim --servername VIM --remote
I get the same message as above that there is no registered server named "VIM", and
a new vim is started up.

I have verified that 'mvim' and 'vim' are both running MacVim as installed via homebrew.
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 13 2018 21:01:05)
macOS version
Included patches: 1-1522
Compiled by Homebrew
Huge version with MacVim GUI. Features included (+) or not (-):

Feature Request

Most helpful comment

There is currently no roadmap on getting remote server to work for terminal mode but I could look into it but it's likely not going to be implemented in the short term as development is a little behind and there are quite a few issues and bugs that need to be resolved and fixed.

As for the reason why, it's basically what the documentation said. It uses distributed objects for interprocess communication, which is only set up when the GUI is running (the "GUI" is a whole macOS Cocoa app that sets up a bunch of stuff that the terminal Vim doesn't do). It's possible to investigate other IPC mechanisms to make it more similar to the other Unix implementations but it would require some work.

Edit: Actually, thinking about it more I need to see why server functionality can't be hooked up to terminal Vim, but the client works. I'll get back to this.

Reopening this issue for tracking.

All 10 comments

Are you asking that Non-GUI Vim can be server on macOS? It isn't supported, IIRC.

So are you dropping support for this ?

@aemonge Sorry what's the question? As the comment above mentioned, remote server works in GUI, but not in terminal. Are you asking if we are dropping support for remote server, or why terminal support doesn't work?

Also, see :h macvim-clientserver:

````

  1. MacVim specific items macvim-clientserver

MacVim uses distributed objects for interprocess communication. A server
listens to a named port for new connections, and clients connect to this port
to send messages. Server listings are made possible by the frontend (MacVim)
keeping a list of all currently running servers. Thus, servers are not aware
of each other directly; only MacVim knows which servers are running.

A client is any object which implements the MMVimClientProtocol (see
MacVim.h). Take a look at MMBackend if you wish to implement this protocol in
your own application. The current implementation assumes that the
NSConnections use mach ports for interprocess communication. This means that
you can only use Vim's client/server feature on a local machine (and not
across a network).

Note: Client mode always works, but server mode only works when the GUI is
started.
````

It wasn't clear to my why did the terminal support doesn't work. I'll check it out on the GUI version.

Do you know if there's a road-map to support server mode on terminal ?.

My only issue with this is describe as follow:

1 Open terminal.
2 Open vim in terminal mode vim +'terminal ++curwin ++close
3 Open a file from the terminal_vim vim open
! Error, theres now a vim inside a vim (a loop that I need to prevent)

In linux I can solve this with --client-server and --remote-send as follows:

# My own version of tmux
  if [ $VIM_TERMINAL ]; then
    # First change directory to PWD, then open files. Giving a IDE impression
    alias vim='vim --servername $VIM_TERMINAL_PARENT_ID --remote-send "<C-\><C-n>:cd $PWD <cr>" --r
emote-tab'
  fi
  if [ -z $VIM_TERMINAL ]; then
    export VIM_TERMINAL_PARENT_ID="$$-VMUX";
    # the exit below is to close the terminal when vmux is done.
    vim +':terminal ++curwin ++close' --servername $VIM_TERMINAL_PARENT_ID && exit
  fi

And I'm trying to do the same thing on mac, avoid the vim inside vim inside vim

@ychin I'd like to hear about remote connections as well, besides "it's not really needed"

There is currently no roadmap on getting remote server to work for terminal mode but I could look into it but it's likely not going to be implemented in the short term as development is a little behind and there are quite a few issues and bugs that need to be resolved and fixed.

As for the reason why, it's basically what the documentation said. It uses distributed objects for interprocess communication, which is only set up when the GUI is running (the "GUI" is a whole macOS Cocoa app that sets up a bunch of stuff that the terminal Vim doesn't do). It's possible to investigate other IPC mechanisms to make it more similar to the other Unix implementations but it would require some work.

Edit: Actually, thinking about it more I need to see why server functionality can't be hooked up to terminal Vim, but the client works. I'll get back to this.

Reopening this issue for tracking.

I haven't had time to check it on my Mac ( my nephew borrowed it ).

But I want to see if by opening the GUI, it holds a server status and I can interact through terminal with it.

Anyway, thanks in advance for your dedication. Also I happy to help testing features, alternatives, etc... I would be happy to help codding, but I think I don't have the context nor scope enough to help in that matter.

But I want to see if by opening the GUI, it holds a server status and I can interact through terminal with it.

No, that just means you will be able to open files in the GUI from the terminal, but you won't fix the Vim in Vim problem when in a terminal (since the terminal Vim can't host a server).

Ohh..... got it.

In that case I'll wait for your feedback.

I was just curious on the topic, I don't require it. For me it's enough to have the existing implementation. YCM could use clangd as it's using Python server with full networking.

Was this page helpful?
0 / 5 - 0 ratings