| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- " Do not try to be compatible with vi
- set nocompatible
- if has("autocmd")
- " Clear existing autocmd
- autocmd!
- endif
- " Initialize directories {
- function! InitializeDirectories()
- let parent = $HOME
- let prefix = 'vim'
- let dir_list = {
- \ 'backup': 'backupdir',
- \ 'swap': 'directory' }
- if has('persistent_undo')
- let dir_list['undo'] = 'undodir'
- endif
- let common_dir = parent . '/.' . prefix
- for [dirname, settingname] in items(dir_list)
- let directory = common_dir . dirname . '/'
- if exists("*mkdir")
- if !isdirectory(directory)
- call mkdir(directory)
- endif
- endif
- if !isdirectory(directory)
- echo "Warning: Unable to create backup directory: " . directory
- echo "Try: mkdir -p " . directory
- else
- let directory = substitute(directory, " ", "\\\\ ", "g")
- exec "set " . settingname . "=" . directory
- endif
- endfor
- endfunction
- call InitializeDirectories()
- " }
- " Use bundles config {
- if filereadable(expand("~/.vimrc.bundles"))
- source ~/.vimrc.bundles
- endif
- " }
- filetype plugin indent on " Automatically detect file types.
- if has("autocmd")
- " Source the vimrc file after saving it
- autocmd BufWritePost .vimrc nested source $MYVIMRC
- endif
- """"""""
- "" Tabs and Text Formatting
- """"""""""""""""""""""""""""""""""""""""""""""""""""""
- syntax on " Syntax highlighting
- set background=dark " Assume a dark background
- colorscheme solarized
- set nowrap
- set cursorline " Highlight current line
- set expandtab " convert tab characters into spaces
- set tabstop=2 " actual tab press distance
- set softtabstop=2 " let backspace delete by indents
- set shiftround " indent to nearest tabstops
- set shiftwidth=2 " amount to indent with > and <
- set smarttab " backspace tabs where appropriate even if spaces
- set textwidth=80 " try to keep text within 80 characters
- set colorcolumn=+1 " mark out the limits of the textwidth
- set mouse=a
- set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
- set splitright " Puts new vsplit windows to the right of the current
- set splitbelow " Puts new split windows to the bottom of the current
- set backspace=indent,eol,start " Backspace for dummies
- set linespace=0 " No extra spaces between rows
- set number " Line numbers on
- set showmatch " Show matching brackets/parenthesis
- set incsearch " Find as you type search
- set hlsearch " Highlight search terms
- set winminheight=0 " Windows can be 0 line high
- set ignorecase " Case insensitive search
- set smartcase " Case sensitive when uc present
- set wildmenu " Show list instead of just completing
- set modeline " Support vim modelines at the top of files
- "set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
- set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
- set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
- set scrolljump=5 " Lines to scroll when cursor leaves screen
- set scrolloff=3 " Minimum lines to keep above and below cursor
- set foldenable " Auto fold code
- set list
- set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
- if has('persistent_undo')
- set undofile " So is persistent undo ...
- set undolevels=1000 " Maximum number of changes that can be undone
- set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
- endif
- """"""""
- "" UI - Mouse & Cursor
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- " The following two settings are related to how vim reacts to the incoming $TERM
- " value from either the terminal emulator (e.g. iTerm2) or tmux. In the best
- " case, both of these should be set to xterm-256color. This will result in vim
- " reacting with the settings below:
- "set ttymouse=xterm2 " Needed to allow mouse support to resize windows
- "set ttyfast " Allows for instantaneous refresh when using the mouse to select
- """"""""
- "" UI - Solarized Fix
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Fix solarized scheme in spf13-vim. The config sets up to use the degraded
- " 256-color mode for sake of some terminal emulators? (see
- " https://github.com/spf13/spf13-vim/issues/113).
- "
- " These two lines Must come in this order or they won't work: number and fold
- " columns and cursor line come out brownish (dark scheme) or black (light
- " scheme).
- "let g:solarized_termcolors=16
- "set t_Co=16
- """"""""
- "" UI - Code Folding
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- set foldmethod=indent
- set foldlevel=10
- """"""""
- "" Key Remaps
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""
- let mapleader = ','
- " More convenient escape
- inoremap kj <ESC>
- inoremap jk <ESC>
- " Yank from the cursor to the end of the line, to be consistent with C and D.
- nnoremap Y y$
- " Add extra lines up and down
- nnoremap <leader>j o<Esc>k
- nnoremap <leader>k O<Esc>j
- " Convert tabs to spaces
- nnoremap <silent> <leader><TAB> :%s/<TAB>/ /g<CR>
- " Backspace to clear current search (and stop highlighting)
- nnoremap <silent> <backspace> :call ClearSearch()<CR>
- function! ClearSearch()
- if (@/ != "")
- let @/=""
- redraw
- endif
- endfunction
- nnoremap <silent> <leader>w :set wrap!<CR>
- " Toggle paste mode - no autoindenting of pasted material
- nnoremap <silent> <leader>p :set paste! paste?<CR>
- " Toggle visible whitespace characters
- nnoremap <silent> <leader>l :set list!<CR>
- " Toggle keyboard layout
- "nnoremap <silent> <leader><space> :call CycleKeymap()<CR>
- "function! CycleKeymap()
- "if has('keymap')
- "if (&keymap == '')
- "set keymap=colemak
- "echo 'Colemak keymap selected'
- "elseif (&keymap == 'colemak')
- "set keymap=dvorak
- "echo 'Dvorak keymap selected'
- "else
- "set keymap=
- "echo 'Qwerty keymap selected'
- "endif
- "else
- "echo 'Keymaps not supported'
- "endif
- "endfunction
- " Toggle scrollbind for moving multiple splits in sync together
- nnoremap <silent> <leader>sb :set scrollbind! scrollbind?<CR>
- " Toggle mouse support.
- nnoremap <silent> <leader>m :call ToggleMouse()<CR>
- function! ToggleMouse()
- if &mouse == 'a'
- set mouse=
- echo 'Mouse usage disabled'
- else
- set mouse=a
- echo 'Mouse usage enabled'
- endif
- endfunction
- " Toggle NERDTree file browser
- nnoremap <silent> <leader>d :NERDTreeMirrorToggle<CR>
- let g:NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr']
- let g:NERDTreeChDirMode=0
- let g:NERDTreeQuitOnOpen=1
- let g:NERDTreeMouseMode=2
- let g:NERDTreeShowHidden=1
- let g:NERDTreeKeepTreeInNewTab=1
- " Toggle Commenting out lines with NERDCommenter
- nnoremap <silent> <leader>, :call NERDComment("n", "toggle")<CR>
- vnoremap <silent> <leader>, <ESC>:call NERDComment("x", "toggle")<CR>
- " Git commands with Fugitive
- nnoremap <silent> <leader>gc :Gcommit -v<CR>
- nnoremap <silent> <leader>gl :Glog<CR><CR>
- nnoremap <silent> <leader>gap :Git add -p<CR>
- nnoremap <silent> <leader>gs :Gstatus<CR>
- nnoremap <silent> <leader>gd :Gdiff<CR>
- nnoremap <silent> <leader>gb :Gblame<CR>
- if has("autocmd")
- " Fugitive - Go up to previous tree object while exploring git tree with '..'
- autocmd User fugitive
- \ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
- \ nnoremap <buffer> .. :edit %:h<CR> |
- \ endif
- " Fugitive - Delete buffers when they are not active
- autocmd BufReadPost fugitive://* set bufhidden=delete
- endif
- " Gundo
- nnoremap <silent> <leader>u :GundoToggle<CR>
- " Tagbar
- nnoremap <silent> <leader>t :TagbarToggle<CR>
- """"""""" CtrlP
- " Function definition jumping with CtrlP's Funky plugin
- nnoremap <silent> <C-F> :CtrlPFunky<CR>
- "let g:ctrlp_working_path_mode = 'rw' let's try out ra
- let g:ctrlp_user_command = {
- \ 'types': {
- \ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
- \ 2: ['.hg', 'hg --cwd %s locate -I .'],
- \ },
- \ 'fallback': 'find %s -type f'
- \ }
- let g:ctrlp_extensions = ['funky']
- """"""""" Powerline
- set laststatus=2
- set rtp+=~/dotfiles/powerline/powerline/powerline/bindings/vim
- set noshowmode " don't show e.g. --INSERT-- since we're using powerline
- """"""""" Tagbar
- let g:tagbar_autoclose = 1 " close sidebar after we go to selection
- """"""""" Indent Guides
- let g:indent_guides_enable_on_vim_startup = 1
- let g:indent_guides_auto_colors = 0
- " reverse indent guides highlighting
- "highlight IndentGuidesOdd ctermbg=grey
- highlight IndentGuidesEven ctermbg=black
- """"""""" Syntastic
- let g:syntastic_auto_jump = 1
- """"""""" Vdebug
- let g:vdebug_options = {
- \ 'break_on_open' : 0,
- \ 'watch_window_style' : 'compact',
- \ 'path_maps' : {"/usr": "/jails/alcatraz/usr"}
- \ }
- """"""""" Supertab
- let g:SuperTabDefaultCompletionType = 'context'
- """"""""" Vim Markdown
- let g:vim_markdown_folding_disabled = 1
- """"""""" Remove completion omni in the event that it is too slow
- "let g:neocomplete#sources#omni#input_patterns = {}
- "let g:neocomplcache_omni_patterns = {}
- " Find merge conflict markers
- map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
- " Allow using the repeat operator with a visual selection (!)
- " http://stackoverflow.com/a/8064607/127816
- vnoremap . :normal .<CR>
- """"""""" Source local scripts/plugins
- for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
- execute 'source' filePath
- endfor
|