Skip to content

Commit

Permalink
feat(defaults): session data in $XDG_STATE_HOME neovim#15583
Browse files Browse the repository at this point in the history
See: https://gitlab.freedesktop.org/xdg/xdg-specs/-/commit/4f2884e16db35f2962d9b64312917c81be5cb54b

- 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: neovim#14805
  • Loading branch information
etircopyh authored and justinmk committed May 12, 2022
1 parent a1b663c commit 78a1e6b
Show file tree
Hide file tree
Showing 15 changed files with 303 additions and 224 deletions.
14 changes: 11 additions & 3 deletions man/nvim.1
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ loading plugins is also skipped.
Use
.Ar shada
instead of the default
.Pa ~/.local/share/nvim/shada/main.shada .
.Pa ~/.local/state/nvim/shada/main.shada .
If
.Ar shada
is
Expand Down Expand Up @@ -326,7 +326,7 @@ Print version information and exit.
.Sh ENVIRONMENT
.Bl -tag -width Fl
.It Ev NVIM_LOG_FILE
Low-level log file, usually found at ~/.cache/nvim/log.
Low-level log file, usually found at ~/.local/state/nvim/log.
:help $NVIM_LOG_FILE
.It Ev VIM
Used to locate user files, such as init.vim.
Expand All @@ -340,12 +340,20 @@ Path to the user-local configuration directory, see
Defaults to
.Pa ~/.config .
:help xdg
.It Ev XDG_DATA_HOME
.It Ev XDG_STATE_HOME
Like
.Ev XDG_CONFIG_HOME ,
but used to store data not generally edited by the user,
namely swap, backup, and ShaDa files.
Defaults to
.Pa ~/.local/state .
:help xdg
.It Ev XDG_DATA_HOME
Like
.Ev XDG_CONFIG_HOME ,
but used to store data not generally edited by the user,
things like runtime files.
Defaults to
.Pa ~/.local/share .
:help xdg
.It Ev VIMINIT
Expand Down
13 changes: 8 additions & 5 deletions runtime/doc/builtin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7465,14 +7465,17 @@ stdpath({what}) *stdpath()* *E6100*
directories.

{what} Type Description ~
cache String Cache directory. Arbitrary temporary
cache String Cache directory: arbitrary temporary
storage for plugins, etc.
config String User configuration directory. The
|init.vim| is stored here.
config_dirs List Additional configuration directories.
config String User configuration directory. |init.vim|
is stored here.
config_dirs List Other configuration directories.
data String User data directory. The |shada-file|
is stored here.
data_dirs List Additional data directories.
data_dirs List Other data directories.
log String Logs directory (for use by plugins too).
state String Session state directory: storage for file
drafts, undo history, shada, etc.

Example: >
:echo stdpath("config")
Expand Down
17 changes: 10 additions & 7 deletions runtime/doc/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ A jump table for the options with a short description can be found at |Q_op|.
again not rename the file.

*'backupdir'* *'bdir'*
'backupdir' 'bdir' string (default ".,$XDG_DATA_HOME/nvim/backup//")
'backupdir' 'bdir' string (default ".,$XDG_STATE_HOME/nvim/backup//")
global
List of directories for the backup file, separated with commas.
- The backup file will be created in the first directory in the list
Expand Down Expand Up @@ -2063,7 +2063,7 @@ A jump table for the options with a short description can be found at |Q_op|.
{char2}. See |digraphs|.

*'directory'* *'dir'*
'directory' 'dir' string (default "$XDG_DATA_HOME/nvim/swap//")
'directory' 'dir' string (default "$XDG_STATE_HOME/nvim/swap//")
global
List of directory names for the swap file, separated with commas.

Expand Down Expand Up @@ -3502,7 +3502,7 @@ A jump table for the options with a short description can be found at |Q_op|.
option. For '@' only characters up to 255 are used.
Careful: If you change this option, it might break expanding
environment variables. E.g., when '/' is included and Vim tries to
expand "$HOME/.local/share/nvim/shada/main.shada". Maybe you should
expand "$HOME/.local/state/nvim/shada/main.shada". Maybe you should
change 'iskeyword' instead.

*'iskeyword'* *'isk'*
Expand Down Expand Up @@ -4942,9 +4942,12 @@ A jump table for the options with a short description can be found at |Q_op|.
but are not part of the Nvim distribution. XDG_DATA_DIRS defaults
to /usr/local/share/:/usr/share/, so system administrators are
expected to install site plugins to /usr/share/nvim/site.
5. $VIMRUNTIME, for files distributed with Neovim.
5. Applications state home directory, for files that contain your
session state (eg. backupdir, viewdir, undodir, etc).
Given by `stdpath("state")`. |$XDG_STATE_HOME|
6. $VIMRUNTIME, for files distributed with Neovim.
*after-directory*
6, 7, 8, 9. In after/ subdirectories of 1, 2, 3 and 4, with reverse
7, 8, 9, 10. In after/ subdirectories of 1, 2, 3 and 4, with reverse
ordering. This is for preferences to overrule or add to the
distributed defaults or system-wide settings (rarely needed).

Expand Down Expand Up @@ -6623,7 +6626,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'ttyfast' 'tf' Removed. |vim-differences|

*'undodir'* *'udir'* *E5003*
'undodir' 'udir' string (default "$XDG_DATA_HOME/nvim/undo//")
'undodir' 'udir' string (default "$XDG_STATE_HOME/nvim/undo//")
global
List of directory names for undo files, separated with commas.
See 'backupdir' for details of the format.
Expand Down Expand Up @@ -6786,7 +6789,7 @@ A jump table for the options with a short description can be found at |Q_op|.
displayed when 'verbosefile' is set.

*'viewdir'* *'vdir'*
'viewdir' 'vdir' string (default: "$XDG_DATA_HOME/nvim/view//")
'viewdir' 'vdir' string (default: "$XDG_STATE_HOME/nvim/view//")
global
Name of the directory where to store files for |:mkview|.
This option cannot be set from a |modeline| or in the |sandbox|, for
Expand Down
Loading

0 comments on commit 78a1e6b

Please sign in to comment.