-
Notifications
You must be signed in to change notification settings - Fork 9
/
vimrc
240 lines (203 loc) · 5.09 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
" Use space as leader key
nnoremap <space> <nop>
let g:mapleader = "\<space>"
" Add personal files to runtimepath
set runtimepath^=~/.vim/personal
" {{{1 Autocommands
augroup vimrc_autocommands
autocmd!
" Only use cursorline for current window, except when in diff mode
autocmd WinEnter,FocusGained * if !&diff | setlocal cursorline | endif
autocmd WinLeave,FocusLost * if !&diff | setlocal nocursorline | endif
autocmd OptionSet diff call personal#init#toggle_diff()
" When editing a file, always jump to the last known cursor position.
autocmd BufReadPost * call personal#init#go_to_last_known_position()
" Set keymapping for command window
autocmd CmdwinEnter * nnoremap <buffer> q <c-c><c-c>
autocmd CmdwinEnter * nnoremap <buffer> <c-f> <c-c>
augroup END
" {{{1 Options
set history=10000
set nrformats-=octal
if has('patch-7.4.399')
set cryptmethod=blowfish2
else
set cryptmethod=blowfish
endif
set autoread
set backspace=indent,eol,start
set wildmenu
set laststatus=2
set autoindent
set incsearch
set viminfo='300,<100,s300,h
" Basic
set tags=tags;~,.tags;~
set path=.,,
if &modifiable
set fileformat=unix
endif
set wildignore=*.o
set wildignore+=*~
set wildignore+=*.pyc
set wildignore+=.git/*
set wildignore+=.hg/*
set wildignore+=.svn/*
set wildignore+=*.DS_Store
set wildignore+=CVS/*
set wildignore+=*.mod
set diffopt=filler,vertical,foldcolumn:0,context:4
silent! set diffopt+=indent-heuristic,algorithm:patience
silent! set diffopt+=hiddenoff
" Backup, swap and undofile
set noswapfile
set undofile
set undodir=$HOME/.cache/vim/undo
set backup
set backupdir=$HOME/.cache/vim/backup
if !isdirectory(&undodir)
call mkdir(&undodir, 'p')
endif
if !isdirectory(&backupdir)
call mkdir(&backupdir, 'p')
endif
" Behaviour
set autochdir
set lazyredraw
set confirm
set hidden
set shortmess=aoOtT
silent! set shortmess+=cI
set textwidth=79
set nowrap
set linebreak
set comments=n:>
set nojoinspaces
set formatoptions+=ronl1j
set formatlistpat=^\\s*[-*]\\s\\+
set formatlistpat+=\\\|^\\s*(\\(\\d\\+\\\|[a-z]\\))\\s\\+
set formatlistpat+=\\\|^\\s*\\(\\d\\+\\\|[a-z]\\)[:).]\\s\\+
set winaltkeys=no
set mouse=
set gdefault
set updatetime=500
" Completion
set wildmode=longest:full,full
set wildcharm=<c-z>
set complete+=U,s,k,kspell,]
set completeopt=menuone
silent! set completeopt+=noinsert,noselect
silent! set pumwidth=35
" Presentation
set list
set listchars=tab:▸\ ,nbsp:␣,trail:\ ,extends:…,precedes:…
set fillchars=vert:│,fold:\ ,diff:⣿
set matchtime=2
set matchpairs+=<:>
if !&diff
set cursorline
endif
set scrolloff=5
set splitbelow
set splitright
set previewheight=20
set noshowmode
if !has('gui_running')
set visualbell
set t_vb=
endif
" Folding
set foldlevelstart=0
set foldcolumn=0
set foldtext=personal#fold#foldtext()
" Indentation
set softtabstop=-1
set shiftwidth=2
set expandtab
set copyindent
set preserveindent
silent! set breakindent
" Searching and movement
set nostartofline
set ignorecase
set smartcase
set infercase
set showmatch
set tagcase=match
set display=lastline
set virtualedit=block
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
elseif executable('ack-grep')
set grepprg=ack-grep\ --nocolor
endif
" Printing
set printexpr=personal#print_file(v:fname_in)
" {{{1 Appearance and UI
set winwidth=70
if has('termguicolors')
set termguicolors
endif
silent! colorscheme my_solarized
call personal#init#cursor()
call personal#init#statusline()
" {{{1 Mappings
" Disable some mappings
noremap <f1> <nop>
inoremap <f1> <nop>
nnoremap Q <nop>
" Some general/standard remappings
inoremap jk <esc>
nnoremap Y y$
nnoremap J mzJ`z
nnoremap dp dp]c
nnoremap do do]c
nnoremap ' `
nnoremap <c-e> <c-^>
nnoremap <c-w><c-e> <c-w><c-^>
nnoremap <expr> j v:count ? 'j' : 'gj'
nnoremap <expr> k v:count ? 'k' : 'gk'
xnoremap <expr> j v:count ? 'j' : 'gj'
xnoremap <expr> k v:count ? 'k' : 'gk'
nnoremap gV `[V`]
nnoremap <c-w>- <c-w>s
nnoremap <c-w><bar> <c-w>v
" Buffer navigation
nnoremap <silent> gb :bnext<cr>
nnoremap <silent> gB :bprevious<cr>
" Navigate folds
nnoremap zv zMzvzz
nnoremap <silent> zj zcjzOzz
nnoremap <silent> zk zckzOzz
" Backspace and return for improved navigation
nnoremap <bs> <c-o>zvzz
" Shortcuts for some files
nnoremap <silent> <leader>ev :execute 'edit' resolve($MYVIMRC)<cr>
nnoremap <silent> <leader>xv :source $MYVIMRC<cr>
nnoremap <leader>ez :edit ~/.zshrc<cr>
nnoremap <leader>pp :hardcopy<cr>
xnoremap <leader>pp :hardcopy<cr>
" Terminal mappings
tnoremap <esc> <c-\><c-n>
nnoremap <silent> <c-c><c-c> :terminal<cr>
" Utility maps for repeatable quickly change/delete current word
nnoremap c* *``cgn
nnoremap c# *``cgN
nnoremap cg* g*``cgn
nnoremap cg# g*``cgN
nnoremap d* *``dgn
nnoremap d# *``dgN
nnoremap dg* g*``dgn
nnoremap dg# g*``dgN
" {{{1 Configure plugins
" Disable a lot of unnecessary internal plugins
let g:loaded_2html_plugin = 1
let g:loaded_getscriptPlugin = 1
let g:loaded_gzip = 1
let g:loaded_logipat = 1
let g:loaded_rrhelper = 1
let g:loaded_spellfile_plugin = 1
let g:loaded_tarPlugin = 1
let g:loaded_vimballPlugin = 1
let g:loaded_zipPlugin = 1
" }}}1