-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
350 lines (291 loc) · 8.64 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
" VUNDLE
" =============================================================
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-eunuch'
Plugin 'tpope/vim-ragtag'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-abolish'
Plugin 'vim-ruby/vim-ruby'
Plugin 'mattn/emmet-vim'
Plugin 'rbgrouleff/bclose.vim'
Plugin 'bling/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'jiangmiao/auto-pairs'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'SirVer/ultisnips'
Plugin 'janko-m/vim-test'
Plugin 'kchmck/vim-coffee-script'
Plugin 'pangloss/vim-javascript'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'tomtom/tcomment_vim'
Plugin 'machakann/vim-textobj-delimited'
Plugin 'rizzatti/dash.vim'
Plugin 'gorkunov/smartpairs.vim'
" Test Run
Plugin 'terryma/vim-expand-region'
Plugin 'AndrewRadev/splitjoin.vim'
Plugin 'kien/ctrlp.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'mxw/vim-jsx'
Plugin 'NLKNguyen/papercolor-theme'
Plugin 'kana/vim-textobj-user'
Plugin 'nelstrom/vim-textobj-rubyblock'
Plugin 'ervandew/supertab'
Plugin 'tpope/vim-vinegar'
Plugin 'Valloric/YouCompleteMe'
" Plugin 'Yggdroot/indentLine'
" Colour Themes
Plugin 'joshdick/onedark.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'gosukiwi/vim-atom-dark'
Plugin 'GertjanReynaert/cobalt2-vim-theme'
call vundle#end()
filetype plugin indent on
syntax on
runtime macros/matchit.vim
" =============================================================
" GENERAL SETTINGS
" =============================================================
set backspace=indent,eol,start
set history=1000
set ruler
set showcmd
set autoindent
set showmatch
set nowrap
set autoread
set autowrite
set backupdir=~/.tmp
set directory=~/.tmp
set viminfo+=!
set guioptions-=T
set laststatus=2
set scrolloff=3
set sidescrolloff=4
set hidden
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set relativenumber
set number
set wrap
set linebreak
set hlsearch
set incsearch
set ignorecase
set smartcase
set mouse=a
set shell=bash
set clipboard=unnamed
set winwidth=100
set winheight=5
set winminheight=5
set winheight=999
set noswapfile
set wildmenu
set nostartofline
" (Hopefully) removes the delay when hitting esc in insert mode
set noesckeys
set nocompatible
set ttimeout
set ttimeoutlen=1
set listchars=tab:>-,trail:~,extends:>,precedes:<,space:.
" =============================================================
" AUTOCOMMANDS
" =============================================================
if has("autocmd")
augroup vimrcEx
au!
autocmd BufRead *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
autocmd BufRead,BufNewFile *.asc setfiletype asciidoc
au BufNewFile,BufReadPost *.md set filetype=markdown
augroup END
endif
" =============================================================
" MAPPINGS
" =============================================================
let mapleader = ","
" insert mode
imap <c-e> <esc>A
" Quick open most used files
nnoremap <leader>em :!open -a 'Marked 2.app' '%:p'<cr>
nnoremap <leader>ev :tabnew ~/.vimrc<cr>
nnoremap <leader>es :split<cr>:UltiSnipsEdit<cr>
" UltiSnips
let g:UltiSnipsExpandTrigger="<c-l>"
" create/open file in current folder
map <Leader>ee :e <C-R>=escape(expand("%:p:h"),' ') . '/'<CR>
nnoremap <silent> <space> :nohl<Bar>:echo<CR>
nnoremap <leader>m mzyyp`zj
nnoremap <leader>v :set invpaste paste?<CR>
nnoremap <leader>V V`]
nmap k gk
nmap j gj
nnoremap H ^
nnoremap E $
inoremap <C-n> <C-j>
noremap <Leader>d :Bclose<CR>
noremap <Leader>D :bufdo bd<CR>
cnoremap %% <C-R>=expand("%:p:h") . "/" <CR>
" CtrlP plugin
nnoremap <leader>f :CtrlP<cr>
" nnoremap <leader>w :CtrlP app/assets/javascripts<cr>
nnoremap <leader>. :CtrlPBuffer<cr>
" nnoremap <leader>p :CtrlPClearCache<cr>
" nnoremap <leader>gc :CtrlP app/controllers<cr>
" nnoremap <leader>gv :CtrlP app/views<cr>
" nnoremap <leader>gm :CtrlP app/models<cr>
" nnoremap <leader>gs :CtrlP app/services<cr>
" nnoremap <leader>gr :CtrlP spec<cr>
" nnoremap <leader>gt :CtrlP ~/Dropbox/gollum<cr>
" nnoremap <leader>gp :CtrlP <C-R>=expand("%:p:h") . "/"<cr><cr>
" Command-T
" nnoremap <leader>f :CommandT<cr>
" nnoremap <leader>. :CommandTBuffer<cr>
nnoremap <leader>z :Gstatus<CR><C-w>20+
nnoremap <leader>1 1gt<cr>
nnoremap <leader>2 2gt<cr>
nnoremap <leader>3 3gt<cr>
nnoremap <leader>4 4gt<cr>
" Rails plugin navigation
" nnoremap <leader>gc :Econtroller
" nnoremap <leader>gm :Emodel
" nnoremap <leader>gv :Eview
" nnoremap <leader>gr :Espec
" nnoremap <leader>gj :Ejavascript
" nnoremap <leader>gs :Eservice
" nnoremap <leader>gi :Einitializer
" inc search for range commands
cnoremap $t <CR>:t''<CR>
cnoremap $T <CR>:T''<CR>
cnoremap $m <CR>:m''<CR>
cnoremap $M <CR>:M''<CR>
cnoremap $d <CR>:d<CR>``
" saves cursor after yanking in visual mode
vnoremap y myy`y
vnoremap Y myY`y
" =============================================================
" PLUGINS CONFIGURATION
" =============================================================
" NERDTree
nnoremap <leader>q :NERDTreeToggle<cr>
let NERDTreeMinimalUI=1
let NERDTreeShowLineNumbers=1
" Easymotion
nmap s <Plug>(easymotion-s)
omap s <Plug>(easymotion-bd-t)
vmap s <Plug>(easymotion-bd-t)
" Airline
let g:airline#extensions#tabline#enabled = 0
let g:airline_powerline_fonts = 1
let g:airline_theme='papercolor'
" Markdown
let g:vim_markdown_folding_disabled=1
let g:vim_markdown_fenced_languages = ['html', 'js=javascript', 'ruby']
" CtrlP
let g:ctrlp_working_path_mode='a'
set wildignore+=**/bower_components/*,**/node_modules/*,**/tmp/*,**/assets/images/*,**/assets/fonts/*,**/public/images/*
" vim-test
nmap <silent> <leader>t :TestNearest<CR>
nmap <silent> <leader>T :TestFile<CR>
nmap <silent> <leader>a :TestSuite<CR>
nmap <silent> <leader>l :TestLast<CR>
" let g:test#rspec#executable = 'bin/rspec'
" JSX
let g:jsx_ext_required = 0
let g:javascript_enable_domhtmlcss = 1
let g:used_javascript_libs = 'underscore,react,chai'
" let g:indentLine_noConcealCursor=""
" let g:vim_json_syntax_conceal = 0
" =============================================================
" APPEARENCE
" =============================================================
"set term=xterm
set t_Co=256
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
" Making cursor a bar in insert mode
" let &t_SI = "\<Esc>]50;CursorShape=1\x7"
" let &t_SR = "\<Esc>]50;CursorShape=2\x7"
" let &t_EI = "\<Esc>]50;CursorShape=0\x7"
colorscheme cobalt2
set background=dark
if has("gui_running")
set guifont=Source\ Code\ Pro\ for\ Powerline:h16
set linespace=2
set guioptions-=r
endif
" =============================================================
" PROJECTIONS
" =============================================================
let g:rails_projections = {
\ "app/services/*.rb": {
\ "command": "service",
\ "template":
\ ["class %S", "end"],
\ "test": [
\ "test/unit/%s_uploader_test.rb",
\ "spec/services/%s_spec.rb"
\ ],
\ "keywords": "process version"
\ }}
" =============================================================
" CUSTOM FUNCTIONS
" =============================================================
" Create folders on file save
" ===========================
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
" Remove whitespaces on save saving cursor position
" =================================================
function! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
" set langmap=йцукенгшщзхъфывапролджэячсмитьбю;qwfpgjluy\\;[]arstdhneio'zxcvbkm\\,.
" abbrevs for Star Wars
iabbrev dgre ö
iabbrev dred ó
iabbrev dpur õ
iabbrev dyel ô
iabbrev dfor ÷
iabbrev dbla ñ
iabbrev dblu ò
iabbrev dlig ø
iabbrev ddar ù
iabbrev ddes ú
iabbrev dadv û
iabbrev dfai ý
iabbrev dsuc ÿ
iabbrev dthr ü
iabbrev dtri þ
let @y=':%s/“/"/g'
let @u=':%s/”/"/g'
let @l=':%s/’/''/g'
let @j=':%s/—/-/g'