From b02c8b9391e2fbf71e39e174167e5537b7a43e1c Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Sun, 20 Dec 2020 14:01:32 -0800 Subject: [PATCH] Convert vim config to XDG standard https://blog.joren.ga/configuring/vim-xdg --- fzf/{.vim => .config/vim}/plug.d/fzf.vim | 0 go/{.vim => .config/vim}/ftplugin/go.vim | 0 .../vim/snips}/go.snippets | 0 vim/.config/profile/env.d/vim.env | 3 +++ vim/{.vim => .config/vim}/autoload/plug.vim | 0 vim/{.vim => .config/vim}/coc-settings.json | 0 vim/{.vim => .config/vim}/ftplugin/coffee.vim | 0 .../vim}/ftplugin/gitcommit.vim | 0 vim/{.vim => .config/vim}/ftplugin/haml.vim | 0 vim/{.vim => .config/vim}/ftplugin/html.vim | 0 .../vim}/ftplugin/javascript.vim | 0 .../vim}/ftplugin/mustache.vim | 0 vim/{.vim => .config/vim}/ftplugin/php.vim | 0 vim/{.vim => .config/vim}/ftplugin/python.vim | 0 vim/{.vim => .config/vim}/ftplugin/ruby.vim | 0 vim/{.vim => .config/vim}/ftplugin/rust.vim | 0 vim/{.vim => .config/vim}/ftplugin/yaml.vim | 0 vim/{.vim => .config/vim}/init.d/mappings.vim | 0 vim/.config/vim/init.d/xdg.vim | 21 +++++++++++++++++++ .../vim}/plug.d/autocomplete.vim | 0 vim/{.vim => .config/vim}/plug.d/core.vim | 0 vim/{.vim => .config/vim}/plug.d/lang.vim | 0 vim/{.vim => .config/vim}/plug.d/lint.vim | 0 vim/{.vim => .config/vim}/plug.d/nerdtree.vim | 0 vim/{.vim => .config/vim}/plug.d/pgsql.vim | 0 vim/{.vim => .config/vim}/plug.d/themes.vim | 0 .../vim}/plugin/autogroup.vim | 0 vim/{.vim => .config/vim}/plugin/commands.vim | 0 vim/{.vim => .config/vim}/plugin/settings.vim | 0 vim/{.vim => .config/vim}/snips/all.snippets | 0 .../vim}/snips/coffee.snippets | 0 vim/{.vim => .config/vim}/snips/html.snippets | 0 .../vim}/snips/javascript.snippets | 0 vim/{.vim => .config/vim}/snips/php.snippets | 0 .../vim}/snips/python.snippets | 0 vim/{.vim => .config/vim}/snips/scss.snippets | 0 vim/{.vim => .config/vim}/vimrc | 6 +++--- 37 files changed, 27 insertions(+), 3 deletions(-) rename fzf/{.vim => .config/vim}/plug.d/fzf.vim (100%) rename go/{.vim => .config/vim}/ftplugin/go.vim (100%) rename go/{.vim/UltiSnips => .config/vim/snips}/go.snippets (100%) create mode 100644 vim/.config/profile/env.d/vim.env rename vim/{.vim => .config/vim}/autoload/plug.vim (100%) rename vim/{.vim => .config/vim}/coc-settings.json (100%) rename vim/{.vim => .config/vim}/ftplugin/coffee.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/gitcommit.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/haml.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/html.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/javascript.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/mustache.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/php.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/python.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/ruby.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/rust.vim (100%) rename vim/{.vim => .config/vim}/ftplugin/yaml.vim (100%) rename vim/{.vim => .config/vim}/init.d/mappings.vim (100%) create mode 100644 vim/.config/vim/init.d/xdg.vim rename vim/{.vim => .config/vim}/plug.d/autocomplete.vim (100%) rename vim/{.vim => .config/vim}/plug.d/core.vim (100%) rename vim/{.vim => .config/vim}/plug.d/lang.vim (100%) rename vim/{.vim => .config/vim}/plug.d/lint.vim (100%) rename vim/{.vim => .config/vim}/plug.d/nerdtree.vim (100%) rename vim/{.vim => .config/vim}/plug.d/pgsql.vim (100%) rename vim/{.vim => .config/vim}/plug.d/themes.vim (100%) rename vim/{.vim => .config/vim}/plugin/autogroup.vim (100%) rename vim/{.vim => .config/vim}/plugin/commands.vim (100%) rename vim/{.vim => .config/vim}/plugin/settings.vim (100%) rename vim/{.vim => .config/vim}/snips/all.snippets (100%) rename vim/{.vim => .config/vim}/snips/coffee.snippets (100%) rename vim/{.vim => .config/vim}/snips/html.snippets (100%) rename vim/{.vim => .config/vim}/snips/javascript.snippets (100%) rename vim/{.vim => .config/vim}/snips/php.snippets (100%) rename vim/{.vim => .config/vim}/snips/python.snippets (100%) rename vim/{.vim => .config/vim}/snips/scss.snippets (100%) rename vim/{.vim => .config/vim}/vimrc (71%) diff --git a/fzf/.vim/plug.d/fzf.vim b/fzf/.config/vim/plug.d/fzf.vim similarity index 100% rename from fzf/.vim/plug.d/fzf.vim rename to fzf/.config/vim/plug.d/fzf.vim diff --git a/go/.vim/ftplugin/go.vim b/go/.config/vim/ftplugin/go.vim similarity index 100% rename from go/.vim/ftplugin/go.vim rename to go/.config/vim/ftplugin/go.vim diff --git a/go/.vim/UltiSnips/go.snippets b/go/.config/vim/snips/go.snippets similarity index 100% rename from go/.vim/UltiSnips/go.snippets rename to go/.config/vim/snips/go.snippets diff --git a/vim/.config/profile/env.d/vim.env b/vim/.config/profile/env.d/vim.env new file mode 100644 index 0000000..2b02fb7 --- /dev/null +++ b/vim/.config/profile/env.d/vim.env @@ -0,0 +1,3 @@ +# shellcheck disable=SC2016,SC2034 +VIMINIT='if !has("nvim") | source $XDG_CONFIG_HOME/vim/vimrc | endif' +MYVIMRC='$XDG_CONFIG_HOME/vim/vimrc' diff --git a/vim/.vim/autoload/plug.vim b/vim/.config/vim/autoload/plug.vim similarity index 100% rename from vim/.vim/autoload/plug.vim rename to vim/.config/vim/autoload/plug.vim diff --git a/vim/.vim/coc-settings.json b/vim/.config/vim/coc-settings.json similarity index 100% rename from vim/.vim/coc-settings.json rename to vim/.config/vim/coc-settings.json diff --git a/vim/.vim/ftplugin/coffee.vim b/vim/.config/vim/ftplugin/coffee.vim similarity index 100% rename from vim/.vim/ftplugin/coffee.vim rename to vim/.config/vim/ftplugin/coffee.vim diff --git a/vim/.vim/ftplugin/gitcommit.vim b/vim/.config/vim/ftplugin/gitcommit.vim similarity index 100% rename from vim/.vim/ftplugin/gitcommit.vim rename to vim/.config/vim/ftplugin/gitcommit.vim diff --git a/vim/.vim/ftplugin/haml.vim b/vim/.config/vim/ftplugin/haml.vim similarity index 100% rename from vim/.vim/ftplugin/haml.vim rename to vim/.config/vim/ftplugin/haml.vim diff --git a/vim/.vim/ftplugin/html.vim b/vim/.config/vim/ftplugin/html.vim similarity index 100% rename from vim/.vim/ftplugin/html.vim rename to vim/.config/vim/ftplugin/html.vim diff --git a/vim/.vim/ftplugin/javascript.vim b/vim/.config/vim/ftplugin/javascript.vim similarity index 100% rename from vim/.vim/ftplugin/javascript.vim rename to vim/.config/vim/ftplugin/javascript.vim diff --git a/vim/.vim/ftplugin/mustache.vim b/vim/.config/vim/ftplugin/mustache.vim similarity index 100% rename from vim/.vim/ftplugin/mustache.vim rename to vim/.config/vim/ftplugin/mustache.vim diff --git a/vim/.vim/ftplugin/php.vim b/vim/.config/vim/ftplugin/php.vim similarity index 100% rename from vim/.vim/ftplugin/php.vim rename to vim/.config/vim/ftplugin/php.vim diff --git a/vim/.vim/ftplugin/python.vim b/vim/.config/vim/ftplugin/python.vim similarity index 100% rename from vim/.vim/ftplugin/python.vim rename to vim/.config/vim/ftplugin/python.vim diff --git a/vim/.vim/ftplugin/ruby.vim b/vim/.config/vim/ftplugin/ruby.vim similarity index 100% rename from vim/.vim/ftplugin/ruby.vim rename to vim/.config/vim/ftplugin/ruby.vim diff --git a/vim/.vim/ftplugin/rust.vim b/vim/.config/vim/ftplugin/rust.vim similarity index 100% rename from vim/.vim/ftplugin/rust.vim rename to vim/.config/vim/ftplugin/rust.vim diff --git a/vim/.vim/ftplugin/yaml.vim b/vim/.config/vim/ftplugin/yaml.vim similarity index 100% rename from vim/.vim/ftplugin/yaml.vim rename to vim/.config/vim/ftplugin/yaml.vim diff --git a/vim/.vim/init.d/mappings.vim b/vim/.config/vim/init.d/mappings.vim similarity index 100% rename from vim/.vim/init.d/mappings.vim rename to vim/.config/vim/init.d/mappings.vim diff --git a/vim/.config/vim/init.d/xdg.vim b/vim/.config/vim/init.d/xdg.vim new file mode 100644 index 0000000..1d56667 --- /dev/null +++ b/vim/.config/vim/init.d/xdg.vim @@ -0,0 +1,21 @@ +if empty($MYVIMRC) | let $MYVIMRC = expand('%:p') | endif + +if empty($XDG_CACHE_HOME) | let $XDG_CACHE_HOME = $HOME.'/.cache' | endif +if empty($XDG_CONFIG_HOME) | let $XDG_CONFIG_HOME = $HOME.'/.config' | endif +if empty($XDG_DATA_HOME) | let $XDG_DATA_HOME = $HOME.'/.local/share' | endif + +set runtimepath^=$XDG_CONFIG_HOME/vim +set runtimepath+=$XDG_CONFIG_HOME/vim/after +set runtimepath+=$XDG_DATA_HOME/vim + +set packpath^=$XDG_DATA_HOME/vim +call mkdir($XDG_DATA_HOME.'/vim/spell', 'p', 0700) + +set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p', 0700) +set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p', 0700) +set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p', 0700) +set viewdir=$XDG_CACHE_HOME/vim/view | call mkdir(&viewdir, 'p', 0700) + +if !has('nvim') + set viminfofile=$XDG_CACHE_HOME/vim/viminfo +endif diff --git a/vim/.vim/plug.d/autocomplete.vim b/vim/.config/vim/plug.d/autocomplete.vim similarity index 100% rename from vim/.vim/plug.d/autocomplete.vim rename to vim/.config/vim/plug.d/autocomplete.vim diff --git a/vim/.vim/plug.d/core.vim b/vim/.config/vim/plug.d/core.vim similarity index 100% rename from vim/.vim/plug.d/core.vim rename to vim/.config/vim/plug.d/core.vim diff --git a/vim/.vim/plug.d/lang.vim b/vim/.config/vim/plug.d/lang.vim similarity index 100% rename from vim/.vim/plug.d/lang.vim rename to vim/.config/vim/plug.d/lang.vim diff --git a/vim/.vim/plug.d/lint.vim b/vim/.config/vim/plug.d/lint.vim similarity index 100% rename from vim/.vim/plug.d/lint.vim rename to vim/.config/vim/plug.d/lint.vim diff --git a/vim/.vim/plug.d/nerdtree.vim b/vim/.config/vim/plug.d/nerdtree.vim similarity index 100% rename from vim/.vim/plug.d/nerdtree.vim rename to vim/.config/vim/plug.d/nerdtree.vim diff --git a/vim/.vim/plug.d/pgsql.vim b/vim/.config/vim/plug.d/pgsql.vim similarity index 100% rename from vim/.vim/plug.d/pgsql.vim rename to vim/.config/vim/plug.d/pgsql.vim diff --git a/vim/.vim/plug.d/themes.vim b/vim/.config/vim/plug.d/themes.vim similarity index 100% rename from vim/.vim/plug.d/themes.vim rename to vim/.config/vim/plug.d/themes.vim diff --git a/vim/.vim/plugin/autogroup.vim b/vim/.config/vim/plugin/autogroup.vim similarity index 100% rename from vim/.vim/plugin/autogroup.vim rename to vim/.config/vim/plugin/autogroup.vim diff --git a/vim/.vim/plugin/commands.vim b/vim/.config/vim/plugin/commands.vim similarity index 100% rename from vim/.vim/plugin/commands.vim rename to vim/.config/vim/plugin/commands.vim diff --git a/vim/.vim/plugin/settings.vim b/vim/.config/vim/plugin/settings.vim similarity index 100% rename from vim/.vim/plugin/settings.vim rename to vim/.config/vim/plugin/settings.vim diff --git a/vim/.vim/snips/all.snippets b/vim/.config/vim/snips/all.snippets similarity index 100% rename from vim/.vim/snips/all.snippets rename to vim/.config/vim/snips/all.snippets diff --git a/vim/.vim/snips/coffee.snippets b/vim/.config/vim/snips/coffee.snippets similarity index 100% rename from vim/.vim/snips/coffee.snippets rename to vim/.config/vim/snips/coffee.snippets diff --git a/vim/.vim/snips/html.snippets b/vim/.config/vim/snips/html.snippets similarity index 100% rename from vim/.vim/snips/html.snippets rename to vim/.config/vim/snips/html.snippets diff --git a/vim/.vim/snips/javascript.snippets b/vim/.config/vim/snips/javascript.snippets similarity index 100% rename from vim/.vim/snips/javascript.snippets rename to vim/.config/vim/snips/javascript.snippets diff --git a/vim/.vim/snips/php.snippets b/vim/.config/vim/snips/php.snippets similarity index 100% rename from vim/.vim/snips/php.snippets rename to vim/.config/vim/snips/php.snippets diff --git a/vim/.vim/snips/python.snippets b/vim/.config/vim/snips/python.snippets similarity index 100% rename from vim/.vim/snips/python.snippets rename to vim/.config/vim/snips/python.snippets diff --git a/vim/.vim/snips/scss.snippets b/vim/.config/vim/snips/scss.snippets similarity index 100% rename from vim/.vim/snips/scss.snippets rename to vim/.config/vim/snips/scss.snippets diff --git a/vim/.vim/vimrc b/vim/.config/vim/vimrc similarity index 71% rename from vim/.vim/vimrc rename to vim/.config/vim/vimrc index c7ca572..8f30356 100644 --- a/vim/.vim/vimrc +++ b/vim/.config/vim/vimrc @@ -1,15 +1,15 @@ " Load from init.d instead of plugin directory. This is done so a leader key " can be set before loading plugin settings. This allows the plugin setting " files to set mappings with leader keys -for f in split(glob('~/.vim/init.d/*.vim'), '\n') +for f in split(glob($XDG_CONFIG_HOME.'/vim/init.d/*.vim'), '\n') exe 'source' f endfor " The plugged plugin manager function calls need to be called between the " plug#begin and plug#end. Because of that, using the normal plugin directory " loading won't work. -call plug#begin('~/.vim/plugged') -for f in split(glob('~/.vim/plug.d/*.vim'), '\n') +call plug#begin($XDG_DATA_HOME.'/vim/plugged') +for f in split(glob($XDG_CONFIG_HOME.'/vim/plug.d/*.vim'), '\n') exe 'source' f endfor call plug#end()