Last active
March 22, 2016 20:45
-
-
Save kormat/d91b65ffd9137a8905ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
" ====================== | |
" Terminal setup | |
" ====================== | |
if &term =~ "^screen" | |
" pretend this is xterm. it probably is anyway, but if term is left as | |
" `screen`, vim doesn't understand ctrl-arrow. | |
if &term == "screen-256color" | |
set term=xterm-256color | |
else | |
set term=xterm | |
endif | |
endif | |
" ====================== | |
" Settings | |
" ====================== | |
" Statefulness | |
set undodir=~/.vim/undo " persistent undo storage | |
set undofile " persistent undo on | |
set history=1000 " remember command mode history | |
" user interface | |
set laststatus=2 " Always display status line | |
set showcmd " Show (partial) command in status line. | |
set matchtime=2 " How many 1/10s to show matching brackets for. | |
set number " show line numbers | |
set relativenumber " line numbers spread out from 0 | |
set cursorline " highlight current line | |
set scrolloff=2 " always have 2 lines of context on the screen | |
set display=lastline,uhex " show last line even if too long; use <xx> | |
" Whitespace | |
set autoindent " keep indenting on <CR> | |
set shiftwidth=4 " one tab = four spaces (autoindent) | |
set softtabstop=4 " one tab = four spaces (tab key) | |
set expandtab " never use hard tabs | |
set shiftround " only indent to multiples of shiftwidth | |
set smarttab " DTRT when shiftwidth/softtabstop diverge | |
set listchars=tab:↹·,extends:⇉,precedes:⇇,nbsp:␠,trail:␠,nbsp:␣ | |
" appearance of invisible characters | |
set linebreak " break on what looks like boundaries | |
set showbreak=↳\ " shown at the start of a wrapped line | |
" Searching options | |
set showmatch " When a bracket is inserted, briefly jump to the matching one. | |
set incsearch " While typing a search pattern, show immediately where the so far typed pattern matches. | |
set nohlsearch " Don't highlight search matches after searching. | |
" Mouse | |
set ttymouse=xterm2 " force mouse support for screen | |
set mouse=a " terminal mouse when possible | |
" File formats | |
set fileformats=unix,dos " unix linebreaks in new files please | |
set encoding=utf-8 " best default encoding | |
setglobal fileencoding=utf-8 | |
set nobomb " do not write utf-8 BOM! | |
set fileencodings=ucs-bom,utf-8,iso-8859-1 | |
" order to detect Unicodeyness | |
" tab completion | |
set wildmenu " show a menu of completions like zsh | |
set wildmode=full " complete longest common prefix first | |
set wildignore+=.*.sw*,__pycache__,*.pyc | |
" ignore junk files | |
"set complete-=i " don't try to tab-complete #included files | |
"set completeopt-=preview " preview window is super annoying | |
"Misc options | |
set pastetoggle=<F11> " Toggle paste on and off with F11 | |
set splitbelow " Open new horizontal windows below | |
set splitright " Open new vertical windows on the right | |
" Set spell-checking dictionary | |
set spelllang=en_gb | |
" ====================== | |
" Plugins | |
" ====================== | |
" Initialise pathogen | |
call pathogen#infect() | |
call pathogen#helptags() | |
" For Syntastic: https://github.com/scrooloose/syntastic | |
" Don't bother flaking on :wq because I won't even see it! | |
let g:syntastic_check_on_wq = 0 | |
" Only use flake8 for Python -- running `python` itself may or may not work | |
" because versions, and pylint is a beast | |
let g:syntastic_python_checkers = ['flake8'] | |
" Stupid Unicode tricks | |
let g:syntastic_error_symbol = "☠" | |
let g:syntastic_warning_symbol = "⚠" | |
let g:syntastic_style_error_symbol = "☢" | |
let g:syntastic_style_warning_symbol = "☹" | |
" Other syntastic settings | |
let g:syntastic_python_flake8_post_args="--max-line-length=80" | |
"let g:syntastic_always_populate_loc_list = 1 | |
"let g:syntastic_auto_loc_list = 0 | |
let g:syntastic_check_on_open = 1 | |
" For python-mode: https://github.com/klen/python-mode | |
let g:pymode_lint = 0 | |
let g:pymode_lint_write = 0 | |
let g:pymode_folding = 0 | |
let g:pymode_trim_whitespaces = 0 | |
let g:pymode_options_colorcolumn = 0 | |
" No rope, just no. | |
let g:pymode_rope = 0 | |
" Rope is fucking idiotic and keeps recursively reading my entire home | |
" directory. This at least tells it not to search upwards looking for a | |
" .ropeproject marker. | |
let g:pymode_rope_lookup_project = 0 | |
" This is pretty fucking annoying too | |
let g:pymode_rope_complete_on_dot = 0 | |
"autocmd BufRead * if exists("g:pymode_version") | setlocal nonumber | endif | |
" For pyflake8: https://github.com/nvie/vim-flake8 | |
let g:flake8_show_quickfix = 0 | |
" For vim-airline: https://github.com/bling/vim-airline | |
let g:airline_powerline_fonts = 1 | |
let g:airline_theme='powerlineish' | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#whitespace#enabled = 0 | |
" For http://github.com/majutsushi/tagbar | |
nmap <F8> :TagbarToggle<CR> | |
let g:airline#extensions#tagbar#enabled = 1 | |
let g:airline#extensions#tagbar#flags = 'f' | |
" For https://github.com/kien/ctrlp.vim | |
"let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] | |
" ====================== | |
" Mappings | |
" ====================== | |
" Leader | |
let mapleader = "\\" | |
let g:mapleader = "\\" | |
" ctrl-arrow in normal mode to switch windows. | |
noremap <C-Left> <C-W><Left> | |
noremap <C-Right> <C-W><Right> | |
noremap <C-Up> <C-W><Up> | |
noremap <C-Down> <C-W><Down> | |
" -/= to navigate tabs | |
nnoremap <M-Right> gt | |
nnoremap <M-Left> gT | |
" Abbreviation to make `:e %%/...` edit in same directory | |
cabbr <expr> %% expand('%:.:h') | |
" Toggle on/off mouse | |
map <Leader>mo :call ToggleMouse()<cr> | |
" Toggle on/off spell checking | |
map <Leader>sp :set spell!<cr> | |
" Toggle on/off line numbers | |
map <Leader>ln :call ToggleLineNumbers()<cr> | |
" ====================== | |
" Misc scripts | |
" ====================== | |
" Always set 'wrap' on for vimdiff, and jump to top | |
autocmd VimEnter * if &diff | call DiffCheck() | endif | |
function DiffCheck() | |
exe 'normal gg' | |
exe 'windo set wrap' | |
if exists(":SyntasticToggleMode") | |
SyntasticToggleMode | |
endif | |
endfunction | |
" Convenient command to see the difference between the current buffer and the | |
" file it was loaded from, thus the changes you made. | |
command! DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | |
\ | wincmd p | diffthis | |
function! ToggleMouse() | |
if &mouse == "" | |
set mouse=a | |
else | |
set mouse="" | |
endif | |
endfunction | |
function! ToggleLineNumbers() | |
if &number || &relativenumber | |
set nonumber norelativenumber | |
else | |
set number relativenumber | |
endif | |
endfunction | |
" ====================== | |
" Color & syntax | |
" ====================== | |
if &t_Co > 2 || has("gui_running") | |
syntax enable | |
set background=dark | |
endif | |
let g:rehash256 = 1 " Molokai theme variant | |
colorscheme molokai " https://github.com/tomasr/molokai | |
" molokai's bg coloring is broken | |
highlight Normal ctermbg=none | |
" molokai's diff coloring is terrible | |
highlight DiffAdd ctermbg=22 | |
highlight DiffDelete ctermbg=52 | |
highlight DiffChange ctermbg=17 | |
highlight DiffText ctermbg=53 | |
filetype plugin indent on | |
" When editing a file, always jump to the last known cursor position. | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
" Try to fix html indentation, sigh. | |
let g:html_indent_inctags = "html,body,head,tbody,p" | |
" trailing whitespace and column; must define AFTER colorscheme, setf, etc! | |
hi ColorColumn ctermbg=black guibg=darkgray | |
hi WhitespaceEOL ctermbg=red guibg=red | |
match WhitespaceEOL /\s\+\%#\@<!$/ | |
" ====================== | |
" Source local config if present | |
" ====================== | |
let localrc=expand("~/.vim/local.rc") | |
if filereadable(localrc) | |
exe "source " . localrc | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment