Skip to content
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

XDG base directory specification support #3470

Merged
merged 43 commits into from
Oct 26, 2015
Merged

Conversation

ZyX-I
Copy link
Contributor

@ZyX-I 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 issues or PRs involving changing the defaults label Oct 17, 2015
@ZyX-I
Copy link
Contributor Author

ZyX-I commented Oct 17, 2015

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

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Oct 17, 2015

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

@ZyX-I
Copy link
Contributor Author

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
Copy link
Member

ZyX-I@dcc02b2 is ok for this PR.

@ZyX-I
Copy link
Contributor Author

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 pr-3198 branch 2 times, most recently from 9b20f12 to 892c8a9 Compare October 17, 2015 18:10
@ZyX-I
Copy link
Contributor Author

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).

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 👍 Treat OSX as unix. Haters gonna hate.

@justinmk
Copy link
Member

&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
Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ZyX-I
Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

17.10.2015, 21:41, "Felipe Morales" [email protected]:

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can stub it out with the examples from https://github.com/ActiveState/appdirs/blob/master/appdirs.py .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghost ghost mentioned this pull request Oct 17, 2015
@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>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

17.10.2015, 22:01, "Michael Reed" [email protected]:

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkdir -p?

@justinmk
Copy link
Member

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
Copy link
Contributor Author

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.

@tarruda
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
Copy link

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
Copy link
Contributor

@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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link

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
Copy link
Contributor

@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
Copy link
Contributor Author

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
Copy link

@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
Copy link
Contributor Author

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
Previous instructions are outdated as of neovim/neovim#3470.
elasticdog added a commit to elasticdog/dotfiles that referenced this pull request Nov 6, 2015
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 mentioned this pull request Dec 11, 2018
@justinmk justinmk changed the title [RFC] XDG base directory specification support XDG base directory specification support Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defaults issues or PRs involving changing the defaults
Projects
None yet
Development

Successfully merging this pull request may close these issues.