From 5444b76f9d182bba4a22903367579515db412375 Mon Sep 17 00:00:00 2001 From: Martin Hans Date: Mon, 13 May 2024 11:15:53 +0200 Subject: [PATCH] Add sourcing from my_configs/ To enable structurizing of own stuff or using *dotfile* managers, this PR add the sourcing of `*.vim` files from the `my_config/` directory. If the `glob("~/.vim_runtime/my_configs/*.vim",1,1)` list is empty, the `~/.vim_runtime/my_configs.vim` is sourced as previously. --- .gitignore | 1 + README.md | 6 +++++- install_awesome_parameterized.sh | 19 +++++++++++++++---- install_awesome_vimrc.sh | 22 +++++++++++++++++----- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 55273366..144e07de 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ sources_forked/yankring/doc/tags sources_non_forked/tlib/doc/tags sources_non_forked/ctrlp.vim/doc/tags* my_plugins/ +my_configs/ my_configs.vim tags .DS_Store diff --git a/README.md b/README.md index 6477280b..718cbabd 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,10 @@ For instance, my `my_configs.vim` looks like this: ~/.vim_runtime > cat my_configs.vim map ct :cd ~/Desktop/Todoist/todoist - map cw :cd ~/Desktop/Wedoist/wedoist + map cw :cd ~/Desktop/Wedoist/wedoist + +To further structurize your own stuff or to enable integration in *dotfile* managers like [chezmoi](https://chezmoi.io) +place `.vim` files with `vimrc` matching syntax in the `~/.vim_runtime/my_configs/` directory. You can also install your plugins, for instance, via pathogen you can install [vim-rails](https://github.com/tpope/vim-rails): @@ -201,6 +204,7 @@ map bd :Bclose " Close all buffers map ba :1,1000 bd! ``` + Useful mappings for managing tabs: ```vim map tn :tabnew diff --git a/install_awesome_parameterized.sh b/install_awesome_parameterized.sh index 1ca2ba5f..d811d7cb 100755 --- a/install_awesome_parameterized.sh +++ b/install_awesome_parameterized.sh @@ -6,6 +6,7 @@ cd $1 VIMRC="\" DO NOT EDIT THIS FILE \" Add your own customizations in $1/my_configs.vim +\" See ~/.vim_runtime/README.md \"How to include your own stuff\" for further options. set runtimepath+=$1 @@ -14,10 +15,20 @@ source $1/vimrcs/filetypes.vim source $1/vimrcs/plugins_config.vim source $1/vimrcs/extended.vim -try - source $1/my_configs.vim -catch -endtry" +let files = glob(\"$1/my_configs/*.vim\", 1, 1) +if empty(files) + try + source $1/my_configs.vim + catch + endtry +else + for file in files + try + execute 'source' fnameescape(file) + catch + endtry + endfor +endif" if [ "$2" = "--all" ]; then USERS=$(ls -l /home | awk '{if(NR>1)print $9}') diff --git a/install_awesome_vimrc.sh b/install_awesome_vimrc.sh index 29466977..59b028fd 100755 --- a/install_awesome_vimrc.sh +++ b/install_awesome_vimrc.sh @@ -4,7 +4,8 @@ set -e cd ~/.vim_runtime echo '" DO NOT EDIT THIS FILE -" Add your own customizations in ~/.vim_runtime/my_configs.vim +" Add your own customizations in $1/my_configs.vim +" See ~/.vim_runtime/README.md "How to include your own stuff" for further options. set runtimepath+=~/.vim_runtime @@ -12,9 +13,20 @@ source ~/.vim_runtime/vimrcs/basic.vim source ~/.vim_runtime/vimrcs/filetypes.vim source ~/.vim_runtime/vimrcs/plugins_config.vim source ~/.vim_runtime/vimrcs/extended.vim -try - source ~/.vim_runtime/my_configs.vim -catch -endtry' > ~/.vimrc + +let files=glob("~/.vim_runtime/my_configs/*.vim", 1, 1) +if empty(files) + try + source ~/.vim_runtime/my_configs.vim + catch + endtry +else + for file in files + try + execute 'source' fnameescape(file) + catch + endtry + endfor +endif' > ~/.vimrc echo "Installed the Ultimate Vim configuration successfully! Enjoy :-)"