From 8497d7595a49db830e6f78c55b114c846246643a Mon Sep 17 00:00:00 2001 From: gryf Date: Sat, 13 Jul 2024 16:43:59 +0200 Subject: [PATCH] Adapt repo to support XDG configuration placemet --- README.rst | 16 +++++++++++++++- vimrc | 28 +++++++++++++++++----------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 1587345..b55743b 100644 --- a/README.rst +++ b/README.rst @@ -7,9 +7,23 @@ of it. It uses `vim-plug`_ plugin manager, so after cloning, just open vim, and it will automatically install all the plugins. +It should be cloned as is into `$HOME`` directory, i.e: + +.. code:: console + + cd $HOME + git clone https://github.com/gryf/.vim + +or in ``$XDG_COFIG_HOME`` directory, which usually is set to ``$HOME/.config``: + +.. code:: console + + git clone https://github.com/gryf/.vim ~/.config/vim + Other than that, there are two additional config files which can be added to the configuration as a local configuration files just to not mess up with main -config file. Both of them should be placed under ``$HOME/.vim`` directory. +config file. Both of them should be placed under ``$HOME/.vim`` or +``$XDG_COFIG_HOME/vim`` depending on your installation. First one is ``vimrc.local``, which might contain additional/override options for specific machine. diff --git a/vimrc b/vimrc index c390f6f..49b70e8 100644 --- a/vimrc +++ b/vimrc @@ -1,15 +1,25 @@ "Basic setup for all files {{{ set nocompatible "VIM over VI -" vimplug conf {{{ +" Get the config dir, as config can be either on ~/.vim or ~/.config/vim +let s:_confdir = fnamemodify($MYVIMRC, ':h') -if empty(glob('~/.vim/autoload/plug.vim')) - silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +" Set colorscheme depending on the environment vim is running +if $TERM == 'linux' && !has('gui_running') + " fallback to basic 8-color colorscheme + let s:_colorscheme = 'pablo' +else + let s:_colorscheme = 'wombat256grf' +endif + +" vimplug conf {{{ +if ! filereadable(s:_confdir . '/autoload/plug.vim') + silent exec "!curl -fLo " . s:_confdir . "/autoload/plug.vim --create-dirs" + \ "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif -call plug#begin('~/.vim/bundle') +call plug#begin(s:_confdir . '/bundle') Plug 'Valloric/MatchTagAlways', { 'for': ['html', 'xml'] } Plug 'ayuanx/vim-mark-standalone' @@ -122,7 +132,7 @@ set softtabstop=4 "spell options set spelllang=pl,en -let &spellfile=expand('~/.vim/spell/pl.utf-8.add') +let &spellfile=expand(s:_confdir . '/spell/pl.utf-8.add') set splitbelow "Create new window below current one set swapfile "Use swap file @@ -767,12 +777,8 @@ if has('gui_running') au GUIEnter * set vb t_vb= endif -silent! colorscheme wombat256grf +silent! exec 'colorscheme ' . s:_colorscheme -if $TERM == 'linux' && !has('gui_running') - " fallback to basic 8-color colorscheme - colorscheme pablo -endif "}}} " Custom: custom config per machine {{{ if filereadable($MYVIMRC . '.local')