-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
312 lines (252 loc) · 10.6 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
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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Line Numbering
set nu
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
imap jk <Esc>
" These redifine existing commands, careful.
map gn :bn<cr>
map gp :bp<cr>
map gd :bd<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Formatting Options
set shiftwidth=4 "set default
set softtabstop=4
set autoindent
set smartindent
set smarttab
set expandtab
set ruler " iTerm needed for showing column,line number
set backspace=2 " Needed for backspace to work properly on OSX/iTerm2
syntax on
filetype plugin indent on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom formatting
" Bash/SH
autocmd FileType sh set softtabstop=2 | set shiftwidth=2 | set expandtab
autocmd FileType yaml set softtabstop=2 | set shiftwidth=2 | set expandtab
autocmd FileType pug set softtabstop=2 | set shiftwidth=2 | set expandtab
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Search Options
"
set magic " search using extended regex
" set incsearch " instant search
set ignorecase " Make search case insensitive
set smartcase " if the search pattern contains upper case letters, then make the search
set hlsearch " Highlight search matches
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Restore cursor to last postion in file """""""""""""""""""""""""""""""""""""""
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tell vim to remember certain things when we exit
"
" " '10 : marks will be remembered for up to 10 previously edited files
" " "100 : will save up to 100 lines for each register
" " :20 : up to 20 lines of command-line history will be remembered
" " % : saves and restores the buffer list
" " n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.vim/viminfo
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mouse Options
" set mouse=a "Enable mouse use in term
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Auto completion
"
"
" Omni Completion
set omnifunc=syntaxcomplete#Complete
" Close doc string buffer after selection, vim 7.4+ only
autocmd CompleteDone * pclose
" Autocomplete with wildchar in command mode
set wildmenu
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set Filetypes
" MarkDown
au BufRead,BufNewFile *.mkdhtml set filetype=markdown
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom Filetype based settings """""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" XML
function Custom_xml()
let g:xml_syntax_folding = 1
set foldmethod=syntax
endfunction
au BufRead,BufNewFile *.xml :call Custom_xml()
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Configure ctags
set tags=tags;
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable inbuilt plugins
runtime macros/matchit.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PATHOGEN AND RELATED PLUGIN SETTINGS
"
" Adding Plugin Pathogen
execute pathogen#infect()
execute pathogen#helptags()
""" Powerline settings
""" Unicode glyphs
set encoding=utf-8 " Necessary to show Unicode glyphs
""" Disable vi-compatibilty
set nocompatible
"" Steps stolen from
"" http://blog.codefront.net/2013/10/27/installing-powerline-on-os-x-homebrew/
"" for OSX
"source /usr/local/lib/python2.7/site-packages/powerline/bindings/vim/plugin/powerline.vim
set laststatus=2 " Always show the statusline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" COLORSCHEME SETTINGS
"
" Set ColorSchemes
" NOTE: Setting this after all the plugins and shii have loaded, because Monokai
" exists in one of added colorscheme plugins
" Default
colorscheme default
set bg=dark
" This fixes some $TERM weirdness when using solarized. The fix is
" to actually find the right $TERM, but I don't know what it is and it's a
" pretty esoteric rabbithole
" set t_Co=16
" colorscheme solarized
" colorscheme gotham256
" Disable background highlighting by colorschemes in transparent/custom
" background term-emulator
" highlight Normal ctermbg=NONE
" This is a lot faster than checking filetype for some reason
"" autocmd BufNewFile,BufRead *.py colorscheme Monokai
"" " Python
"" " See -- http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim
"" autocmd FileType python colorscheme default
"" " Markdown
"" autocmd BufNewFile,BufRead *.mkd colorscheme 256-jungle
"" " Plain Text
"" autocmd BufNewFile,BufRead *.txt colorscheme 256-jungle
"" " LaTeX
"" autocmd BufNewFile,BufRead *.tex colorscheme blacklight
"" " C++
"" autocmd BufNewFile,BufRead *.cpp colorscheme zephyr
"" " C
"" autocmd BufNewFile,BufRead *.c colorscheme zephyr
"" " Headers
"" autocmd BufNewFile,BufRead *.h colorscheme zephyr
""
"" autocmd BufNewFile,BufRead * highlight WS ctermbg=yellow guibg=yellow | match WS /\s\+$/
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" CUSTOM HIGHLIGHT RULES """""""""""""""""""""""""""""""""""""""""""""""""""""
" We use matchadd instead of using match, because match is only matches onej
" group at a time.
" Highlight trailing whitespaces
highlight whitespace ctermbg=red guibg=red
call matchadd('whitespace','\s\+$')
" Highlight log messages
highlight log ctermfg=215 guifg=SandyBrown
call matchadd('log','logg\(er\|ing\)\.\(debug\|info\|warning\|error\)')
" Highlight Python Error messages
highlight pyerr ctermfg=205 guifg=HotPink
call matchadd('pyerr','\w\+Error')
" CUSTOM FUNCTIONS """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Add better word processing
function WordProcessing()
" Turn on UK English spell checker
set spell spelllang=en_gb
" Do not exceed 100 chars in a line
set textwidth=100
endfunction
"
" ack
function CodeProcessing()
set spell spelllang=en_us
set textwidth=80
endfunction
function FlipColors()
set background=light
colorscheme solarized
endfunction
function FixBG()
highlight Normal ctermbg=NONE
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom Mappings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Toggle pastemode
nnoremap <F3> :set paste!<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" airline configuration """"""""""""""""""""""""""""""""""""""""""""""""""""""""
""" let g:airline#extensions#tabline#enabled = 1
""" let g:airline#extensions#tabline#left_sep = ' '
""" let g:airline#extensions#tabline#left_alt_sep = '|'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" syntastic configuration """"""""""""""""""""""""""""""""""""""""""""""""""""""
""" 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_python_checkers = ['pyflakes']
""" let g:syntastic_py_checkers = ['pyflakes']
""" let g:syntastic_check_on_open = 0
""" let g:syntastic_loc_list_height = 5
""" let g:syntastic_enable_highlighting = 0
""" let g:syntastic_mode_map = { 'passive_filetypes': ['go'] }
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" au VimEnter * NERDTree | wincmd l
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pretty Lambdas """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"au VimEnter * syntax keyword Statement lambda conceal cchar=λ
au VimEnter * syntax keyword racketSyntax lambda conceal cchar=λ
au VimEnter * hi! link Conceal racketSyntax
au VimEnter * set conceallevel=2
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Racket Config """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" vim-slime
let g:slime_target = "tmux"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Niji (Rainbow Parenthesis) Config """"""""""""""""""""""""""""""""""""""""""""
"
let g:niji_matching_filetypes = ['lisp', 'racket', 'clojure', 'python']
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Language Server Configuration
set hidden
let g:LanguageClient_serverCommands = {
\ 'cpp': ['clangd', '-index-file=/spare/local/jaisingh/sim/bin/compdb_gen/clangd.dex',],
\ }
function SetLSPShortcuts()
nnoremap <leader>ld :call LanguageClient#textDocument_definition()<CR>
nnoremap <leader>lr :call LanguageClient#textDocument_rename()<CR>
nnoremap <leader>lf :call LanguageClient#textDocument_formatting()<CR>
nnoremap <leader>lt :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap <leader>lx :call LanguageClient#textDocument_references()<CR>
nnoremap <leader>la :call LanguageClient_workspace_applyEdit()<CR>
nnoremap <leader>lc :call LanguageClient#textDocument_completion()<CR>
nnoremap <leader>lh :call LanguageClient#textDocument_hover()<CR>
nnoremap <leader>ls :call LanguageClient_textDocument_documentSymbol()<CR>
nnoremap <leader>lm :call LanguageClient_contextMenu()<CR>
endfunction()
augroup LSP
autocmd!
autocmd FileType cpp,c call SetLSPShortcuts()
autocmd FileType cpp,c set signcolumn=yes
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""