From f0c9878f870e244ffa3299fdee4cbffcfd53f84f Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 6 Oct 2013 18:26:59 -0700 Subject: [PATCH] Ensuring we are serializing real Python objects Trying to json.dump Vim dictionaries fails. --- python/ycm/base.py | 2 +- python/ycm/vimsupport.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python/ycm/base.py b/python/ycm/base.py index 555c6c7f..dfcb5f7b 100644 --- a/python/ycm/base.py +++ b/python/ycm/base.py @@ -41,7 +41,7 @@ def BuildServerConf(): """Builds a dictionary mapping YCM Vim user options to values. Option names don't have the 'ycm_' prefix.""" - vim_globals = vimsupport.GetReadOnlyVimGlobals() + vim_globals = vimsupport.GetReadOnlyVimGlobals( force_python_objects = True ) server_conf = {} for key, value in vim_globals.items(): if not key.startswith( YCM_VAR_PREFIX ): diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index dacf3a4e..c4663c09 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -95,7 +95,10 @@ def LoadDictIntoVimGlobals( new_globals, overwrite = True ): # Changing the returned dict will NOT change the value in Vim. -def GetReadOnlyVimGlobals(): +def GetReadOnlyVimGlobals( force_python_objects = False ): + if force_python_objects: + return vim.eval( 'g:' ) + try: # vim.vars is fairly new so it might not exist return vim.vars