mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
feat(defaults): session data in $XDG_STATE_HOME #15583
See: 4f2884e16d
- Move session persistent data to $XDG_STATE_HOME Change 'directory',
'backupdir', 'undodir', 'viewdir' and 'shadafile' default location to
$XDG_STATE_HOME/nvim.
- Move logs to $XDG_STATE_HOME, too.
- Add stdpath('log') support.
Fixes: #14805
This commit is contained in:
@@ -51,7 +51,7 @@ static bool log_try_create(char *fname)
|
||||
|
||||
/// Initializes path to log file. Sets $NVIM_LOG_FILE if empty.
|
||||
///
|
||||
/// Tries $NVIM_LOG_FILE, or falls back to $XDG_CACHE_HOME/nvim/log. Path to log
|
||||
/// Tries $NVIM_LOG_FILE, or falls back to $XDG_STATE_HOME/nvim/log. Path to log
|
||||
/// file is cached, so only the first call has effect, unless first call was not
|
||||
/// successful. Failed initialization indicates either a bug in expand_env()
|
||||
/// or both $NVIM_LOG_FILE and $HOME environment variables are undefined.
|
||||
@@ -69,16 +69,16 @@ static bool log_path_init(void)
|
||||
|| log_file_path[0] == '\0'
|
||||
|| os_isdir((char_u *)log_file_path)
|
||||
|| !log_try_create(log_file_path)) {
|
||||
// Make kXDGCacheHome if it does not exist.
|
||||
char *cachehome = get_xdg_home(kXDGCacheHome);
|
||||
// Make kXDGStateHome if it does not exist.
|
||||
char *loghome = get_xdg_home(kXDGStateHome);
|
||||
char *failed_dir = NULL;
|
||||
bool log_dir_failure = false;
|
||||
if (!os_isdir((char_u *)cachehome)) {
|
||||
log_dir_failure = (os_mkdir_recurse(cachehome, 0700, &failed_dir) != 0);
|
||||
if (!os_isdir((char_u *)loghome)) {
|
||||
log_dir_failure = (os_mkdir_recurse(loghome, 0700, &failed_dir) != 0);
|
||||
}
|
||||
XFREE_CLEAR(cachehome);
|
||||
XFREE_CLEAR(loghome);
|
||||
// Invalid $NVIM_LOG_FILE or failed to expand; fall back to default.
|
||||
char *defaultpath = stdpaths_user_cache_subpath("log");
|
||||
char *defaultpath = stdpaths_user_state_subpath("log", 0, true);
|
||||
size_t len = xstrlcpy(log_file_path, defaultpath, size);
|
||||
xfree(defaultpath);
|
||||
// Fall back to .nvimlog
|
||||
|
Reference in New Issue
Block a user