-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
295 lines (244 loc) · 8.77 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
" <[VIM SETTINGS]>
syntax enable " Enable syntax highlighting
set re=0 " Use new regular expression engine
set hidden " Set hidden buffer behavior
set tabstop=2 " Number of visual spaces per TAB
set softtabstop=2 " Number of spaces in TAB when editing
set shiftwidth=2 " Stop indenting a million spaces!
set expandtab " TABs are spaces
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 absolutely necessary
set showmatch " Highlight matching [{()}]
set foldcolumn=1 " Set the foldcolumn width to 1
set clipboard=unnamed " Use the system clipboard with the unnamed register
set incsearch " Search as characters are entered
set hlsearch " Highlight matches
set ignorecase " Ignore casing for search
set smartcase " Smartcase for search
let mapleader=" " " Set leader key to <space>
" Create and set the swapfile directory
silent !mkdir ~/.vim/swapfiles > /dev/null 2>&1
set directory=~/.vim/swapfiles//
" Create and set the backup directory
silent !mkdir ~/.vim/backup > /dev/null 2>&1
set backupdir=~/.vim/backup//
autocmd VimResized * :wincmd = "automatically rebalance windows on vim resize
" <[VIM BINDINGS]>
" Highlight last inserted text
nnoremap gv `[v`]
" Turn off search highlighting with , + SPACE
nnoremap <leader>/ :nohlsearch<CR>
" Move vertically by visual line
nnoremap j gj
nnoremap k gk
" Zoom a vim pane, <C-w>= to rebalance
nnoremap <leader>- :wincmd _<cr>:wincmd \|<cr>
nnoremap <leader>= :wincmd =<cr>
set backspace=indent,eol,start " Backspace should always work as expected
" Tab bindings
nnoremap <leader>t :tabedit<cr>
nnoremap <leader><Right> :tabn<cr>
nnoremap <leader><Left> :tabp<cr>
" Write and Quit
nnoremap <leader>w :w<cr>
nnoremap <leader>qw :wq<cr>
nnoremap <leader>qq :q!<cr>
" Disable polyglot javascript
let g:polyglot_disabled = ['javascript']
" <[VIM PLUGINS]>
call plug#begin('~/.vim/plugged')
Plug 'sainnhe/gruvbox-material' " Color palettes
Plug 'sheerun/vim-polyglot' " Multiple language packs bundled into one repository
Plug 'christoomey/vim-tmux-navigator' " Vim-Tmux Navigator
Plug 'jelera/vim-javascript-syntax' " Vim Enhanced Javascript Syntax
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " Fuzzy Finder
Plug 'christoomey/vim-tmux-runner' " Vim-Tmux-Runner
Plug 'terryma/vim-multiple-cursors' " Vim-Multiple-Cursors
Plug 'lukaszb/vim-web-indent' " Vim-Web-Indent
Plug 'scrooloose/nerdtree' " Nerdtree
Plug 'dense-analysis/ale' " Vim8 Async Linters
Plug 'scrooloose/nerdcommenter' " Nerd Commenter
Plug 'rking/ag.vim' " The Silver Searcher plugin (requires the_silver_searcher)
Plug 'thoughtbot/vim-rspec' " Vim-Rspec
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Autocompletion
Plug 'vim-ruby/vim-ruby' " Ensure the latest version of vim-ruby
Plug 'artur-shaik/vim-javacomplete2' " JavaComplete2
Plug 'ludovicchabant/vim-gutentags' " Automatic CTags
Plug 'jlanzarotta/bufexplorer' " Buffer Explorer
Plug 'masukomi/vim-markdown-folding' " Foldexpr for markdown files
Plug 'kovisoft/slimv' " Superior Lisp Interaction Mode for Vim
Plug 'luochen1990/rainbow' " Rainbow Parentheses Improved
call plug#end()
" <[PLUGIN SETTINGS]>
" Gruvbox colors settings
if has('termguicolors')
set termguicolors
endif
" Gruvbox Enable True Colors
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
set background=dark
let g:gruvbox_material_disable_italic_comment = 1
let g:gruvbox_material_background = 'hard'
colorscheme gruvbox-material
" Vim-JSX plugin settings
let g:jsx_ext_required = 0 " JSX highlighting in .js files
" FZF settings
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
" Nerdtree plugin settings
" > Open nerdtree when vim starts with no specified file
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " Close vim if nerdtree is the only open window
" Ale settings
let g:ale_sign_error = '✖'
let g:ale_sign_warning = '⚠'
" The Silver Searcher settings
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
endif
" Nerd Commenter settings
let g:NERDSpaceDelims = 1 " Spaces after comment delimiters
let g:NERDCompactSexyComs = 1 " Prettified mult-line comments
let g:NERDDefaultAlign = 'left' " Left-justify comment delimiters
let NERDTreeShowHidden = 1 " Show hidden files and folders
" Vim Rspec settings
let g:rspec_command = "call VtrSendCommand('bundle exec rspec {spec}')"
" Matchit - enable
runtime macros/matchit.vim
" Slimv settings
let g:paredit_electric_return = 0 " Disable electric return
" Buffer Explorer settings
let g:bufExplorerShowRelativePath = 1
" COC settings
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Gutentags status display setting
set statusline+=%{gutentags#statusline()}
let g:gutentags_add_default_project_roots = 0
let g:gutentags_project_root = ['package.json', '.git']
let g:gutentags_cache_dir = expand('~/.cache/vim/ctags/')
command! -nargs=0 GutentagsClearCache call system('rm ' . g:gutentags_cache_dir . '/*')
let g:gutentags_generate_on_new = 1
let g:gutentags_generate_on_missing = 1
let g:gutentags_generate_on_write = 1
let g:gutentags_generate_on_empty_buffer = 0
let g:gutentags_ctags_extra_args = [
\ '--tag-relative=yes',
\ '--fields=+ailmnS',
\ ]
let g:gutentags_ctags_exclude = [
\ '*.git', '*.svg', '*.hg',
\ '*/tests/*',
\ 'build',
\ 'dist',
\ '*sites/*/files/*',
\ 'bin',
\ 'node_modules',
\ 'bower_components',
\ 'cache',
\ 'compiled',
\ 'docs',
\ 'example',
\ 'bundle',
\ 'vendor',
\ '*.md',
\ '*-lock.json',
\ '*.lock',
\ '*bundle*.js',
\ '*build*.js',
\ '.*rc*',
\ '*.json',
\ '*.min.*',
\ '*.map',
\ '*.bak',
\ '*.zip',
\ '*.pyc',
\ '*.class',
\ '*.sln',
\ '*.Master',
\ '*.csproj',
\ '*.tmp',
\ '*.csproj.user',
\ '*.cache',
\ '*.pdb',
\ 'tags*',
\ 'cscope.*',
\ '*.css',
\ '*.less',
\ '*.scss',
\ '*.exe', '*.dll',
\ '*.mp3', '*.ogg', '*.flac',
\ '*.swp', '*.swo',
\ '*.bmp', '*.gif', '*.ico', '*.jpg', '*.png',
\ '*.rar', '*.zip', '*.tar', '*.tar.gz', '*.tar.xz', '*.tar.bz2',
\ '*.pdf', '*.doc', '*.docx', '*.ppt', '*.pptx',
\ ]
" <[PLUGIN BINDINGS]>
" Fuzzy File Finder shortcuts
nnoremap <leader>p :FZF<cr>
nnoremap <leader><S-p> :FZF ~<cr>
" Vim Tmux Runner shortcuts
nnoremap <leader>a :VtrAttachToPane<cr>
nnoremap <leader>s :VtrSendCommand
" Vim tab shortcuts
nnoremap <leader>[ :tabp<cr>
nnoremap <leader>] :tabn<cr>
" nerdtree shortcuts
nnoremap <leader>b :NERDTreeToggle<cr>
nnoremap <leader>n :NERDTreeFind<cr>
" The Silver Searcher shortcuts
nnoremap <leader><S-k> :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
nnoremap <leader>f :Ag
" Vim-Rspec shortcuts
map <Leader>rf :call RunCurrentSpecFile()<CR>
map <Leader>rr :call RunNearestSpec()<CR>
map <Leader>rl :call RunLastSpec()<CR>
map <Leader>ra :call RunAllSpecs()<CR>
" JavaComplete2
autocmd FileType java setlocal omnifunc=javacomplete#Complete
nmap <F5> <Plug>(JavaComplete-Imports-Add)
" Rainbow Parentheses Improved
let g:rainbow_active = 1
" <[CUSTOM FUNCTIONALITY]>
" Write files including parent directories
function! s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
augroup BWCCreateDir
autocmd!
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
augroup END
augroup rubypath
autocmd!
autocmd FileType ruby setlocal suffixesadd+=.rb
augroup END