-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
314 lines (247 loc) · 8.37 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
" This must be first, because it changes other options as side effect
set nocompatible
" fix for mac osx copy/paste issue
set clipboard=unnamed
" vim plugins
" -----------------------------------------------------------------
call plug#begin('~/.local/share/nvim/plugged')
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'scrooloose/nerdcommenter'
" color scheme
"Plug 'https://github.com/morhetz/gruvbox'
"Plug 'crusoexia/vim-monokai'
"Plug 'jacoborus/tender'
" colorscheme
"Plug 'w0ng/vim-hybrid'
Plug 'joshdick/onedark.vim'
Plug 'mhartington/oceanic-next'
" git plugin
Plug 'tpope/vim-fugitive'
" rails specific
Plug 'tpope/vim-rails'
Plug 'tpope/vim-haml'
Plug 'slim-template/vim-slim'
" ctrlp - but use ripgrep for doing the actual search
Plug 'https://github.com/ctrlpvim/ctrlp.vim'
" a wrapper for searching and displaying in quickfix window
"Plug 'mileszs/ack.vim'
" make things look nice
Plug 'vim-airline/vim-airline'
" for running tests in separate window
Plug 'janko/vim-test'
"Plug 'vim-test/vim-test'
Plug 'christoomey/vim-tmux-runner'
" maybe replace vim-tmux-runner with https://github.com/kassio/neoterm ??
" seamless vim/tmux navigation
Plug 'christoomey/vim-tmux-navigator'
"Plug 'pechorin/any-jump.vim'
Plug '/usr/local/opt/fzf', { 'do': { -> fzf#install() } }
" syntax highlight requirement for fzf
Plug 'sharkdp/bat'
Plug 'junegunn/fzf.vim'
Plug 'sheerun/vim-polyglot'
"Plug 'mhinz/vim-signify'
Plug 'lewis6991/gitsigns.nvim'
"Plug 'skywind3000/asyncrun.vim'
"Plug 'jgdavey/tslime.vim'
" tig-explorer is slowing down ag.vim. disable for now and just use from
" command line
"Plug 'iberianpig/tig-explorer.vim'
" tig-explorer dependency for neovim
"Plug 'rbgrouleff/bclose.vim'
" Add plugins to &runtimepath
call plug#end()
lua require('gitsigns').setup()
" behavior
" -----------------------------------------------------------------
set hidden " hide buffers instead of closing
set nowrap
set backspace=indent,eol,start " allow backspacing over everything in insert mode
" use incremental search
set incsearch
" ignore case but be smart about it
set ignorecase
set smartcase
filetype plugin indent on
set autoindent
set expandtab
set softtabstop=2
set tabstop=2
set shiftwidth=2
set smarttab
" show ruler
set ru
" show line numbers
set number
set showcmd
" leader key mappings
" -----------------------------------------------------------------
let mapleader = ","
let g:mapleader = ","
" fzf.vim for buffers
map <leader>b :Buffers<CR>
map <leader>p :GFiles<CR>
map <leader>s :nohlsearch<CR>
map <leader>e :TagbarToggle<CR>
" toggle NERDTree
map <leader>d :NERDTreeToggle<CR>
" use ripgrep for search
map <leader>a :Rg<space>
" test runner settings - vim-test which is using vim-tmux-runner (vtr) underneath
let test#strategy = "vtr"
map <leader>vn :TestNearest<CR>
map <leader>vf :TestFile<CR>
map <leader>vs :TestSuite<CR>
map <leader>vl :TestLast<CR>
map <leader>vv :TestVisit<CR>
" vim-tmux-runner settings
map <leader>vx :VtrKillRunner<CR>
map <leader>vo :VtrOpenRunner<CR>
" other key mappings
" -----------------------------------------------------------------
" for navigating split windows easily
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-H> <C-W>h
map <C-L> <C-W>l
" hit space to enter commands in vim
noremap <space> :
" goto next line (useful when linewrap is on)
noremap j gj
noremap k gk
" history / backup
" -----------------------------------------------------------------
" tell vim to keep a backup file
set backup
" tell vim where to put its backup files
set backupdir=~/.vimbackup
" tell vim where to put swap files
set directory=~/.vimswap
set history=1000
" graphics / look and feel / layout
" -----------------------------------------------------------------
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
syn on
syntax enable
let g:onedark_termcolors = 256
"set bg=dark
colorscheme onedark
"colorscheme OceanicNext
"let $BAT_THEME='gruvbox'
" fix neovim popup window color scheme
"hi CocFloating guibg=none guifg=none
hi Quote ctermbg=109 guifg=#83a598
" can't tell if t_Co is working or not
set t_Co=256
" always show statusline, never realized how useful this is
set laststatus=2
" show trailing white spaces
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set list
" auto adjust win height
set winwidth=95
set winminwidth=10
" files / file system
" -----------------------------------------------------------------
" Syntax Highlighting
au BufNewFile,BufRead *.hbs.erb set ft=mustache
au BufNewFile,BufRead *.scss.erb set ft=scss
au FileType python setl sw=4 sts=4 et
" detect jsx
autocmd BufNewFile,BufRead *.jsx let b:jsx_ext_found = 1
autocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx
" plugin specific
" -----------------------------------------------------------------
" don't let fugitive buffers pile up
autocmd BufReadPost fugitive://* set bufhidden=delete
" default fugitive into vertial splits
set diffopt+=vertical
" Customize fzf colors to match your color scheme
" - fzf#wrap translates this to a set of `--color` options
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
let $FZF_DEFAULT_COMMAND='rg --files'
let $FZF_DEFAULT_OPTS="--bind \"ctrl-n:preview-down,ctrl-p:preview-up\""
" fzf.vim - Popup window
let g:fzf_layout = { 'window': { 'width': 0.95, 'height': 0.9, 'highlight': 'Comment' } }
" jsx linting
let g:syntastic_javascript_checkers = ['jsxhint']
let g:syntastic_javascript_jsxhint_exec = 'jsx-jshint-wrapper'
" powerline settings
let g:airline_powerline_fonts = 1
let g:airline_left_sep = ''
let g:airline_right_sep = ''
" taglist plugin
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
let g:tagbar_usearrows = 1
" ignore somd folders from fuzzy search
set wildignore+=bower_components,node_modules,tmp
" CtrlP settings
let g:ctrlp_match_window = 'max:25,results:25'
if executable('rg')
" default ripgrep settings
set grepprg=rg\ -H\ --no-heading\ --vimgrep
set grepformat=%f:%l:%c:%m
" Use rg in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
" rg is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" old CtrlP settings that used Ack
"if executable('ag')
" " Use Ag over ack
" let g:ackprg = 'ag --nocolor --column --vimgrep --nogroup --ignore sorbet --ignore node_modules --ignore log --ignore "./public/stylesheets/*"'
" " Use ag in CtrlP for listing files. Lightning fast, respects .gitignore,
" " ignores hidden files
" "
" let g:ctrlp_user_command = 'ag -Q -l --nocolor -g "" %s'
" " ag is fast enough that CtrlP doesn't need to cache
" let g:ctrlp_use_caching = 0
"endif
" Navigate quickfix list with ease
nnoremap <silent> [q :previous<CR>
nnoremap <silent> ]q :cnext<CR>c
" my unique preferences
" -----------------------------------------------------------------
" insert capybara screenshot
imap <c-l> save_and_open_page
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
cmap <C-P> <C-R>=expand("%:h") . "/" <CR>
" hacks / fixes
" -----------------------------------------------------------------
" Temporary fix for neovim/neovim#2048 - ctrl-h treated as back sp
if has('nvim')
nmap <BS> <C-W>h
endif
" experimental
" -----------------------------------------------------------------
"colorscheme hybrid
" Inserts the start of rspec script
" Command mode: Ctrl+P
"cmap <C-R> <C-R>="map ,t :w \|!clear && rspec --tag r" . expand("%:h") . "/" <CR>
" remove trailing white spaces on :w
" hold off on this - a bit too aggressive
"autocmd BufWritePre * :%s/\s\+$//e