Repository: neovim/neovim
File: src/nvim/main.c (C)

Code before:
      memmove(vimrc + dir_len + 1, path_tail, sizeof(path_tail));
      if (do_source(vimrc, true, DOSO_VIMRC, NULL) != FAIL) {
        do_exrc = p_exrc;
        if (do_exrc) {
          do_exrc = (path_full_compare(VIMRC_FILE, vimrc, false, true) != kEqualFiles);
        }
        xfree(vimrc);
        xfree(config_dirs);
        return do_exrc;
      }
      xfree(vimrc);
    } while (iter != NULL);
    xfree(config_dirs);
  }

  if (execute_env("EXINIT") == OK) {
    do_exrc = p_exrc;
    return do_exrc;
  }
  return do_exrc;
}

// Read initialization commands from ".nvim.lua", ".nvimrc", or ".exrc" in
// current directory.  This is only done if the 'exrc' option is set.
// Only do this if VIMRC_FILE is not the same as vimrc file sourced in
// do_user_initialization.
static void do_exrc_initialization(void)
{
  char *str;

  if (os_path_exists(VIMRC_LUA_FILE)) {
    str = nlua_read_secure(VIMRC_LUA_FILE);
    if (str != NULL) {
      Error err = ERROR_INIT;
      nlua_exec(cstr_as_string(str), "@"VIMRC_LUA_FILE, (Array)ARRAY_DICT_INIT, kRetNilBool, NULL,
                &err);
      xfree(str);
      if (ERROR_SET(&err)) {
        semsg("Error in %s:", VIMRC_LUA_FILE);
        semsg_multiline("emsg", err.msg);
        api_clear_error(&err);
      }
    }
  } else if (os_path_exists(VIMRC_FILE)) {
    str = nlua_read_secure(VIMRC_FILE);
    if (str != NULL) {
      do_source_str(str, VIMRC_FILE);
      xfree(str);
    }
  } else if (os_path_exists(EXRC_FILE)) {
    str = nlua_read_secure(EXRC_FILE);

Review comment (suggestion):
Is `Only if VIMRC_FILE is not the same as vimrc in do_user_initialization` still true?

Oh, that seems to be up to the caller.

Code after:
      memmove(vimrc + dir_len + 1, path_tail, sizeof(path_tail));
      if (do_source(vimrc, true, DOSO_VIMRC, NULL) != FAIL) {
        do_exrc = p_exrc;
        if (do_exrc) {
          do_exrc = (path_full_compare(VIMRC_FILE, vimrc, false, true) != kEqualFiles);
        }
        xfree(vimrc);
        xfree(config_dirs);
        return do_exrc;
      }
      xfree(vimrc);
    } while (iter != NULL);
    xfree(config_dirs);
  }

  if (execute_env("EXINIT") == OK) {
    do_exrc = p_exrc;
    return do_exrc;
  }
  return do_exrc;
}

// Read initialization commands from ".nvim.lua", ".nvimrc", or ".exrc" in
// current directory and all parent directories.  This is only done if the 'exrc'
// option is set. Only do this if VIMRC_FILE is not the same as vimrc file
// sourced in do_user_initialization.
static void do_exrc_initialization(void)
{
  lua_State *const L = get_global_lstate();
  assert(L);

  lua_getglobal(L, "require");
  lua_pushstring(L, "vim._core.exrc");
  if (nlua_pcall(L, 1, 0)) {
    fprintf(stderr, "%s\n", lua_tostring(L, -1));
  }
}

/// Source startup scripts
static void source_startup_scripts(const mparm_T *const parmp)
  FUNC_ATTR_NONNULL_ALL
{
  // If -u given, use only the initializations from that file and nothing else.
  if (parmp->use_vimrc != NULL) {
    if (strequal(parmp->use_vimrc, "NONE") || strequal(parmp->use_vimrc, "NORC")) {
      // Do nothing.
    } else {
      if (do_source(parmp->use_vimrc, false, DOSO_NONE, NULL) != OK) {
        semsg(_(e_cannot_read_from_str_2), parmp->use_vimrc);
      }
    }