-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
350 lines (237 loc) · 7.56 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
" Section Misc {{{
set laststatus=2
let g:auto_save = 1 " enable AutoSave on Vim startup
let g:auto_save_silent = 1 " do not display the auto-save notification
" }}}
" Section Spaces and Tabs {{{
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set expandtab " tabs are spaces
set shiftwidth=2 " when indenting with '>', use 4 spaces
" }}}
" Section UI Config {{{
set number " show line numbers
set showcmd " show command in bottom bar
set cursorline " highlight current line
filetype indent on " load filetype-specific indent files
set wildmenu " visual autocomplete for command menu
set lazyredraw " redraw only when we need to.
set showmatch " highlight matching [{()}]
" }}}
" Section Searching {{{
set incsearch " search as characters are entered
set hlsearch " highlight matches
" }}}
" Section Folding {{{
set foldenable " enable folding
set foldlevelstart=10 " open most folds by default
set foldnestmax=10 " 10 nested fold max
" space open/closes folds
nnoremap <space> za
set foldmethod=indent " fold based on indent level
" }}}
" Section Movement {{{
" mouse is annoying in this land
set mouse=r
" resize using arrows keys instead
nnoremap <Left> :vertical resize -1<CR>
nnoremap <Right> :vertical resize +1<CR>
nnoremap <Up> :resize -1<CR>
nnoremap <Down> :resize +1<CR>
" Disable arrow keys completely in Insert Mode
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
" move vertically by visual line
nnoremap j gj
nnoremap k gk
" move to beginning/end of line
nnoremap B ^
nnoremap E $
" $/^ doesn't do anything
nnoremap $ <nop>
nnoremap ^ <nop>
" highlight last inserted text
nnoremap gV `[v`]
" }}}
" Section Leader Shortcuts {{{
let mapleader="," " leader is comma
" jk is escape
inoremap jk <esc>
" toggle gundo
nnoremap <leader>u :GundoToggle<CR>
" edit vimrc/fish and load vimrc bindings
nnoremap <leader>ev :vsp $MYVIMRC<CR>
nnoremap <leader>ef :vsp ~/.config/omf/init.fish<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
" save session
nnoremap <leader>s :mksession<CR>
" Vim Indent guide
nnoremap <leader>ig :IndentLinesToggle<CR>
" turn off search highlight
nnoremap <leader><space> :nohlsearch<CR>
" open CtrlP
map <leader>j :CtrlP<CR>
" Vim Grepper shortcuts
" search in entire project
nnoremap <Leader>fp :Grepper<Space>-query<Space>
" search in entire buffer
nnoremap <Leader>fb :Grepper<Space>-buffers<Space>-query<Space>-<Space>
" Toggle paste mode on and off
map <leader>pp :setlocal paste!<cr>
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove<cr>
map <leader>t<leader> :tabnext<cr>
" Fast saving
nmap <leader>w :w!<cr>
map <leader>nn :NERDTreeToggle<cr>
map <leader>nb :NERDTreeFromBookmark
map <leader>nf :NERDTreeFind<cr>
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" remove trailing whitespace
nnoremap <Leader>rtw :%s/\s\+$//e<CR>
" map goyovim
nnoremap <silent> <leader>z :Goyo<cr>
" Copy-Paste
noremap <Leader>y "*y
noremap <Leader>p "*p
noremap <Leader>Y "+y
noremap <Leader>P "+p
" Section goyovim {{{
" goyo vim config
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
"}}}
" Section deoplete {{{
" let g:deoplete#enable_at_startup = 1
" inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
"}}}
" Section ale {{{
let g:ale_fixers = {
\ 'javascript': ['prettier', 'eslint'],
\}
let g:ale_fix_on_save = 1
let g:airline#extensions#ale#enabled = 1
"}}}
" Section CtrlP {{{
" CtrlP settings
let g:ctrlp_match_window = 'bottom,order:ttb'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_working_path_mode = 0
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" }}}
" Section Vim Sneak {{{
" Vim Sneak settings
let g:sneak#s_next = 1
nmap f <Plug>Sneak_f
nmap F <Plug>Sneak_F
xmap f <Plug>Sneak_f
xmap F <Plug>Sneak_F
omap f <Plug>Sneak_f
omap F <Plug>Sneak_F
" }}}
" Section IndentLine {{{
" Vim IndentLine settings
let g:indentLine_enabled = 0
let g:indentLine_char = ">"
" }}}
" Section VimPlug Config {{{
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-easy-align' " everything to do with alignments
Plug 'junegunn/vim-github-dashboard' " shows github events
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " sidebar
Plug 'tpope/vim-fugitive' " git wrapper
Plug 'tpope/vim-surround' " allow operations on surroundings({''}) in pairs
Plug 'tpope/vim-commentary' " comments
Plug 'ctrlpvim/ctrlp.vim', { 'on': 'CtrlP' } " fuzzy finder
Plug 'vim-airline/vim-airline' " status bar
Plug 'vim-airline/vim-airline-themes'
Plug 'junegunn/goyo.vim' " distraction free mode
Plug 'mhinz/vim-grepper' " search in files
Plug 'christoomey/vim-tmux-navigator' " bindings for navigation when launch from tmux
Plug 'nathanaelkane/vim-indent-guides' " indent guides
Plug 'airblade/vim-gitgutter' " shows git diff for each line and other goodies
Plug 'Shougo/denite.nvim' " unite interfaces
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " auto complete
" Plug 'valloric/youcompleteme' " autocomplete
" Plug 'scrooloose/syntastic' " linter
Plug 'w0rp/ale' " linter
Plug 'justinmk/vim-sneak' " efficient moving around
Plug 'Yggdroot/indentLine' " indent guides
Plug '907th/vim-auto-save' " autosave files
Plug 'mattn/emmet-vim/' " html css
Plug 'rizzatti/dash.vim'
Plug 'elixir-editors/vim-elixir'
Plug 'slashmili/alchemist.vim'
" Themes
Plug 'altercation/vim-colors-solarized'
Plug 'dracula/vim'
" Add plugins to &runtimepath
call plug#end()
" }}}
" Section Vim-easy-align {{{
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
"}}}
" Section Vim Airline Config {{{
let g:airline#extensions#tabline#enabled=1
" airline fonts
let g:airline_powerline_fonts = 1
" }}}
" Section Colors and GUI config {{{
syntax enable " enable syntax processing
if has('gui_running')
set guioptions -=m " no menubar
set guioptions -=T " no toolbar
set guioptions -=r " no scrollbar
set lines=60 columns=108 linespace=0
set guifont=Fira\ Code\ 16
else
" awesome colorscheme
set termguicolors
endif
color Dracula
" }}}
" Section Backups {{{
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set backupskip=/tmp/*,/private/tmp/*
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set writebackup
" }}}
" Section Custom Functions {{{
" Arduino status bar info
" my_file.ino [arduino:avr:uno] [arduino:usbtinyisp] (/dev/ttyACM0:9600)
" function! b:MyStatusLine()
" let port = arduino#GetPort()
" let line = '%f [' . g:arduino_board . '] [' . g:arduino_programmer . ']'
" if !empty(port)
" let line = line . ' (' . port . ':' . g:arduino_serial_baud . ')'
" endif
" return line
" endfunction
" setl statusline=%!b:MyStatusLine()
" toggle between number and relativenumber
function! ToggleNumber()
if(&relativenumber == 1)
set norelativenumber
set number
else
set relativenumber
endif
endfunc
" }}}
set foldmethod=marker
set foldlevel=0
set modelines=1
" vim:foldmethod=marker:foldlevel=0