Builds a dictionary mapping YCM Vim user options to values. Option names don't have the 'ycm_' prefix.
( default_options = {} )
| 25 | |
| 26 | |
| 27 | def GetUserOptions( default_options = {} ): |
| 28 | """Builds a dictionary mapping YCM Vim user options to values. Option names |
| 29 | don't have the 'ycm_' prefix.""" |
| 30 | |
| 31 | user_options = {} |
| 32 | |
| 33 | # First load the default settings from ycmd. We do this to ensure that any |
| 34 | # client-side code that assumes all options are loaded (such as the |
| 35 | # omnicompleter) don't have to constantly check for values being present, and |
| 36 | # so that we don't jave to dulicate the list of server settings in |
| 37 | # youcomplete.vim |
| 38 | defaults_file = os.path.join( paths.DIR_OF_YCMD, |
| 39 | 'ycmd', |
| 40 | 'default_settings.json' ) |
| 41 | if os.path.exists( defaults_file ): |
| 42 | with open( defaults_file ) as defaults_file_handle: |
| 43 | user_options = json.load( defaults_file_handle ) |
| 44 | |
| 45 | # Override the server defaults with any client-generated defaults |
| 46 | user_options.update( default_options ) |
| 47 | |
| 48 | # Finally, override with any user-specified values in the g: dict |
| 49 | |
| 50 | # We only evaluate the keys of the vim globals and not the whole dictionary |
| 51 | # to avoid unicode issues. |
| 52 | # See https://github.com/Valloric/YouCompleteMe/pull/2151 for details. |
| 53 | keys = vimsupport.GetVimGlobalsKeys() |
| 54 | for key in keys: |
| 55 | if not key.startswith( YCM_VAR_PREFIX ): |
| 56 | continue |
| 57 | new_key = key[ len( YCM_VAR_PREFIX ): ] |
| 58 | new_value = vimsupport.VimExpressionToPythonType( 'g:' + key ) |
| 59 | user_options[ new_key ] = new_value |
| 60 | |
| 61 | return user_options |
| 62 | |
| 63 | |
| 64 | def CurrentIdentifierFinished(): |
nothing calls this directly
no outgoing calls
no test coverage detected