From 00485841df4c828c0aff247593bf52fd168bc63d Mon Sep 17 00:00:00 2001 From: Pavel Lutskov Date: Sat, 2 Dec 2017 12:37:55 +0100 Subject: [PATCH] make this repo compatible with plugin managers --- .vimrc_template | 36 +++++++++++++++++++++++++++++++++++ README.md | 27 ++++++++++++++------------ local_template.vim | 1 - .vimrc => plugin/settings.vim | 13 ------------- plugin/statusline.vim | 20 +++++++++---------- plugin_template.vim | 31 ------------------------------ setup.sh | 35 +++++++++++++--------------------- 7 files changed, 74 insertions(+), 89 deletions(-) create mode 100644 .vimrc_template delete mode 100644 local_template.vim rename .vimrc => plugin/settings.vim (93%) delete mode 100644 plugin_template.vim diff --git a/.vimrc_template b/.vimrc_template new file mode 100644 index 0000000..2d47e2e --- /dev/null +++ b/.vimrc_template @@ -0,0 +1,36 @@ +set nocompatible + +"Vundle stuff +"{{{ +filetype off + +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() + +Plugin 'VundleVim/Vundle.vim' +Plugin 'tmhedberg/SimpylFold' +Plugin 'Valloric/YouCompleteMe' +Plugin 'scrooloose/syntastic' +Plugin 'vim-scripts/indentpython.vim' +"Plugin 'vim-airline/vim-airline' +Plugin 'scrooloose/nerdtree' +Plugin 'tpope/vim-fugitive' +Plugin 'majutsushi/tagbar' +"Plugin 'jmcantrell/vim-virtualenv' +Plugin 'petRUShka/vim-opencl' + +call vundle#end() +"}}} + +"Path variables for Plugins +"{{{ +let g:tagbar_ctags_bin = '/usr/local/bin/ctags' +let g:ycm_global_ycm_extra_conf = '~/.ycm_global_extra_config.py' +let g:ycm_python_binary_path = '/usr/local/bin/python' +let g:syntastic_python_python_exec = '/usr/local/bin/python' +"}}} + +"Local settings +"{{{ +set guifont=Consolas:h12 +"}}} diff --git a/README.md b/README.md index 917cfc6..894f0b0 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,22 @@ ## Usage -If you find yourself wanting to use these settings, do the following: +If you find yourself wanting to use these settings, `git clone` this repository, +and copy or link the following directories: ``` -./colors -> ~/.vim/colors -./ftplugin -> ~/.vim/ftplugin -./.vimrc -> ~/.vimrc +colors -> ~/.vim/colors +ftplugin -> ~/.vim/ftplugin +plugin -> ~/.vim/plugin ``` -Also create two files `~/.vimplugin` and `~/.vimlocal`. The first one contains -commands for your plugin manager. The idea is that you might need a different -set of plugins on different machines. Some plugins require paths to programs, -which can differ from machine to machine too. -In `.vimlocal` you should should put settings that are local to the machine. -You might use `plugin_template.vim` and `locals_template.vim` for reference. -Alternatively, if you are on UNIX and haven't configured VIM yet, you could just -run `setup.sh`, which will do everything for you. +In `plugin/settings.vim` are settings that you can use on every workstation. +You can put into `~/.vimrc` settings that are local to the machine (such as +plugins, settings for plugins, font settings, etc.). Some reasonable default +local settings can be found in `.vimrc_template`. + +If you are on UNIX and haven't configured VIM yet, you could just +run `setup.sh`, which will create links from the repository to the `~/.vim` +folder and install plugin manager Vundle. Because of links, you shouldn't move +or remove the directory in which you cloned this repo. The benefit is that you +can get updates to the settings with just `git pull`. diff --git a/local_template.vim b/local_template.vim deleted file mode 100644 index 2a85f8d..0000000 --- a/local_template.vim +++ /dev/null @@ -1 +0,0 @@ -set guifont=Consolas:h12 diff --git a/.vimrc b/plugin/settings.vim similarity index 93% rename from .vimrc rename to plugin/settings.vim index 9132085..f5aaa46 100644 --- a/.vimrc +++ b/plugin/settings.vim @@ -1,16 +1,3 @@ -set nocompatible - -"Plugin stuff -"{{{ -if has("win32") - source $HOME/_vimplugin - source $HOME/_vimlocal -else - source $HOME/.vimplugin - source $HOME/.vimlocal -endif -"}}} - "Syntax "{{{ filetype plugin indent on diff --git a/plugin/statusline.vim b/plugin/statusline.vim index 7b0e5c5..04c71fa 100644 --- a/plugin/statusline.vim +++ b/plugin/statusline.vim @@ -11,20 +11,20 @@ function! GetGitStatus() endfunction set statusline= -set statusline+=%w%q%h -set statusline+=%{GetGitStatus()} +set statusline+=%w%q%h "Is it help/preview/loclist? +set statusline+=%{GetGitStatus()} "Is it git? set statusline+=\ -set statusline+=%f -set statusline+=%m%r -set statusline+=%= +set statusline+=%f "What's the filename? +set statusline+=%m%r "Is it modifiable/readonly? +set statusline+=%= "Go to the right ----> set statusline+=\ -set statusline+=%< +set statusline+=%< "Trim here set statusline+=%{&fileencoding?&fileencoding:&encoding} -set statusline+=\|%{&fileformat} +set statusline+=\|%{&fileformat} "Unix/Win? set statusline+=\ -set statusline+=%y +set statusline+=%y "What's the type of the file? set statusline+=\ -set statusline+= +set statusline+= "Character under cursor set statusline+=\ -set statusline+=(%2c:%l)/%L +set statusline+=(%2c:%l)/%L "(col:line)/total lines set statusline+=\ diff --git a/plugin_template.vim b/plugin_template.vim deleted file mode 100644 index d9a9661..0000000 --- a/plugin_template.vim +++ /dev/null @@ -1,31 +0,0 @@ -"Vundle stuff -"{{{ -filetype off - -"Unix -set rtp+=$HOME/.vim/bundle/Vundle.vim -call vundle#begin() - -"Win -"set rtp+=$HOME/vimfiles/bundle/Vundle.vim -"call vundle#begin('$HOME/vimfiles/bundle/') - -Plugin 'VundleVim/Vundle.vim' -Plugin 'tmhedberg/SimpylFold' -Plugin 'Valloric/YouCompleteMe' -Plugin 'scrooloose/syntastic' -Plugin 'vim-scripts/indentpython.vim' -"Plugin 'vim-airline/vim-airline' -Plugin 'scrooloose/nerdtree' -Plugin 'tpope/vim-fugitive' -Plugin 'majutsushi/tagbar' -"Plugin 'jmcantrell/vim-virtualenv' -"Plugin 'petRUShka/vim-opencl' - -call vundle#end() -"}}} - -"let g:tagbar_ctags_bin = '' -"let g:ycm_global_ycm_extra_conf = '' -"let g:ycm_python_binary_path = '' -"let g:syntastic_python_python_exec = '' diff --git a/setup.sh b/setup.sh index ecb4eb0..913ae86 100755 --- a/setup.sh +++ b/setup.sh @@ -1,41 +1,32 @@ #!/usr/bin/env bash -read -p "---WARNING--- -This script will brutally delete your .vimrc file, -if such exists in your home directory. -Are you sure you want to proceed? [y/n]: " responce - -[[ "$responce" = "y" ]] || { echo "Abort!" >&2; exit 1; } -echo "Proceeding..." repo="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -f "$HOME/.vimrc" ] && rm "$HOME/.vimrc" -ln -s "$repo/.vimrc" "$HOME/.vimrc" -echo "Created link to .vimrc" +read -p "Would you like to use template from this repository +as your .vimrc? WARNING: if you do, the existing ~/.vimrc +will be deleted! [y/n]: " responce + +[[ "$responce" = "y" ]] \ + && { [ -f "$HOME/.vimrc" ] && rm "$HOME/.vimrc"; \ + cp "$repo/.vimrc_template" "$HOME/.vimrc"; \ + echo "Created ~/.vimrc from template"; } \ + || echo "Not creating ~/.vimrc from template" [ -d "$HOME/.vim" ] || { mkdir "$HOME/.vim"; \ echo "Created .vim directory in your HOME"; } [ -d "$HOME/.vim/colors" ] \ - && echo "colors dir already exists, deal with it manually" \ + && echo "~/.vim/colors already exists, deal with it manually" \ || ln -s "$repo/colors" "$HOME/.vim/colors" [ -d "$HOME/.vim/plugin" ] \ - && echo "plugin dir already exists, deal with it manually" \ + && echo "~/.vim/plugin already exists, deal with it manually" \ || ln -s "$repo/plugin" "$HOME/.vim/plugin" [ -d "$HOME/.vim/ftplugin" ] \ - && echo "ftplugin already exists, deal with it manually" \ + && echo "~/.vim/ftplugin already exists, deal with it manually" \ || ln -s "$repo/ftplugin" "$HOME/.vim/ftplugin" -[ -f "$HOME/.vimplugin" ] \ - && echo "not creating ~/.vimplugin, it exists already" \ - || cp "$repo/plugin_template.vim" "$HOME/.vimplugin" - -[ -f "$HOME/.vimlocal" ] \ - && echo "not creating ~/.vimlocal, it exists already" \ - || cp "$repo/local_template.vim" "$HOME/.vimlocal" - -[ -d "$HOME/.vim/bundle" ]\ +[ -d "$HOME/.vim/bundle" ] \ && echo "You seem to already have some plugin manager" \ || { mkdir "$HOME/.vim/bundle"; \ git clone https://github.com/Vundle/Vundle.vim.git \