-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
365 lines (308 loc) · 10.1 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
" START PLUGINS
"
set nocompatible " be iMproved, required
filetype off " required
" Consider migrating from Vundle to vim-plug:
" https://github.com/junegunn/vim-plug
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" YouCompleteMe
" Plugin 'Valloric/YouCompleteMe'
" Surround
Plugin 'tpope/vim-surround'
" Command-T
Plugin 'wincent/command-t'
let g:CommandTPreferredImplementation='lua'
" snipMate
" Plugin 'MarcWeber/vim-addon-mw-utils'
" Plugin 'tomtom/tlib_vim'
" Plugin 'garbas/vim-snipmate'
" vimtex (LaTeX)
" See: https://wikimatze.de/vimtex-the-perfect-tool-for-working-with-tex-and-vim/
Plugin 'lervag/vimtex'
let g:vimtex_view_method = 'zathura'
let g:vimtex_complete_bib_simple = 1
let g:tex_flavor = 'latex'
" Syntastic
Plugin 'vim-syntastic/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_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
" Air-line
Plugin 'vim-airline/vim-airline'
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#buffer_nr_show = 1
" Rainbow CSV
" For better visualization of CSV files
" See: https://github.com/mechatroner/rainbow_csv
" Alternative: https://github.com/chrisbra/csv.vim
Plugin 'mechatroner/rainbow_csv'
let g:disable_rainbow_csv_autodetect = 1 " disable autodetect
" Activate by:
" :set ft=csv
" SympylFold (Python code folding)
" Plugin 'tmhedberg/SimpylFold'
"
" Black (Python linter)
" Plugin 'psf/black'
"
" Linediff
Plugin 'AndrewRadev/linediff.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
" Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"
" END PLUGINS
"
"---------------------------------------------------------------------------------------
"
" sensible.vim from https://github.com/tpope/vim-sensible
" START of sensible.vim
" sensible.vim - Defaults everyone can agree on
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 1.1
if exists('g:loaded_sensible') || &compatible
finish
else
let g:loaded_sensible = 'yes'
endif
if has('autocmd')
filetype plugin indent on
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
" Use :help 'option' to see the documentation for the given option.
set autoindent
set backspace=indent,eol,start
set complete-=i
set smarttab
set nrformats-=octal
if !has('nvim') && &ttimeoutlen == -1
set ttimeout
set ttimeoutlen=100
endif
set incsearch
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif
set laststatus=2
set ruler
set wildmenu
if !&scrolloff
set scrolloff=1
endif
if !&sidescrolloff
set sidescrolloff=5
endif
set display+=lastline
if &encoding ==# 'latin1' && has('gui_running')
set encoding=utf-8
endif
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment character when joining commented lines
endif
if has('path_extra')
setglobal tags-=./tags tags-=./tags; tags^=./tags;
endif
if &shell =~# 'fish$' && (v:version < 704 || v:version == 704 && !has('patch276'))
set shell=/bin/bash
endif
set autoread
if &history < 1000
set history=1000
endif
if &tabpagemax < 50
set tabpagemax=50
endif
if !empty(&viminfo)
set viminfo^=!
endif
set sessionoptions-=options
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^linux\|^Eterm'
set t_Co=16
endif
" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
inoremap <C-U> <C-G>u<C-U>
" vim:set ft=vim et sw=2:
" END of sensible.vim
"---------------------------------------------------------------------------------------
" Colorscheme: elflord
colorscheme elflord
" Colorscheme: slate
" colorscheme slate
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
" Line numbers
set number
" Make search "smartcase"-sensitive: Uppercase is sensitive; lowercase is not
" A search can always be made case-sensitive with \C in the end
" See: https://vim.fandom.com/wiki/Searching
set ignorecase
set smartcase
""" Set Python column limits
" Color column at 88 characters
" See: http://vim.wikia.com/wiki/Automatic_word_wrapping
" See: https://robots.thoughtbot.com/wrap-existing-text-at-80-characters-in-vim
au BufRead,BufNewFile *.py setlocal colorcolumn=88
au BufRead,BufNewFile *.py setlocal textwidth=87
au BufRead,BufNewFile *.py setlocal formatoptions+=t
""" Flag unnecessary whitespaces in Python
" au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
""" Set 2-spaces indent for specific languages (HTML, YAML, TEX, etc.)
au BufRead,BufNewFile *.html,*.yml,*.tex setlocal tabstop=2
au BufRead,BufNewFile *.html,*.yml,*.tex setlocal shiftwidth=2
" map gr to go-to-previous-tab
nmap gr gT
" Allow changing buffer without write
set hidden
" Highlight current line (toggle with \h)
set cursorline
hi CursorLine cterm=NONE ctermbg=Black guibg=Black
:nnoremap <Leader>h :set cursorline!<CR>
"Comment/uncomment with #/'# in Visual mode
vnoremap <silent> # :s/^/# /<cr>:noh<cr>
vnoremap <silent> '# :s/^# //<cr>:noh<cr>
"
" LaTeX comments
au BufRead,BufNewFile *.tex vnoremap <silent> # :s/^/% /<cr>:noh<cr>
au BufRead,BufNewFile *.tex vnoremap <silent> '# :s/^% //<cr>:noh<cr>
" Python: set idbp breakpoint line in register i
" See: https://blog.afoolishmanifesto.com/posts/editing-registers-in-vim-regedit
:let @i='import ipdb; ipdb.set_trace()'
" Folding
set foldmethod=indent
set foldlevel=4
set nofoldenable
" Delete buffer without closing split, setting previously used buffer on the split
:command Bq bp\|bd #
" List contents of the first registers when typing "".
nnoremap <silent> "" :registers "01234/.<CR>
" Mappings to access buffers (don't use '\p' because a
" delay before pressing 'p' would accidentally paste).
" \l : list buffers
" \b \f \g : go back/forward/last-used
" \1 \2 \3 : go to buffer 1/2/3 etc
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>b :bp<CR>
nnoremap <Leader>f :bn<CR>
nnoremap <Leader>g :e#<CR>
nnoremap <Leader>1 :1b<CR>
nnoremap <Leader>2 :2b<CR>
nnoremap <Leader>3 :3b<CR>
nnoremap <Leader>4 :4b<CR>
nnoremap <Leader>5 :5b<CR>
nnoremap <Leader>6 :6b<CR>
nnoremap <Leader>7 :7b<CR>
nnoremap <Leader>8 :8b<CR>
nnoremap <Leader>9 :9b<CR>
nnoremap <Leader>0 :10b<CR>
" Togle paste mode with F3
set pastetoggle=<F3>
" vim as a text-processor
" See: https://www.maketecheasier.com/turn-vim-word-processor/
" See: https://www.linux.com/learn/using-spell-checking-vim
func! TextProcessor()
" movement changes
map j gj
map k gk
" formatting text
setlocal formatoptions=1
setlocal noexpandtab
setlocal wrap
setlocal linebreak
" Disable python colorcolumn
set colorcolumn=0
" spelling and thesaurus
" setlocal spell spelllang=en_us,en_gb
setlocal spell spelllang=en_gb
" setlocal spell spelllang=en_us
set thesaurus+=/home/alex/.vim/thesaurus/mthesaur.txt
" complete+=s makes autocompletion search the thesaurus
set complete+=s
endfu
com! TP call TextProcessor()
" Block of comments in .tex documents: [Visual] Shift+S C
" See: https://two-wrongs.com/custom-surrounding-text-with-surroundvim
let g:surround_67 = "\\begin{comment}\n\r\n\\end{comment}"
" Avoid scrolling when switch buffers
" See: https://vim.fandom.com/wiki/Avoid_scrolling_when_switch_buffers
" Save current view settings on a per-window, per-buffer basis.
function! AutoSaveWinView()
if !exists("w:SavedBufView")
let w:SavedBufView = {}
endif
let w:SavedBufView[bufnr("%")] = winsaveview()
endfunction
" Restore current view settings.
function! AutoRestoreWinView()
let buf = bufnr("%")
if exists("w:SavedBufView") && has_key(w:SavedBufView, buf)
let v = winsaveview()
let atStartOfFile = v.lnum == 1 && v.col == 0
if atStartOfFile && !&diff
call winrestview(w:SavedBufView[buf])
endif
unlet w:SavedBufView[buf]
endif
endfunction
" When switching buffers, preserve window view.
if v:version >= 700
autocmd BufLeave * call AutoSaveWinView()
autocmd BufEnter * call AutoRestoreWinView()
endif
" Avoid scrolling when switch buffers
" Map word count to F4
map <F4> :!wc -m %<CR>