New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] XDG base directory specification support #3470

Merged
merged 43 commits into from Oct 26, 2015

Conversation

Projects
None yet
@ZyX-I
Copy link
Contributor

ZyX-I commented Oct 17, 2015

This is the replacement for #3198, that fully implements #78, including documentation update, as requested in #3198 (comment).

I have not touched pi_.txt, os_.txt, vi_diff.txt, todo.txt, various.txt files.

Note: since it was not discussed, I assumed that ~/.gvimrc is replaced with $XDG_CONFIG_HOME/nvim/ginit.vim. Unless it is going away though.

@ZyX-I ZyX-I added the defaults label Oct 17, 2015

@ZyX-I ZyX-I force-pushed the ZyX-I:pr-3198 branch from 679486f to 3795136 Oct 17, 2015

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 17, 2015

Most of documentation changes is replacing .vimrc (with dot) with vimrc (without dot).

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 17, 2015

Also many removes regarding windows (as I have no idea what should be written there).

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 17, 2015

3795136 hanged on unknown test. If 3796471 also hangs I am considering #3427 a blocker (instead of using temporary commit that sets gtest output).

BTW, I do not think ZyX-I@dcc02b2 should be a part of this PR, but I do not know whether this should be part of a separate PR, or of something existing windows-related.

@justinmk

This comment has been minimized.

Copy link
Member

justinmk commented Oct 17, 2015

ZyX-I@dcc02b2 is ok for this PR.

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 17, 2015

This one also hangs. Hang does not happen locally, thus I am waiting for resolution with #3427.

@ZyX-I ZyX-I force-pushed the ZyX-I:pr-3198 branch 2 times, most recently from 9b20f12 to 892c8a9 Oct 17, 2015

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 17, 2015

By the way, not that this PR originally has &backupdir value different from #78: specifically ., prefix is absent (no backups inside current directory).

@ZyX-I ZyX-I force-pushed the ZyX-I:pr-3198 branch from 892c8a9 to 0a4b7a0 Oct 17, 2015

#ifdef WIN32
// Windows
#elif APPLE
// Apple (this includes iOS, which we might need to handle differently)

This comment has been minimized.

@fmoralesc

fmoralesc Oct 17, 2015

Contributor

I think we decided to use the same XDG paths as in other *nixes for OSX (see #3198 (comment) and following)

This comment has been minimized.

@justinmk

justinmk Oct 17, 2015

Member

Yes 👍 Treat OSX as unix. Haters gonna hate.

@justinmk

This comment has been minimized.

Copy link
Member

justinmk commented Oct 17, 2015

&backupdir value different from #78: specifically ., prefix is absent (no backups inside current directory).

👍 One of the major advantages of adopting XDG is that we have standard directories to persist swap/undo/backup. We should default to using those and consider enabling swap & persistent undo by default.

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 17, 2015

Also it would be good to merge #1909 before this: to place socket in $XDG_RUNTIME_DIR I in any case need a single entry point.

version_msg(_(" 3rd user vimrc file: \""));
version_msg(USR_VIMRC_FILE3);
version_msg("\"\n");
#endif // ifdef USR_VIMRC_FILE3
#ifdef USR_EXRC_FILE

This comment has been minimized.

@justinmk

justinmk Oct 17, 2015

Member

I do not think it makes sense to support USR_EXRC_FILE or USR_EXRC_FILE2 if we are removing vimrc already.

}
} else {
#endif
file = SHADA_FILE;
file = shada_get_default_file();
#ifdef SHADA_FILE2

This comment has been minimized.

@justinmk

justinmk Oct 17, 2015

Member

When would SHADA_FILE2 be defined? Why is it optional?

This comment has been minimized.

@ZyX-I

ZyX-I Oct 17, 2015

Contributor

I have no idea. Inherited from viminfo. Maybe for windows ./_ support, in which case it is not needed (no leading dots in file name anymore).

This comment has been minimized.

@justinmk

justinmk Oct 17, 2015

Member

Even if so the _ prefix is not need in modern Windows.

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 17, 2015

I have a reason to want ., default there: until we have support for // like &directory there will be overlaps.

static const char *const xdg_defaults[] = {
// Windows, Apple stuff are just shims right now
#ifdef WIN32
// Windows

This comment has been minimized.

@fmoralesc

fmoralesc Oct 17, 2015

Contributor

If we leave this empty for now, what would it mean for people who are building/using nvim in Windows already?

This comment has been minimized.

@ZyX-I

ZyX-I Oct 17, 2015

Contributor

17.10.2015, 21:41, "Felipe Morales" notifications@github.com:

In src/nvim/os/stdpaths.c:

+static const char *xdg_env_vars[] = { > + [kXDGConfigHome] = "XDG_CONFIG_HOME", > + [kXDGDataHome] = "XDG_DATA_HOME", > + [kXDGCacheHome] = "XDG_CACHE_HOME", > + [kXDGRuntimeDir] = "XDG_RUNTIME_DIR", > + [kXDGConfigDirs] = "XDG_CONFIG_DIRS", > + [kXDGDataDirs] = "XDG_DATA_DIRS", > +}; > + > +/// Defaults for XDGVarType values > +/// > +/// Used in case environment variables contain nothing. Need to be expanded. > +static const char *const xdg_defaults[] = { > + // Windows, Apple stuff are just shims right now > +#ifdef WIN32 > + // Windows

If we leave this empty for now, what would it mean for people who are building/using nvim in Windows already?

That this will fail with syntax error. #endif is wrongly placed.

If it is correctly placed it should SEGV.


Reply to this email directly or view it on GitHub.

This comment has been minimized.

@justinmk

This comment has been minimized.

@ZyX-I

ZyX-I Oct 17, 2015

Contributor

@justinmk Even assuming that C:\\Users\\user\\ from examples is ~\\ (I can’t reliably use $USER even on *nix) I have no idea what is AppAuthor. Also what exactly is AppName: nvim/Neovim/neovim?

This comment has been minimized.

@fmoralesc

fmoralesc Oct 17, 2015

Contributor

@ZyX-I AppAuthor in this case should be Neovim, and the same for AppName. Supposedly, you could use the %AppData% environment variable, see http://blogs.msdn.com/b/patricka/archive/2010/03/18/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions.aspx

This comment has been minimized.

@justinmk

@ghost ghost referenced this pull request Oct 17, 2015

Closed

[WIP] XDG support #3198

@ZyX-I ZyX-I changed the title [RFC] XDG base directory specification support [WIP] XDG base directory specification support Oct 17, 2015

@@ -994,7 +994,7 @@ expect.
Environment variables can be used in a pattern: >
:autocmd BufRead $VIMRUNTIME/doc/*.txt set expandtab
And ~ can be used for the home directory (if $HOME is defined): >
:autocmd BufWritePost ~/.vimrc so ~/.vimrc
:autocmd BufWritePost ~/.config/nvim/init.vim so <afile>

This comment has been minimized.

@ghost

ghost Oct 17, 2015

Regarding all these references to ~/.config/...: shouldn't these instead say $XDG_CONFIG_HOME/...?

This comment has been minimized.

@ZyX-I

ZyX-I Oct 17, 2015

Contributor

17.10.2015, 22:01, "Michael Reed" notifications@github.com:

In runtime/doc/autocmd.txt:

@@ -994,7 +994,7 @@ expect. > Environment variables can be used in a pattern: > > :autocmd BufRead $VIMRUNTIME/doc/*.txt set expandtab > And ~ can be used for the home directory (if $HOME is defined): > > - :autocmd BufWritePost ~/.vimrc so ~/.vimrc > + :autocmd BufWritePost ~/.config/nvim/init.vim so

Regarding all these references to ~/.config/...: shouldn't these instead say $XDG_CONFIG_HOME/...?

Not all of them: $XDG_CONFIG_HOME is not guaranteed to be defined since PR with approach which adds support for XDG_* vars to vim_getenv was rejected.

Most of other stay as-is because I am not fond of explaining WTF is $XDG_CONFIG_HOME and what is its default. I guess we need another section somewhere in documentation (options.txt?) with explanations.


Reply to this email directly or view it on GitHub.

This comment has been minimized.

@ghost

ghost Oct 17, 2015

I guess we need another section somewhere in documentation (options.txt?) with explanations.

I think that would be a good idea. It's not too complicated, so I think it should be doable in a paragraph or two, at least as a high level overview.

This comment has been minimized.

@justinmk

justinmk Oct 17, 2015

Member

I don't think it's necessary to be so specific. It is understood that ~/.config means "what ~/.vim used to mean". And for new users, also, it is easier to understand ~/.config than an env var from the linux desktop standard.

This comment has been minimized.

@ghost

ghost Oct 17, 2015

Eh, probably. Let's not complicate it further.

Unix $HOME/.vimrc or $HOME/.vim/vimrc
MS-Windows $HOME/_vimrc, $HOME/vimfiles/vimrc
or $VIM/_vimrc
Unix $XDG_CONFIG_HOME/.config/nvim/init.vim

This comment has been minimized.

@ghost

ghost Oct 17, 2015

shouldn't this be Unix $XDG_CONFIG_HOME/nvim/init.vim

$HOME/.vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it
easy to copy it to another system.
RECOMMENDATION: Put all your Vim configuration stuff in the
$HOME/.config/nvim/ directory. That makes it easy to copy it to

This comment has been minimized.

@ghost

ghost Oct 17, 2015

$XDG_CONFIG_HOME was just introduced above, so I think it should be used here instead of $HOME/.config.

@ZyX-I ZyX-I force-pushed the ZyX-I:pr-3198 branch from 9bb001f to 90ad4a7 Oct 17, 2015

@@ -224,7 +224,7 @@ D. If your filetype can only be detected by inspecting the contents of the

1. Create your user runtime directory. You would normally use the first
item of the 'runtimepath' option. Example for Unix: >
:!mkdir ~/.vim
:!mkdir ~/.config/nvim

This comment has been minimized.

@ghost
@@ -196,7 +196,7 @@ B. If you want to detect your file after the default file type checks.
C. If your file type can be detected by the file name.
1. Create your user runtime directory. You would normally use the first
item of the 'runtimepath' option. Example for Unix: >
:!mkdir ~/.vim
:!mkdir ~/.config/nvim

This comment has been minimized.

@ghost
:!mkdir ~/.vim
:!mkdir ~/.vim/ftdetect
:!mkdir ~/.config/nvim
:!mkdir ~/.config/nvim/ftdetect

This comment has been minimized.

@ghost

@ZyX-I ZyX-I force-pushed the ZyX-I:pr-3198 branch from 90ad4a7 to 887814e Oct 17, 2015

@justinmk

This comment has been minimized.

Copy link
Member

justinmk commented Oct 17, 2015

XDG defaults for Windows (reference):

+  [kXDGConfigHome] = "~\\$CSIDL_LOCAL_APPDATA\\nvim",
+  [kXDGDataHome]   = "~\\$CSIDL_LOCAL_APPDATA\\nvim",  //same as kXDGConfigHome
+  [kXDGCacheHome]  = "~\\$CSIDL_LOCAL_APPDATA\\nvim\\cache",
+  [kXDGRuntimeDir] = "",  //I don't know what this is for
+  [kXDGConfigDirs] = "$CSIDL_COMMON_APPDATA\\nvim\\nvim",
+  [kXDGDataDirs] = "$CSIDL_COMMON_APPDATA\\nvim\\nvim",  //same as kXDGConfigDirs

Note that this does not switch on "roaming" but that is out of scope for now. This should be good enough.

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 17, 2015

@justinmk Try echo %CSIDL_LOCAL_APPDATA% in wineconsole cmd.exe. It will echo %CSIDL_LOCAL_APPDATA%. For %PATH% it works fine.

@justinmk justinmk removed the RFC label Oct 26, 2015

@justinmk

This comment has been minimized.

Copy link
Member

justinmk commented Oct 26, 2015

Thank you @ZyX-I .

@xu-cheng

This comment has been minimized.

Copy link
Contributor

xu-cheng commented Oct 26, 2015

Looks like this PR introduced an backward incompatibility. It doesn't respect ~/.nvimrc or ~/.nvim/nvimrc as configure file anymore. Is such breaking change intentional?

$ nvim -v
NVIM 0.0.0-alpha+201510252238 (compiled Oct 26 2015 11:25:35)
Commit: 1ca5646bb52ec5c23b28f45bb7bc5d25cffad9b0
Build type: RelWithDebInfo
Compilation: /home/comp/chengxu/usr/bin/gcc-5 -Os -w -pipe -march=core2 -Wconversion -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/tmp/neovim20151026-26575-xo616q/build/config -I/tmp/neovim20151026-26575-xo616q/src -I/tmp/neovim20151026-26575-xo616q/deps-build/usr/include -I/tmp/neovim20151026-26575-xo616q/deps-build/usr/include -I/tmp/neovim20151026-26575-xo616q/deps-build/usr/include/luajit-2.0 -I/tmp/neovim20151026-26575-xo616q/deps-build/usr/include -I/tmp/neovim20151026-26575-xo616q/deps-build/usr/include -I/tmp/neovim20151026-26575-xo616q/deps-build/usr/include -I/tmp/neovim20151026-26575-xo616q/deps-build/usr/include -I/home/comp/chengxu/usr/include -I/tmp/neovim20151026-26575-xo616q/build/src/nvim/auto -I/tmp/neovim20151026-26575-xo616q/build/include
Compiled by chengxu@csr40.comp.hkbu.edu.hk

Optional features included (+) or not (-): +acl   +iconv    +jemalloc
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/home/comp/chengxu/usr/Cellar/neovim/HEAD/share/nvim"

Compared with compiling revision before this PR:

$ nvim -v
NVIM 0.0.0-alpha+201510231011 (compiled Oct 26 2015 11:41:09)
Commit: de4cb766ca381c09fd3f938136c1932ebf008f63
Build type: RelWithDebInfo
Compilation: /home/comp/chengxu/usr/bin/gcc-5 -Os -w -pipe -march=core2 -Wconversion -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/tmp/neovim20151026-17981-bt0ppn/build/config -I/tmp/neovim20151026-17981-bt0ppn/src -I/tmp/neovim20151026-17981-bt0ppn/deps-build/usr/include -I/tmp/neovim20151026-17981-bt0ppn/deps-build/usr/include -I/tmp/neovim20151026-17981-bt0ppn/deps-build/usr/include/luajit-2.0 -I/tmp/neovim20151026-17981-bt0ppn/deps-build/usr/include -I/tmp/neovim20151026-17981-bt0ppn/deps-build/usr/include -I/tmp/neovim20151026-17981-bt0ppn/deps-build/usr/include -I/tmp/neovim20151026-17981-bt0ppn/deps-build/usr/include -I/home/comp/chengxu/usr/include -I/tmp/neovim20151026-17981-bt0ppn/build/src/nvim/auto -I/tmp/neovim20151026-17981-bt0ppn/build/include
Compiled by chengxu@csr40.comp.hkbu.edu.hk

Optional features included (+) or not (-): +acl   +iconv    +jemalloc
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/nvimrc"
     user vimrc file: "~/.nvimrc"
 2nd user vimrc file: "~/.nvim/nvimrc"
      user exrc file: "~/.exrc"
  fall-back for $VIM: "/home/comp/chengxu/usr/Cellar/neovim/HEAD/share/nvim"
@justinmk

This comment has been minimized.

Copy link
Member

justinmk commented Oct 26, 2015

@xu-cheng It is intentional; back-compat make be broken in some cases before 1.0. Here the migration is minimal, see :help nvim-from-vim for steps.

@ZyX-I ZyX-I deleted the ZyX-I:pr-3198 branch Oct 26, 2015

@tarruda

This comment has been minimized.

Copy link
Member

tarruda commented Oct 26, 2015

Great, will update my nvim version with this branch. Thanks to all involved in this.

BTW could #3498 be caused by this?

@wbinnssmith

This comment has been minimized.

Copy link

wbinnssmith commented Oct 27, 2015

hey folks,

anyone know where the default location for the autoload directory (so basically the runtimepath) went? neovim's not picking it up (for example, plug.vim in $XDG_DATA_HOME or $XDG_CONFIG_HOME).

:help autoload, points to runtimepath, and :help runtimepath claims that these directories are evaluated, but I can't reproduce this.

@fmoralesc

This comment has been minimized.

Copy link
Contributor

fmoralesc commented Oct 27, 2015

@wbinnssmith In that case, you should place the autoload directory in ~/.config/nvim/ or whatever split(runtimepath, ',', 0)[0] is. It should be $XDG_CONFIG_DIR/nvim/.

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 27, 2015

@wbinnssmith Location of autoload directory did not change at all. The only thing which did change is the default value of &runtimepath. You may create autoload subdirectory in any directory you will see in :set runtimepath? output.

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 27, 2015

@wbinnssmith If you are not using some plugin manager it is now expected that you put plug.vim (i.e. third-party autoload file) into $XDG_DATA_HOME/nvim/autoload. $XDG_DATA_HOME defaults to ~/.local/share.

Note: putting it into $XDG_CONFIG_HOME/nvim/autoload (which is ~/.config/nvim/autoload by default) will also work, but this is going against XDG spec: plug.vim is not a user configuration file.

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 27, 2015

@fmoralesc There is no $XDG_CONFIG_DIR: there are variables $XDG_CONFIG_HOME (one directory, default ~/.config) and $XDG_CONFIG_DIRS (colon-separated list, default /etc/xdg).

@wbinnssmith

This comment has been minimized.

Copy link

wbinnssmith commented Oct 27, 2015

Location of autoload directory did not change at all. The only thing which did change is the default value of &runtimepath. You may create autoload subdirectory in any directory you will see in :set runtimepath? output.

This is exactly what I expected it would be. Thanks 😄

re: $XDG_CONFIG_DIR, that was my slipup here on the comments. Should be $XDG_CONFIG_HOME

@wbinnssmith If you are not using some plugin manager it is now expected that you put plug.vim (i.e. third-party autoload file) into $XDG_DATA_HOME/nvim/autoload. $XDG_DATA_HOME defaults to ~/.local/share.

I'm actually trying to use a plugin manager in this case, which would in this case be the only file in autoload, yes? I agree that $XDG_DATA_HOME is a better place for this over CONFIG, but unfortunately neither are panning out for me at the moment. I'll continue looking into it.

@fmoralesc

This comment has been minimized.

Copy link
Contributor

fmoralesc commented Oct 27, 2015

@ZyX-I Sorry, you are right about XDG_CONFIG_DIR; dunno where I got that from.

It's worth noting that ~/.local/share/nvim/autoload won't work: the default &runtimepath would not use that but ~/.local/share/nvim/site/autoload. (Why is that, btw?)

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 27, 2015

@fmoralesc You are right, I forgot about site. About why: default for $XDG_DATA_DIRS is /usr/local/share/:/usr/share/. $VIMRUNTIME is normally /usr/share/nvim/runtime. So I used $xdg_data_dir/nvim/site to make structure similar to the current Vim variant: $xdg_data_dir/vim/vim74 ($VIMRUNTIME) + $xdg_data_dir/vim/vimfiles (third-party files). $XDG_DATA_HOME got site mainly because I have choosen to treat it identically to directories in $XDG_DATA_DIRS.

Additionally users that install Neovim in $HOME may use the same layout: VIMRUNTIME=$HOME/.local/share/nvim/runtime with plugins in $HOME/.local/share/nvim/site.

@wbinnssmith Note that I forgot about site subdirectory: ~/.local/share/nvim/site/autoload, not ~/.local/share/nvim/autoload. Though this should be seen in set rtp?.

@wbinnssmith

This comment has been minimized.

Copy link

wbinnssmith commented Oct 27, 2015

@ZyX-I yeah, I resolved my issue — it was unrelated to the autoload path and just coincided with moving my configuration to XDG 😄

I do think that ~/.local/share/nvim ($XDG_DATA_HOME) should be in the runtimepath though. Do you agree?

@ZyX-I

This comment has been minimized.

Copy link
Contributor

ZyX-I commented Oct 27, 2015

@wbinnssmith No. I have said why site subdirectory is there and it is useful. ($XDG_DATA_HOME is ~/.local/share, without nvim.)

fwalch added a commit to fwalch/homebrew-neovim that referenced this pull request Oct 28, 2015

Formula: Mention ':h nvim-from-vim'.
Previous instructions are outdated as of neovim/neovim#3470.

elasticdog added a commit to elasticdog/dotfiles that referenced this pull request Nov 6, 2015

Move nvimrc to XDG-compliant configuration location
There was an upstream change in how the config file locations are
handled. So now I must symlink ~/.config/nvim/ -> ~/.dotfiles/nvim/

See: neovim/neovim#3470

@justinmk justinmk referenced this pull request Dec 11, 2018

Closed

Config in Windows #9352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment