def _ShouldLoad(module_file, is_global):
    """Checks if a module is safe to be loaded. By default this will try to
  decide using a white-/blacklist and ask the user for confirmation as a
  fallback."""

    if is_global or not user_options_store.Value('confirm_extra_conf'):
        return True

    globlist = user_options_store.Value('extra_conf_globlist')
    for glob in globlist:
        is_blacklisted = glob[0] == '!'
        if _MatchesGlobPattern(module_file, glob.lstrip('!')):
            return not is_blacklisted

    raise UnknownExtraConf(module_file)
Esempio n. 2
0
def JumpToLocation(filename, line, column):
    # Add an entry to the jumplist
    vim.command("normal! m'")

    if filename != GetCurrentBufferFilepath():
        # We prefix the command with 'keepjumps' so that opening the file is not
        # recorded in the jumplist. So when we open the file and move the cursor to
        # a location in it, the user can use CTRL-O to jump back to the original
        # location, not to the start of the newly opened file.
        # Sadly this fails on random occasions and the undesired jump remains in the
        # jumplist.
        user_command = user_options_store.Value('goto_buffer_command')

        if user_command == 'new-or-existing-tab':
            try:
                TryJumpLocationInOpenedTab(filename, line, column)
                return
            except ValueError:
                user_command = 'new-tab'

        command = BUFFER_COMMAND_MAP.get(user_command, 'edit')
        if command == 'edit' and not BufferIsUsable(vim.current.buffer):
            command = 'split'
        vim.command('keepjumps {0} {1}'.format(command,
                                               EscapedFilepath(filename)))
    vim.current.window.cursor = (line, column - 1)

    # Center the screen on the jumped-to location
    vim.command('normal! zz')
Esempio n. 3
0
def StopServer_KeepLogFiles(app):
    filepath = PathToTestFile('testy', 'GotoTestCase.cs')
    with WrapOmniSharpServer(app, filepath):
        event_data = BuildRequest(filetype='cs', filepath=filepath)

        response = app.post_json('/debug_info', event_data).json

        logfiles = []
        for server in response['completer']['servers']:
            logfiles.extend(server['logfiles'])

        try:
            for logfile in logfiles:
                assert_that(os.path.exists(logfile),
                            f'Logfile should exist at { logfile }')
        finally:
            app.post_json(
                '/run_completer_command',
                BuildRequest(filetype='cs',
                             filepath=filepath,
                             command_arguments=['StopServer']))

        if user_options_store.Value('server_keep_logfiles'):
            for logfile in logfiles:
                assert_that(os.path.exists(logfile),
                            f'Logfile should still exist at { logfile }')
        else:
            for logfile in logfiles:
                assert_that(not os.path.exists(logfile),
                            f'Logfile should no longer exist at { logfile }')
Esempio n. 4
0
def StopServer_KeepLogFiles(app):
    filepath = PathToTestFile('testy', 'GotoTestCase.cs')
    contents = ReadFile(filepath)
    event_data = BuildRequest(filepath=filepath,
                              filetype='cs',
                              contents=contents,
                              event_name='FileReadyToParse')

    app.post_json('/event_notification', event_data)
    WaitUntilCompleterServerReady(app, 'cs')

    event_data = BuildRequest(filetype='cs', filepath=filepath)

    response = app.post_json('/debug_info', event_data).json

    logfiles = []
    for server in response['completer']['servers']:
        logfiles.extend(server['logfiles'])

    try:
        for logfile in logfiles:
            ok_(os.path.exists(logfile),
                'Logfile should exist at {0}'.format(logfile))
    finally:
        StopCompleterServer(app, 'cs', filepath)

    if user_options_store.Value('server_keep_logfiles'):
        for logfile in logfiles:
            ok_(os.path.exists(logfile),
                'Logfile should still exist at {0}'.format(logfile))
    else:
        for logfile in logfiles:
            ok_(not os.path.exists(logfile),
                'Logfile should no longer exist at {0}'.format(logfile))
Esempio n. 5
0
def JumpToLocation( filename, line, column, modifiers ):
  # Add an entry to the jumplist
  vim.command( "normal! m'" )

  if filename != GetCurrentBufferFilepath():
    # We prefix the command with 'keepjumps' so that opening the file is not
    # recorded in the jumplist. So when we open the file and move the cursor to
    # a location in it, the user can use CTRL-O to jump back to the original
    # location, not to the start of the newly opened file.
    # Sadly this fails on random occasions and the undesired jump remains in the
    # jumplist.
    user_command = user_options_store.Value( 'goto_buffer_command' )

    if user_command == 'split-or-existing-window':
      if 'tab' in modifiers:
        if TryJumpLocationInTabs( filename, line, column ):
          return
      elif TryJumpLocationInTab( vim.current.tabpage, filename, line, column ):
        return
      user_command = 'split'

    # This command is kept for backward compatibility. :tab should be used with
    # the 'split-or-existing-window' command instead.
    if user_command == 'new-or-existing-tab':
      if TryJumpLocationInTabs( filename, line, column ):
        return
      user_command = 'new-tab'

    if not JumpToFile( filename, user_command, modifiers ):
      return

  vim.current.window.cursor = ( line, column - 1 )

  # Center the screen on the jumped-to location
  vim.command( 'normal! zz' )
Esempio n. 6
0
def JumpToLocation(filename, line, column):
    # Add an entry to the jumplist
    vim.command("normal! m'")

    if filename != GetCurrentBufferFilepath():
        # We prefix the command with 'keepjumps' so that opening the file is not
        # recorded in the jumplist. So when we open the file and move the cursor to
        # a location in it, the user can use CTRL-O to jump back to the original
        # location, not to the start of the newly opened file.
        # Sadly this fails on random occasions and the undesired jump remains in the
        # jumplist.
        user_command = user_options_store.Value('goto_buffer_command')

        if user_command == 'new-or-existing-tab':
            if TryJumpLocationInOpenedTab(filename, line, column):
                return
            user_command = 'new-tab'

        vim_command = GetVimCommand(user_command)
        try:
            escaped_filename = EscapeFilepathForVimCommand(filename)
            vim.command('keepjumps {0} {1}'.format(vim_command,
                                                   escaped_filename))
        # When the file we are trying to jump to has a swap file
        # Vim opens swap-exists-choices dialog and throws vim.error with E325 error,
        # or KeyboardInterrupt after user selects one of the options.
        except vim.error as e:
            if 'E325' not in str(e):
                raise
            # Do nothing if the target file is still not opened (user chose (Q)uit)
            if filename != GetCurrentBufferFilepath():
                return
        # Thrown when user chooses (A)bort in .swp message box
        except KeyboardInterrupt:
            return
    vim.current.window.cursor = (line, column - 1)

    # Center the screen on the jumped-to location
    vim.command('normal! zz')
Esempio n. 7
0
def _GlobalYcmExtraConfFileLocation():
    return os.path.expanduser(
        user_options_store.Value('global_ycm_extra_conf'))
Esempio n. 8
0
def ErrorHandler( httperror ):
  body = _JsonResponse( BuildExceptionResponse( httperror.exception,
                                                httperror.traceback ) )
  hmac_plugin.SetHmacHeader( body, user_options_store.Value( 'hmac_secret' ) )
  return body
Esempio n. 9
0
def _GlobalYcmExtraConfFileLocation():
    return ExpandVariablesInPath(
        user_options_store.Value('global_ycm_extra_conf'))