def ShouldEnableGoCompleter(user_options): server_exists = utils.FindExecutableWithFallback( user_options['gopls_binary_path'], PATH_TO_GOPLS) if server_exists: return True utils.LOGGER.info('No gopls executable at %s.', PATH_TO_GOPLS) return False
def FindTSServer( user_options_path ): tsserver = utils.FindExecutableWithFallback( user_options_path , None ) if tsserver and os.path.isfile( tsserver ): return tsserver # The TSServer executable is installed at the root directory on Windows while # it's installed in the bin folder on other platforms. for executable in [ os.path.join( TSSERVER_DIR, 'bin', 'tsserver' ), os.path.join( TSSERVER_DIR, 'tsserver' ), 'tsserver' ]: tsserver = utils.FindExecutable( executable ) if tsserver: return tsserver return None
def ShouldEnableRustCompleter(user_options): if (user_options['rls_binary_path'] and not user_options['rustc_binary_path']): LOGGER.error('Not using Rust completer: RUSTC not specified') return False rls = utils.FindExecutableWithFallback(user_options['rls_binary_path'], RLS_EXECUTABLE) if not rls: LOGGER.error('Not using Rust completer: no RLS executable found at %s', rls) return False LOGGER.info('Using Rust completer') return True
def ShouldEnableJavaCompleter(user_options): LOGGER.info('Looking for jdt.ls') global PATH_TO_JAVA PATH_TO_JAVA = utils.FindExecutableWithFallback( user_options['java_binary_path'], utils.FindExecutable('java')) if not PATH_TO_JAVA: LOGGER.warning("Not enabling java completion: Couldn't find java 11") return False if not os.path.exists(LANGUAGE_SERVER_HOME): LOGGER.warning('Not using java completion: jdt.ls is not installed') return False if not _PathToLauncherJar(): LOGGER.warning('Not using java completion: jdt.ls is not built') return False return True
def test_FindExecutableWithFallback_UserProvided(self): with TemporaryExecutable() as executable: with TemporaryExecutable() as fallback: assert_that( utils.FindExecutableWithFallback(executable, fallback), equal_to(executable))
def test_FindExecutableWithFallback_Empty(self): with TemporaryExecutable() as fallback: assert_that(utils.FindExecutableWithFallback('', fallback), equal_to(fallback))
def FindExecutableWithFallback_UserProvided_Invalid_test(find_executable): with TemporaryExecutable() as executable: with TemporaryExecutable() as fallback: assert_that(utils.FindExecutableWithFallback(executable, fallback), equal_to(None))
def __init__(self, user_options): super().__init__(user_options) self._user_supplied_gopls_args = user_options['gopls_args'] self._gopls_path = utils.FindExecutableWithFallback( user_options['gopls_binary_path'], PATH_TO_GOPLS)
def __init__(self, user_options): super().__init__(user_options) self._rls_path = utils.FindExecutableWithFallback( user_options['rls_binary_path'], RLS_EXECUTABLE) self._rustc_path = utils.FindExecutableWithFallback( user_options['rustc_binary_path'], RUSTC_EXECUTABLE)