-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
275 lines (217 loc) · 7.22 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
" ----------------------------------------------------------------------
" NATIVE CONFIG
" ----------------------------------------------------------------------
" Specify that we will use Vim and not vi
set nocompatible
" Set hidden for buffers
set hidden
" Set a global <Leader>
let mapleader = "\<Space>"
" Turn on syntax highlight
syntax on
" Always show sign column for any errors
set signcolumn=yes
" Auto source vim files on save
augroup Reload_vimrc
autocmd!
autocmd BufWritePost *.vim* source $MYVIMRC | echom "Reloaded vim file..."
augroup END
" Show relative numbers with numberWidth = 5
set number
set relativenumber
" Soft tabs
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
" Netrw settings
let g:netrw_banner = 0
let g:netrw_winsize = 25
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
autocmd FileType netrw setl bufhidden=delete
" Es6 files as javascript files
au BufNewFile,BufRead *.es6 set filetype=javascript
" Highlight search results
set hlsearch
" Find next searched item as I type
set incsearch
" Ignore case by default for search
" Search can be made case sensitive by adding \C before text to be searched
set ignorecase
" Smart case search
set smartcase
" Open new split panes to right and bottom
set splitbelow
set splitright
" Re-balance splits on vim resize
autocmd VimResized * :wincmd =
" ----------------------------------------------------------------------
" PLUGINS
" ----------------------------------------------------------------------
" Install
" ----------------------------------------------------------------------
" Auto install Plug
" https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
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
" Resets for plugins
" ----------------------------------------------------------------------
" Ale
" Use Coc for lsp
let g:ale_disable_lsp = 1
" Enable airline for diagnostics
let g:airline#extensions#ale#enabled = 1
" Load plugins
" ----------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox', { 'as': 'gruvbox' }
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
Plug 'joukevandermaas/vim-ember-hbs'
Plug 'vim-airline/vim-airline'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'dense-analysis/ale'
Plug 'jiangmiao/auto-pairs'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-rhubarb'
Plug 'christoomey/vim-tmux-navigator'
Plug 'udalov/kotlin-vim'
Plug 'martinda/Jenkinsfile-vim-syntax'
Plug 'peitalin/vim-jsx-typescript'
Plug 'leafgarland/typescript-vim'
call plug#end()
" ----------------------------------------------------------------------
" PLUGIN CONFIGS
" ----------------------------------------------------------------------
" Tmux navigation
let g:tmux_navigator_no_mappings = 1
" Gruvbox
" ----------------------------------------------------------------------
" Set color themes
set background=dark
let g:gruvbox_contrast_dark='hard'
let g:gruvbox_sign_column='bg0'
colorscheme gruvbox
" Ripgrep via FZF
" ----------------------------------------------------------------------
" CTRL-A CTRL-Q to select all and build quickfix list
" https://github.com/junegunn/fzf.vim/issues/185#issuecomment-322120216
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all'
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden -g "!.git"'
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ "rg --hidden -g \'!*.git\' --column --line-number --no-heading --color=always --smart-case -- ".shellescape(<q-args>), 1,
\ fzf#vim#with_preview(), <bang>0)
" coc.nvim
" ----------------------------------------------------------------------
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=500
" Use tab for trigger completion with characters ahead and navigate.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Ale
" ----------------------------------------------------------------------
" Signs for ale
let g:ale_sign_error = '‣'
let g:ale_sign_warning = '‣'
" Disable all highlights since they add clutter
let g:ale_set_highlights = 0
" ----------------------------------------------------------------------
" MAPPINGS
" ----------------------------------------------------------------------
" Escape out of insert and visual mode with jk or kj
inoremap jk <Esc>
inoremap kj <Esc>
vnoremap jk <Esc>
vnoremap kj <Esc>
"Easier way to enter command mode
nnoremap <leader>; :
" Stop using arrow keys
nnoremap <Left> :echo "No arrow keys"<CR>
nnoremap <Right> :echo "No arrow keys"<CR>
nnoremap <Up> :echo "No arrow keys"<CR>
nnoremap <Down> :echo "No arrow keys"<CR>
" Easier way to save and quit
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
" Clear search highlight
nnoremap <silent> <leader>n :nohls<CR>
" Page down and page up
nnoremap <C-j> <C-f>
nnoremap <C-k> <C-b>
" Netrw settings
nnoremap <leader>f :Vexplore<CR>
" Navigation between splits
nnoremap <leader>j <C-w>j
nnoremap <leader>k <C-w>k
nnoremap <leader>h <C-w>h
nnoremap <leader>l <C-w>l
" Resize splits easily
nnoremap <S-j> mm :resize +10<CR>`mh
nnoremap <S-k> mm :resize -10<CR>`m
nnoremap <S-l> mm :vertical resize -10<CR>`m
nnoremap <S-h> mm :vertical resize +10<CR>`m
" Create new splits
nnoremap <leader>\ :vsp<CR>
nnoremap <leader>- :sp<CR>
" Close other splits
nnoremap <leader>o :only<CR>
" Ripgrep find
nnoremap <C-f> :Rg<space>
" FZF fuzzy find files
nnoremap <leader><leader> :FZF<CR>
" Git status using fugitive
nnoremap gs :Git<CR>
" Git blame using fugitive
nnoremap gb :Git blame<CR>
" Git diff in split using fugitive
nnoremap gd :Gdiff<CR>
" Git log using fugitive
nnoremap gl :Git log<CR>
" Git browse to open github
nnoremap gh :Gbrowse<CR>
vnoremap gh :Gbrowse<CR>
" Copy visually selected text
vnoremap <C-c> :w !pbcopy<CR>
" Paste text from clipboard
nnoremap <C-v> :r !pbpaste<CR>
" Substitute across all quickfix files
nnoremap <Leader>r :cdo %s///ge \| update<C-b><Right><Right><Right><Right><Right><Right><Right>
" Create new tab
nnoremap <C-t> :tabe TAB<CR>
" Delete tab
nnoremap <C-w> :tabc<CR>
" Mappings for tmux navigation with vim
nnoremap <silent> <leader>h :TmuxNavigateLeft<cr>
nnoremap <silent> <leader>j :TmuxNavigateDown<cr>
nnoremap <silent> <leader>k :TmuxNavigateUp<cr>
nnoremap <silent> <leader>l :TmuxNavigateRight<cr>