-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
403 lines (349 loc) · 10 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
" vim:fdm=marker
" Basics {{{
set nocompatible
""}}}
" Map Leaders {{{
let mapleader = ","
let maplocalleader = ","
" }}}
" Pathogen {{{
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
execute pathogen#helptags()
" }}}
" Plugins {{{
" UI Improvements {{{
" Use ,u to open Gundo only in normal mode
nnoremap <Leader>u :GundoToggle<CR>
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.crypt = '🔒'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
let g:airline#extensions#tabline#enabled = 1
" }}}
" Misc {{{
augroup init_aliases
autocmd!
" Alias internal :bd to use bufkill's :BD
autocmd VimEnter * :call CmdAlias('bd', 'Bdelete')
augroup END
" }}}
" Startify {{{
let g:startify_custom_header = []
" }}}
" Goyo {{{
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
" }}}
" Gundo {{{
let g:gundo_prefer_python3 = 1
" }}}
" FZF {{{
if filereadable("/usr/local/opt/fzf/README.md")
set rtp+=/usr/local/opt/fzf
endif
if filereadable("/usr/share/doc/fzf/README.Debian")
set rtp+=/usr/share/doc/fzf/examples/
endif
nnoremap <leader>f :Files<cr>
nnoremap <leader>b :Buffers<cr>
" }}}
" }}}
" Colorscheme {{{
let g:base16_shell_path='~/.zsh/3rdparty'
let base16colorspace=256
set background=dark
colorscheme base16-tomorrow-night
syntax on
" }}}
" Basic Options {{{
filetype plugin indent on
set encoding=utf-8
set number
set ruler
set list listchars=tab:▸\ ,eol:¬,trail:·
set showbreak=↪
set autoread
set autowrite
set hidden
set backspace=indent,eol,start
set notitle
set mouse=a
set laststatus=2
set history=1000
" Force myself to keep text skinny.
set nowrap
" Sets the default splitting to be to the bottom and to the right.
set splitbelow
set splitright
set novisualbell "Don't blink please
set noerrorbells "Don't make noise
set showcmd " Show the current command in the status line.
set vb t_vb= "Disable any time of beeping or flashing
" Use the system clipboard by default. So I don't need to specify * +
" registers for every copy and paste action.
set clipboard=unnamed
" Automatically resize splits when the window is resized
augroup basic_options
autocmd!
autocmd VimResized * :wincmd =
augroup END
" Custom dictionary
set spellfile=~/.vim/custom-dictionary.en.utf8.add
" Less delay between escape and normal mode.
set ttimeoutlen=50
" Use DECSCUSR escape codes on iTerm2/xterm to change cursor shape in terminal
" vim. See http://git.io/zvDeWQ for example code.
if !has("gui_running")
" Enter Insert Mode (Cursor Shape: vertical bar)
let &t_SI = "\<Esc>[6 q"
" Leave Insert Mode (Cursor Shape: block)
let &t_EI = "\<Esc>[2 q"
endif
" Enable better matching with '%'
runtime macros/matchit.vim
" Fixes a problem with pathogen and sessions
set sessionoptions-=options
" }}}
" Backups and Undo {{{
set nobackup
set writebackup
set undofile
set undodir=~/.vim/tmp/undo//
set backupdir=~/.vim/tmp/backup//
set directory=~/.vim/tmp/swap//
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
" }}}
" Whitespace {{{
" These are the defaults for whitespae for all of my documents if there are no
" file specific ones set. Normally they are overridden either by a plugin or
" by something in my /.vim/ftplugins directory.
"
" This sets the number of spaces a tab counts for.
set tabstop=2
" This sets the number of spaces a tab counts for during editing. This means
" backspacing indentation will move this value.
set softtabstop=2
" This is the spaces to insert when using indenting functionality. I don't
" know why this is and `softtabstop` exits but they should be equal.
set shiftwidth=2
" No real tab characters only spaces
set expandtab
" This ensures indents are a multiple of `shiftwidth`
set shiftround
set textwidth=80
" Function to remove trailing whitespace from a file, used in autocmds for
" different files.
" Taken from http://vimcasts.org/episodes/tidying-whitespace/
function! <SID>strip_trailing_whitespace()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" }}}
" Highlights {{{
" Highlight the currentline.
set cursorline
" Highlight the column after `textwidth`
set colorcolumn=+1
augroup highlights
autocmd!
" Hide the cursor line when the split is not in focus
autocmd WinLeave * setlocal nocursorline
autocmd WinEnter * setlocal cursorline
" Hide the column line when the split is not in focus
autocmd WinLeave * setlocal colorcolumn=""
autocmd WinEnter * setlocal colorcolumn=+1
augroup END
" }}}
" Searching {{{
set hlsearch "highlight searched text
set incsearch "incremental search
set ignorecase "case InSeNsTiVE
set smartcase "If I do use a captial letter in the search, be case-sensitive
"Clear highlights by doing ,/
nnoremap <silent> <leader>/ :nohlsearch<CR>
" }}}
" Mappings {{{
" I press the `:` key a lot in Vim and I often get typos such as `:W` because
" I have to hold shift. I thus map it to `;`.
nnoremap ; :
" I don't want to lose the functionality of the `;` key so I map that
" behaviour to the `:` key. This also disables the original function of the
" `:` key which forces me to use the `;` key. This is really helpful in fixing
" muscle memory.
nnoremap : ;
" By default `j` and `k` both move in a file by lines delimited by `\n` which
" is not helpful when linewrapping is enabled. These mappings ensure that I
" move up and down by display lines and not just lines delimited by `\n`.
noremap j gj
noremap k gk
" In order to not lose the original functionality of the `j` and `k` keys I
" map their functionality to `gj` and `gk` respectively.
noremap gj j
noremap gk k
" Make Y consistent with C and D. See :help Y.
nnoremap Y y$
" This allows for faster navigation of windows/splits.
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
" }}}
" Wildmenu {{{
set wildmenu
set wildignore+=*.o,.git,*.jpg,*.png,*.swp,*.d,*.gif
set wildignore+=*.zip,*.tar,*.obj,*.class,*.pyc
set wildignore+=.sass-cache/*
" }}}
" Netrw {{{
" Porting https://github.com/vim/vim/issues/4738#issuecomment-798790444
if has('macunix')
function! OpenURLUnderCursor()
let s:uri = expand('<cWORD>')
let s:uri = matchstr(s:uri, "[a-z]*:\/\/[^ >,;)'\"]*")
let s:uri = substitute(s:uri, '#', '\\#', '')
if s:uri != ''
silent exec "!open '".s:uri."'"
:redraw!
endif
endfunction
nnoremap gx :call OpenURLUnderCursor()<CR>
endif
" }}}
" File Type Configurations {{{
" C {{{
augroup ft_c
autocmd!
autocmd FileType c setlocal tabstop=4
autocmd FileType c setlocal softtabstop=4
autocmd FileType c setlocal shiftwidth=4
autocmd FileType c setlocal textwidth=80
autocmd FileType c setlocal smarttab
autocmd FileType c setlocal foldmethod=syntax
autocmd BufWritePre * if &ft == "c" |
\ :call <SID>strip_trailing_whitespace() |
\ endif
augroup END
" }}}
" CPP {{{
" Should be the same as C
augroup ft_cpp
autocmd!
autocmd FileType cpp setlocal tabstop=4
autocmd FileType cpp setlocal softtabstop=4
autocmd FileType cpp setlocal shiftwidth=4
autocmd FileType cpp setlocal textwidth=80
autocmd FileType cpp setlocal smarttab
autocmd FileType cpp setlocal foldmethod=syntax
autocmd BufWritePre * if &ft == "cpp" |
\ :call <SID>strip_trailing_whitespace() |
\ endif
augroup END
" }}}
" TeX {{{
augroup ft_tex
autocmd!
autocmd FileType tex setlocal textwidth=80
autocmd FileType tex setlocal smarttab
autocmd FileType tex setlocal cole=2
autocmd FileType tex setlocal spell
autocmd FileType tex setlocal autoindent
autocmd BufWritePre * if &ft == "tex" |
\ :call <SID>strip_trailing_whitespace() |
\ endif
augroup END
" }}}
" Markdown {{{
augroup ft_markdown
autocmd!
autocmd FileType markdown setlocal spell
autocmd FileType markdown setlocal foldlevel=2
autocmd FileType markdown setlocal autoindent
autocmd BufWritePre * if &ft == "markdown" |
\ :call <SID>strip_trailing_whitespace() |
\ endif
let g:pandoc#formatting#mode = 'hA'
let g:pandoc#toc#position = 'bottom'
let g:pandoc#folding#fold_fenced_codeblocks = 1
let g:pandoc#folding#fastfolds = 1
augroup END
" }}}
" Ruby {{{
augroup ft_ruby
autocmd!
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd BufWritePre * if &ft == "ruby" |
\ :call <SID>strip_trailing_whitespace() |
\ endif
augroup END
" }}}
" Python {{{
augroup ft_python
autocmd!
autocmd FileType python setlocal smarttab
autocmd BufWritePre * if &ft == "python" |
\ :call <SID>strip_trailing_whitespace() |
\ endif
augroup END
" }}}
" Java {{{
augroup ft_java
autocmd!
autocmd FileType java setlocal tabstop=4
autocmd FileType java setlocal softtabstop=4
autocmd FileType java setlocal shiftwidth=4
autocmd FileType java setlocal smarttab
autocmd FileType java setlocal expandtab
autocmd BufWritePre * if &ft == "java" |
\ :call <SID>strip_trailing_whitespace() |
\ endif
augroup END
" }}}
" Man {{{
augroup ft_man
autocmd!
autocmd FileType man setlocal textwidth=0
augroup END
" }}}
let g:vimwiki_folding='syntax'
" VimWiki {{{
augroup ft_vimwiki
autocmd!
autocmd FileType vimwiki setlocal spell
autocmd FileType vimwiki setlocal foldlevel=2
autocmd FileType vimwiki setlocal autoindent
autocmd FileType vimwiki setlocal foldmethod=syntax
augroup END
" }}}
" }}}