201 lines
5.2 KiB
VimL
201 lines
5.2 KiB
VimL
set nocompatible
|
|
|
|
filetype off
|
|
|
|
" --- init vundle
|
|
set rtp+=~/.vim/bundle/Vundle.vim
|
|
call vundle#begin()
|
|
|
|
" --- Let Vundle manage Vundle
|
|
Plugin 'VundleVim/Vundle.vim'
|
|
|
|
" --- My plugins
|
|
Plugin 'scrooloose/nerdtree' " FileBrowser on the left side
|
|
Plugin 'ervandew/supertab' "Auto completion
|
|
Plugin 'jeetsukumaran/vim-buffergator' "Easy buffer switching
|
|
Plugin 'ap/vim-templates' "File templates
|
|
Plugin 'godlygeek/tabular' "Tabularize
|
|
Plugin 'MarcWeber/vim-addon-mw-utils' " Dependency for snipmate
|
|
Plugin 'tomtom/tlib_vim' "Dependency for snipmate
|
|
Plugin 'garbas/vim-snipmate' "Snippets
|
|
Plugin 'easymotion/vim-easymotion' "Easy Motion
|
|
Plugin 'kana/vim-textobj-user' "User defined text objects
|
|
Plugin 'kana/vim-textobj-indent' "Indent based text objects
|
|
Plugin 'benmills/vimux' "Tmux integration
|
|
Plugin 'vim-scripts/argtextobj.vim' "function argument textobj
|
|
|
|
" --- End init vundle
|
|
call vundle#end()
|
|
filetype plugin indent on
|
|
|
|
" --- General configurations
|
|
set whichwrap+=<,>,[,]
|
|
set autoread "auto read file if changed
|
|
set wildmenu "Command completion
|
|
set gdefault " substitute all by default
|
|
set noruler
|
|
set laststatus=2 " Add Status line always
|
|
set number "Show linenumbers
|
|
set backspace=eol,start,indent "Make backspace behave like it's supposed to
|
|
set incsearch "Search while typing pattern
|
|
set lazyredraw "No redrawing while running macros
|
|
set magic "Allow magic modelines
|
|
set showmatch
|
|
set mat=2
|
|
set noerrorbells "No visual nuisance
|
|
set novisualbell
|
|
set t_vb=
|
|
set tm=500
|
|
set encoding=utf8 "Always use utf8
|
|
set ffs=unix,dos,mac
|
|
set nobackup "Don't need a backup, I live on the edge
|
|
set nowb
|
|
set noswapfile
|
|
set expandtab "Tabbing
|
|
set smarttab
|
|
set ai "auto indent
|
|
set si "smart indent
|
|
set wrap "wrap lines
|
|
set shiftwidth=4
|
|
set tabstop=4
|
|
set lbr
|
|
set tw=500
|
|
set t_Co=256
|
|
set hidden
|
|
set switchbuf=vsplit
|
|
|
|
syntax enable
|
|
colorscheme desert
|
|
" Autoload when saving vimrc
|
|
au! BufWritePost .vimrc source ~/.vimrc
|
|
|
|
" --- Own functions
|
|
function! AddSemicolon()
|
|
normal m'A;
|
|
normal `'
|
|
endfunction
|
|
|
|
function! RunCmdVimux()
|
|
let l:cmd = input("Run: ")
|
|
if l:cmd !~ '\s\+'
|
|
call VimuxRunCommand("clear && " . l:cmd)
|
|
endif
|
|
endfunction
|
|
|
|
function! IsModified()
|
|
if &modified
|
|
return '* '
|
|
endif
|
|
return ''
|
|
endfunction
|
|
|
|
" Show insert mode in statusbar
|
|
function! ModeColor(mode)
|
|
if a:mode == 'i'
|
|
if &paste
|
|
hi ModeLine ctermbg=blue
|
|
else
|
|
hi ModeLine ctermbg=green
|
|
endif
|
|
elseif a:mode == 'r'
|
|
hi ModeLine ctermbg=red
|
|
else
|
|
hi ModeLine ctermbg=none
|
|
endif
|
|
endfunction
|
|
|
|
au InsertEnter * call ModeColor(v:insertmode)
|
|
au InsertChange * call ModeColor(v:insertmode)
|
|
au InsertLeave * call ModeColor('n')
|
|
call ModeColor('n')
|
|
|
|
" --- Bindings
|
|
let mapleader = ","
|
|
" Close buffers
|
|
nnoremap <silent> <leader>q :bd<cr>
|
|
" Insert empty line before and after
|
|
nnoremap <silent> <C-o> o<ESC>k
|
|
" Goto next emptyline
|
|
nnoremap <silent> <space> /^$<cr>
|
|
" nnoremap <silent> <> ?^$<cr>
|
|
" evil spaces
|
|
nnoremap <silent> <leader>c m':%s/\s\+$//e<cr>`'
|
|
" double empty lines
|
|
nnoremap <silent> <leader>v m':%s/\n\{3,}/\r\r/e<cr>`'
|
|
" Toggle paste
|
|
nnoremap <silent> <leader>p :set invpaste paste?<cr>
|
|
" Quick tabularize
|
|
nnoremap <leader>a :Tabularize /
|
|
vnoremap <leader>a :'<,'>Tabularize /
|
|
" VimRC
|
|
nnoremap <leader>oc :e ~/.vimrc<cr>
|
|
nnoremap <leader>sc :so ~/.vimrc<cr>
|
|
" Vimux
|
|
nnoremap <leader>rr :call RunCmdVimux()<cr>
|
|
nnoremap <leader>rq :call VimuxCloseRunner()<cr>
|
|
nnoremap <silent> ; :call AddSemicolon()<cr>
|
|
nnoremap <silent> <leader>todo :g/TODO/<cr>
|
|
" 0 should find first non blank
|
|
nmap 0 ^
|
|
" --- Don't need a help
|
|
inoremap <F1> <nop>
|
|
nnoremap <F1> <nop>
|
|
vnoremap <F1> <nop>
|
|
|
|
" --- Just a nuisance
|
|
nnoremap q: <nop>
|
|
|
|
" --- No moving in insert mode allowed
|
|
ino <down> <Nop>
|
|
ino <up> <Nop>
|
|
ino <left> <Nop>
|
|
ino <right> <Nop>
|
|
|
|
" --- Different use of undo
|
|
nnoremap U <c-r>
|
|
|
|
" --- We don't need useless whitespace at the end of the line
|
|
highlight WhitespaceEOL ctermbg=Red guibg=Red
|
|
match WhitespaceEOL /\s\+$/
|
|
|
|
" --- Rice
|
|
set statusline=\ %#Modified#%{IsModified()}%*
|
|
set statusline+=%f
|
|
set statusline+=\ %#ModeLine#%=%*
|
|
set statusline+=\ L%l
|
|
set statusline+=\ C%c
|
|
hi Modified ctermfg=red
|
|
hi StatusLine cterm=None ctermfg=green ctermbg=none
|
|
hi Search cterm=NONE
|
|
hi IncSearch cterm=underline ctermbg=none ctermfg=green
|
|
hi VertSplit cterm=none ctermbg=none ctermfg=blue
|
|
|
|
" --- Supertab
|
|
hi Pmenu ctermfg=green ctermbg=black
|
|
hi PmenuSel ctermfg=white ctermbg=black
|
|
hi PmenuSbar ctermfg=white ctermbg=black cterm=none
|
|
let g:SuperTabNoCompleteAfter = ['^',',','\s']
|
|
|
|
" --- NERDTree tabs
|
|
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
|
|
nmap <silent> <leader>e :NERDTreeToggle<CR>
|
|
autocmd StdinReadPre * let s:std_in=1
|
|
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
|
|
" autocmd BufLeave * if (exists("b:NERDTreeType") && b:NERDTreeType == "primary") | normal :bd | endif
|
|
let NERDTreeWinSize = 30
|
|
let NERDChristmasTree = 0
|
|
let NERDTreeChDirMode = 2
|
|
let NERDTreeIgnore=['\~$','\.pyc$','\.swp$']
|
|
let NERDTreeWinPos="left"
|
|
let NERDTreeMinimalUI = 1
|
|
|
|
" --- EasyMotion
|
|
map / <Plug>(easymotion-sn)
|
|
omap / <Plug>(easymotion-tn)
|
|
map ? <Plug>(easymotion-bd-jk)
|
|
|
|
map n <Plug>(easymotion-next)
|
|
map N <Plug>(easymotion-prev)
|
|
|
|
" --- Auto pairs
|
|
|