-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
453 lines (306 loc) · 12.5 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
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
"vundle
if has('python3')
endif
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" =========[ Powerbar ]======================================================
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'MarcWeber/vim-addon-mw-utils'
" =========[ NERDtree ]======================================================
" "filesystem
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'kien/ctrlp.vim'
"html
" isnowfy only compatible with python not python3
" Plugin 'isnowfy/python-vim-instant-markdown'
" Plugin 'jtratner/vim-flavored-markdown'
" Plugin 'suan/vim-instant-markdown'
" Plugin 'nelstrom/vim-markdown-preview'
" =========[ Fortran ]=======================================================
Plugin 'rudrab/vimf90'
" Linter for fortran and other languages
Plugin 'dense-analysis/ale'
" =========[ Python syntax ]=================================================
Plugin 'nvie/vim-flake8'
Plugin 'vim-scripts/Pydiction'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'scrooloose/syntastic'
Plugin 'tmhedberg/SimpylFold'
"auto-completion stuff
" Plugin 'klen/python-mode'
" Plugin 'Valloric/YouCompleteMe'
" Plugin 'klen/rope-vim'
" Plugin 'davidhalter/jedi-vim'
" Plugin 'ervandew/supertab'
" ==========[ LaTeX related plugins ]==========================================
" A Vim Plugin for Lively Previewing LaTeX PDF Output
" Plugin 'xuhdev/vim-latex-live-preview'
" vimtex for LaTeX and BibTex
Plugin 'lervag/vimtex'
" Plugin 'LaTeX-Suite-aka-Vim-LaTeX'
Plugin 'KeitaNakamura/tex-conceal.vim'
" ==========[ Markdown related plugins ]==========================================
" gfm: github flavored Markdown:'
Plugin 'rhysd/vim-gfm-syntax'
" markdown previewer
Plugin 'JamshedVesuna/vim-markdown-preview'
" ==========[ Snippets ]======================================================
" neosnippets uses deoplete to suggest snippets
" This might be superior to ultisnips
" Plugin 'Shougo/neosnippet.vim'
" Plugin 'Shougo/neosnippet-snippets'
" Ultisnips requires vim installed with python.
" This is just the engine.
" See vim-snippets for the snippets.
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
" ==========[ Damian Conway's Plugins ]=======================================
Plugin 'galli-a/dragvisuals'
Plugin 'galli-a/listtrans'
Plugin 'galli-a/vmath'
" ==========[tpope's Plugins ]================================================
Plugin 'tpope/vim-surround'
"git interface
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-commentary:'
Plugin 'reedes/vim-wordy'
" ==========[ Stan Plugins ]=======================================
Plugin 'eigenfoo/stan-vim'
Plugin 'bioSyntax/bioSyntax-vim'
call vundle#end()
" ===========[ General settings ]============================================
filetype plugin on " enables
filetype plugin indent on " enables filetype detection
let g:SimpylFold_docstring_preview = 1
"autocomplete
let g:ycm_autoclose_preview_window_after_completion=1
"custom keys
" let mapleader=" "
" map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
"
" call togglebg#map("<F5>")
"I don't like swap files
set noswapfile
"python with virtualenv support
" py << EOF
" import os.path
" import sys
" import vim
" if 'VIRTUA_ENV' in os.environ:
" project_base_dir = os.environ['VIRTUAL_ENV']
" sys.path.insert(0, project_base_dir)
" activate_this = os.path.join(project_base_dir,'bin/activate_this.py')
" execfile(activate_this, dict(__file__=activate_this))
" EOF
"it would be nice to set tag files by the active virtualenv here
":set tags=~/mytags "tags for ctags and taglist
"omnicomplete
autocmd FileType python set omnifunc=pythoncomplete#Complete
"------------Start Python PEP 8 stuff----------------
" Number of spaces that a pre-existing tab is equal to.
" au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=4
"spaces for indentss
"au BufNewFile,BufRead *.py set tabstop=4 set softtabstop=4 set shiftwidth=4 set textwidth=79 set expandtab set autoindent set fileformat=unix
" Use the below highlight group when displaying bad whitespace is desired.
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
" Wrap text after a certain number of characters
au BufRead,BufNewFile *.py,*.pyw, set textwidth=100
" Use UNIX (\n) line endings.
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
" Set the default file encoding to UTF-8:
set encoding=utf-8
" For full syntax highlighting:
let python_highlight_all=1
syntax on
" Keep indentation level from previous line:
autocmd FileType python set autoindent
" make backspaces more powerfull
set backspace=indent,eol,start
"Folding based on indentation:
autocmd FileType python set foldmethod=indent
"use space to open folds
nnoremap <space> za
"----------Stop python PEP 8 stuff--------------
" Turn on filetype detection for plugins
filetype plugin on
" ==========[ Fortran Settings ]==============================================
let g:VimF90Leader = "`"
let g:VimF90Linter = 1
" ==========[ YCM ]==========================================================
" Inform vim of the location of pydiction
let g:pydiction_location = '/Users/blaine/.vim/bundle/Pydiction/complete-dict'
" Control height of YCM window.
let g:pydiction_menu_height = 5
" Trigger configuration.
" Turn off tab usage by YCM. It conflicts with UtliSnip.
" let g:ycm_key_list_select_completion=[]
" let g:ycm_key_list_previous_completion=[]
" ==========[ NerDTree settings ]===========================================
" Settings for nerdtree
map <C-E> :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen=1
let NERDTreeShowHidden=1
let NERDTreeIgnore = ['\.pyc$']
" ==========[ Python settings ]==============================================
" Disable virtualenv in Pymode
let g:pymode_virtualenv = 0
" Disable pymode init and lint because of #897
let g:pymode_init = 0
let g:python3_host_prog = expand('/opt/local/bin/python3.7')
" ==========[ UltiSnips related commands ]===================================
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
let g:UltiSnipsSnippetDirectories=['/Users/blaine/.vim/my-snippets/Ultisnips','UltiSnips']
" ==========[ vimtex settings ]==============================================
let g:tex_flavor='latex'
let g:vimtex_view_method='skim'
let g:vimtex_quickfix_mode=0
" Set pdf previewer
let g:livepreview_previewer = 'gv'
" ==========[ Enforce true colors ]===========================================
" let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
let g:solarized_termcolors=256
set background=light " set colorscheme
" colorscheme solarized8_high
" run ./solarized.sh from script file to set true colors
" ==========[ Enable syntax highlighting ]====================================
syntax enable
" enable all Python syntax highlighting features
let python_highlight_all=1
syntax on
" flag unnecessary whitespacei as per PEP8
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
" Need to be using utf-8 with Python3
set encoding=utf-8
" ==========[ Turn on line numbering ]=======================================
set nu " turn on line numbering
" turn hybrid line numbers on
:set number relativenumber
:set nu rnu
" turn hybrid line numbers off
" :set nonumber norelativenumber
" :set nonu nornu
" toggle hybrid line numbers
" :set number! relativenumber!
" :set nu! rnu!
" ==========[ Set line width to 81 columns ]==================================
" OR ELSE just the 81st column of wide lines...
highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%81v', 100)
" ==========[ Visualize the invisible characters ]============================
" Make tabs, trailing whitespace, and non-breaking spaces visible
exec "set listchars=tab:\uBB\uBB,trail:\uB7,nbsp:~"
set list
" ==========[ Formatting of the status line ]=================================
" Automatically displays all buffers when there's only one tab open.
let g:airline#extensions#tabline#enabled = 1
" Define "straight" tabs
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
" Define the path format
let g:airline#extensions#tabline#formatter = 'default'
" ===========[ Autocompletion ]==============================================
set omnifunc=syntaxcomplete#Complete
" ==========[ Spell checking ]================================================
setlocal spell
" turn on spell checking
set spelllang=en_us
" ==========[ Tab spacing ]==================================================
" set tabs to have 4 spaces
set ts=4
" indent when moving to the next line while writing code
set autoindent
" expand tabs into spaces
set expandtab
" when using the >> or << commands, shift lines by 4 spaces
set shiftwidth=4
" show a visual line under the cursor's current line
set cursorline
" show the matching part of the pair for [] {} and ()
set showmatch
" ==========[ Folding ]=======================================================
" Enable folding
set foldmethod=indent
set foldlevel=99
" Enable folding with the spacebar
nnoremap <space> za
" ==========[ Commands to be run on startup ]=================================
" Enables use of :Man <whatever topic>
:runtime! ftplugin/man.vim
" ==========[ The mappings section ]=========================================
" The leader is the backslash. Comma is easier to enter. This is a good of the
" wide line.
:let mapleader = ","
"==========[ Quicker access to Ex commands ]=================================
" swap : and ; to spare yourself the trouble of using shift to go the ex
" command line.
" This idea is from Damian Conway.
" Two nnoremap commands are required.
" nnoremap ; :
" nnoremap : ;
" I found these mappings in Conway's 2019 vimrc
nmap ; :
xmap ; :
"==========[ Enable Nmap command for documented mappings ]====================
" runtime plugin/documap.vim
"=========[ Toggle between lists and bulleted lists ]=========================
" The toggle keys for Damian Conways's listtrans plugin.
" Surprisingly, the recommended toggle uses :l which conflicts with the
" remapping of ; to ;.
nmap lt :call ListTrans_toggle_format()<CR>
xmap lt :call ListTrans_toggle_format('visual')<CR>
" I lifted these mappings from Conway's vimrc file.
" The Namp commend depends on the documap plugin.
" Nmap <silent> ;l [Toggle list format (bullets <-> commas)] :call ListTrans_toggle_format()<CR>f
" xnoremap <silent> ;l :call ListTrans_toggle_format('visual')<CR>f
"=========[ Convert list from plain list into item list ]======================
nmap cl :%s/^/\\item /
"=========[ Toggling out of insert mode ]======================================
" i for insert from normal mode; ii for escape to normal mode
inoremap ii <Esc>
" another means of escape to normal mode
inoremap <C-CR> <Esc>
"=========[ Split windows ]===================================================
set splitbelow
set splitright
"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
"=========[ Drag visual blocks ]==============================================
" mappings for the dragvisuals plugin
vmap <expr> <LEFT> DVB_Drag('left')
vmap <expr> <RIGHT> DVB_Drag('right')
vmap <expr> <DOWN> DVB_Drag('down')
vmap <expr> <UP> DVB_Drag('up')
vmap <expr> D DVB_Duplicate()
"=========[ Vmath ]==========================================================
" Mappings from the vmath plugin by Damian Conway.
" Average, sum, min, max on a column of numbers.
" Type a column of numbers, then use the mappings.
" After the computation is finished, the stats are
" stored in buffers. the sum is available in the default yank buffer,
" and also in the "s buffer. The average is available in the "a buffer,
" the minimum in the "n buffer,
" the maximum in the "x buffer and
" the min-to-max range in the "r buffer.
vmap <expr> ++ VMATH_YankAndAnalyse()
nmap ++ vip++
"=========[ Unwrap sentences to leave one sentence per line ]===================
" https://vi.stackexchange.com/questions/2846/how-to-set-up-vim-to-work-with-one-sentence-per-line
" function! MyFormatExpr(start, end)
" silent execute a:start.','.a:end.'s/[.!?]\zs /\r/g'
" endfunction
" set formatexpr=MyFormatExpr(v:lnum,v:lnum+v:count-1)