def _LauncherConfiguration(): if utils.OnMac(): config = 'config_mac' elif utils.OnWindows(): config = 'config_win' else: config = 'config_linux' return os.path.abspath(os.path.join(LANGUAGE_SERVER_HOME, config))
def _LauncherConfiguration( workspace_root, wipe_config ): if utils.OnMac(): config = 'config_mac' elif utils.OnWindows(): config = 'config_win' else: config = 'config_linux' CONFIG_FILENAME = 'config.ini' # The 'config' directory is a bit of a misnomer. It is really a working area # for eclipse to store things that eclipse feels entitled to store, # that are not specific to a particular project or workspace. # Importantly, the server writes to this directory, which means that in order # to allow installations of ycmd on readonly filesystems (or shared # installations of ycmd), we have to make it somehow unique at least per user, # and possibly per ycmd instance. # # To allow this, we let the client specify the workspace root and we always # put the (mutable) config directory under the workspace root path. The config # directory is simply a writable directory with the config.ini in it. # # Note that we must re-copy the config when it changes. Otherwise, eclipse # just won't start. As the file is generated part of the jdt.ls build, we just # always copy and overwrite it. working_config = os.path.abspath( os.path.join( workspace_root, config ) ) working_config_file = os.path.join( working_config, CONFIG_FILENAME ) base_config_file = os.path.abspath( os.path.join( LANGUAGE_SERVER_HOME, config, CONFIG_FILENAME ) ) if os.path.isdir( working_config ): if wipe_config: shutil.rmtree( working_config ) os.makedirs( working_config ) elif os.path.isfile( working_config_file ): os.remove( working_config_file ) else: os.makedirs( working_config ) shutil.copy2( base_config_file, working_config_file ) return working_config