Adding new g:ycm_path_to_python_interpreter option

Fixes #663
This commit is contained in:
Strahinja Val Markovic 2013-11-14 10:50:05 -08:00
parent 2f9be85b93
commit 450403044b
3 changed files with 38 additions and 12 deletions

View File

@ -887,6 +887,20 @@ Default: `[]`
let g:ycm_extra_conf_vim_data = []
### The `g:ycm_path_to_python_interpreter` option
YCM will by default search for an appropriate Python interpreter on your system.
You can use this option to override that behavior and force the use of a
specific interpreter of your choosing.
NOTE: This interpreter is only used for the `ycmd` server. The YCM client
running inside Vim always uses the Python interpreter that's embedded inside
Vim.
Default: `''`
let g:ycm_path_to_python_interpreter = ''
### The `g:ycm_server_use_vim_stdout` option
By default, the `ycmd` completion server writes logs to logfiles. When this

View File

@ -116,6 +116,9 @@ let g:ycm_server_idle_suicide_seconds =
let g:ycm_extra_conf_vim_data =
\ get( g:, 'ycm_extra_conf_vim_data', [] )
let g:ycm_path_to_python_interpreter =
\ get( g:, 'path_to_python_interpreter', '' )
" On-demand loading. Let's use the autoload folder and not slow down vim's
" startup procedure.

View File

@ -79,7 +79,28 @@ def GetUnusedLocalhostPort():
return port
def Memoize( obj ):
cache = obj.cache = {}
@functools.wraps( obj )
def memoizer( *args, **kwargs ):
key = str( args ) + str( kwargs )
if key not in cache:
cache[ key ] = obj( *args, **kwargs )
return cache[ key ]
return memoizer
@Memoize
def PathToPythonInterpreter():
if not RunningInsideVim():
return sys.executable
import vim # NOQA
user_path_to_python = vim.eval( 'g:ycm_path_to_python_interpreter' )
if user_path_to_python:
return user_path_to_python
# We check for 'python2' before 'python' because some OS's (I'm looking at you
# Arch Linux) have made the... interesting decision to point /usr/bin/python
# to python3.
@ -138,18 +159,6 @@ def AddThirdPartyFoldersToSysPath():
sys.path.insert( 0, os.path.realpath( os.path.join( path_to_third_party,
folder ) ) )
def Memoize( obj ):
cache = obj.cache = {}
@functools.wraps( obj )
def memoizer( *args, **kwargs ):
key = str( args ) + str( kwargs )
if key not in cache:
cache[ key ] = obj( *args, **kwargs )
return cache[ key ]
return memoizer
def ForceSemanticCompletion( request_data ):
return ( 'force_semantic' in request_data and
bool( request_data[ 'force_semantic' ] ) )