-
Notifications
You must be signed in to change notification settings - Fork 5
/
vimrc
511 lines (420 loc) · 12.6 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
set nocompatible " be improved, required
filetype off " required
call plug#begin('~/.vim/plugged')
Plug 'gmarik/Vundle.vim'
" Main group
Plug 'Yggdroot/indentLine'
Plug 'nvim-lualine/lualine.nvim'
Plug 'gorodinskiy/vim-coloresque'
Plug 'bruno-/vim-husk'
Plug 'powerman/vim-plugin-ruscmd'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
" Navigation
Plug 'rking/ag.vim'
Plug 'corntrace/bufexplorer'
Plug 'kien/ctrlp.vim'
Plug 'dockyard/vim-easydir'
Plug 'scrooloose/nerdtree'
Plug 'davydovanton/any-jump.vim'
" Snippets
Plug 'tomtom/tlib_vim'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'garbas/vim-snipmate'
" Programming
Plug 'scrooloose/syntastic'
Plug 'vim-scripts/tComment'
Plug 'jbgutierrez/vim-partial'
" Plug 'tpope/vim-rsi'
Plug 'elzr/vim-json'
" Vim text objects
" Markdown
" Plug 'tpope/vim-markdown'
" Color schemes
Plug 'cocopon/iceberg.vim'
Plug 'junegunn/seoul256.vim'
Plug 'robertmeta/nofrils'
" Ruby group
Plug 'tpope/vim-endwise'
Plug 'slim-template/vim-slim'
Plug 'tpope/vim-rails'
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-bundler'
Plug 'sunaku/vim-ruby-minitest'
" tmux group
Plug 'jgdavey/tslime.vim'
Plug 'jpalardy/vim-slime'
" js group
" Plug 'pangloss/vim-javascript'
" elexir group
" Plug 'elixir-lang/vim-elixir'
" coffee group
" Plug 'kchmck/vim-coffee-script'
" crystal group
" Plug 'rhysd/vim-crystal'
" julia group
" Plug 'JuliaLang/julia-vim'
" clojure group
" Plug 'guns/vim-clojure-static'
" Plug 'guns/vim-clojure-highlight'
" Plug 'tpope/vim-fireplace'
" Plug 'kien/rainbow_parentheses.vim'
" Plug 'venantius/vim-eastwood'
" haskell group
" Plug 'eagletmt/ghcmod-vim'
" Plug 'eagletmt/neco-ghc'
" rust group
" Plug 'rust-lang/rust.vim'
" Plug 'racer-rust/vim-racer'
" statistic
" Plug 'wakatime/vim-wakatime'
" Racket group
" Plug 'wlangstroth/vim-racket'
" test plugin functionality
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'kassio/neoterm'
" obsidian
" Plug 'epwalsh/obsidian.nvim'
" Plug 'nvim-lua/plenary.nvim'
" Plug 'hrsh7th/nvim-cmp'
call plug#end()
" Load plugins and indentation for file types
if has('autocmd')
filetype indent plugin on
" Shortcuts to quickly switch to common file types; handy when using
" editing abstractions like sudoedit(8)
nnoremap _cs :setlocal filetype=css<CR>
nnoremap _ht :setlocal filetype=html<CR>
nnoremap _sl :setlocal filetype=slim<CR>
nnoremap _js :setlocal filetype=javascript<CR>
nnoremap _md :setlocal filetype=markdown<CR>
nnoremap _rb :setlocal filetype=ruby<CR>
nnoremap _sh :setlocal filetype=sh<CR>
nnoremap _vi :setlocal filetype=vim<CR>
endif
" Color Scheme
set guifont=Droid\ Sans\ Mono\ 12
" let g:seoul257_background = 236
" colo seoul256
" colo iceberg
colo nofrils-dark
" colo ddd
" Use relative line numbers
if exists("&relativenumber")
set relativenumber
au BufReadPost * set relativenumber
endif
syntax on
set tags=.git/tags
set iskeyword-=. " use dot for limiter word
set iskeyword+=_
set clipboard=unnamed
set ttyfast " u got a fast terminal
set lazyredraw " to avoid scrolling problems
set synmaxcol=200
set mouse=nv
set hidden
set number
set ts=2
set sw=2
set autoindent
set smartindent
set expandtab
set ignorecase
set hlsearch
set splitbelow " new splits are down
set splitright " new vsplits are to the right
set smartcase
set incsearch
set laststatus=2
set visualbell
set showcmd
set pastetoggle=
set iminsert=0
set linebreak
set completeopt=longest,menuone
set wildmenu
set noerrorbells
set novisualbell
set t_vb=
set t_ut=
set tm=500
set nobackup
set nowb
set noswapfile
set timeoutlen=500
set langmenu=en_US.UTF-8
set encoding=utf-8
set fileencoding=utf-8
set shm+=I " Startup message is irritating
set dictionary=/usr/share/dict/words
" fold values
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=2
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set notimeout
set ttimeout
set ttimeoutlen=10
if executable('zsh')
set shell=zsh
endif
language mes en_US.UTF-8
let g:markdown_fenced_languages = ['javascript', 'ruby', 'sh', 'yaml', 'javascript', 'html', 'vim', 'coffee', 'json', 'diff']
let g:tube_terminal = "iterm"
let g:ruby_path = system('rvm current')
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#branch#empty_message = ''
let g:airline#extensions#syntastic#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_close_button = 0
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#left_sep = '|'
let g:airline#extensions#tabline#show_buffers = 0
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_theme = 'lucius'
let g:bufExplorerDefaultHelp=0
let g:bufExplorerShowRelativePath=1
let g:bufExplorerSortBy='mru'
let g:bufExplorerSplitRight=0
let g:indentLine_color_term = 239
let g:indentLine_char = '¦'
let g:ruby_indent_access_modifier_style = 'outdent'
let ruby_operators = 1
let g:surround_{char2nr('%')} = "%(\r)"
let g:surround_{char2nr('w')} = "%w(\r)"
let g:surround_{char2nr('#')} = "#{\r}"
let g:surround_{char2nr('|')} = "|\r|"
let g:syntastic_enable_signs = 1
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚠'
let g:syntastic_disabled_filetypes = ['html', 'slim', 'erb', 'md']
" change log settings
let g:changelog_dateformat = "%c"
let g:changelog_timeformat = "%c"
let g:changelog_username = "Anton Davydov, <antondavydov.o@gmail.com>"
" vim-slime
let g:slime_target = 'tmux'
" vim rust
" let g:racer_cmd = "<path-to-racer>/target/release/racer"
" let $RUST_SRC_PATH="<path-to-rust-srcdir>/src/"
" fix copy full string command, source: https://www.reddit.com/r/neovim/comments/petq61/neovim_060_y_not_yanking_line_but_to_end_of_line/
nnoremap Y Y
" Disable Ex mode
map Q <Nop>
nmap <space> <leader>
vmap <space> <leader>
nmap <leader>n :noh<CR>
nnoremap <F1> <nop>
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap gj j
nnoremap gk k
vnoremap gj j
vnoremap gk k
" Quicker window movement
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" experimental mappings------------
nnoremap <tab> >>
nnoremap <s-tab> <<
vnoremap <tab> >
vnoremap <s-tab> <
nnoremap th :tabfirst<CR>
nnoremap tj :tabprev<CR>
nnoremap tk :tabnext<CR>
nnoremap tl :tablast<CR>
nnoremap td :tabclose<CR>
nnoremap tn :tabnew<CR>
nnoremap Q <nop>
nnoremap K <nop>
nmap <leader>o o<ESC>
nmap <leader>O O<ESC>j
nmap <leader>< <C-w>10<
nmap <leader>> <C-w>10>
nmap <leader>+ <C-w>10+
nmap <leader>- <C-w>10-
nmap <leader>p :CtrlPBufTag<CR>
nmap <leader>hh :%s/:\([^ ]*\)\(\s*\)=>/\1:/g<CR>
" Replace mapping
nmap <leader>; :%s:::g<Left><Left><Left>
nmap <leader>;; :%s:::g<Left><Left>
" vim-partial
vmap <Leader>x :PartialExtract<cr>
" ruby xmpfilter
autocmd FileType ruby nmap <buffer> <F5> <Plug>(xmpfilter-mark)
autocmd FileType ruby xmap <buffer> <F5> <Plug>(xmpfilter-mark)
autocmd FileType ruby imap <buffer> <F5> <Plug>(xmpfilter-mark)
autocmd FileType ruby nmap <buffer> <F4> <Plug>(xmpfilter-run)
autocmd FileType ruby xmap <buffer> <F4> <Plug>(xmpfilter-run)
autocmd FileType ruby imap <buffer> <F4> <Plug>(xmpfilter-run)
let g:rct_completion_use_fri = 1
" NERDTree plugin
nmap <F2> :NERDTree<cr>
cabbrev CSScomb :!csscomb %:p<CR>
cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
" --------------------------------------
" lualine.nvim plugin
lua << END
require('lualine').setup {
options = {
icons_enabled = false,
theme = 'seoul256',
component_separators = { left = ':', right = ':'},
section_separators = { left = ' ', right = ' '},
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {'nvim-tree'}
}
END
" obsidian.nvim plugin
lua << END
require('obsidian').setup {
}
END
" --------------------------------------
" bind K to grep word under cursor
nnoremap <leader>f :grep! "\b<C-R><C-W>\b" --ignore-dir log<CR>:cw<CR>
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
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
else
" Fall back to using git ls-files if Ag is not available
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others']
endif
function! ClearRegisters()
let regs='abcdefghijklmnopqrstuvwxyz0123456789'
let i=0
while (i<strlen(regs))
exec 'let @'.regs[i].'=""'
let i=i+1
endwhile
endfunction
command! ClearRegisters call ClearRegisters()
" Strip trailing whitespace (,ss)
function! StripWhitespace()
let save_cursor = getpos(".")
let old_query = getreg('/')
:%s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfunction
noremap <leader>ss :call StripWhitespace()<CR>
" rename current file (thanks Gary Bernhardt)
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
command! RENAME call RenameFile()
" change CamlCase to under_scores
function! ToUnderScores() range
s#\C\(\<\u[a-z0-9]\+\|[a-z0-9]\+\)\(\u\)#\l\1_\l\2#g
endfunction
noremap <leader>cc :call ToUnderScores()<CR>
" change under_scores to CamlCase
function! ToCamlCase() range
s#\(\%(\<\l\+\)\%(_\)\@=\)\|_\(\l\)#\u\1\2#g
endfunction
noremap <leader>cC :call ToCamlCase()<CR>
" Automatic commands
if has("autocmd")
" Enable file type detection
filetype on
" Treat .json files as .js
autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
autocmd BufNewFile,BufRead *.md set filetype=markdown
endif
autocmd FileType ruby compiler ruby
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd Filetype gitcommit setlocal spell textwidth=72
au BufNewFile,BufRead,BufWrite *.md syntax match Comment /\%^---\_.\{-}---$/
" Turn on spell-checking in markdown and text.
" au BufRead,BufNewFile *.md,*.txt setlocal spell
" Neovim confixg
if has('nvim')
" let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
tnoremap <Esc> <c-\><c-n>
tnoremap <C-[> <c-\><c-n>
highlight TermCursor ctermfg=red guifg=red
endif
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
autocmd BufWritePost * set iskeyword-=.
autocmd BufWritePost * set clipboard=unnamed
autocmd BufWritePost * set path+=**
set iskeyword-=. " use dot for limiter word
set iskeyword+=_
set path+=**
set clipboard=unnamed
"------------- any-jump.vim ------------------------------
let g:any_jump_search_prefered_engine = 'ag'
let g:any_jump_grouping_enabled = 0
let g:any_jump_preview_lines_count = 10
let g:any_jump_window_width_ratio = 0.7
let g:any_jump_ignored_files = ['*.tmp', '*.temp', '*.log']
" Or override all default colors
let g:any_jump_colors = {
\"plain_text": "Normal",
\"preview": "Operator",
\"preview_keyword": "Directory",
\"heading_text": "StatusLineNC",
\"heading_keyword": "StatusLineNC",
\"group_text": "Operator",
\"group_name": "ErrorMsg",
\"more_button": "Operator",
\"more_explain": "Operator",
\"result_line_number": "ErrorMsg",
\"result_text": "Statement",
\"result_path": "ErrorMsg",
\"help": "StatusLineNC"
\}
"------------- neoterm ------------------------------
" Send selected contents in visual mode.
xmap ts <Plug>(neoterm-repl-send)
nmap ts <Plug>(neoterm-repl-send-line)