-
Notifications
You must be signed in to change notification settings - Fork 5
/
.vimrc
318 lines (253 loc) · 8.04 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
" F1 - F12 Hotkeys
" ----------------
" hit F1 to pick a font
map <F1> :set guifont=*<CR>
" hit F2 for file/folder tree
map <F2> :NERDTreeToggle<CR>
" hit F3 for tag bar
map <F3> :Tagbar<CR>
" hit F4 for undo history
map <F4> :GundoToggle<CR>
" hit F5 for syntax highlighting
map <F5> :SyntasticToggleMode<CR>
set nonumber
" hit F6 for line numbers
nnoremap <F6> :set nonumber!<CR>
set nospell
" ** hit F7, F8, F9 for 'prose writing' mode **
" hit F7 for line wrapping
nnoremap <F7> :set wrap nolist linebreak!<CR>
" hit F8 for spell checking
nnoremap <F8> :setlocal nospell! spelllang=en_us<CR>:set mousemodel=popup_setpos<CR>:set spellfile=~/.vim/spell/added.utf-8.add<CR>
" hit F9 for distraction-free writing mode
nnoremap <F9> :Goyo<CR>
" hit F10 in gvim GUI mode to hide menu bar and toolbar
nnoremap <F10> :set guioptions-=m<CR>:set guioptions-=T<CR>
" integrate goyo and limelight.vim
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
" hit F10 for Python style check
autocmd FileType python map <buffer> <F10> :call Flake8()<CR>
" reserve F11 for full-screen at WM level
" hit F12 for quick save
inoremap <F12> <c-o>:w<cr>
nnoremap <F12> :w<cr>
" Other Hotkeys and Shortcuts
" ---------------------------
" leader keys
let mapleader = ","
let maplocalleader = "\\"
" ,,0 to jump to a big font in gVim
" ,,= to set a font with +/- in gVim
let g:fontsize#defaultSize = 26
" :w!! to write a file as sudo
cmap w!! w !sudo tee % >/dev/null
" :cur will open current dir in Nautilus (on Desktop linux)
abbr cur !nautilus %:p:h
" ,l to toggle list mode
nmap <leader>l :set list!<CR>
" ,lt for comma-separated list to bullet point transform
nmap <leader>lt :call ListTrans_toggle_format()<CR>
vmap <leader>lt :call ListTrans_toggle_format('visual')<CR>
" ,cd to change director to current file
nmap <leader>cd :cd %:p:h<CR>:pwd<CR>
" ,md to preview Markdown in browser
nmap <leader>md :LivedownPreview<CR>
" ,q to clear searches and highlights
nmap <leader>q :nohlsearch<CR>
" ,c to clear comments
map <leader>c :s/^\/\/ \\|^-- \\|^> \\|^[#"%!;] //<CR>:nohlsearch<CR>
" multiline commenting tools
map <leader># :s/^/# /<CR>:nohlsearch<CR>
map <leader>/ :s/^/\/\/ /<CR>:nohlsearch<CR>
map <leader>> :s/^/> /<CR>:nohlsearch<CR>
map <leader>" :s/^/\" /<CR>:nohlsearch<CR>
map <leader>% :s/^/% /<CR>:nohlsearch<CR>
map <leader>! :s/^/! /<CR>:nohlsearch<CR>
map <leader>; :s/^/; /<CR>:nohlsearch<CR>
map <leader>- :s/^/-- /<CR>:nohlsearch<CR>
" Configure vim plugins
" ---------------------
" load pathogen for other plugin management
call pathogen#infect()
filetype on
filetype indent plugin on
" default indentation options
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
" fix smartindent's stupidness with '#'
inoremap # X#
" support manpages
runtime! ftplugin/man.vim
" search highlighting
set hls
" autosave before external command
set autowrite
" smarter backspacing
set backspace=indent,eol,start
" extended regular expressions
set magic
" enable console mouse
set mouse=a
" enable status line
set laststatus=2
set ruler
syntax on
" mail files have 72 char limit
autocmd FileType mail set tw=72
" fix backspace mapping
imap <Del> <BS>
map <Del> <BS>
" wildmenu, for console menuing
set wildmenu
set wildmode=longest,full
source $VIMRUNTIME/menu.vim
set cpo-=<
set wcm=<C-Z>
" some color overrides
hi PmenuSel ctermfg=0 ctermbg=3
hi perlComment ctermfg=0 ctermbg=1
" convenience abbreviations
abbr pyimport #!/usr/bin/env python3
abbr pymain def main():<CR>print("Hello World!")<CR><BS><CR>if __name__ == "__main__":<CR>main()<CR><BS>
abbr sysout System.out.println
" get better up/down support
" so that visual line breaks are actually treated like lines
noremap <up> g<up>
noremap <down> g<down>
" vertical splitting when using :Explore
let g:netrw_browse_split=2
" disables annoying audio bell
set vb t_vb=
" Windows-specific settings
" makes vim terminal work (pageup/pagedown for example)
if $OS == "Windows_NT"
set term=cygwin
endif
" gui font
set guifont="Monospace 10"
" prevent annoying close behavior for open buffers
set hidden
set copyindent
set shiftround
set showmatch
set ignorecase
set smartcase
set smarttab
set history=1000
set undolevels=1000
set wildignore=*.swp,*.bak,*.pyc,*.class
set title
set visualbell
set noerrorbells
set nobackup
set noswapfile
set notitle
" fallback color scheme if we don't have colors available
colo desert
" preferred color scheme with colors
if &t_Co >= 256 || has("gui_running")
colo mustang
" disable Background Color Erase (BCE) so that color schemes
" render properly when inside 256-color tmux and GNU screen.
" see also http://snk.tuxfamily.org/log/vim-256color-bce.html
set t_ut=
endif
" enable omnicompletion for Python
"
" TODO: this python3complete.vim autoload script hasn't been
" modified since 2009, and it actually has a bug where imports
" of this style:
"
" from concurrent.futures import (Future, ThreadPoolExecutor, ...)
"
" ... are simply not supported. Might be worth fixing and sending
" upstream. Also, oddly the script is split into two separate
" completion functions, pythoncomplete#Complete (python2) and
" python3complete#Complete (python3), even though there is only
" one vim FileType (python).
autocmd FileType python set omnifunc=python3complete#Complete
" enable omnicompletion for other languages beyond Python
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" TODO: apparently there is a default 'syntax completer' that one
" can set up as a fallback to the above lang-specific ones.
" Add the virtualenv's site-packages to vim path
" show current virtualenv
let g:virtualenv_stl_format='[Venv(%n)]'
au FileType python setlocal statusline=%<%f\ %h%m%r%{VirtualEnvStatusline()}%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
let g:virtualenv_auto_activate=1
" make virtualenv plugin work with pyenv directory
let g:virtualenv_directory = '~/.pyenv/versions'
" open gundo on right (no conflict with NERDTree)
let g:gundo_right=1
let NERDTreeIgnore = ['\.pyc$']
" disable jedi auto init
let g:jedi#auto_initialization = 0
" allow ropevim autocompletion
let ropevim_vim_completion=1
let ropevim_extended_complete=1
" system clipboard
inoremap <C-v> <ESC>"+pa
vnoremap <C-c> "+y
vnoremap <C-d> "+d
" Ctrl+Bksp for delete word
imap <C-BS> <C-W>
" Use the special symbols for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
" Visual blocks can now be dragged around
vmap <expr> h DVB_Drag('left')
vmap <expr> l DVB_Drag('right')
vmap <expr> j DVB_Drag('down')
vmap <expr> k DVB_Drag('up')
vmap <expr> D DVB_Duplicate()
let g:DVB_TrimWS = 1
" make VimClojure work a little more nicely
let g:vimclojure#HighlightBuiltins = 1
let g:vimclojure#ParenRainbow = 1
" make Ctrl-P must faster for git projects
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard --exclude=node_modules/', 'find %s -type f']
let g:ctrlp_use_caching = 0
let g:used_javascript_libs = 'jquery,angularjs'
" backup files
set backupdir=~/.vim/backup/
set directory=~/.vim/backup/
" persistent undo
set undofile
set undodir=~/.vim/undodir/
if filereadable(expand("~/.simplenoterc"))
source ~/.simplenoterc
endif
" markdown live preview
let g:livedown_open = 1
let g:livedown_port = 9337
let g:livedown_browser = "google-chrome"
" help tmux work better with arrow keys
map <Esc>[B <Down>
" help tmux figure out terminal mode
if match($TERM, "screen") != -1
set term=screen-256color
endif
if has('python3')
let g:gundo_prefer_python3 = 1
endif
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_mode_map = {"mode": "passive"}
" add zig support to tagbar
" from: https://github.com/preservim/tagbar/wiki#zig
let g:tagbar_type_zig = {
\ 'ctagstype': 'zig',
\ 'kinds' : [
\'f:functions',
\'s:structs',
\'e:enums',
\'u:unions',
\'E:errors'
\]
\}