-
-
Notifications
You must be signed in to change notification settings - Fork 6k
defaults.vim: add XDG support #19421
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
Changes from all commits
074c009
9dee4da
d713dac
647f9aa
fbeb76c
c2b966f
b0157e2
9d3f9a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| " XDG Base Directory support | ||
|
|
||
| if empty($XDG_CONFIG_HOME) | let $XDG_CONFIG_HOME = $HOME."/.config" | endif | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for just chiming in, but I don't think Vim should define these variables as environment variables, as they bleed into processes Vim spawns. Other programs Vim might spawn are expected handle the absence of these environment variables themselves and set their configuration accordingly.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I also noticed this. That's one of the reasons I completely re-wrote the script.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defining these standard So defining them here also gives additional convenience for any other vim scripts that goes after.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @janvhs 's point is that some programs behave differently if the environment variables are set at all (for example, a program that supports XDG but has it's own defaults that are not XDG might honor the environment but otherwise default to |
||
| if empty($XDG_DATA_HOME) | let $XDG_DATA_HOME = $HOME."/.local/share" | endif | ||
| if empty($XDG_STATE_HOME) | let $XDG_STATE_HOME = $HOME."/.local/state" | endif | ||
|
|
||
| set packpath^=$XDG_DATA_HOME/vim | ||
| set packpath+=$XDG_DATA_HOME/vim/after | ||
|
|
||
| if isdirectory(expand($XDG_CONFIG_HOME."/vim")) | ||
| set viminfofile=$XDG_STATE_HOME/vim/viminfo | call mkdir($XDG_STATE_HOME."/vim", 'p', 0700) | ||
|
|
||
| " These options are not essential for XDG, but you might want to set them: | ||
| " set backupdir=$XDG_STATE_HOME/vim/backup// | call mkdir(&backupdir, 'p', 0700) | ||
| " set directory=$XDG_STATE_HOME/vim/swap | call mkdir(&directory, 'p', 0700) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could someone outline format of the swap file? Does it always contain a full copy of the original? |
||
| " set viewdir=$XDG_STATE_HOME/vim/view | call mkdir(&viewdir, 'p', 0700) | ||
| " set undodir=$XDG_STATE_HOME/vim/undo | call mkdir(&undodir, 'p', 0700) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. viewdir and undo files I would also consider DATA files
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So among all of these write-sensitive options, only |
||
|
|
||
| " let g:netrw_home = $XDG_DATA_HOME."/vim" | ||
| " call mkdir($XDG_DATA_HOME."/vim/spell", 'p', 0700) | ||
| endif | ||
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.
This can simply be
:ru xdg.vim, but I don't want this to be part of defaults.vimThere 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.
$VIMRUNTIME is more precise, as we know where the file is.