-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_vimrc
276 lines (220 loc) · 10.5 KB
/
dot_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
set shell=/bin/sh " ensure fish term is off
set nocompatible " be iMproved, required
filetype off " required
"Set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"Bundles
"------------------------------------------------------------------------------
Plugin 'Raimondi/delimitMate'
Plugin 'Yggdroot/indentLine'
Plugin 'airblade/vim-gitgutter'
Plugin 'bling/vim-airline.git'
Plugin 'digitaltoad/vim-jade'
Plugin 'flazz/vim-colorschemes'
Plugin 'gmarik/Vundle.vim'
Plugin 'godlygeek/tabular'
Plugin 'heavenshell/vim-jsdoc'
Plugin 'kchmck/vim-coffee-script'
Plugin 'kien/ctrlp.vim'
Plugin 'lfilho/cosco.vim'
Plugin 'rking/ag.vim'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'rstacruz/sparkup'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic.git'
Plugin 'slim-template/vim-slim'
Plugin 'tomasr/molokai'
Plugin 'tpope/vim-commentary.git'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-haml'
Plugin 'tpope/vim-surround.git'
Plugin 'vim-scripts/BufOnly.vim'
Plugin 'vim-scripts/bufkill.vim'
Plugin 'vim-scripts/closetag.vim'
Plugin 'wavded/vim-stylus'
Plugin 'maksimr/vim-jsbeautify'
Plugin 'shime/vim-livedown.git'
Plugin 'ap/vim-css-color'
Plugin 'dyng/ctrlsf.vim'
Plugin 'othree/yajs.vim'
Plugin 'chriskempson/base16-vim'
Plugin 'Lokaltog/vim-easymotion'
" Plugin 'jelera/vim-javascript-syntax'
" Plugin 'mxw/vim-jsx'
call vundle#end()
"General VIM configuration
"------------------------------------------------------------------------------
filetype plugin indent on " filetype detection and settings
filetype plugin on
syntax on " syntax highlighting
silent! runtime macros/matchit.vim " matchit comes with Vim
set nocompatible " not strictly necessary but useful in some scenarii
set autoindent " always set autoindent on
set copyindent " copy previous autoindent
set autoread " reload files if changed by filesystem
set backspace=indent,eol,start " let the backspace key work normally
set background=dark " Sets the Base16 colorsceme package to dark by default
set clipboard=unnamed " Now all operations such as yy, D, and P work with the clipboard. No need to prefix them with * or +.
set cursorline " cursorline on by default
" Folding settings:
" za - toggle, zc - closes, zo - opens, zR - opens all, zM - closes all
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1 "this is just what i use
set guioptions-=r " disable scrollbars on mvim
set guioptions-=L " disable left scrollbar on vsplit
set history=1000 " number of history levels
set undolevels=10000 " more undo
set hlsearch " highlight search as you type
set noswapfile " disable swp file creation
set nobackup " ***
set nowritebackup " ***
set nowrap " no wordwrapping
set hidden " hide unsaved buffers
set incsearch " incremental search rules
set laststatus=2 " not strictly necessary but good for consistency
set number " set line numbers on by default
" set relativenumber " sets relative numbers in visualmode for simpler counts
set ruler " shows line number in the status line
set scrolloff=10 " scrolling and panning offsets
set sidescrolloff=15
set sidescroll=1
set smartindent " auto indent after brackets
set smarttab " better tabs
set switchbuf=useopen,usetab " better behavior for the quickfix window and :sb
set tabstop=2 shiftwidth=2 expandtab " set tabs to 2 spaces
set tags=./tags;/,tags;/ " search tags files efficiently
set vb " turn off annoying beeps
set wildmenu " better command line completion, shows a list of matches
nnoremap gb :buffers<CR>:sb<Space> " quick buffer navigation
" Enable per-project .vimrc files
" -----------------------------------------------------------------------------
set exrc " enable per-directory .vimrc files
set secure " disable unsafe commands in local .vimrc files
" Vim configuration
"------------------------------------------------------------------------------
autocmd! BufWritePost vimrc.symlink so ~/.vimrc " reload .vimrc on save
autocmd BufWritePre * :%s/\s\+$//e " trim trailing whitespace
autocmd BufNewFile,BufRead *.cjsx set syntax=coffee " set .cjsx syntax to coffee
autocmd QuickFixCmdPost [^l]* nested cwindow " auto open quickfix when populated
autocmd QuickFixCmdPost l* nested lwindow
"Highlight text that exceeds 74 characters
augroup vimrc_autocmds
autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#592929
autocmd BufEnter * match OverLength /\%104v.*/
autocmd Filetype html,xml,xsl,coffee,cjsx,jsx source ~/.vim/bundle/closetag.vim/plugin/closetag.vim
augroup END
" Additional syntax settings
"------------------------------------------------------------------------------
"Ensure that rails jbuilder files are read as ruby
au BufNewFile,BufRead *.json.jbuilder set ft=ruby
" Key Re-mappings
"------------------------------------------------------------------------------
let mapleader="," " remap leader to ,
map <C-J> :bprev<CR> " prev buffer
map <C-K> :bnext<CR> " next buffer
map <C-L> :tabn<CR> " next tab
map <C-H> :tabp<CR> " prev tab
vmap <C-x> :!pbcopy<CR> " simulate native cut
vmap <C-c> :w !pbcopy<CR><CR> " and paste
"Enables <Leader>; to auto insert or remove semicolons
"Usage: ,; adds ; or : depending upon context
autocmd FileType javascript,css, noremap <silent> <Leader>; :call cosco#commaOrSemiColon()<CR>
autocmd FileType javascript,css, inoremap <silent> <Leader>; <c-o>:call cosco#commaOrSemiColon()<CR>
"Quickly edit/reload the vimrc file
"Usage: ,ev - Edit .vimrc. ,sv - Reload .vimrc
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
"This unsets the last search pattern register by hitting return
"Usage: After searching, hitting enter clears all search finds. Pressing `n`
" returns them
nnoremap <CR> :noh<CR><CR>
"JSBeautify
"Usage: ,f
autocmd FileType javascript noremap <buffer> <leader>f :call JsBeautify()<cr>
"Open error panel
"Usage: When there are errors, ,er opens panel)
nmap <silent> <leader>er :Errors<CR>
"Remap escape key
"Usage: In insert mode, jk exits)
:inoremap jk <Esc>
"Autoclose html tags
"Usage: <tag>[PRESS TAB]
inoremap ><Tab> ><Esc>F<lyt>o</<C-r>"><Esc>O<Space>
"Remaps :CtrlSF (SublimeText-like search) to :Af, close to :Ag
ca Af CtrlSF
"Remaps :BW (Close current buffer) to :JJ
ca JJ BW
"Remaps <C-x><C-o> command to ,,
inoremap <leader>, <C-x><C-o>
" EasyMotion configuration
"------------------------------------------------------------------------------
"Two character search
nmap s <Plug>(easymotion-s2)
nmap t <Plug>(easymotion-t2)
" Update search to use EM
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
" NERDTree configuration
"------------------------------------------------------------------------------
autocmd VimEnter * NERDTree " open nerdtree by default
let NERDTreeShowHidden = 1 " show hidden files by default
let NERDTreeMinimalUI = 1 " only relevant parts
let NERDTreeDirArrows = 1 " add arrows
let NERDTreeIgnore = ['\.DS_Store\|\.sass-cache'] " ignore certain files and patterns
let g:NERDTreeNodeDelimiter = "\u00a0"
autocmd VimEnter * wincmd p " start cursor on file pane
" FuzzyFinder (CtrlP) Settings
"------------------------------------------------------------------------------
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_map = '<c-p>'
let g:ctrlp_custom_ignore = {
\ 'dir' : '\.sass-cache$\|bower_components$\|node_modules$\|\.git$\|tmp$\|\.svn$\|\.sass-cache$\|public/compiled$\|vendor/gems$',
\ 'file': '\.git$\|\.hg$\|\.svn$\|\.scssc$'
\ }
" JSDoc Settings
"------------------------------------------------------------------------------
let g:jsdoc_allow_input_prompt = 1
let g:jsdoc_return = 0
" Sparkup Configuration
"------------------------------------------------------------------------------
augroup sparkup_types
" Remove ALL autocommands of the current group.
autocmd!
" Add sparkup to new filetypes
autocmd FileType coffee,cjsx,jsx,js runtime! ftplugin/react/sparkup.vim
autocmd FileType mustache,hbs,handlebars,php,htmldjango runtime! ftplugin/html/sparkup.vim
augroup END
" Airline configuration
"------------------------------------------------------------------------------
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#buffer_nr_format = '%s > '
" GitGutter Config
"------------------------------------------------------------------------------
let g:gitgutter_max_signs = 1000
" Syntasitc settings
"------------------------------------------------------------------------------
" let g:syntastic_javascript_checkers = ['jsxhint']
let g:syntastic_javascript_checkers = ['eslint']
" CtrlSF (SublimeText-like search)
let g:ctrlsf_winsize = '100'
" JSX Settings
"------------------------------------------------------------------------------
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
" Colorscheme - See http://chriskempson.github.io/base16/#bright
"------------------------------------------------------------------------------
colors abra "sorcerer molokai busybee apprentice abra distinguished jellybeans railscasts
set fillchars+=vert:\. " Dotted vertical line separating nerdtree gutter
hi clear VertSplit " Clear defaults
highlight SignColumn guibg=#31322c " GitGutter background color
set guifont=Monaco:h12
" Change cursor shape between insert and normal mode in iTerm2.app
if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
endif
"Force enable sass syntax
au BufRead,BufNewFile *.sass set ft=sass