1 " TODO: Make .vimrc read in my .vimrclite then stack on top of it.
  2 set nocompatible               " be iMproved
  3 set t_Co=256
  4 syntax on
  5 filetype off                   " required!
  6 
  7 set rtp+=~/.vim/bundle/Vundle.vim
  8 call vundle#begin()
  9 
 10 " let Vundle manage Vundle
 11 Plugin 'gmarik/Vundle.vim'
 12 
 13 " Fuzzy completion + some language specific completion.
 14 Plugin 'https://github.com/Valloric/YouCompleteMe'
 15 
 16 " Syntax checking
 17 "Plugin 'https://github.com/scrooloose/syntastic.git'
 18 
 19 " History of yanks
 20 Plugin 'https://github.com/vim-scripts/YankRing.vim'
 21 
 22 " Dem snippets.
 23 Plugin 'https://github.com/sirver/UltiSnips'
 24 " Actual snippets for ultisnips to use
 25 Plugin 'https://github.com/honza/vim-snippets'
 26 
 27 " bufferline shows information about all the buffers in the command bar area
 28 Plugin 'https://github.com/bling/vim-bufferline'
 29 " Nice looking line at bottom
 30 Plugin 'https://github.com/itchyny/lightline.vim'
 31 " git wrapper, also a dependency for status lines to get branch names
 32 Plugin 'https://github.com/tpope/vim-fugitive'
 33 
 34 " Color each nested paren, bracket, etc, a different color
 35 Plugin 'https://github.com/kien/rainbow_parentheses.vim'
 36 " Toggle rainbow parens at start
 37 au VimEnter * RainbowParenthesesToggle
 38 au Syntax * RainbowParenthesesLoadRound
 39 au Syntax * RainbowParenthesesLoadSquare
 40 au Syntax * RainbowParenthesesLoadBraces
 41 
 42 " Note that I removed the 'black' element because it conflicted with the
 43 " bandit colorscheme's background and was not visible
 44 let g:rbpt_colorpairs = [
 45     \ ['brown',       'RoyalBlue3'],
 46     \ ['Darkblue',    'SeaGreen3'],
 47     \ ['darkgray',    'DarkOrchid3'],
 48     \ ['darkgreen',   'firebrick3'],
 49     \ ['darkcyan',    'RoyalBlue3'],
 50     \ ['darkred',     'SeaGreen3'],
 51     \ ['darkmagenta', 'DarkOrchid3'],
 52     \ ['brown',       'firebrick3'],
 53     \ ['gray',        'RoyalBlue3'],
 54     \ ['darkmagenta', 'DarkOrchid3'],
 55     \ ['Darkblue',    'firebrick3'],
 56     \ ['darkgreen',   'RoyalBlue3'],
 57     \ ['darkcyan',    'SeaGreen3'],
 58     \ ['darkred',     'DarkOrchid3'],
 59     \ ['red',         'firebrick3'],
 60     \ ]
 61 
 62 if has("gui_running")
 63     " This one only works in gvim, maybe terminal support someday.
 64     Plugin 'jaxbot/semantic-highlight.vim'
 65 else
 66     " From https://bitbucket.org/abudden/taghighlight/
 67     Plugin 'file:///home/hpatel/.vim/bundle/taghighlight'
 68     " Plugin by guy who made taghighlight. Most color schemes dont support all the
 69     " possible highlightable elements, so use this or something.
 70     Plugin 'file:///home/hpatel/.vim/bundle/easycolour'
 71     " Taghighlight guy's custom colorscheme which has all the possible
 72     " highlightable choices.
 73     set background=dark
 74 endif
 75 " This one needs a tag file.
 76 "Plugin 'ferranpm/vim-colorcode'
 77 
 78 call vundle#end()
 79 
 80 if has("gui_running")
 81     set guifont=Inconsolata\ 12
 82     colo molokai
 83 else
 84     colo bandit
 85 endif
 86 
 87 filetype plugin indent on     " required!
 88 set tabstop=4
 89 set shiftwidth=4
 90 set backspace=indent,eol,start
 91 set statusline=%<%f\%h%m%r%=%-20.(line=%l\ \ col=%c%V\ \ totlin=%L%)\ \ \%h%m%r%=%-40(bytval=0x%B,%n%Y%)\%P
 92 
 93 " Vim - I like opening help in new tabs now.
 94 cnoremap help tab help
 95 " Vim - move between buffers with hotkeys. Ctrl+(left/right).
 96 map <silent> <C-Right> :bnext<CR>
 97 map <silent> <C-Left> :bprev<CR>
 98 map <silent> <C-h> :bprev<CR>
 99 map <silent> <C-l> :bnext<CR>
100 
101 " When a line is wrapped, treat it as multiple lines when moving with up and
102 " down.
103 map <silent> <UP> g<UP>
104 map <silent> <DOWN> g<DOWN>
105 map <silent> j gj
106 map <silent> k gk
107 
108 noremap <Up> <NOP>
109 noremap <Down> <NOP>
110 noremap <Left> <NOP>
111 noremap <Right> <NOP>
112 
113 " Visual bell is annoying, and I imagine sounds would be too if I had them on.
114 set noerrorbells
115 set novisualbell
116 
117 " The wildmenu is cool. See help page.
118 set wildmenu
119 " Ignore compiled files when using the wildmenu. (Will probably add more)
120 set wildignore=*.o,*.so,*.pyc
121 " This does tab completion like the normal shell does, keep going until a
122 " conflict. I shall use the default, which is like Windows Command Prompt.
123 "set wildmode=longest:full
124 
125 " Use VERY MAGIC with vim search and replaces. See 'magic' in help.
126 " Normally I need to escape regex stuff like captures (), and pipes.
127 " All ASCII characters except '0'-'9', 'a'-'z', 'A'-'Z' and '_' have
128 " a special meaning in very magic mode.
129 :cnoremap s/ s/\v
130 
131 " Return to previous file location after closing vim.
132 autocmd BufReadPost *
133      \ if line("'\"") > 0 && line("'\"") <= line("$") |
134      \   exe "normal! g`\"" |
135      \ endif
136 
137 " Spell check
138 map <silent> ss :setlocal spell!<cr>
139 
140 " Show tabs and trailing characters.
141 set list
142 set listchars=tab:>-,trail:-
143 
144 " This makes it keep X lines at the top and bottom before scrolling. This
145 " helps keep some context. Note that this does cause H and L (they go to the
146 " top and bottom of the current page respectively) to go nearest to top and bottom
147 " before the page would start scrolling. That is H and L now go X lines from
148 " the top and bottom.
149 set scrolloff=10
150 
151 " This shows the current command you are entering near the bottom right.
152 set showcmd
153 
154 " Search options. ignorecase=thisisobvious, smartcase only is case sensitive
155 " if a capital letter is present.
156 set ignorecase
157 set smartcase
158 
159 "" syntastic
160 " This shows the quick fix list at the bottom. TODO: Figure out how to toggle.
161 let g:syntastic_auto_loc_list=1
162 " This shows markers near the line numbers indicating that the line has
163 " something wrong with it.
164 let g:syntastic_enable_signs=1
165 " This checks a file once you open it.
166 let g:syntastic_check_on_open=1
167 
168 "" Ultisnips
169 let g:UltiSnipsExpandTrigger="<c-j>"
170 let g:UltiSnipsListSnippets="<c-tab>"
171 let g:UltiSnipsJumpForwardTrigger="<c-j>"
172 let g:UltiSnipsJumpBackwardTrigger="<c-k>"
173 
174 "" Yankring, remap the show yanklist key.
175 nnoremap <silent> <F4> :YRShow<CR>
176 
177 " Let bufferline automatically echo to the command bar area.
178 let g:bufferline_echo = 1
179 
180 " For lightline to show things
181 set laststatus=2
182 let g:lightline = {
183       \ 'colorscheme': 'wombat',
184       \ 'active': {
185       \   'left': [ [ 'mode', 'paste' ],
186       \             [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
187       \ },
188       \ 'component': {
189       \   'readonly': '%{&filetype=="help"?"":&readonly?"ReadOnly":""}',
190       \   'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
191       \   'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
192       \ },
193       \ 'component_function': {
194       \   'fugitive': 'MyFugitive'
195       \ },
196       \ 'component_visible_condition': {
197       \   'readonly': '(&filetype!="help"&& &readonly)',
198       \   'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
199       \   'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
200       \ },
201       \ 'separator': { 'left': '>>', 'right': '<<' },
202       \ 'subseparator': { 'left': '>', 'right': '<' }
203       \ }
204 " Shows a nifty branch icon when in a git repo.
205 function! MyFugitive()
206   if exists("*fugitive#head")
207     let _ = fugitive#head()
208     return strlen(_) ? '⎇  '._ : ''
209   endif
210   return ''
211 endfunction
212 
213 " Fix by maker of vim-powerline. For all the status line plugins, the
214 " transition from insert->normal mode always had a lag. To fix the lag you
215 " would have to break most of your remap by setting a timeoutlen to a low
216 " value. This seems to fix it without destroying mappings.
217 augroup FastEscape
218     autocmd!
219     au InsertEnter * set timeoutlen=0
220     au InsertLeave * set timeoutlen=1000
221 augroup END
222 " Remove the default status bar below lightline from showing modes, it is
223 " useless with lightline present.
224 set noshowmode
225 
226 " The combo of 'set number' and 'set relativenumber' ends up setting
227 " relative numbers, but where it would say line 0 for relative numbers,
228 " shows the actual line number. The F5 remapping causes it to toggle from
229 " absolute line numbers to relative with the actual line number at the current
230 " line.
231 set number
232 set relativenumber
233 nnoremap <silent> <F5> :set relativenumber!<CR>
234 
235 " Disable folding
236 set nofoldenable
237 
238 " In many terminal emulators the mouse works just fine, thus enable it.
239 if has('mouse')
240   set mouse=a
241 endif
242 
243 " Need to include 'stty -ixon' in .bashrc or .zshrc for this to work.
244 inoremap <silent><C-S> <C-O>:update<CR>
245 nnoremap <silent><C-S> :update<CR>
246 noremap <silent>; :
247 set nowrap
248 
249 nnoremap Y y$
250