dotfiles / vimrc

The default branch has multiple heads

Full commit
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()

filetype plugin indent on
syntax on

let g:colorsamplerpack_loaded = 1
let did_install_default_menus = 1
let did_install_syntax_menu = 1
let g:user_zen_leader_key = '<D-Space>'

colorscheme molokai
set background=dark

" Settings --------------------------------------------------------------------
set nocompatible
set modelines=0
set tabstop=4 shiftwidth=4 softtabstop=4 expandtab
set number ruler
set encoding=utf-8
set autoindent smartindent
set showmode showcmd
set hidden
set wildmenu wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
set scrolloff=3
set ignorecase smartcase
set gdefault
set incsearch showmatch hlsearch
set wrap
set textwidth=79
set formatoptions=qrn1
set ffs=unix,dos,mac
set fencs=utf-8,cp1251,cp866,koi8-r,ucs-2
set shellslash
set grepprg=grep\ -nH\ $*
set spelllang=ru_yo,en
set nospell
if v:version >= 703
    set colorcolumn=85

    set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
    set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
    set undodir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
    set undofile swapfile backup
au FocusLost * :wa " In case of emergency, save files when Vim loses focus

" Mappings --------------------------------------------------------------------
let mapleader = "," 
" Cycle through windows
nnoremap <M-TAB> <C-w><C-w>
nnoremap <M-S-TAB> <C-w><C-p>
nnoremap <C-tab> :bn<cr>
nnoremap <c-s-tab> :bp<cr>
" Smart way to move btw. windows
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
" Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>

""Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
nmap <leader>f :set fu!<CR>
map <leader>v :vsp $MYVIMRC<CR>
map <leader>V :source $MYVIMRC<CR>
map <leader>pt :Pytest file<CR>

nmap <leader>ac :Ack
nmap <leader>cd :FufDir<CR>
nmap <leader>of :FufFile<CR>
nmap <leader>bu :FufBuffer<CR>
nmap <leader>er :Error<CR>
nmap <leader>td :TaskList<CR>
nmap <leader>gu :GundoToggle<CR>
nnoremap <silent> <leader>nt :NERDTreeToggle %:p:h<CR>
nnoremap <silent> <leader>tl :TagbarToggle<CR>
nmap <silent> <Leader>pr <Plug>ToggleProject
""Searching yamies
nnoremap / /\v
vnoremap / /\v
nnoremap <leader><space> :noh<cr>
"" Navigate mappings
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
nnoremap ; :
nnoremap <leader>w <C-w>v<C-w>l
map <S-Enter> O<Esc>
map <c-Enter> o<Esc>

" Python specific settings -----------------------------------------------------
func! DeleteTrailingWS()
  exe "normal mz"
  exe "normal `z"
autocmd BufWrite *.py,*.pyw :call DeleteTrailingWS()
" Use the below highlight group when displaying bad whitespace is desired
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set textwidth=79
au BufRead,BufNewFile *.c,*.h set formatoptions-=c formatoptions-=o formatoptions-=r
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
autocmd FileType python highlight BadWhitespace ctermbg=red guibg=red

" Autocomplete settings -------------------------------------------------------
let ropevim_vim_completion=1
autocmd Filetype python setlocal omnifunc=RopeCompleteFunc
autocmd Filetype python nmap <buffer> gd :call RopeGotoDefinition()<CR>
let g:SuperTabDefaultCompletionType = "context"

" View opts -------------------------------------------------------------------
if has("gui_running")
    set guifont=Menlo:h12
    set antialias " Terminus looks better that way
    set guioptions-=T
    set guioptions-=L
    set guioptions-=r
    set fuopt+=maxhorz
  set t_Co=256
  let g:indent_guides_indent_levels = 0

" Status line opts ------------------------------------------------------------
hi StatColor guibg=#95e454 guifg=black ctermbg=lightgreen ctermfg=black
hi Modified guibg=orange guifg=black ctermbg=lightred ctermfg=black

set laststatus=2
set statusline=

" Формат статусной строки
function! MyStatusLine(mode)
    let stl=""
    if a:mode == 'Enter'
        let stl .= "%#StatColor#"
    let stl.="[%n]"    " Номер буфера
    let stl.="["
    let stl.="%<"
    let stl.="%f"     " Имя файла загруженного в буфер
    let stl.="]"
    if a:mode == 'Enter'
        let stl .= "%*"
    let stl .= "%#Modified#%m"
    if a:mode == 'Leave'
        let stl .= "%*%r"
    elseif a:mode == 'Enter'
        let stl .= "%r%*"
    let stl.=" [%{&ft}" " Тип файла, загруженного в буфер, например [cpp]
    let stl.="\ \|\ "
    let stl.="%{&fileencoding}" " Кодировка файла
    let stl.="\ \|\ " 
    let stl.="%{&ff}]" " Формат файла
    let stl.="%{SyntasticStatuslineFlag()}"
    "let stl.="%="      " Выравнивание по правому краю
    let stl.=" ["
    let stl.="Line:"
    let stl.="\ %l/"   " Номер строки
    let stl.="%L"      " Количество строк в буфере
    let stl.="\ \|\ "
    let stl.="Col:"
    let stl.="\ %3v"   " Номер колонки
    let stl.="]"
    let stl.=" [Pos: %P]"
    return stl

au WinEnter * setlocal statusline=%!MyStatusLine('Enter')
au WinLeave * setlocal statusline=%!MyStatusLine('Leave')
set statusline=%!MyStatusLine('Enter')

function! InsertStatuslineColor(mode)
  if a:mode == 'i'
    hi StatColor guibg=orange ctermbg=lightred
  elseif a:mode == 'r'
    hi StatColor guibg=#e454ba ctermbg=magenta
  elseif a:mode == 'v'
    hi StatColor guibg=#e454ba ctermbg=magenta
    hi StatColor guibg=red ctermbg=red

au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi StatColor guibg=#95e454 guifg=black ctermbg=lightgreen ctermfg=black

" Tag list settings -----------------------------------------------------------
let Tlist_Use_Right_Window=1
let Tlist_Enable_Fold_Column=0
let Tlist_Compact_Format=1
set updatetime=1000
let g:Tlist_Show_One_File = 1 
let g:Tlist_GainFocus_On_ToggleOpen = 1

" HTML close tag plugin -------------------------------------------------------
let g:closetag_html_style=1
" au Filetype html,xml,xsl source ~/.vim/scripts/closetag.vim 

" Pascal specific settings ----------------------------------------------------
au FileType pascal set tabstop=2 shiftwidth=2 softtabstop=2 expandtab

" Latex settings --------------------------------------------------------------
let g:tex_flavor='latex'
au FileType latex :set sw=2
au FileType latex :set iskeyword+=:

" Syntastic settings ----------------------------------------------------------
let g:syntastic_enable_signs=1

" Vimwiki settings ------------------------------------------------------------
let wiki = {}
let wiki.path = '~/wiki/'
let wiki.path_html = '~/Sites/wiki/'
let wiki.nested_syntaxes = {'python': 'python'}
let wiki.auto_export = 1
let wiki.html_header = '~/wiki/header.tpl'
let g:vimwiki_list = [wiki]

" Foldings --------------------------------------------------------------------
function! ToggleFoldColumn()
    if &foldenable == 1
        set foldcolumn=1
        set foldcolumn=0
set nofoldenable
nnoremap <silent> <leader>fe :set foldenable!<cr>:call ToggleFoldColumn()<cr>

" Less
au BufNewFile,BufRead *.less set filetype=less

python << EOF
import os
import sys
import vim
for p in sys.path:
    if os.path.isdir(p):
        vim.command(r"set path+=%s" % (p.replace(" ", r"\ ")))
set tags+=$HOME/.vim/tags/python.ctags

let g:indent_guides_enable_on_vim_startup = 1
let g:pyflakes_use_quickfix = 1
let g:pep8_map='<leader>8'

" Execute the tests
nmap <silent><Leader>tf <Esc>:Pytest file<CR>
nmap <silent><Leader>tc <Esc>:Pytest class<CR>
nmap <silent><Leader>tm <Esc>:Pytest method<CR>
" cycle through test errors
nmap <silent><Leader>tn <Esc>:Pytest next<CR>
nmap <silent><Leader>tp <Esc>:Pytest previous<CR>
nmap <silent><Leader>te <Esc>:Pytest error<CR>

" vim -b : edit binary using xxd-format!
augroup Binary
  au BufReadPre  *.bin let &bin=1
  au BufReadPost *.bin if &bin | %!xxd
  au BufReadPost *.bin set ft=xxd | endif
  au BufWritePre *.bin if &bin | %!xxd -r
  au BufWritePre *.bin endif
  au BufWritePost *.bin if &bin | %!xxd
  au BufWritePost *.bin set nomod | endif
augroup END