forked from anishathalye/dotfiles_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
257 lines (228 loc) · 9.9 KB
/
vimrc
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
"-----------------------------------------------------------------------------
" PRELIMINARY SETUP
"-----------------------------------------------------------------------------
set shell=/bin/bash " Use bash shell
set nocompatible " Use Vim settings, rather than vi
call plug#begin('~/.vim/plugged') " Use Vim-Plug
"-----------------------------------------------------------------------------
" PLUGINS
"-----------------------------------------------------------------------------
Plug 'tpope/vim-sensible' " Sensible defaults
Plug 'tomtom/tcomment_vim' " Makes commenting easy
Plug 'vim-scripts/Solarized' " Solarized color scheme
Plug 'godlygeek/tabular' " Automatic indent completion
Plug 'kien/ctrlp.vim' " Fuzzy path finder
Plug 'joehanchoi/nerdtree' " Folder management
Plug 'bling/vim-airline' " Airline status bar
Plug 'terryma/vim-multiple-cursors' " Multiple cursors
Plug 'myusuf3/numbers.vim' " Adds smart number lines
Plug 'gregsexton/MatchTag' " Match tags with highlighting
Plug 'Shougo/neocomplete.vim' " Autocompletion
Plug 'sjl/gundo.vim' " Undo tree pane
Plug 'tpope/vim-vinegar' " Avoid project drawer plugin
Plug 'tpope/vim-repeat' " Enable repeating plugin maps with .
Plug 'svermeulen/vim-easyclip' " Simplified clipboard functionality
Plug 'christoomey/vim-tmux-navigator' " Vim and tmux seamless navigation
Plug 'scrooloose/syntastic' " Syntax checker
Plug 'majutsushi/tagbar' " Tag navigation
Plug 'rking/ag.vim' " Keyword searcher
Plug 'tpope/vim-unimpaired' " Paired mapping
Plug 'tpope/vim-surround' " Mappings to change surroundings
Plug 'justinmk/vim-sneak' " Fast text movement
Plug 'joehanchoi/vim-jinja' " Jinja syntax highlighting
Plug 'Yggdroot/indentLine' " Show indentation visually
Plug 'Shougo/neosnippet.vim' " Code snippets
Plug 'hynek/vim-python-pep8-indent' " Correct indentation for Python
Plug 'Raimondi/delimitMate' " Automatic closing of brackets
Plug 'hdima/python-syntax' " Enhanced Python syntax highlighting
Plug 'mustache/vim-mustache-handlebars' " Mustache/Handlebars syntax highlighting
Plug 'joehanchoi/vim-markdown' " Markdown syntax highlighting
Plug 'tpope/vim-fugitive' " Git commands
Plug 'henrik/vim-qargs' " Quickfix to Arglist commands
Plug 'airblade/vim-gitgutter' " Show git diffs in gutter
Plug 'ludovicchabant/vim-gutentags' " Automated tag generation
Plug 'vim-airline/vim-airline-themes' " Airline themes
call plug#end()
"-----------------------------------------------------------------------------
" MAPPINGS
"-----------------------------------------------------------------------------
" Map <Leader> to <Space>
map <Space><Space> <Leader><Leader>
map <Space> <Leader>
" Map marks to 'gm'
nnoremap gm m
"-----------------------------------------------------------------------------
" VIM SETTINGS
"-----------------------------------------------------------------------------
" Ignore case in command mode, but keep search case-sensitive if beginning
" with a capital letter
set ignorecase
set smartcase
" Disable auto-commenting
" autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
"-----------------------------------------------------------------------------
" PLUGIN SPECIFIC SETTINGS
"-----------------------------------------------------------------------------
"--- NEOCOMPLETE -------------------------------------------------------------
" Start neocomplete at startup, disable autocomplete
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#disable_auto_complete = 0
" Smart close popup when backspacing
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" Close Popup with <Enter>
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplete#close_popup() . "\<CR>"
endfunction
" Disable preview window
set completeopt-=preview
"--- GUNDO -------------------------------------------------------------------
" Toggle Gundo with <Leader>gun
map <Leader>gun :GundoToggle<CR>
"--- SYNTASTIC ---------------------------------------------------------------
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_enable_highlighting = 0
let g:syntastic_enable_balloons = 0
" Python chckers
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_python_python_exec = '/usr/local/bin/python3'
"--- TAGBAR ------------------------------------------------------------------
" Add a toggle leader
nnoremap <leader>tag :TagbarToggle<CR>
" Add support for markdown files in tagbar.
let g:tagbar_type_mkd = {
\ 'ctagstype': 'mkd',
\ 'ctagsbin' : '~/.vim/markdown2ctags/markdown2ctags.py',
\ 'ctagsargs' : '-f - --sort=yes',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '|',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0,
\ }
" Focus Tagbar automatically when called
let g:tagbar_autofocus = 1
"--- MULTIPLE CURSORS --------------------------------------------------------
" Compatability with neocomplete
" Called once right before you start selecting multiple cursors
function! Multiple_cursors_before()
if exists(':NeoCompleteLock')==2
exe 'NeoCompleteLock'
endif
endfunction
" Called once only when the multiple selection is canceled (default <Esc>)
function! Multiple_cursors_after()
if exists(':NeoCompleteUnlock')==2
exe 'NeoCompleteUnlock'
endif
endfunction
"--- SNEAK -------------------------------------------------------------------
" Enable streak
let g:sneak#streak = 1
" Enable keys
nmap s <Plug>Sneak_s
nmap S <Plug>Sneak_S
xmap s <Plug>Sneak_s
xmap S <Plug>Sneak_S
" Enable case-insensitive search
let g:sneak#use_ic_scs = 1
" Colors
augroup SneakPluginColors
autocmd!
autocmd ColorScheme * hi SneakPluginTarget ctermfg=235 ctermbg=136
autocmd ColorScheme * hi SneakStreakTarget ctermfg=235 ctermbg=136
autocmd ColorScheme * hi SneakStreakMask ctermfg=136 ctermbg=136
augroup END
"--- NEOSNIPPET --------------------------------------------------------------
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" Tell Neosnippet about the other snippets
let g:neosnippet#snippets_directory='~/.vim/snippets'
" Disable runtime snippets (use custom snippets only)
let g:neosnippet#disable_runtime_snippets = {'_' : 1,}
"--- INDENT-LINE -------------------------------------------------------------
" Color for indent marker
let g:indentLine_color_term = 236
"--- PYTHON-SYNTAX -----------------------------------------------------------
let python_highlight_space_errors = 0
let python_highlight_indent_errors = 0
let python_print_as_function = 0
let python_highlight_all = 1
"--- MARKDOWN-SYNTAX ---------------------------------------------------------
let g:vim_markdown_no_default_key_mappings = 1
"--- FUGITIVE ----------------------------------------------------------------
" Leader aliases for git
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gcm :Gcommit -m ""<Left>
nnoremap <Leader>gaa :Git add -A<CR><CR>
" Amend to last commit
nnoremap <Leader>gca :Git commit --amend --no-edit<CR><CR>
nnoremap <Leader>gd :Gvdiff<CR>
"--- GUTENTAGS ---------------------------------------------------------------
" Change default tag file name
let g:gutentags_tagfile = ".tags"
"--- SURROUND ----------------------------------------------------------------
" Shortcut for bolding text
let b:surround_{char2nr('b')} = "**\r**"
"-----------------------------------------------------------------------------
" USER INTERFACE
"-----------------------------------------------------------------------------
set noeb vb t_vb= " gets rid of beeping
set number " Show line numbers
let g:airline_powerline_fonts=1 " Enable Powerline symbols for Airline
let g:vim_markdown_math=1 " Allow LaTeX math syntax highlighting
let g:solarized_termcolors=16 " correctly colored for terminal vim
set background=dark " required for solarized dark
colorscheme solarized " set color scheme to solarized dark
set nofoldenable " Disable folding
set nowrap " Disable line wrap
set noswapfile " No backups
" Set columncolor bar
autocmd FileType cpp,c,cxx,h,hpp,python,sh,vim,mkd,jinja,html,lua setlocal cc=80
"--- INTEGRATION -------------------------------------------------------------
" Change cursor when in Insert mode
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" Enable mouse anywhere
" set mouse=a
" Enable Vim to use OSX clipboard
set clipboard=unnamed
" Timeout fix for inserting new line above with 'O' - for tmux
set ttimeoutlen=100
" Strip whitespace on save
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()