" vim: spell foldmethod=marker : " Setup & Plugins {{{ " Setup Vundle set nocompatible filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " Plugins {{{ Plugin 'VundleVim/Vundle.vim' " Library for other plugins Plugin 'https://github.com/vim-scripts/L9.git' " Git inside vim Plugin 'https://github.com/tpope/vim-fugitive.git' Plugin 'https://github.com/airblade/vim-gitgutter' Plugin 'https://github.com/tpope/vim-unimpaired' " Intelligent date inc/dec Plugin 'https://github.com/tpope/vim-speeddating' " Show colors in CSS format Plugin 'https://github.com/ap/vim-css-color' " Load project .vimrc files Plugin 'https://github.com/MarcWeber/vim-addon-local-vimrc' " Fuzzy finder Plugin 'https://github.com/ctrlpvim/ctrlp.vim' " Finder Plugin 'https://github.com/vim-scripts/FuzzyFinder.git' " Solarized colorscheme Plugin 'https://github.com/lifepillar/vim-solarized8' " Zen codding Plugin 'https://github.com/mattn/emmet-vim.git' " Code snippets Plugin 'https://github.com/msanders/snipmate.vim' " Silversearch plugin Plugin 'https://github.com/rking/ag.vim' " Support dot command for plugins Plugin 'https://github.com/tpope/vim-repeat.git' Plugin 'https://github.com/tpope/vim-surround.git' " Files tree plugin Plugin 'https://github.com/scrooloose/nerdtree' " Commenting text Plugin 'https://github.com/scrooloose/nerdcommenter.git' " Automatic closing of quotes, parenthesis, etc... Plugin 'https://github.com/raimondi/delimitmate' " Syntax check and linting Plugin 'https://github.com/scrooloose/syntastic.git' " Text alignment commands Plugin 'https://github.com/godlygeek/tabular' " Pasting in vim Plugin 'https://github.com/ConradIrwin/vim-bracketed-paste' " File templates Plugin 'https://github.com/aperezdc/vim-template' " File types " Ledger Plugin 'https://github.com/abobov/vim-ledger' " Jade templates Plugin 'https://github.com/digitaltoad/vim-jade.git' " Markdown Plugin 'https://github.com/plasticboy/vim-markdown.git' " TypeScript Plugin 'https://github.com/HerringtonDarkholme/yats.vim' " Orgmode Plugin 'https://github.com/jceb/vim-orgmode' "Plugin 'https://github.com/othree/xml.vim' "Plugin 'https://github.com/terryma/vim-multiple-cursors' "Plugin 'https://github.com/motemen/git-vim' " }}} call vundle#end() filetype plugin indent on syntax on " }}} " Options {{{ " Locale {{{ language C set encoding=utf-8 " Encodings try list if has("multi_byte") set fileencodings=ucs-bom,utf-8,cp1251,koi8-r,cp866 endif set keymap=russian-jcukenwin set spelllang=ru,en set spell set iminsert=0 set imsearch=0 " }}} set autoread set visualbell t_vb= if exists('&belloff') set belloff=all endif set title " Скрывать буфер редактировании другого set hidden " Отображать текущую команду set showcmd " По умолчанию пользоваться :help справкой set keywordprg= set omnifunc=syntaxcomplete#Complete runtime! macros/matchit.vim set virtualedit+=block set backspace=indent,eol,start set diffopt+=vertical " Показывать столбец с номерами строк set number set relativenumber set nostartofline " many jump commands move the cursor to the first non-blank character of a line " Сколько строк оставлять при прокрутке с низу и с боку set scrolljump=4 set scrolloff=4 set sidescrolloff=5 set display+=lastline " Число столбцов отведенное на фолдинг " set foldcolumn=3 " Позволить перемещать курсор после начала и конца строки на предыдущую и " следующую соответственно. set whichwrap+=<>[] " Показывать позицию курсора (номер строки, номер позиции в строке) set ruler " Всегда показывать строку статуса set laststatus=2 " Задать формат статусной строки set statusline=%<%f\ %h%m%r%y%=%k\ fenc=%{&fileencoding}\ enc=%{&encoding}\ %l,%c%V\ %P " Начальная директория для просмотра файлов также откуда буфер set browsedir=buffer " Размер истории команд set history=1000 " Изменить действие на в режиме команд set wildmenu " command-line completion shows a list of matches " Дополнять по до максимально схожей строки, по второму выбирать из " вариантов set wildmode=list:longest,full " Не перерисовывать экран пока не выполнится макрос set lazyredraw " Не создавать swap файл в текущей директории set directory-=. " Язык проверки орфографии по умолчанию set wildignore=*.swp,*.bak,*.pyc,*.class set pastetoggle= set cursorline set ttyfast set mouse=a set autoindent set smartindent set splitright set splitbelow " Tuneup delays when using escape key set timeout set timeoutlen=1000 set ttimeout set ttimeoutlen=10 " List chars {{{ set list set listchars=tab:»\ ,trail:·,extends:#,nbsp:· augroup trailing au! au InsertEnter * :set listchars-=trail:· au InsertLeave * :set listchars+=trail:· augroup END " }}} " Tabs and formatting {{{ set tabstop=4 set shiftwidth=4 set softtabstop=4 set smarttab set shiftround set expandtab set wrap set textwidth=80 set formatoptions=rqnl1j set cpoptions+=J set linebreak set showbreak=↵ set breakindent if exists('&breakindentopt') set breakindentopt=shift:2 endif " }}} let mapleader="," let maplocalleader="\\" " Color scheme {{{ if &t_Co < 16 set t_Co=16 endif let &t_8f = "\[38;2;%lu;%lu;%lum" let &t_8b = "\[48;2;%lu;%lu;%lum" let g:solarized_termcolors=256 let g:solarized_termtrans=1 set background=light colorscheme solarized8_light set termguicolors " }}} digraphs ru 8381 digraphs e= 8364 " }}} " Backup {{{ set backup set noswapfile set undofile set undodir=$HOME/tmp/vim/undo// set backupdir=$HOME/tmp/vim/backup// set directory=$HOME/tmp/vim/swap// " Make directories if !isdirectory(expand(&undodir)) call mkdir(expand(&undodir), "p") endif if !isdirectory(expand(&backupdir)) call mkdir(expand(&backupdir), "p") endif if !isdirectory(expand(&directory)) call mkdir(expand(&directory), "p") endif " }}} " Search {{{ set gdefault set hlsearch set ignorecase set incsearch set showmatch set smartcase nnoremap / /\v vnoremap / /\v nnoremap * :let stay_star_view = winsaveview()*:call winrestview(stay_star_view) noremap :silent nohlsearch " Visual mode search {{{ function! s:VSetSearch() let temp = @@ norm! gvy let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') let @@ = temp endfunction vnoremap * :call VSetSearch()// vnoremap # :call VSetSearch()?? " }}} " }}} " Autocommands {{{ if has('autocmd') " Cursor line only in current window and not insert mode au WinEnter * set cursorline au WinLeave * set nocursorline au InsertEnter * set nocursorline au InsertLeave * set cursorline " TODO перенести в ftplugin autocmd FileType tex setlocal spell textwidth=79 autocmd FileType java setlocal omnifunc=javacomplete#Complete autocmd FileType python set expandtab autocmd FileType html,xml,ant set nolist " Restore cursor position au BufReadPost * if line("'\.") > 0 && line("'\.") <= line("$") | exe 'normal g`.zvzz' | endif au BufRead,BufNewFile /etc/nginx/* if &ft == "" | setfiletype nginx | endif au BufEnter * if &filetype == "" | setlocal ft=text | endif au BufReadPost *.ledger norm G au BufRead,BufNewFile *.geojson if &ft == "" | setfiletype json | endif " Set scripts to be executable from shell "au BufWritePost * if getline(1) =~ "^#!.*/bin/" | silent !chmod +x | endif au BufWritePost * if getline(1) =~ "^#!.*/bin/" | silent exec "!chmod +x " | endif endif " }}} " Mappings {{{ " Vim rocks! nnoremap ; : inoremap kk nnoremap % vnoremap % nnoremap H ^ nnoremap L g_ inoremap l nnoremap J mzJ`z nnoremap n :setlocal number! nnoremap s :setlocal spell! nnoremap w :setlocal wrap! nnoremap l :setlocal list! nnoremap p :silent! set paste"*p:set nopaste vnoremap y "*y " Disable keys {{{ inoremap nnoremap vnoremap noremap noremap noremap noremap nnoremap Q @q " }}} nnoremap za vnoremap za nnoremap d "_d vnoremap d "_d " Увеличить шаг прокрутки буфера nnoremap 3 nnoremap 3 " Передвигаться держа курсор в центре по вертикале "map j jzz "map k kzz " Двигать блоки vnoremap < >gv nnoremap V V`] " Wrapped lines navigation {{{ nnoremap j gj nnoremap k gk nnoremap g$ $ nnoremap $ g$ nnoremap g0 0 nnoremap 0 g0 nnoremap g^ ^ nnoremap ^ g^ vnoremap g$ $ vnoremap $ g$ vnoremap g0 0 vnoremap 0 g0 vnoremap g^ ^ vnoremap ^ g^ " }}} " Speedup moving over windows map h map j map k map l " Open current buffer in new tab noremap :tab sp " Write file with sudo cmap w!! w !sudo tee % >/dev/null map gf :e inoremap u inoremap u inoremap inoremap nnoremap :cnextz. nnoremap :cpreviousz. " Quick editing {{{ nnoremap ev :vsplit $MYVIMRC " }}} " }}} " Commands {{{ command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ \ | diffthis | wincmd p | diffthis if executable('jq') command -range Jq ,!jq --indent 4 . endif " }}} " Filetype {{{ " XML {{{ augroup ft_xml au! au FileType xml nnoremap z Vatzf au FileType xml vnoremap z zf augroup END " }}} " Javascript {{{ augroup ft_javascript au! au FileType javascript setlocal foldmethod=marker foldmarker={,} augroup END " }}} " JSON {{{ augroup ft_json au! if exists(':Jq') au FileType json noremap jq :%Jq au FileType json vnoremap jq :%Jq endif augroup END " }}} " Ledger {{{ augroup ft_ledger au! au FileType ledger inoremap e :call ledger#entry() au FileType ledger noremap = :LedgerAlign augroup END " }}} " Org {{{ augroup ft_org au! au FileType org setlocal spell nolist tabstop=2 shiftwidth=2 augroup END " }}} " QuickFix {{{ augroup ft_qf au! au FileType qf set nowrap augroup END " }}} " }}} " Plugins {{{ " Surround {{{ " Surrounds double angle quotes «» let g:surround_171="« \r »" let g:surround_187="«\r»" " }}} " Syntastic {{{ "let g:syntastic_check_on_open = 0 "let g:syntastic_check_on_wq = 0 "let g:syntastic_auto_jump = 0 "let g:syntastic_java_checker = 'javac' let g:syntastic_mode_map = { \ 'mode': 'passive', \ 'active_filetypes': [], \ 'passive_filetypes': ['java'] \ } nnoremap C :SyntasticCheck " }}} " Taglist {{{ nnoremap :Tlist " }}} " Fuzzy Finder {{{ nnoremap '. :FufFileWithCurrentBufferDir nnoremap 'f :FufFile nnoremap 'h :FufFile $HOME/ nnoremap 'k :FufBuffer " }}} " NERD Tree {{{ noremap :NERDTreeToggle noremap :NERDTreeToggle let NERDTreeMinimalUI = 1 let NERDTreeDirArrows = 1 let NERDChristmasTree = 1 let NERDTreeChDirMode = 2 let NERDTreeAutoDeleteBuffer=1 let NERDTreeIgnore = [ '\.pyc$' ] " }}} " Scratch {{{ function! ScratchToggle() if exists("w:is_scratch_window") unlet w:is_scratch_window exec "q" else exec "norm! :Sscratch\\l" let w:is_scratch_window = 1 endif endfunction command! ScratchToggle call ScratchToggle() nnoremap :ScratchToggle " }}} " Tabular {{{ function! TabularizeUnderCursos() let ch = getline(".")[col(".") - 1] call Tabularize('/\V' . ch) endfunction nnoremap T :call TabularizeUnderCursos() " }}} " Emmet {{{ let g:user_emmet_expandabbr_key = '' " }}} " delimitMate {{{ let delimitMate_expand_cr = 1 au FileType html let b:delimitMate_matchpairs="(:),[:],{:}" " }}} " Template {{{ let g:templates_directory=$HOME . "/.vim/templates" " }}} " Ctrl-P {{{ let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' let g:ctrlp_user_caching = 0 " }}} " Ledger {{{ let g:ledger_commodity_spell = 0 " }}} " }}} " Load custom local config {{{ let s:local_vimrc=$MYVIMRC . ".local" if filereadable(s:local_vimrc) silent! execute ':source ' . s:local_vimrc endif " }}}