From c76c740d0770c8599a50aa77ffc208d57b4a342a Mon Sep 17 00:00:00 2001 From: Pavel Lutskov Date: Fri, 1 Dec 2017 17:04:24 +0100 Subject: [PATCH] setup script, own statusline, coding style highlight --- .vimrc | 25 ++++++++++++++++-------- README.md | 18 +++++++++++------- colors/izi.vim | 5 ++++- ftplugin/vim.vim | 2 +- plugin/statusline.vim | 27 ++++++++++++++++++++++++++ setup.sh | 44 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 plugin/statusline.vim create mode 100755 setup.sh diff --git a/.vimrc b/.vimrc index 9eab510..40e3a3c 100644 --- a/.vimrc +++ b/.vimrc @@ -3,11 +3,11 @@ set nocompatible "Plugin stuff "{{{ if has("win32") - source $HOME/vimfiles/plugins.vim - source $HOME/vimfiles/locals.vim + source $HOME/_vimplugin + source $HOME/_vimlocal else - source $HOME/.vim/plugins.vim - source $HOME/.vim/locals.vim + source $HOME/.vimplugin + source $HOME/.vimlocal endif "}}} @@ -15,7 +15,7 @@ endif "{{{ filetype plugin indent on syntax enable -syntax sync maxlines=256 +syntax sync maxlines=100 set synmaxcol=200 "}}} @@ -69,11 +69,20 @@ let g:ycm_autoclose_preview_window_after_completion = 1 set shortmess+=c "}}} -"Misc +"Coding style "{{{ -augroup overlength +augroup badstyle autocmd! - autocmd BufWinEnter * match OverLength '\%81v.' + autocmd BufWinEnter * let w:m1 = matchadd('Unstylish', '\%81v.') + autocmd BufWinEnter * if &ft != 'make' && &ft != 'gitcommit' | + \ let w:m2 = matchadd('Unstylish', '\t') | endif +augroup END + +augroup trailingwhite + autocmd! + autocmd BufWinEnter,InsertLeave * if &ft != 'markdown' + \ | match TrailingWhite '\v\s+$' | endif + autocmd InsertEnter * match TrailingWhite '' augroup END "}}} diff --git a/README.md b/README.md index 25bcdd5..917cfc6 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,16 @@ If you find yourself wanting to use these settings, do the following: ``` -colors -> ~/.vim/colors -ftplugin -> ~/.vim/ftplugin -.vimrc -> ~/.vimrc +./colors -> ~/.vim/colors +./ftplugin -> ~/.vim/ftplugin +./.vimrc -> ~/.vimrc ``` -Also create two files `~/.vim/plugins.vim` and `~/.vim/locals.vim`. The first -one contains commands for your plugin manager and in the second one are commands -that are local to the machine. You might use `plugin_template.vim` and -`locals_template.vim` for reference. +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. diff --git a/colors/izi.vim b/colors/izi.vim index 6fc6ebd..87f3f8a 100644 --- a/colors/izi.vim +++ b/colors/izi.vim @@ -30,6 +30,8 @@ hi SignColumn cterm=NONE ctermbg=15 gui=NONE guibg=#ffffff hi TabLine cterm=NONE ctermbg=7 gui=NONE guibg=#c0c0c0 hi TabLineFill cterm=NONE ctermbg=7 gui=NONE guibg=#c0c0c0 hi TabLineSel cterm=bold ctermfg=0 ctermbg=15 gui=bold guifg=#000000 guibg=#ffffff +hi StatusLine gui=bold guibg=#c0c0c0 guifg=#000000 cterm=bold ctermbg=7 ctermfg=0 +hi StatusLineNc gui=NONE guibg=#c0c0c0 guifg=#808080 cterm=NONE ctermbg=7 ctermfg=8 hi Title cterm=bold ctermfg=0 gui=bold guifg=#000000 hi VertSplit cterm=bold ctermfg=0 ctermbg=15 gui=bold guifg=#000000 guibg=#ffffff @@ -39,7 +41,8 @@ hi Visual cterm=NONE ctermbg=159 gui=none guibg=#afffff hi Error cterm=bold ctermfg=9 ctermbg=15 gui=bold guifg=#ff0000 guibg=#ffffff hi SyntasticError cterm=bold ctermfg=9 ctermbg=15 gui=bold guifg=#ff0000 guibg=#ffffff hi SyntasticWarning cterm=underline gui=undercurl guisp=#ffaf00 -hi OverLength cterm=NONE ctermfg=0 ctermbg=210 gui=NONE guibg=#ffc0c0 guifg=#000000 +hi Unstylish cterm=NONE ctermfg=0 ctermbg=210 gui=NONE guibg=#ffc0c0 guifg=#000000 +hi def link TrailingWhite Unstylish hi Identifier cterm=NONE ctermfg=6 ctermbg=NONE gui=NONE guifg=#00afaf guibg=#ffffff "hi Ignore gui=NONE guifg=bg guibg=NONE hi PreProc cterm=NONE ctermfg=94 ctermbg=15 gui=NONE guifg=#a75f5f guibg=#ffffff diff --git a/ftplugin/vim.vim b/ftplugin/vim.vim index 7e1ca58..b27bff4 100644 --- a/ftplugin/vim.vim +++ b/ftplugin/vim.vim @@ -1,4 +1,4 @@ -setlocal foldmethod=marker +setlocal foldmethod=marker foldlevel=0 nnoremap c mcI"`c:delm c vnoremap f `>o"}}}` nnoremap xf mx?"{{{dd/"}}}dd`x:noh:delm x diff --git a/plugin/statusline.vim b/plugin/statusline.vim new file mode 100644 index 0000000..6e5f3b7 --- /dev/null +++ b/plugin/statusline.vim @@ -0,0 +1,27 @@ +function! GetGitStatus() + let result=fugitive#statusline() + if strlen(result) == 0 + return result + else + return "{" . split(result,'[()]')[1] . "}" + endif +endfunction + +set statusline= +set statusline+=%w%q%h +set statusline+=%{GetGitStatus()} +set statusline+=\ +set statusline+=%f +set statusline+=%m%r +set statusline+=%= +set statusline+=\ +set statusline+=%< +set statusline+=%{&fileencoding?&fileencoding:&encoding} +set statusline+=\|%{&fileformat} +set statusline+=\ +set statusline+=%y +set statusline+=\ +set statusline+= +set statusline+=\ +set statusline+=(%2c:%l)/%L +set statusline+=\ diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..ecb4eb0 --- /dev/null +++ b/setup.sh @@ -0,0 +1,44 @@ +#!/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" + +[ -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" \ + || ln -s "$repo/colors" "$HOME/.vim/colors" + +[ -d "$HOME/.vim/plugin" ] \ + && echo "plugin dir 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" \ + || 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" ]\ + && echo "You seem to already have some plugin manager" \ + || { mkdir "$HOME/.vim/bundle"; \ + git clone https://github.com/Vundle/Vundle.vim.git \ + "$HOME/.vim/bunlde/Vundle.vim"; } + +echo "Setup finished."