[vim/vim] Add initial XDG_CONFIG_HOME compatibility (#8188)

289 views
Skip to first unread message

txtsd

unread,
May 8, 2021, 12:42:42 PM5/8/21
to vim/vim, Subscribed

So far this only handles the (.)vimrc file.

It currently takes care of the fallbacks on Linux. I haven't modified the VMS part because I don't understand that yet. And I couldn't find a windows version of vimrc.

Is this an okay change to start with? What recommendations do y'all have?

This will eventually fix #2034


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/8188

Commit Summary

  • Add initial XDG_CONFIG_HOME change

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Romain Lafourcade

unread,
May 8, 2021, 1:18:29 PM5/8/21
to vim/vim, Subscribed

$HOME/.vim and $HOME/.vimrc are not legacy and shouldn't be treated that way. Having config files in $HOME is the de-facto standard on UNIX-like systems. If anything, I would prefer to see the files tried in the other direction:

De-facto standard first:

$HOME/.vimrc
$HOME/.vim/vimrc

XDG-compliant paths second, with XDG fallback:

$XDG_CONFIG_HOME/.vimrc
$HOME/.config/.vimrc
$XDG_CONFIG_HOME/.vim/vimrc
$HOME/.config/vim/vimrc

Bram Moolenaar

unread,
May 8, 2021, 3:31:43 PM5/8/21
to vim/vim, Subscribed


> So far this only handles the (.)vimrc file.
>
> It currently takes care of the fallbacks on Linux. I haven't
> modified the VMS part because I don't understand that yet. And I
> couldn't find a windows version of vimrc.

>
> Is this an okay change to start with? What recommendations do
> y'all have?

>
> This will eventually fix #2034

Checking for $XDG_CONFIG_HOME/vim/vimrc looks OK to me. It's just a
different place for the user to put his .vimrc.

I'm not so sure about the use of $XDG_CONFIG_DIRS. I haven't
specifically set it, but the value is:

/etc/xdg/xdg-gnome-flashback-metacity:/etc/xdg

And the first directory doesn't actually exist. I guess this is meant
for system wide configuration. In that case, it's probably better to
use it before the personal vimrc, so that the user can override
system-wide preferences.

--
Emacs is a nice OS - but it lacks a good text editor.
That's why I am using Vim. --Anonymous

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Romain Lafourcade

unread,
May 8, 2021, 6:49:56 PM5/8/21
to vim/vim, Subscribed

Allow me to remind everyone that the content of $HOME/.vim/ (and various other files outside of it) is not 100% "config".

Snippets, dictionaries, spell files are not "config": they are data, which, according to the specification, should be stored under $XDG_DATA_HOME/vim/.

.netrwhist, .viminfo, views, swap files, history, etc. are "state", as defined by the spec, and as such should be stored under $XDG_STATE_HOME/vim/:

  • actions history (logs, history, recently used files, …)
  • current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

Cache files generated by plugins (CtrlP comes to mind, maybe there are others) fall under "cache" and should be stored under $XDG_CACHE_HOME/vim/.

In my opinion…

  • Shoving everything into $XDG_CONFIG_HOME/vim/ is a bad interpretation/understanding of the spec that betrays both its spirit and its letter.
  • Splitting the runtime into 4 directories sounds a lot like trouble.

txtsd

unread,
May 8, 2021, 9:52:57 PM5/8/21
to vim/vim, Subscribed

Thank you for your inputs! The plan is not to shove everything into $XDG_CONFIG_HOME. This is just the first step toward adhering to the freedesktop spec.
Keep in mind, this is my first time writing C code. I come from a Python background.

@chrisbra I'd like feedback from you too!

バクダンくん

unread,
May 16, 2021, 5:49:38 AM5/16/21
to vim/vim, Subscribed

I think it's not good to make hidden files under .config directory, which is already hidden. As Bram says, just adding $XDG_CONFIG_HOME/vim (and its default value) to the candidates for the personal initialization directories should be enough.

For Windows, I think $APPDATA instead of $XDG_CONFIG_HOME is appropriate. It is typically C:\Users\USERNAME\AppData\Roaming.
$LOCALAPPDATA can be used for unportable files like viminfo. It is typically C:\Users\USERNAME\AppData\Local.

cf. KNOWNFOLDERID, CSIDL

Christian Brabandt

unread,
May 17, 2021, 3:38:59 AM5/17/21
to vim/vim, Subscribed

You shouldn't use Bool. We use int in the Vim code base for that and the values TRUE and FALSE. For the printing status messages, you can use smsg(). it supports printf() % tokens.

Perhaps, write some documentation first, before going to write the patch. So we can all agree on the default or fallback-values and you do not have to change the implementation again and again.

I am not sure about windows, I generally tend to find C:\Users\USERNAME\AppData mysterious, but as a fallback after $HOME/_vimfiles I suppose this should be okay.

For Unix, I think the most important things have already been mentioned. In my opinion, having different directories for different purposes ($XDG_CACHE_HOME, $XDG_CONFIG_HOME, $XDG_STATE_HOME/vim), is asking for trouble and will make the configuration for users more complex (and harder to debug), but that is just my opinion.

One thing to keep in mind, undo files and swap files may become very long (since the path name can be encoded in the name), using something like /home/user/config/vim/undo may cause the complete path name to become too long (I think this has happened before for Neovim with encrypted user-homes (encfs, ecryptfs) where generally only a path limit of 200 characters (or even less, see e.g. https://unix.stackexchange.com/a/32834/303213) is possible. You don't have to solve this now, just something to be aware of (or to mention the limitation in the documentation).

txtsd

unread,
May 22, 2021, 10:57:51 AM5/22/21
to vim/vim, Subscribed

Thanks for your inputs!
I'll work on pseudocode first.

txtsd

unread,
Oct 24, 2022, 6:59:55 AM10/24/22
to vim/vim, Subscribed

Closing because my C skills aren't as good as I'd like them to be, and I've already moved on to neovim.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8188/c1288860057@github.com>

txtsd

unread,
Oct 24, 2022, 7:00:00 AM10/24/22
to vim/vim, Subscribed

Closed #8188.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/8188/issue_event/7652873218@github.com>

Reply all
Reply to author
Forward
0 new messages