-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
393 lines (321 loc) · 11 KB
/
vimrc
File metadata and controls
393 lines (321 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
" Plugins
" =============
"Setup Vundle For Package Management
"Vundle begins here, turn off filetype temporarily
filetype off
"Add vundle and any other packages not installed through vundle to our lookup
"path
set rtp+=~/.vim/bundle/Vundle.vim,/usr/local/lib/node_modules/typescript-tools
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" # Themes
Plugin 'flazz/vim-colorschemes'
Plugin 'chriskempson/base16-vim'
" # Enhanced Syntax
Plugin 'plasticboy/vim-markdown'
Plugin 'elzr/vim-json'
" # Extra Syntax
" Functionality
" ### Indispensable
" ctrlp is file fuzzy search
Plugin 'kien/ctrlp.vim'
" Ag.vim uses ack to search within files
Plugin 'rking/ag.vim'
"Airline provides a stylish appearance for the styleline
Plugin 'bling/vim-airline'
" Syntastic provides syntax info
Plugin 'scrooloose/syntastic'
" PEP8 Checking
Plugin 'nvie/vim-flake8'
" Show git info in the gutter, sad that it and syntastic fight for space though
"Plugin 'airblade/vim-gitgutter'
" For use with things version control tools other than git
"Plugin 'mhinz/vim-signify'
" Integrate with tmux
Plugin 'christoomey/vim-tmux-navigator'
" Provides Sublime-Text like smart completion of braces, parens and such
Plugin 'Raimondi/delimitMate'
" Great helpful autocompletion (requires a separate compile step)
Plugin 'Valloric/YouCompleteMe'
" Support plugin for YCM
Plugin 'rdnetto/YCM-Generator'
" Easy commenting in Vim
Plugin 'tpope/vim-commentary'
" Adds more text objects
Plugin 'wellle/targets.vim'
" Python Folding
Plugin 'tmhedberg/SimpylFold'
" Python Indeting'
Plugin 'vim-scripts/indentpython.vim'
" ### Use sometimes
"Nerdtree provides a file explorer, which is sometimes useful. Mostly ctrlp handles file finding though
Plugin 'scrooloose/nerdtree'
" fugitive provides git bindings in Vim. Don't use too much, but useful for blame
Plugin 'tpope/vim-fugitive'
" Surround is useful for adding surrounding tags to elements (especially html and quotes)
Plugin 'tpope/vim-surround'
" Allows vim-surround to be used with . command
Plugin 'tpope/vim-repeat'
"Adds convenience stuff for writers
Plugin 'reedes/vim-pencil'
"Provide snippets functionality in Vim
Plugin 'SirVer/ultisnips'
"UltiSnip snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
"Standardize whitespace
Plugin 'editorconfig/editorconfig-vim'
"End Vundle
call vundle#end()
"Vundle ended so reenable filetypes
filetype plugin indent on
"Pull in matchit.vim, which is already bundled with Vim
runtime! macros/matchit.vim
" Appearance
" ==========
"Syntax highlighting should be in 256 colors
let python_highlight_all=1
syntax on
syntax enable
set t_Co=256
" Use base-16 for the color scheme, different themes in GUI and terminal
if has('gui_running')
colorscheme solarized
set background=light
set guifont=Source\ Code\ Pro\ For\ Powerline
else
let base16colorspace=256 " Access colors present in 256 colorspace
colorscheme deepsea
endif
" Sanity Config
" ==============================================
set nocompatible " Use vim rather than vi settings
set encoding=utf-8 " standard encoding
set relativenumber " prefer absolute #
set number " Its nice to see line numbers
set backspace=indent,eol,start " Allow backspace in insert mode
set autoread " Reload files changed outside vim
set hidden " Buffers can exist in the background
set history=1000 " Store lots of :cmdline history (its not 1990)
set shellpipe=2>/dev/null> " Don't dump distracting text to terminal during searches!
set re=1 " Use a non-broken regex engine for syntax highlighting
" General Config
" ==============
let mapleader = "\<Space>" " I just use the default Leader
set showcmd " Show incomplete cmds down the bottom
set gcr=a:blinkon0 " Disable cursor blink
set laststatus=2 " Always show status line
set splitright " Opens vertical split right of current window
set splitbelow " Opens horizontal split below current window
set shortmess=filnxtToOI " see :help shortmess
"set t_ti= t_te= " Use a different terminal to run external commands
set shell=bash " Set shell to bash (fish and VIM don't play well together)
" Mouse
" ======
" Send more characters for redraws
set ttyfast
" Enable mouse use in all modes
set mouse=a
" Set this to the name of your terminal that supports mouse codes.
" Must be one of: xterm, xterm2, netterm, dec, jsbterm, pterm
set ttymouse=xterm2
" Search Settings
" ===============
set incsearch " Find the next match as we type the search
set hlsearch " Highlight searches by default
set viminfo='100,f1 " Save up to 100 marks, enable capital marks
" Turn Off Swap Files
" ===================
set noswapfile
set nobackup
set nowritebackup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" Persistent Undo
" ===============
:nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
" Keep undo history across sessions, by storing in file
" Only works in MacVim (gui) mode
if has('gui_running')
set undodir=~/.vim/backups
set undofile
endif
" Indentation and Display
" =======================
" We want to replace tabs with spaces and have 4 space width indentation
set autoindent
set smarttab
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
" Python specific
au BufNewFile,BufRead *.py set textwidth=79 fileformat=unix
set list listchars=tab:\ \ ,trail:· " Display tabs and trailing spaces visually
set nowrap " Don't wrap lines
" Change curser with insert mode
:autocmd InsertEnter * set cul
:autocmd InsertLeave * set nocul
" Folds
" =====
set foldmethod=indent " Fold based on indent
set foldnestmax=3 " Deepest fold is 3 levels
set nofoldenable " Don't fold by default
nnoremap <space> za " Fold/Unfold with space
" Completion
" ==========
"set wildmode=list:longest
set wildmode=longest,list,full
set wildmenu " Enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~ " Stuff to ignore when tab completing
set wildignore+=*vim/backups*
" Scrolling
" =========
" Start scrolling when we're getting close to margins
set scrolloff=20
set sidescrolloff=20
set sidescroll=1
" vimdiff Specific controls
" =========================
if &diff
" Remap change navigation
nmap <c-u> [c
nmap <c-d> ]c
endif
" General remaps
" =============
" Fast quit everything
nmap ZA :qa<CR>
" Custom commands
" ===============
"Let K be the opposite of J
map K i<Enter><Esc>
"\ rr => refresh vimrc
map <leader>rr :source ~/.vimrc<CR>
" Have j and k move down visual likes when pressing, and physical lines with
" count.
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
" Make a commend to enable wrapping
command! -nargs=* Wrap set wrap linebreak nolist
" \ s Make a comand to start a search and replace under cursor
:nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
" \ l redraws the screen and removes any search highlighting.
:nnoremap <Leader>l :nohlsearch<CR>
" Trim trailing whitespace
function! ShowSpaces(...)
let @/='\v(\s+$)|( +\ze\t)'
let oldhlsearch=&hlsearch
if !a:0
let &hlsearch=!&hlsearch
else
let &hlsearch=a:1
end
return oldhlsearch
endfunction
function! TrimSpaces() range
let oldhlsearch=ShowSpaces(1)
execute a:firstline.",".a:lastline."substitute ///gec"
let &hlsearch=oldhlsearch
endfunction
command! -bar -nargs=? ShowSpaces call ShowSpaces(<args>)
command! -bar -nargs=0 -range=% TrimSpaces <line1>,<line2>call TrimSpaces()
"PJ
"
function! PJOpen()
enew
read ! pj
endfunction
function! OpenFile()
let bufferno = bufnr('%')
exe 'edit' . getline('.')
exe 'bw!' . bufferno
endfunction
command! PJOpen call PJOpen()
command! OpenFile call OpenFile()
" Plugin Options
" ==============
" Ag.vim options
let g:ag_working_pathMode="r"
" CTRL+P options
set wildignore+=*/wcui/dist/*
let g:ctrlp_user_command = 'ag %s -i --nocolor --ignore .git --ignore .svn --ignore .hg --ignore .DS_Store --ignore "static" --ignore "**/*.pyc" -g ""'
" Airline options
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
set noshowmode " Let airline handle the mode display
" Timeout faster insert mode
set timeoutlen=1000 ttimeoutlen=0
"Syntastic Options
" let g:syntastic_check_on_open = 1
" map <Leader>e :Errors<cr>
" let g:syntastic_error_symbol = "✗"
" let g:syntastic_warning_symbol = "⚠"
" let g:syntastic_javascript_checkers = ["eslint"]
" SimpylFold Options
let g:SimpylFold_docstring_preview=1
"NerdTree Options
map <c-t> :NERDTreeToggle<CR>
let NERDTreeHijackNetrw=1 "Put Nerdtree into a window
"YouCompleteMe options
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
let g:ycm_key_list_select_completion = ['<TAB>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-E>', '<Up>']
let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
"python with virtualenv support
py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
"jinja config
au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm set ft=jinja
"Utisnips config
"" Trigger configuration. Can't use tab with YouCompleteMe
function! g:UltiSnips_Complete()
call UltiSnips#ExpandSnippet()
if g:ulti_expand_res == 0
if pumvisible()
return "\<C-n>"
else
call UltiSnips#JumpForwards()
if g:ulti_jump_forwards_res == 0
return "\<TAB>"
endif
endif
endif
return ""
endfunction
au BufEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsListSnippets="<c-e>"
" Edit snippets in a split
let g:UltiSnipsEditSplit='vertical'
"Tmux (Doing this again because Neovim thats why)
nnoremap <silent> <ctrl-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <ctrl-l> :TmuxNavigateRight<cr>
"Markdown options
let g:vim_markdown_folding_disabled=1
let g:pencil#wrapModeDefault = 'hard' " or 'soft'
" Pencil Options
augroup pencil
autocmd!
autocmd FileType markdown,mkd call pencil#init({'wrap': 'soft'})
autocmd FileType text call pencil#init({'wrap': 'hard'})
augroup END
nnoremap <silent> <leader>ps :SoftPencil<cr>
nnoremap <silent> <leader>ph :HardPencil<cr>
nnoremap <silent> <leader>pn :NoPencil<cr>
nnoremap <silent> <leader>pt :TogglePencil<cr>
"Treat es6 as js
autocmd BufNewFile,BufRead *.es6 set filetype=javascript
"Typescript
let g:syntastic_typescript_tsc_args ='-t ES5 --module commonjs'
"Tern for es6
"let g:tern#command=['/usr/local/bin/node', '/Users/ben/Code/projects/tern-es6/bin/tern']
" Allow doxygen syntax highlighting
let g:load_doxygen_syntax=1