[vim/vim] Add XDG_CONFIG_HOME/vim/vimrc support (PR #14182)

150 views
Skip to first unread message

Luca Saccarola

unread,
Mar 11, 2024, 5:27:38 PM3/11/24
to vim/vim, Subscribed

continues: #14167
fixes: #2034

I've added the check for $XDG_CONFIG_HOME.


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

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

Commit Summary

  • 1b69a9a Add XDG_CONFIG_HOME/vim/vimrc support

File Changes

(3 files)

Patch Links:


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/14182@github.com>

Christian Brabandt

unread,
Mar 11, 2024, 5:33:55 PM3/11/24
to vim/vim, Subscribed

Thanks. I think we should add something to the documentation, about what $XDG_CONFIG_HOME is and where to find it.

Then we should probably add something to :version, mentioning $XDG_CONFIG_HOME as fourth vimrc File.

And finally, I suppose this does not make $XDG_CONFIG_HOME/vim part of the default runtime directory? That leaves the question, where do I put my other runtime files?


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/14182/c1989483928@github.com>

Luca Saccarola

unread,
Mar 12, 2024, 1:49:55 AM3/12/24
to vim/vim, Subscribed

I was thinking to introduce full XDG_BASE_DIR in another PR but make sense to do it all here

I think we should add something to the documentation, about what $XDG_CONFIG_HOME is and where to find it.

Yes it is probably a good a idea. Where exacly do you think we should put it this explenation (I'm not super versed on where is the appropriate spot for this information).

And finally, I suppose this does not make $XDG_CONFIG_HOME/vim part of the default runtime directory? That leaves the question, where do I put my other runtime files?

We could make a file to put under $VIMRUNTIME/xdg.vim that uses the appropriate XDG_BASE_DIR, that will be sourced when we detect that the user is using $XDG_CONFIG_HOME/vim/vimrc. This can also be beneficial for the users that wants to use XDG_BASE_DIR but still wants their vimrc in the home directory because they would just need to source $VIMRUNTIME/xdg.vim in their vimrc.


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/14182/c1990661008@github.com>

Maxim Kim

unread,
Mar 12, 2024, 2:15:15 AM3/12/24
to vim/vim, Subscribed

This can also be beneficial for the users that wants to use XDG_BASE_DIR but still wants their vimrc in the home directory because they would just need to source $VIMRUNTIME/xdg.vim in their vimrc.

Let's not introduce yet another defaults.vim.

Can we add $XDG_CONFIG_HOME/vim/{plugin,after,ftplugin,...etc} to runtime path if $XDG_CONFIG_HOME/vim/vimrc was used?

PS, do we target Windows ~/AppData/vim/ here?


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/14182/c1990779590@github.com>

Luca Saccarola

unread,
Mar 12, 2024, 3:51:50 AM3/12/24
to vim/vim, Subscribed

PS, do we target Windows ~/AppData/vim/ here?

Ideally yes, but probably is better to address it in another PR since I don't really know the windows convention.

Let's not introduce yet another defaults.vim.

Why not exactly? What is the disadvantage of doing this in your opinion?

Can we add $XDG_CONFIG_HOME/vim/{plugin,after,ftplugin,...etc} to runtime path if $XDG_CONFIG_HOME/vim/vimrc was used?

I'm not against this just wanna know why the $VIMRUNTIME/xdg.vim is a bad idea.


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/14182/c1990973034@github.com>

Maxim Kim

unread,
Mar 12, 2024, 4:24:01 AM3/12/24
to vim/vim, Subscribed

Let's not introduce yet another defaults.vim.

Why not exactly? What is the disadvantage of doing this in your opinion?

There might be vim without eval. Or distro maintainer that will not package this .vim file for good(or whatever) reason.

defaults.vim caused probably the most user questions in freenode and then libera #vim channel, so whatever new default with regards to runtimepath to be introduced, it is better be in vim source code.


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/14182/c1991019490@github.com>

Maxim Kim

unread,
Mar 12, 2024, 4:25:41 AM3/12/24
to vim/vim, Subscribed

I take it, eval shouldn't matter as then your configuration doesn't make sense anywhere in filesystem.


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/14182/c1991022004@github.com>

Luca Saccarola

unread,
Mar 12, 2024, 4:29:04 AM3/12/24
to vim/vim, Subscribed

And finally, I suppose this does not make $XDG_CONFIG_HOME/vim part of the default runtime directory? That leaves the question, where do I put my other runtime files?

I want to layout what I was thinking for the runtime files layout.

First I give a brief explenation of the XDG varibles with their realative fallbacks:

  • XDG_CONFIG_HOME or $HOME/.config: user configuration
  • XDG_DATA_HOME or $HOME/.local/share: persistent user data
  • XDG_CACHE_HOME or $HOME/.cache: ephemiral user data

Having that in mind I was thinking the following layout:

XDG_CONFIG_HOME
| after/
| autoload/
| ...
| vimrc
XDG_DATA_HOME
| netrwhist
| viminfo
| ...
XDG_CACHE_HOME
| undo/
| backup/

For something like the pack dir, I don't really know where would be the appropriate spot. Someone could argue it belongs in XDG_CONFIG_HOME since some people like to have plugin as submodules, neovim user XDG_DATA_HOME.


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/14182/c1991027688@github.com>

Luca Saccarola

unread,
Mar 12, 2024, 4:31:26 AM3/12/24
to vim/vim, Subscribed

[...] add $XDG_CONFIG_HOME/vim/{plugin,after,ftplugin,...etc} to runtime path if $XDG_CONFIG_HOME/vim/vimrc was used [...]

@habamax makes sense. It make sense to do it this way.


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/14182/c1991031599@github.com>

Maxim Kim

unread,
Mar 12, 2024, 4:36:27 AM3/12/24
to vim/vim, Subscribed

For something like the pack dir, I don't really know where would be the appropriate spot. Someone could argue it belongs in XDG_CONFIG_HOME since some people like to have plugin as submodules, neovim user XDG_DATA_HOME.

I consider them the same as vim/ directory -- config, and put there my own configuration (filetypes, colorschemes, syntax files) I do for myself and would like them to be separate from ~/.vim/{ftplugin, plugin, colors, syntax, indent} to avoid clutter.


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/14182/c1991040052@github.com>

Christian Brabandt

unread,
Mar 12, 2024, 5:00:34 PM3/12/24
to vim/vim, Subscribed

Puh, I am not sure I like this. First of all:

XDG_CONFIG_HOME
| after/
| autoload/
| ...
| vimrc
XDG_DATA_HOME
| netrwhist
| viminfo
| ...
XDG_CACHE_HOME
| undo/
| backup/

Shouldn't there be a vim directory under which undo/backup/viminfo/netrwhist/autoload etc are stored? Else we will be cluttering various $XDG_ directories with Vim related files and it's hard to find out what belongs to Vim (which matters if you want to make a backup, or move it to a new pc, etc).

Second, personally, I hate ripping apart the existing .vim directory for a similar reason. Nowadays, I can simply go to ~/.vim and archive it and move it to a new host. In the future I have to remember where all potential data for Vim will be stored. That makes my life as a user harder.

In short, I am not yet convinced we should spread out the data among several directories, even if this is what the freedesktop specification is about.

Same for Windows, I wholeheartly hate that I have to find anything below AppData, because it has become like a trash bin and it's hard to find the correct place (do I need to go to Local or Roaming? But fine, if this is just an alternative directory and I can still use my precious vimfiles directory. Oh well...


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/14182/c1992575021@github.com>

Maxim Kim

unread,
Mar 12, 2024, 8:18:20 PM3/12/24
to vim/vim, Subscribed

Shouldn't there be a vim directory under which undo/backup/viminfo/netrwhist/autoload etc are stored? Else we will be cluttering various $XDG_ directories with Vim related files and it's hard to find out what belongs to Vim (which matters if you want to make a backup, or move it to a new pc, etc).

I think this is a typo and it should have been XDG_CONFIG_HOME/vim/, XDG_DATA_HOME/vim/, etc.

Second, personally, I hate ripping apart the existing .vim directory for a similar reason. Nowadays, I can simply go to ~/.vim and archive it and move it to a new host. In the future I have to remember where all potential data for Vim will be stored. That makes my life as a user harder.

Same, I would like to have a vim config directory that is easily manageable. Not sure about .viminfo -- it is by default saved as ~/.viminfo even if you have ~/.vim/ directory.


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/14182/c1992798571@github.com>

Luca Saccarola

unread,
Mar 13, 2024, 2:34:58 AM3/13/24
to vim/vim, Subscribed

Shouldn't there be a vim directory under which undo/backup/viminfo/netrwhist/autoload etc are stored? Else we will be cluttering various $XDG_ directories with Vim related files and it's hard to find out what belongs to Vim (which matters if you want to make a backup, or move it to a new pc, etc).

It is a typo everything is under a vim directory in the respective XDG folders.

Second, personally, I hate ripping apart the existing .vim directory for a similar reason. Nowadays, I can simply go to ~/.vim and archive it and move it to a new host. In the future I have to remember where all potential data for Vim will be stored. That makes my life as a user harder.

This comes down to personal preference of the user. This days a lot of people dislike having a lot of file in their home. Also this will be only an option if the user activly opt in. A lot of programs do it this way while preserving their home location by default (tmux, emacs, etc).I think we should have a least the option.

Also:

XDG_CONFIG_HOME
| after/
| autoload/
| ...
| vimrc
XDG_DATA_HOME
| netrwhist
| viminfo
| ...
XDG_CACHE_HOME
| undo/
| backup/

this was an idea, is up for debate an modification.


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/14182/c1993663717@github.com>

Diego Viola

unread,
Mar 13, 2024, 5:06:40 PM3/13/24
to vim/vim, Subscribed

@saccarosium Thanks for reviving #14167! Happy to see progress on this. Cheers.


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/14182/c1995813643@github.com>

Luca Saccarola

unread,
Mar 14, 2024, 7:08:54 PM3/14/24
to vim/vim, Subscribed

@chrisbra we could just use XDG_CONFIG_HOME/vim as we use $HOME/.vim only if we find a XDG_CONFIG_HOME/vim/vimrc. But I would also put the viminfo in XDG_CONFIG_HOME/vim since if the user is using XDG_DIRS they don't want clutter in their HOME.


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/14182/c1998623463@github.com>

Diego Viola

unread,
Mar 14, 2024, 9:25:36 PM3/14/24
to vim/vim, Subscribed

@saccarosium @chrisbra What about XDG_STATE_HOME for viminfo and other history related files?


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/14182/c1998733701@github.com>

Christian Brabandt

unread,
Mar 15, 2024, 3:12:18 AM3/15/24
to vim/vim, Subscribed

we could just use XDG_CONFIG_HOME/vim as we use $HOME/.vim only if we find a XDG_CONFIG_HOME/vim/vimrc. But I would also put the viminfo in XDG_CONFIG_HOME/vim since if the user is using XDG_DIRS they don't want clutter in their HOME.

That sounds fine.


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/14182/c1999062958@github.com>

Christian Brabandt

unread,
Mar 15, 2024, 3:12:46 AM3/15/24
to vim/vim, Subscribed

@saccarosium @chrisbra What about XDG_STATE_HOME for viminfo and other history related files?

As mentioned before, I don't like scattering around vim folder across various $XDG related folders.


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/14182/c1999063614@github.com>

Gary Johnson

unread,
Mar 15, 2024, 12:09:17 PM3/15/24
to reply+ACY5DGCKKC7TYA2PX2...@reply.github.com, vim...@googlegroups.com
On 2024-03-15, Christian Brabandt wrote:
> we could just use XDG_CONFIG_HOME/vim as we use $HOME/.vim only if we find
> a XDG_CONFIG_HOME/vim/vimrc. But I would also put the viminfo in
> XDG_CONFIG_HOME/vim since if the user is using XDG_DIRS they don't want
> clutter in their HOME.
>
> That sounds fine.

Except that the contents of ~/.vim is typically shareable among
different vim installations, e.g., on different machines, while
files such as ~/.viminfo are not.

I use Dropbox and unison to keep my configuration files synced
across several machines. I don't want register contents and command
histories shared among those machines.

If someone wants their viminfo file in some directory other than
$HOME, they can always rename it in 'viminfo'. Yes, I could do
that, too, but I really don't think the viminfo file belongs in the
vim directory.

Regards,
Gary

vim-dev ML

unread,
Mar 15, 2024, 12:09:46 PM3/15/24
to vim/vim, vim-dev ML, Your activity


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/14182/c1999986791@github.com>

Christian Brabandt

unread,
Mar 15, 2024, 1:52:58 PM3/15/24
to vim/vim, vim-dev ML, Comment

Well true, except when you want your register-contents or search-/ex- history shared accross several systems 🤷 .

So let's leave the viminfo alone for now. People can already set :set viminfofile= to point it some other location.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2000160730@github.com>

Luca Saccarola

unread,
Mar 18, 2024, 5:28:09 PM3/18/24
to vim/vim, vim-dev ML, Push

@saccarosium pushed 1 commit.

  • 5d8548f Add XDG_CONFIG_HOME runtimepath support


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14182/push/17599171059@github.com>

Gary Johnson

unread,
Mar 18, 2024, 8:40:53 PM3/18/24
to vim/vim, vim-dev ML, Comment

@ghgary commented on this pull request.


In src/os_unix.h:

> @@ -349,13 +355,19 @@ typedef struct dsc$descriptor   DESC;
 #  ifdef RUNTIME_GLOBAL
 #   ifdef RUNTIME_GLOBAL_AFTER
 #    define DFLT_RUNTIMEPATH	"~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER ",~/.vim/after"
+#    define XDG_RUNTIMEPATH	"$XDG_CONFIG_HOME/vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER "/after,$XDG_CONFIG_HOME/after"

Here, and at line 363, the last rtp element should be $XDG_CONFIG_HOME/vim/after, that is, it should include /vim before /after.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1944690554@github.com>

Luca Saccarola

unread,
Mar 19, 2024, 4:26:35 AM3/19/24
to vim/vim, vim-dev ML, Push

@saccarosium pushed 1 commit.

  • 54ed71e Add XDG_CONFIG_HOME runtimepath support


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14182/push/17605226512@github.com>

Luca Saccarola

unread,
Mar 19, 2024, 4:31:03 AM3/19/24
to vim/vim, vim-dev ML, Push

@saccarosium pushed 1 commit.

  • 37c2f0d Fix typo in XDG_RUNTIMEPATH


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14182/push/17605291637@github.com>

Luca Saccarola

unread,
Mar 19, 2024, 4:31:35 AM3/19/24
to vim/vim, vim-dev ML, Comment

@saccarosium commented on this pull request.


In src/os_unix.h:

> @@ -349,13 +355,19 @@ typedef struct dsc$descriptor   DESC;
 #  ifdef RUNTIME_GLOBAL
 #   ifdef RUNTIME_GLOBAL_AFTER
 #    define DFLT_RUNTIMEPATH	"~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER ",~/.vim/after"
+#    define XDG_RUNTIMEPATH	"$XDG_CONFIG_HOME/vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER "/after,$XDG_CONFIG_HOME/after"

Thank you was a typo.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1945503595@github.com>

Luca Saccarola

unread,
Mar 19, 2024, 4:36:27 AM3/19/24
to vim/vim, vim-dev ML, Comment

This is ready for review. The only thing is missing is some documentation on what is XDG_CONFIG_HOME or what is XDG.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2006309885@github.com>

Gary Johnson

unread,
Mar 19, 2024, 12:09:53 PM3/19/24
to vim/vim, vim-dev ML, Comment

@ghgary commented on this pull request.


In src/option.c:

> +    if ((opt_idx = findoption((char_u *)"runtimepath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_rtp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"packpath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_pp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"viminfo")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

I don't understand why 'viminfo' is being set to the runtime path.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1946734006@github.com>

Gary Johnson

unread,
Mar 19, 2024, 12:10:51 PM3/19/24
to vim/vim, vim-dev ML, Comment

":help 'runtimepath'" also needs to be updated.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2007592426@github.com>

Christian Brabandt

unread,
Mar 19, 2024, 1:26:36 PM3/19/24
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/option.c:

> +    if ((opt_idx = findoption((char_u *)"runtimepath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_rtp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"packpath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_pp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"viminfo")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

please leave out viminfo file


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1946923308@github.com>

Christian Brabandt

unread,
Mar 19, 2024, 1:28:58 PM3/19/24
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/os_unix.h:

> @@ -236,7 +236,7 @@ typedef struct dsc$descriptor   DESC;
 # ifdef VMS
 # define USR_VIMRC_FILE  "sys$login:.vimrc"
 # else
-#  define USR_VIMRC_FILE "$HOME/.vimrc"
+#  define USR_VIMRC_FILE "~/.vimrc"

why this change? That seems unrelated


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1946928942@github.com>

Christian Brabandt

unread,
Mar 19, 2024, 1:35:30 PM3/19/24
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In runtime/doc/starting.txt:

> @@ -809,7 +809,8 @@ accordingly.  Vim proceeds in this order:
 	name.  Also see |vimrc-intro|.
 
 	Places for your personal initializations:
-		Unix		$HOME/.vimrc or $HOME/.vim/vimrc
+		Unix		$HOME/.vimrc, $HOME/.vim/vimrc
+                                or $XDG_CONFIG_HOME/vim/vimrc

you are changing also changing 'runtimepath' and 'packpath'. That should also be documented.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1946945565@github.com>

Christian Brabandt

unread,
Mar 19, 2024, 1:38:45 PM3/19/24
to vim/vim, vim-dev ML, Comment

Can we please also have some tests? Have a look at github.com/vim/vim/blob/master/src/testdir/test_startup.vim


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2007773878@github.com>

Luca Saccarola

unread,
Mar 19, 2024, 1:41:12 PM3/19/24
to vim/vim, vim-dev ML, Comment

@saccarosium commented on this pull request.


In src/os_unix.h:

> @@ -236,7 +236,7 @@ typedef struct dsc$descriptor   DESC;
 # ifdef VMS
 # define USR_VIMRC_FILE  "sys$login:.vimrc"
 # else
-#  define USR_VIMRC_FILE "$HOME/.vimrc"
+#  define USR_VIMRC_FILE "~/.vimrc"

I got a strange bug where it did expanded correctly (I was probably doing something wrong). Also is more consistent between other prepocessor variables. I can adress it in another PR if you want to.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1946958025@github.com>

Luca Saccarola

unread,
Mar 19, 2024, 1:42:25 PM3/19/24
to vim/vim, vim-dev ML, Comment

@saccarosium commented on this pull request.


In src/option.c:

> +    if ((opt_idx = findoption((char_u *)"runtimepath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_rtp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"packpath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_pp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"viminfo")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

Sorry, I was experimenting with viminfo and I probably committed by accident.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1946960587@github.com>

Christian Brabandt

unread,
Mar 20, 2024, 4:24:30 PM3/20/24
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/option.c:

> +	    !file_is_readable(vimrc_xdg))
+	goto theend;
+
+    xdg_rtp = has_xdg_env ? (char_u *)XDG_RUNTIMEPATH 
+	: (char_u *)XDG_RUNTIMEPATH_FB;
+
+    if ((opt_idx = findoption((char_u *)"runtimepath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_rtp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"packpath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

This just overrides the default, right? I guess, this is not needed or is it?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1950072609@github.com>

Luca Saccarola

unread,
Mar 20, 2024, 4:52:46 PM3/20/24
to vim/vim, vim-dev ML, Comment

@saccarosium commented on this pull request.


In src/option.c:

> +	    !file_is_readable(vimrc_xdg))
+	goto theend;
+
+    xdg_rtp = has_xdg_env ? (char_u *)XDG_RUNTIMEPATH 
+	: (char_u *)XDG_RUNTIMEPATH_FB;
+
+    if ((opt_idx = findoption((char_u *)"runtimepath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_rtp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"packpath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

'packpath' defaults to DFLT_RUNTIMEPATH witch is:

# src/os_unix.h

#  ifdef RUNTIME_GLOBAL
#   ifdef RUNTIME_GLOBAL_AFTER
#    define DFLT_RUNTIMEPATH	"~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER ",~/.vim/after"
#    define XDG_RUNTIMEPATH	"$XDG_CONFIG_HOME/vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER "/after,$XDG_CONFIG_HOME/vim/after"
#    define XDG_RUNTIMEPATH_FB	"~/.config/vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER "/after,~/.config/vim/after"
#    define CLEAN_RUNTIMEPATH	RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER
#   else
#    define DFLT_RUNTIMEPATH	"~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after,~/.vim/after"
#    define XDG_RUNTIMEPATH	"$XDG_CONFIG_HOME/vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after,$XDG_CONFIG_HOME/vim/after"
#    define XDG_RUNTIMEPATH_FB	"~/.config/vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after,~/.config/vim/after"
#    define CLEAN_RUNTIMEPATH	RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after"
#   endif
#  else
#   define DFLT_RUNTIMEPATH	"~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
#   define XDG_RUNTIMEPATH	"$XDG_CONFIG_HOME/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$XDG_CONFIG_HOME/vim/after"
#   define XDG_RUNTIMEPATH_FB	"~/.config/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.config/vim/after"
#   define CLEAN_RUNTIMEPATH	"$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
#  endif
# src/optiondefs.h

    {"packpath",    "pp",   P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
								    |P_SECURE,
			    (char_u *)&p_pp, PV_NONE, NULL, NULL,
			    {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
			    SCTX_INIT},

It should be need it unless I do the checks when initializing the options. But I don't know if there is a benefit or not


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1950126236@github.com>

Christian Brabandt

unread,
Mar 21, 2024, 4:14:14 PM3/21/24
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/option.c:

> +	    !file_is_readable(vimrc_xdg))
+	goto theend;
+
+    xdg_rtp = has_xdg_env ? (char_u *)XDG_RUNTIMEPATH 
+	: (char_u *)XDG_RUNTIMEPATH_FB;
+
+    if ((opt_idx = findoption((char_u *)"runtimepath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_rtp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"packpath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

Yes I know. I was just wondering if we need to override the default or if simply setting the option pointer is enough.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1953321720@github.com>

Gary Johnson

unread,
Mar 21, 2024, 5:32:26 PM3/21/24
to vim/vim, vim-dev ML, Comment

@ghgary commented on this pull request.


In src/option.c:

> +	    !file_is_readable(vimrc_xdg))
+	goto theend;
+
+    xdg_rtp = has_xdg_env ? (char_u *)XDG_RUNTIMEPATH 
+	: (char_u *)XDG_RUNTIMEPATH_FB;
+
+    if ((opt_idx = findoption((char_u *)"runtimepath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_rtp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"packpath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

What do you want :set packpath& to do? Doesn't the default have to be overwritten with the XDG path for that command to restore the initial state?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1953469053@github.com>

Christian Brabandt

unread,
Mar 22, 2024, 2:54:27 AM3/22/24
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In src/option.c:

> +	    !file_is_readable(vimrc_xdg))
+	goto theend;
+
+    xdg_rtp = has_xdg_env ? (char_u *)XDG_RUNTIMEPATH 
+	: (char_u *)XDG_RUNTIMEPATH_FB;
+
+    if ((opt_idx = findoption((char_u *)"runtimepath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
+    p_rtp = xdg_rtp;
+
+    if ((opt_idx = findoption((char_u *)"packpath")) < 0)
+	goto theend;
+
+    options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;

ah, yes makes sense. Thanks


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/1954061335@github.com>

Luca Saccarola

unread,
Mar 22, 2024, 1:05:57 PM3/22/24
to vim/vim, vim-dev ML, Push

@saccarosium pushed 2 commits.

  • fc6605a Fix typo in XDG_RUNTIMEPATH
  • 48aeb77 Adding documentation on freedesktop and xdg


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14182/push/17665896141@github.com>

Luca Saccarola

unread,
Mar 22, 2024, 1:08:10 PM3/22/24
to vim/vim, vim-dev ML, Comment

I've added some documentation on freedesktop and xdg. But I don't know how to connect it to 'runtimepath'. I think I need an help on that front.

I'll work on the test.


Reply to this email directly, view it on GitHub.
You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2015532421@github.com>

Christian Brabandt

unread,
Mar 22, 2024, 3:02:06 PM3/22/24
to vim/vim, vim-dev ML, Comment

oh great thanks. There are a few typos in the document and we probably don't need it in a separate doc file, but I can fix this when merging. Just a note to myself :)


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2015731888@github.com>

Luca Saccarola

unread,
Mar 24, 2024, 1:40:34 PM3/24/24
to vim/vim, vim-dev ML, Push

@saccarosium pushed 1 commit.

  • 37ded4a Adding documentation on freedesktop and xdg


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14182/push/17682774542@github.com>

Luca Saccarola

unread,
Apr 11, 2024, 9:50:52 AM4/11/24
to vim/vim, vim-dev ML, Push

@saccarosium pushed 1 commit.

  • a2a413e Add tests for XDG_VIMRC detection


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14182/push/17954182458@github.com>

Luca Saccarola

unread,
Apr 11, 2024, 10:02:00 AM4/11/24
to vim/vim, vim-dev ML, Comment

Hi @chrisbra
I've made a very simple test case and corrected some typos in the documentation. I'm not super good yet at writing test so I think I can't add anything more useful.

I think this can be merged.

Also there are some other things we may need to consider:

  • A function that returns the current vim dir location (e.g. $XDG_CONFIG_HOME/vim if they are using the xdg_vimrc or ~/.vim if their using ~/.vimrc/~/.vim/vimrc).
  • A way in the C code to check what rc is been used.


Reply to this email directly, view it on GitHub.
You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2049764342@github.com>

Gary Johnson

unread,
Apr 11, 2024, 11:30:25 AM4/11/24
to vim/vim, vim-dev ML, Comment

Rather than a function, how about an environment variable? It's much easier to use an environment variable on the command line. $MYVIMRC is used now for the configuration file; you could use something like $MYVIM or $MYVIMDIR.
$MYVIMRC should already be visible in the C code.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2049967091@github.com>

Christian Brabandt

unread,
Apr 11, 2024, 11:58:00 AM4/11/24
to vim/vim, vim-dev ML, Comment

Is there a reason you cannot use echo fnamemodify(expand("$MYVIMRC"), ':p:h')?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2050022008@github.com>

Luca Saccarola

unread,
Apr 11, 2024, 12:01:53 PM4/11/24
to vim/vim, vim-dev ML, Comment

Is there a reason you cannot use echo fnamemodify(expand("$MYVIMRC"), ':p:h')?

Nope, I didn't know I could do that.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2050028900@github.com>

Gary Johnson

unread,
Apr 11, 2024, 12:17:31 PM4/11/24
to vim/vim, vim-dev ML, Comment

That won't work if $MYVIMRC is ~/.vimrc.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2050055462@github.com>

Christian Brabandt

unread,
Apr 14, 2024, 4:58:48 PM4/14/24
to vim/vim, vim-dev ML, Comment

Closed #14182 via c9df1fb.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/issue_event/12461284958@github.com>

Kreijstal

unread,
Apr 15, 2024, 2:51:40 AM4/15/24
to vim/vim, vim-dev ML, Comment

so this patch will live on?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2055674090@github.com>

Christian Brabandt

unread,
Apr 15, 2024, 3:12:24 AM4/15/24
to vim/vim, vim-dev ML, Comment

sorry, what is your question?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/c2055769632@github.com>

Jonathan Schleifer

unread,
Apr 15, 2024, 8:30:01 AM4/15/24
to vim/vim, vim-dev ML, Comment

@Midar commented on this pull request.


In runtime/doc/freedesktop.txt:

> +
+				      *freedesktop* *X-desktop-group* *xdg*
+This file contains some information on what it is freedesktop and the XDG
+families of specifications.
+
+Freedesktop is a project aiming to develop specifications to enable
+interoperability between Unix-like operating systems.
+
+Vim tries to conform, for some extent, to the specifications made by
+freedesktop (see |xdg-base-dir|).
+
+==============================================================================
+XDG Base Directory Specification	*xdg-base-dir* *$XDG_CONFIG_HOME*
+
+The XDG Base Directory Specification aim to define standard locations for the
+multilple data e configuration files used by applications. In order to divide

Typo


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/2000972552@github.com>

Christian Brabandt

unread,
Apr 15, 2024, 9:39:55 AM4/15/24
to vim/vim, vim-dev ML, Comment

@chrisbra commented on this pull request.


In runtime/doc/freedesktop.txt:

> +
+				      *freedesktop* *X-desktop-group* *xdg*
+This file contains some information on what it is freedesktop and the XDG
+families of specifications.
+
+Freedesktop is a project aiming to develop specifications to enable
+interoperability between Unix-like operating systems.
+
+Vim tries to conform, for some extent, to the specifications made by
+freedesktop (see |xdg-base-dir|).
+
+==============================================================================
+XDG Base Directory Specification	*xdg-base-dir* *$XDG_CONFIG_HOME*
+
+The XDG Base Directory Specification aim to define standard locations for the
+multilple data e configuration files used by applications. In order to divide

I fixed those when merging. You should probably compare against what was committed instead.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/2001147988@github.com>

Diego Viola

unread,
Apr 15, 2024, 10:04:56 AM4/15/24
to vim/vim, vim-dev ML, Comment

@diegoviola commented on this pull request.


In runtime/doc/freedesktop.txt:

> +
+				      *freedesktop* *X-desktop-group* *xdg*
+This file contains some information on what it is freedesktop and the XDG
+families of specifications.
+
+Freedesktop is a project aiming to develop specifications to enable
+interoperability between Unix-like operating systems.
+
+Vim tries to conform, for some extent, to the specifications made by
+freedesktop (see |xdg-base-dir|).
+
+==============================================================================
+XDG Base Directory Specification	*xdg-base-dir* *$XDG_CONFIG_HOME*
+
+The XDG Base Directory Specification aim to define standard locations for the
+multilple data e configuration files used by applications. In order to divide

@chrisbra #14559


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14182/review/2001215915@github.com>

Reply all
Reply to author
Forward
0 new messages