-
Notifications
You must be signed in to change notification settings - Fork 31
/
.vimrc
executable file
·284 lines (236 loc) · 7.38 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
" Vim
" ===
set nocompatible " be iMproved
filetype off " required!
" Install vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/bundle')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
Plug 'airblade/vim-gitgutter'
Plug 'andyl/vim-textobj-elixir'
" Plug 'chriskempson/base16-vim'
Plug 'danielwe/base16-vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'epmatsw/ag.vim'
Plug 'ervandew/supertab'
Plug 'fatih/vim-go'
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
Plug 'gcmt/wildfire.vim'
Plug 'godlygeek/tabular'
Plug 'inside/vim-textobj-jsxattr'
Plug 'jayflo/vim-skip'
Plug 'jparise/vim-graphql'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'junegunn/vim-github-dashboard'
Plug 'justinmk/vim-gtfo'
Plug 'kana/vim-textobj-user'
Plug 'mattn/gist-vim'
Plug 'mattn/webapi-vim'
Plug 'reedes/vim-textobj-sentence'
Plug 'sbdchd/neoformat'
Plug 'scrooloose/nerdtree'
Plug 'sheerun/vim-polyglot'
Plug 'tek/vim-textobj-ruby'
Plug 'tmux-plugins/vim-tmux'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rbenv'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-surround'
Plug 'vim-scripts/L9'
Plug 'vim-scripts/ZoomWin'
Plug 'vim-scripts/gem.vim'
Plug 'w0rp/ale'
Plug 'kristijanhusak/vim-carbon-now-sh'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --go-completer --ts-completer --rust-completer ' }
Plug 'hotoo/jsgf.vim'
Plug 'metakirby5/codi.vim'
Plug 'tpope/vim-scriptease'
Plug 'jxnblk/vim-mdx-js'
Plug 'vimwiki/vimwiki'
call plug#end()
" Per-directory .vimrc files
set exrc
set secure
" Syntax
" ======
syntax on
syntax enable
set t_Co=256
" General Config
" ==============
let mapleader='\'
set gfn=Menlo:h14
set encoding=utf-8
set number " Line numbers are good
set backspace=indent,eol,start " Allow backspace in insert mode
set history=1000 " Store lots of :cmdline history
set showcmd " Show incomplete cmds down the bottom
set showmode " Show current mode down the bottom
set gcr=a:blinkon0 " Disable cursor blink
set autoread " Reload files changed outside vim
set laststatus=2 " Always show status line
set clipboard=unnamed " Use system clipboard
set hidden " Buffers can exist in the background
set splitright " Opens vertical split right of current window
set splitbelow " Opens horizontal split below current window
" Send more characters for redraws
set ttyfast
" Enable mouse use in all modes
set mouse=a
" Set this to the name of your terminal that supports mouse codes.
" Must be one of: xterm, xterm2, netterm, dec, jsbterm, pterm
set ttymouse=xterm2
" Search Settings
" ===============
set incsearch " Find the next match as we type the search
set hlsearch " Hilight searches by default
set viminfo='100,f1 " Save up to 100 marks, enable capital marks
" Turn Off Swap Files
" ===================
set noswapfile
set nobackup
set nowritebackup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" Persistent Undo
" ===============
" Keep undo history across sessions, by storing in file
" Only works in MacVim (gui) mode
if has('gui_running')
set undodir=~/.vim/backups
set undofile
" Hide the toolbar
set guioptions-=T
endif
" Indentation and Display
" =======================
set autoindent
set smartindent
set smarttab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set expandtab
filetype plugin on
filetype indent on
set list listchars=tab:\ \ ,trail:· " Display tabs and trailing spaces visually
set nowrap " Don't wrap lines
set linebreak " Wrap lines at convenient points
" Folds
" =====
set foldmethod=indent " Fold based on indent
set foldnestmax=3 " Deepest fold is 3 levels
set nofoldenable " Don't fold by default
" Completion
" ==========
"set wildmode=list:longest
set wildmode=longest,list,full
set wildmenu " Enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~ " Stuff to ignore when tab completing
set wildignore+=*vim/backups*
" Scrolling
" =========
" Start scrolling when we're getting close to margins
set scrolloff=10
set sidescrolloff=15
set sidescroll=1
" Status Line
" ===========
set statusline= " Override default
set statusline+=%{fugitive#statusline()[4:-2]} " Show fugitive git info
set statusline+=\ %f\ %m\ %r " Show filename/path
set statusline+=%= " Set right-side status info after this line
set statusline+=%l/%L:%v " Set <line number>/<total lines>:<column>
set statusline+=\ " Set ending space
let base16colorspace=256
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
endif
" NERDTree
" ========
function! ShowFileInNERDTree()
if exists("t:NERDTreeBufName")
NERDTreeFind
else
NERDTree
wincmd l
NERDTreeFind
endif
endfunction
map <leader>r :call ShowFileInNERDTree()<cr>
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
let g:NERDTreeIgnore=['node_modules$[[dir]]']
" Git Gutter
" ==========
if exists('&signcolumn') " Vim 7.4.2201
set signcolumn=yes
else
let g:gitgutter_sign_column_always = 1
endif
" GH Dashboard
" ==========
let g:github_dashboard = { 'username': 'pengwynn', 'password': $GITHUB_TOKEN }
" JSX in .js files
" ==========
let g:jsx_ext_required = 0
" Searching
" ==========
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
endif
" Committing
" =========
"
" BufRead seems more appropriate here but for some reason the final `wincmd p` doesn't work if we do that.
autocmd VimEnter COMMIT_EDITMSG call OpenCommitMessageDiff()
function OpenCommitMessageDiff()
" Save the contents of the z register
let old_z = getreg("z")
let old_z_type = getregtype("z")
try
call cursor(1, 0)
let diff_start = search("^diff --git")
if diff_start == 0
" There's no diff in the commit message; generate our own.
let @z = system("git diff --cached -M -C")
else
" Yank diff from the bottom of the commit message into the z register
:.,$yank z
call cursor(1, 0)
endif
" Paste into a new buffer
vnew
normal! V"zP
finally
" Restore the z register
call setreg("z", old_z, old_z_type)
endtry
" Configure the buffer
set filetype=diff noswapfile nomodified readonly
silent file [Changes\ to\ be\ committed]
" Get back to the commit message
wincmd p
endfunction
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }