Skip to content

Commit 78a1e6b

Browse files
etircopyhjustinmk
authored andcommitted
feat(defaults): session data in $XDG_STATE_HOME neovim#15583
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
1 parent a1b663c commit 78a1e6b

File tree

15 files changed

+303
-224
lines changed

15 files changed

+303
-224
lines changed

man/nvim.1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ loading plugins is also skipped.
188188
Use
189189
.Ar shada
190190
instead of the default
191-
.Pa ~/.local/share/nvim/shada/main.shada .
191+
.Pa ~/.local/state/nvim/shada/main.shada .
192192
If
193193
.Ar shada
194194
is
@@ -326,7 +326,7 @@ Print version information and exit.
326326
.Sh ENVIRONMENT
327327
.Bl -tag -width Fl
328328
.It Ev NVIM_LOG_FILE
329-
Low-level log file, usually found at ~/.cache/nvim/log.
329+
Low-level log file, usually found at ~/.local/state/nvim/log.
330330
:help $NVIM_LOG_FILE
331331
.It Ev VIM
332332
Used to locate user files, such as init.vim.
@@ -340,12 +340,20 @@ Path to the user-local configuration directory, see
340340
Defaults to
341341
.Pa ~/.config .
342342
:help xdg
343-
.It Ev XDG_DATA_HOME
343+
.It Ev XDG_STATE_HOME
344344
Like
345345
.Ev XDG_CONFIG_HOME ,
346346
but used to store data not generally edited by the user,
347347
namely swap, backup, and ShaDa files.
348348
Defaults to
349+
.Pa ~/.local/state .
350+
:help xdg
351+
.It Ev XDG_DATA_HOME
352+
Like
353+
.Ev XDG_CONFIG_HOME ,
354+
but used to store data not generally edited by the user,
355+
things like runtime files.
356+
Defaults to
349357
.Pa ~/.local/share .
350358
:help xdg
351359
.It Ev VIMINIT

runtime/doc/builtin.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7465,14 +7465,17 @@ stdpath({what}) *stdpath()* *E6100*
74657465
directories.
74667466

74677467
{what} Type Description ~
7468-
cache String Cache directory. Arbitrary temporary
7468+
cache String Cache directory: arbitrary temporary
74697469
storage for plugins, etc.
7470-
config String User configuration directory. The
7471-
|init.vim| is stored here.
7472-
config_dirs List Additional configuration directories.
7470+
config String User configuration directory. |init.vim|
7471+
is stored here.
7472+
config_dirs List Other configuration directories.
74737473
data String User data directory. The |shada-file|
74747474
is stored here.
7475-
data_dirs List Additional data directories.
7475+
data_dirs List Other data directories.
7476+
log String Logs directory (for use by plugins too).
7477+
state String Session state directory: storage for file
7478+
drafts, undo history, shada, etc.
74767479

74777480
Example: >
74787481
:echo stdpath("config")

runtime/doc/options.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ A jump table for the options with a short description can be found at |Q_op|.
841841
again not rename the file.
842842

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

20652065
*'directory'* *'dir'*
2066-
'directory' 'dir' string (default "$XDG_DATA_HOME/nvim/swap//")
2066+
'directory' 'dir' string (default "$XDG_STATE_HOME/nvim/swap//")
20672067
global
20682068
List of directory names for the swap file, separated with commas.
20692069

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

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

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

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

67886791
*'viewdir'* *'vdir'*
6789-
'viewdir' 'vdir' string (default: "$XDG_DATA_HOME/nvim/view//")
6792+
'viewdir' 'vdir' string (default: "$XDG_STATE_HOME/nvim/view//")
67906793
global
67916794
Name of the directory where to store files for |:mkview|.
67926795
This option cannot be set from a |modeline| or in the |sandbox|, for

0 commit comments

Comments
 (0)