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

Support XDG directory specification #78

Closed
ZyX-I opened this issue Feb 23, 2014 · 88 comments
Closed

Support XDG directory specification #78

ZyX-I opened this issue Feb 23, 2014 · 88 comments
Labels
enhancement feature request ui

Comments

@ZyX-I
Copy link
Contributor

ZyX-I commented Feb 23, 2014

From #26, but I am talking not only about configuration files.

  1. Configuration:
    1. populate runtimepath from XDG_CONFIG_DIRS, XDG_DATA_DIRS, XDG_DATA_HOME and XDG_CONFIG_HOME (and $VIMRUNTIME as well):

      $XDG_CONFIG_HOME/nvim
      $xdg_config_dir/nvim (for each directory in $XDG_CONFIG_DIRS)
      $XDG_DATA_HOME/nvim
      $xdg_data_dir/nvim/site (for each directory in $XDG_DATA_DIRS)
      $VIMRUNTIME (looks something like /usr/share/nvim/runtime)
      $xdg_data_dir/nvim/site/after (for each directory in $XDG_DATA_DIRS, reverse order)
      $XDG_DATA_HOME/nvim
      $xdg_config_dir/nvim/after (for each directory in $XDG_CONFIG_DIRS, reverse order)
      $XDG_CONFIG_HOME/nvim/after

    2. init.vim should be taken from the first directory in $XDG_CONFIG_HOME:$XDG_CONFIG_DIRS where it was found (e.g. first from ~/.config/nvim/init.vim, then from /etc/xdg/nvim/init.vim).

  2. Default &directory option (it holds swap files there) to $XDG_DATA_HOME/nvim/swap//.
  3. Default &backupdir to .,$XDG_DATA_HOME/nvim/backup.
  4. Default &undodir to $XDG_DATA_HOME/nvim/undo//.
  5. Default ShaDa location is $XDG_DATA_HOME/nvim/shada/main.shada.
  6. Default &viewdir to $XDG_DATA_HOME/nvim/view.

OS defaults:

  1. On nix operating systems default XDG_ variables according XDG base directory specification.
  2. On windows default XDG_CONFIG_HOME and XDG_DATA_HOME to %APPDATA%, XDG_CACHE_HOME and XDG_RUNTIME_DIR to %TEMP% (just in case) and XDG_CONFIG_DIRS to empty (as VIMRUNTIME is handled separately).

Some other notes:

  1. In any case respect existing values on any operating system.
  2. Entry separator is a colon on any system. It is expected that path separator is a forward slash inside these variables on systems where path separator is a colon.
  3. On startup absent environment variables (only XDG_CONFIG_HOME and XDG_DATA_HOME) should be set to their default values for use in scripts. Code that sets default options this will not have to handle this on its own.
  4. On startup invalid values (XDG base directory specification says that paths must be absolute, relative paths are to be ignored) are replaced with default ones.
  5. Code that sets those variables should live in src/nvim/os/env.c, alongside with restored init_homedir (which currently lives in misc1.c and lacks code for Windows).

Note some renamings: vim74 to 7.4, vimfiles to site-contrib, .vimrc to init.vim. Reasoning behind this: to avoid duplicating data. We already know this directory contains files for neovim since it is named /usr/share/nvim, why should this information be repeated in the subdirectory? Also it is hard to tell from the directory name what is the difference in vim74 and vimfiles contents, but it is easy for 7.4 and site-contrib (names are taken from /usr/share/zsh). Extension designates file type, so no need to remove it, it is for separate purpose.

Update: Renamed rc.vim to startup.vim. Reasoning: this way config file name resembles its purpose. See also #235.

Update 2:

  • Renamed neovim to nvim as it is new convention.
  • Moved &directory, &backupdir and &undodir defaults to $XDG_DATA_HOME.
  • Made &undodir use trailing // as well.
  • Removed ~/tmp/$TEMP/etc defaults from &backupdir (backups in %TEMP%?!).
  • Removed current directory from &undodir default. If &backupdir was supporting trailing // I would happily remove current directory from there as well: nobody likes spamming working directory with files that are needed only by vim and hardly ever by user.

Update 3: All options sharing the same $XDG_DATA_HOME/nvim directory were supplied with distinct subpaths.

Update 4: Added OS defaults and notes.

Update 5: Renamed startup.vim to init.vim.

Update 6: Added default for ShaDa.

Update 7: Added default for viewdir.

Update 8: Updated init.vim search path, as discussed in some of the PRs.

@erinzm
Copy link

erinzm commented Feb 23, 2014

👍

@ashleyh
Copy link
Contributor

ashleyh commented Feb 23, 2014

👍

2 similar comments
@Olivia5k
Copy link
Contributor

👍

@vheon
Copy link
Contributor

vheon commented Feb 24, 2014

👍

@scott-linder
Copy link

👍 long overdue

@Earnestly
Copy link

Definitely needed

@tssm
Copy link

tssm commented Feb 26, 2014

  1. Move .viminfo to $XDG_CACHE_HOME/neovim/info.

@tssm
Copy link

tssm commented Mar 7, 2014

@tarruda
Copy link
Member

tarruda commented Apr 4, 2014

I think we should take the approach suggested in #460 and delegate it to an external tool. In any case we can revisit this later

@kopischke
Copy link

@tarruda I think you might be misunderstanding what this is about: the XDG Base Directory Specification is meant to stop applications from littering the user’s home dir with configuration files and directories by offering a common, configurable set of base directories for these. In the case of Vim, we are talking about .vim, .vimrc, .gvimrc, the default values for rtp, plus anything set in directory, backupdir and the viminfo n argument. At least when it comes to its own initialisation files and to the defaults it sets, the application needs to support the XDG scheme natively to work (no, exporting shell vars is not a solution – MacVim for instance does not read them, due to the way OS X handles environment settings for GUI applications; other GUI front ends might gave similar problems). In short, this is not something that can, or should, be delegated to a helper app.

@ZyX-I good call, but swap files should not be put in $XDG_RUNTIME_DIR, as the persistence of that directory is not guaranteed. Per the spec:

Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.

@vially
Copy link

vially commented Jun 14, 2014

Completely agree with @kopischke
I don't think this should be delegated to a helper app.

Using a wrapper around the vim executable just so it can read the configuration files from the correct paths does not sound like a sensible option.

@mrak
Copy link

mrak commented Jun 14, 2014

Please support this. It is what compliant Unix citizens are adopting. Neovim is attempting to be a modernization of vim, so I think this qualifies.

Thanks for all of the other awesome y'all are bringing! Looking forward to the first release.

@justinmk
Copy link
Member

Vim itself will be adding support for this pretty soon, so we'll probably just merge that.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Jun 14, 2014

@justinmk I do not like this idea. Vim support will be optional, falling back to old behaviour because Vim cannot drop backwards compatibility. We can make XDG directories the only default variant since we do not have to be compatible with Vim configuration locations.

I do not see any sense in having two default locations for user configuration.

@justinmk
Copy link
Member

@ZyX-I you don't want to support ~/.nvimrc?

@aktau
Copy link
Contributor

aktau commented Jun 14, 2014

@ZyX-I you don't want to support ~/.nvimrc?

That's what I read as well. On the face of it, I'm not really in favour of removing support for .*vimrc whenever the XDG path is not found.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Jun 14, 2014

Why should I want it?

That's what I read as well. On the face of it, I'm not really in favour of removing support for .*vimrc whenever the XDG path is not found.

Why? If one wants to have it there there are shell aliases, variables like VIMINIT (perhaps should be renamed to NVIMINIT), MYVIMRC (did we drop support for it? MYNVIMRC and MYVIMRC seem not to work), system-wide configuration (which is to be placed in /etc/xdg/nvim, but since it the package maintainers business its location is completely irrelevant), … Supporting both XDG base directory specification and non-XDG .nvimrc path is like saying “we do not know where you should put your configuration”. There must be one default and there must be ways to omit using it, but there should not be two defaults.

If we do support Vim directories for some reasons this is a separate issue, but currently this is not the case.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Jun 14, 2014

By the way, Vim is the only software I know which supports more then one configuration location. But this support is based on historical reasons and POSIX compliance. This is not the case here:

  1. Neovim is a new project without releases: no own compatibility reasons.
  2. Neovim is not supporting Vim directories and in any case Vim does not support ~/.nvimrc: no other compatibility reasons.
  3. Neovim is dropping Vi compatibility options in [RFC] Remove VI option defaults #228: no POSIX compliance (and in any case POSIX does not require us to source .nvimrc).

Based on this facts I think it is required that you will be explaining why if XDG specification is supported ~/.nvimrc should be supported as well, not me explaining why it should not be supported: if XDG specification is supported it is about having additional code to support .nvimrc, not about having additional code to not support it.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Jun 14, 2014

Thus I think we should tie XDG support and dropping .nvim/.nvimrc and discuss whether both XDG support and drop should happen or whether both XDG support and drop should not happen.

@justinmk
Copy link
Member

Only reason is because I like .nvimrc, and XDG is irrelevant to Windows and OS X, and if we merge the Vim support for XDG then we get everything for "free" (except the maintenance cost).

But you're right about symlinks, and it's better to have one recommended path instead of two.

If one wants to have it there there are shell aliases, variables like VIMINIT (perhaps should be renamed to NVIMINIT), MYVIMRC (did we drop support for it? MYNVIMRC and MYVIMRC seem not to work)

Ok. I'm not sure about renaming those, nor VIMRUNTIME. Need to think about that, because that could affect legacy plugins.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Jun 14, 2014

While XDG is irrelevant for windows using $XDG_CONFIG_HOME/nvim/{…,startup.vim} means that only special-cased (underscore or vimfiles) name at the start of the path component may only be present in $XDG_CONFIG_HOME default. Anybody knows an established convention for $XDG_* locations on windows? I think it is %APPDATA% for configs and data and %TEMP% for runtime and caches.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Jun 14, 2014

Update2:

  • Renamed neovim to nvim as it is new convention.
  • Moved &directory, &backupdir and &undodir defaults to $XDG_DATA_HOME.
  • Made &undodir use trailing // as well.
  • Removed ~/tmp/$TEMP/etc defaults from &backupdir (backups in %TEMP%?!).
  • Removed current directory from &undodir default. If &backupdir was supporting trailing // I would happily remove current directory from there as well: nobody likes spamming working directory with files that are needed only by vim and hardly ever by user.

@justinmk justinmk added this to the first release milestone Jun 14, 2014
@justinmk justinmk reopened this Jun 14, 2014
ZyX-I pushed a commit to ZyX-I/neovim that referenced this issue Oct 17, 2015
- Add functions that are able to query XDG.
- Replace defaults for
  - &runtimepath. Does not follow neovim#78.
  - &viewdir.
  - &undodir.
  - &directory.
  - &backupdir. Does not follow neovim#78.
  - vimrc location.
- Remove user vimrc file line from :version message.
@ZyX-I
Copy link
Contributor Author

ZyX-I commented Oct 17, 2015

Update 8: Updated init.vim search path, as discussed in some of the PRs.

ZyX-I pushed a commit to ZyX-I/neovim that referenced this issue Oct 23, 2015
- Add functions that are able to query XDG.
- Replace defaults for
  - &runtimepath. Does not follow neovim#78.
  - &viewdir.
  - &undodir.
  - &directory.
  - &backupdir. Does not follow neovim#78.
  - vimrc location.
- Remove user vimrc file line from :version message.
sts10 added a commit to sts10/homebrew-neovim that referenced this issue Oct 28, 2015
Change symlink targets to point to the new location of Neovim's config files. I think the change was fairly recent, as per [this Reddit thread](https://www.reddit.com/r/neovim/comments/3qgsza/psa_if_neovim_stopped_loading_your_nvimrc_after/), which points to a [issue neovim#78](neovim/neovim#78).
sts10 added a commit to sts10/homebrew-neovim that referenced this issue Oct 28, 2015
Change symlink targets to point to the new location of Neovim's config files. I think the change was fairly recent, as per [this Reddit thread](https://www.reddit.com/r/neovim/comments/3qgsza/psa_if_neovim_stopped_loading_your_nvimrc_after/), which points to [issue neovim#78](neovim/neovim#78).
grmwld pushed a commit to grmwld/nvim-config that referenced this issue Oct 29, 2015
mgraczyk pushed a commit to mgraczyk/neovim that referenced this issue Nov 2, 2015
- Add functions that are able to query XDG.
- Replace defaults for
  - &runtimepath. Does not follow neovim#78.
  - &viewdir.
  - &undodir.
  - &directory.
  - &backupdir. Does not follow neovim#78.
  - vimrc location.
- Remove user vimrc file line from :version message.
dwb pushed a commit to dwb/neovim that referenced this issue Feb 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request ui
Projects
None yet
Development

No branches or pull requests