From 6d9969fa9c70fbd5761ebecbc5eb6f598d586dce Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Tue, 22 Oct 2013 10:51:37 -0700 Subject: [PATCH] Surfacing ycmd server PID to user scripts To get the PID, call function youcompleteme#ServerPid(). --- autoload/youcompleteme.vim | 5 +++++ python/ycm/vimsupport.py | 1 + python/ycm/youcompleteme.py | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 64d43c91..4aa6feab 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -588,6 +588,11 @@ function! youcompleteme#OmniComplete( findstart, base ) endfunction +function! youcompleteme#ServerPid() + return pyeval( 'ycm_state.ServerPid()' ) +endfunction + + function! s:RestartServer() py ycm_state.RestartServer() endfunction diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index 7138cf49..6ee36e3a 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -217,3 +217,4 @@ def GetBoolValue( variable ): def GetIntValue( variable ): return int( vim.eval( variable ) ) + diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index 8d8fee92..0cc60340 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -109,6 +109,12 @@ class YouCompleteMe( object ): vimsupport.PostVimMessage( SERVER_CRASH_MESSAGE_SAME_STDERR ) + def ServerPid( self ): + if not self._server_popen: + return -1 + return self._server_popen.pid + + def RestartServer( self ): vimsupport.PostVimMessage( 'Restarting ycmd server...' ) self.OnVimLeave()