forked from lentz/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
269 lines (210 loc) · 6.19 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
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" Leader
let mapleader = " "
" Make backspace behave in a sane manner.
set backspace=indent,eol,start
" Save files on focus lost and allow hidden buffers
au FocusLost * :wa
set autowriteall
set autoread
set hidden
" Don't create backup and swap files
set nobackup
set nowritebackup
set noswapfile
" Set hidden characters for list mode
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set list
" Don't wrap lines
set nowrap
" Folding
set foldmethod=indent
set nofoldenable
let g:fzf_history_dir = '~/.fzf-history'
nnoremap <leader>sp :set paste!<CR>
nnoremap <leader>sl :set nonumber!<CR>
nnoremap zx zMzvzazOzz
vnoremap zx zMzvzazOzz
nnoremap zt zt
vnoremap zt zt
nnoremap zz zt
vnoremap zz zt
nnoremap zm zz
vnoremap zm zz
nnoremap zb zb
vnoremap zb zb
" Change tab left
nnoremap gr gT
" Open new tab
nnoremap <C-w>t :tabe<CR>
" Show additional lines when on the last line
set scrolloff=3
set sidescrolloff=5
set display+=lastline
set showcmd
set laststatus=2
:iabbr teh the
nnoremap <leader>vv :tabnew ~/.vimrc<CR>
nnoremap <leader>vr :source ~/.vimrc<CR>
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
" Enable file type detection and do language-dependent indenting.
filetype plugin indent on
" Use 2 spaces for all indentation
set tabstop=2
set shiftwidth=2
set expandtab
set number
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" Always use vertical diffs
" set diffopt+=vertical
set history=1000
set undolevels=1000
" Searching
set ignorecase
set smartcase
set incsearch
set gdefault
set hlsearch
nmap <silent> <leader><leader> :nohlsearch<CR>
nnoremap <tab> %
vnoremap <tab> %
" Key mappings
" Prevent recording when trying to quit
map q <nop>
inoremap jk <Esc>:w<CR>
" Make ctrl+space autocomplete
inoremap <C-Space> <C-p>
nnoremap <C-p> :GFiles<CR>
" this catches <C-Space> in normal mode
nnoremap <NUL> :GFiles<CR>
nnoremap <Leader>ff :GFiles<CR>
" fzf all files
nnoremap <Leader>fa :Files<CR>
" fzf controllers
nnoremap <Leader>fm :GFiles app/controllers<CR>
" fzf models
nnoremap <Leader>fm :GFiles app/models<CR>
" fzf stylesheets
nnoremap <Leader>fs :GFiles app/assets/stylesheets<CR>
" fzf javascripts
nnoremap <Leader>fj :GFiles app/assets/javascripts<CR>
" Find shortcut
nnoremap <Leader>f<space> /
imap <C-@> <C-Space>
" Save and Quit shortcuts
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>wq :wq<CR>
" Run rubocop on current file
nnoremap <leader>r :!rubocop -a %<CR>
" Ggrep whole project for the word under cursor
nnoremap <leader>g :Ggrep '<cword>'<CR>
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Better window manipulation
nnoremap <C-w>e <C-w>=
nnoremap <C-w><C-e> <C-w>=
nnoremap <C-w><C-w> <C-w>_<C-w>\|
" Don't skip over wrapped lines when moving
nnoremap j gj
nnoremap k gk
" nnoremap <Leader>c :Console<CR>
nnoremap <Left> :vertical resize +5<CR>
nnoremap <Right> :vertical resize -5<CR>
nnoremap <Up> :resize +5<CR>
nnoremap <Down> :resize -5<CR>
set wildignore=*/log/*,*/tmp/*
" Color scheme
syntax enable
set background=light
" set color column at 110 and gray
" set colorcolumn=110
" run: ":so $VIMRUNTIME/syntax/colortest.vim" to find all vim colors available
" :hi ColorColumn ctermbg=gray guibg=blue
" Open last file
nnoremap <leader>ll <C-^>
" ctrl-p use git indexing
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
nnoremap <leader>1 :!<space>
nmap <C-_> gcc
vmap <C-_> gcc
" Fugitive shortcuts
nnoremap <leader>G :Git<space>
nnoremap <leader>gst :Git<CR>
nnoremap <leader>gg :Ggrep -i<space>
nnoremap <leader>ag :Ag <space>
nnoremap <leader>gp :Git pull<CR>
nnoremap <leader>gpush :Git push<space>
nnoremap <leader>gls :Commits<CR>
nnoremap <leader>gdr :!clear; git log -p<CR>
nnoremap <leader>gdrf :!clear; git log -p %<CR>
nnoremap <leader>gsh :!clear;git show<space>
nnoremap <leader>ga :!clear;git add -p %<CR>
nnoremap <leader>gci :Git ci<CR>
nnoremap <leader>gca :Git ci --amend<CR>
nnoremap <leader>gcf :Git checkout %<space>
nnoremap <leader>gbr :GBranches<CR>
nnoremap <leader>gcm :Git checkout ma<TAB>
nnoremap <leader>gcl :Git checkout -<CR>
nnoremap <leader>gcb :Git checkout -b<space>
nnoremap <leader>gco :Git checkout<space>
nnoremap <leader>grm :Git rebase origin/master<space>
nnoremap <leader>gri :Git rebase -i HEAD~~~~
nnoremap <leader>gml :Git merge --no-ff -<CR>
nnoremap <leader>gm :Git merge --no-ff<space>
nnoremap <leader>gd<space> :!clear;git diff -w<CR>
nnoremap <leader>gd :!clear;git diff -w<CR>
nnoremap <leader>gdd :!clear;git diff -w<CR>
nnoremap <leader>gdf :!clear;git diff -w %<CR>
nnoremap <leader>gds :!clear;git diff --staged<CR>
nnoremap <leader>gsl :!clear;git stash list<CR>
nnoremap <leader>gsd :!clear;git stash show -p<CR>
nnoremap <leader>gss :!clear;git stash save<space>
nnoremap <leader>gsp :!clear;git stash pop stash@{<space>
" Ale
map <leader>at :ALEToggle<CR>
" Pry
nnoremap <leader>bb obinding.pry<ESC>
nnoremap <leader>BB Obinding.pry<ESC>
"TMux Nav
" let g:tmux_navigator_no_mappings=1
" NERDTree
let g:NERDTreeWinPos = "right"
nnoremap <Leader>nt :NERDTreeToggle<CR>
nnoremap <Leader>nf :NERDTreeFind<CR>
noremap <Leader>foc :Goyo<CR>:SoftPencil<CR>
" keep running glow: while true; do clear; date; echo; echo; echo; glow 2020-06-14-racial-inequality.md; sleep 2; done
nnoremap <Leader>glow :!glow %<CR>
function! QuickfixToggle()
if g:quickfix_is_open
cclose
let g:quickfix_is_open = 0
execute g:quickfix_return_to_window . "wincmd w"
else
let g:quickfix_return_to_window = winnr()
copen
let g:quickfix_is_open = 1
endif
endfunction
au FileType qf call AdjustWindowHeight(3, 30)
function! AdjustWindowHeight(minheight, maxheight)
exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
endfunction
"nnoremap <C-m> <C-w>\| <C-w>_
"nnoremap <C-n> <C-w>=
nnoremap <C-w>t :tabe<CR>
" Local config
if filereadable($HOME . "/.vimrc.local")
source ~/.vimrc.local
endif
set complete+=kspell
autocmd FileType gitcommit,md,markdown setlocal spell