This repository has been archived by the owner on Jun 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
292 lines (237 loc) · 7.64 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
" vim:foldmethod=marker:foldlevel=0
set nocompatible
" Windows {{{
if has('win32') || has('win64')
" on windows add $HOME/.vim and runtimepath
set runtimepath=$HOME/.vim,$VIMRUNTIME,$HOME/.vim/after
endif
" }}}
" Vundle {{{
filetype off
set runtimepath+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
"
" Brief help
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginUpdate
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginList - lists configured plugins
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
Plugin 'jiangmiao/auto-pairs', {'name': 'autopairs'}
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-fugitive', {'name': 'fugitive'}
Plugin 'tpope/vim-repeat', {'name': 'repeat'}
Plugin 'tpope/vim-surround', {'name': 'surround'}
Plugin 'tpope/vim-unimpaired', {'name': 'unimpaired'}
Plugin 'tpope/vim-endwise', {'name': 'endwise'}
Plugin 'alvan/vim-closetag', {'name': 'closetag'}
Plugin 'preservim/tagbar'
Plugin 'chrisbra/Colorizer.git'
Plugin 'othree/html5.vim'
Plugin 'pangloss/vim-javascript', {'name': 'javascript'}
Plugin 'leafgarland/typescript-vim', {'name': 'typescript'}
Plugin 'vim-python/python-syntax', {'name': 'python'}
Plugin 'psf/black'
Plugin 'Vimjas/vim-python-pep8-indent', {'name': 'pep8indent'}
Plugin 'davidhalter/jedi-vim', {'name': 'jedi'}
call vundle#end()
" }}}
" VIM Editor Settings {{{
set encoding=utf-8
set number "unimpaired: *yon*
set norelativenumber "unimpaired: *yor*
set nowrap "unimpaired: *yow*
set linebreak
set nospell "unimpaired: *yos*
set virtualedit= "unimpaired: *yov*
set splitbelow
set splitright
set history=100
set wildmenu
set backspace=indent,eol,start
set scrolloff=8
set title
" searching
set hlsearch "unimpaired: *yoh*
set noincsearch
set ignorecase "unimpaired: *yoi*
set smartcase
" marking
set nolist "unimpaired: *yol*
set listchars=tab:→\ ,nbsp:␣,trail:•,extends:⟩,precedes:⟨
set cursorline "unimpaired: *yoc*
set nocursorcolumn "unimpaired: *you*
set colorcolumn=80,100 " add marker on column 80 and 100
set showmatch
" damn the bell
set noerrorbells
set novisualbell
set t_vb=
" indentation settings
set autoindent
set nosmartindent
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
" colorscheme
set background=dark "unimpaired: *yob*
if (has("termguicolors"))
set termguicolors
endif
try
let g:gruvbox_italic=1
let g:gruvbox_transparent_bg=1
let g:gruvbox_contrast_dark="hard"
let g:gruvbox_contrast_light="hard"
let g:gruvbox_improved_strings=1
let g:gruvbox_improved_warnings=1
let g:gruvbox_invert_selection=1
colorscheme gruvbox
catch
endtry
" syntax configuration
filetype plugin indent on
syntax on
set omnifunc=syntaxcomplete#Complete
" square cursor in mintty
let &t_EI.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_SR.="\e[4 q"
let &t_te.="\e[0 q"
let &t_ti.="\e[1 q"
" enable mouse in mintty
set mouse=a
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
" automatically set working directory to current file
set autochdir
" prevent vim from generating swap and backup files in working directory
set directory=$HOME/.vim/swapfiles//
set backupcopy=yes
" tell vim to remember certain things when we exit
" '100 marks will be remembered for up to 10 previously edited files
" "100 will save up to 100 lines for each register
" :20 up to 20 lines of command-line history will be remembered
" % saves and restores the buffer list
" n... where to save the viminfo files
set viminfo='100,\"100,:20,%,n~/.viminfo
" recursivly go up until home directory to find a tags file
set tags^=tags;~,.git/tags;~
" }}}
" Custom Statusline {{{
set showcmd " display incomplete commands.
set showmode " show the current mode
set laststatus=2
set statusline=""
set statusline+=%f " tail of filename
set statusline+=%m " modified flag '[+]'
set statusline+=\ %y " filetype
set statusline+=\ %r " read only flag '[RO]'
set statusline+=\ %h " help file flag
set statusline+=\ %{fugitive#statusline()}
set statusline+=%= " left/right separator
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
set statusline+=\ %4l/%L:C%-2c%4p%% "78/274:C50 28%
" }}}
" Key Re-Maps {{{
" in normal mode have space alternate folds
nnoremap <space> za
" windowsplit jumper; use ctrl+jkhl to jump between window splits instead of
" ctrl+w jkhl
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" map shift+y to yank to end of line to match shift+c and shift+d
nnoremap Y y$
" map shift+h and shift+l jump to begining and end of line
noremap H ^
noremap L $
" in visual mode < and > shifts indentation and does not clear selection
vnoremap > >gv
vnoremap < <gv
" quick macro to the q registry, use shift+q to play back
nnoremap Q @q
vnoremap Q :normal @q<cr>
" in insert mode ctrl+j inserts a new line at the end of the current line and
" goes to the next line; this allows you to jump to the next line while in
" the middle of text.
" ctrl+; and ctrl+, does the same but also adds a semicolon and comma
inoremap <c-j> <c-o>$<cr>
inoremap <c-;> <c-o>$;<cr>
inoremap <c-,> <c-o>$,<cr>
"------------------------------------------------------------------------------
" Leader Commands
"------------------------------------------------------------------------------
let mapleader = ","
" shortcuts to open and load vimrc
nnoremap <silent> <leader>ve :e $HOME/.vim/vimrc<CR>
nnoremap <silent> <leader>vo :e! $HOME/.vim/vimrc<CR>
nnoremap <silent> <leader>vs :so $HOME/.vim/vimrc<CR>
" 'cd' to the directory containing the file in the buffer
nnoremap <silent> <leader>cd :lcd %:h<CR>
" dump current date after current line, good for appending to log files
nnoremap <silent> <leader>da o<c-r>=strftime("%m/%d/%Y")<CR>
nnoremap <silent> <leader>dt o<c-r>=strftime("%m/%d/%Y %r")<CR>
nnoremap <silent> <leader>di o<c-r>=strftime("%F")<CR>
"------------------------------------------------------------------------------
" Function Keys
"------------------------------------------------------------------------------
" F5 calls make
nnoremap <silent> <F5> :w<cr>:make<cr>
" }}}
" Auto Commands {{{
" automatically restore cursor position
augroup restore_cursor
autocmd!
autocmd BufWinEnter * call RestoreCursor()
augroup END
function! RestoreCursor()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
" Automatically open, but do not go to (if there are errors) the quickfix /
" location list window, or close it when is has become empty.
"
" Note: Must allow nesting of autocmds to enable any customizations for quickfix
" buffers.
" Note: Normally, :cwindow jumps to the quickfix window if the command opens it
" (but not if it's already open). However, as part of the autocmd, this doesn't
" seem to happen.
augroup auto_load_quickfix
autocmd!
autocmd QuickFixCmdPost [^l]* nested botright cwindow
autocmd QuickFixCmdPost l* nested botright lwindow
augroup END
" }}}
" NERDTree {{{
nnoremap <silent> <leader>nt :NERDTreeToggle<cr>
let NERDTreeShowBookmarks=1
let NERDTreeChDirMode=1
let NERDTreeDirArrows=1
let NERDTreeIgnore=[ '\.hi$', '\.o$', '\.sw.$', '\~$', '\.smx$', '\.exe$', '\.beam$', '\~$' ]
let g:NERDTreeDirArrowExpandable="\U25B6"
let g:NERDTreeDirArrowCollapsible="\U25BC"
" }}}
" Tagbar {{{
nnoremap <silent> <leader>tb :TagbarToggle<cr>
" }}}
" Syntastic {{{
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
" }}}