-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add XDG_BASE_DIR support #14182
Add XDG_BASE_DIR support #14182
Conversation
Thanks. I think we should add something to the documentation, about what Then we should probably add something to And finally, I suppose this does not make |
I was thinking to introduce full XDG_BASE_DIR in another PR but make sense to do it all here
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).
We could make a file to put under |
Let's not introduce yet another Can we add PS, do we target Windows |
Ideally yes, but probably is better to address it in another PR since I don't really know the windows convention.
Why not exactly? What is the disadvantage of doing this in your opinion?
I'm not against this just wanna know why the |
There might be vim without
|
I take it, |
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:
Having that in mind I was thinking the following layout:
For something like the |
@habamax makes sense. It make sense to do it this way. |
I consider them the same as |
Puh, I am not sure I like this. First of all:
Shouldn't there be a Second, personally, I hate ripping apart the existing 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 |
I think this is a typo and it should have been
Same, I would like to have a vim config directory that is easily manageable. Not sure about |
It is a typo everything is under a vim directory in the respective XDG folders.
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:
this was an idea, is up for debate an modification. |
@saccarosium Thanks for reviving #14167! Happy to see progress on this. Cheers. |
@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. |
@saccarosium @chrisbra What about XDG_STATE_HOME for viminfo and other history related files? |
That sounds fine. |
As mentioned before, I don't like scattering around vim folder across various |
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
|
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 |
This is ready for review. The only thing is missing is some documentation on what is XDG_CONFIG_HOME or what is XDG. |
":help 'runtimepath'" also needs to be updated. |
@@ -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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change? That seems unrelated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are changing also changing 'runtimepath' and 'packpath'. That should also be documented.
Can we please also have some tests? Have a look at github.com/vim/vim/blob/master/src/testdir/test_startup.vim |
if ((opt_idx = findoption((char_u *)"packpath")) < 0) | ||
goto theend; | ||
|
||
options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
This just overrides the default, right? I guess, this is not needed or is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I know. I was just wondering if we need to override the default or if simply setting the option pointer is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yes makes sense. Thanks
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. |
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 :) |
Hi @chrisbra I think this can be merged. Also there are some other things we may need to consider:
|
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. |
Is there a reason you cannot use |
Nope, I didn't know I could do that. |
That won't work if $MYVIMRC is ~/.vimrc. |
so this patch will live on? |
sorry, what is your question? |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed those when merging. You should probably compare against what was committed instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continues: #14167
fixes: #2034
I've added the check for
$XDG_CONFIG_HOME
.