forked from briancain/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
243 lines (193 loc) · 6.51 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
"-----------------------------------------------------------------------------
" Vim Configuration (Dotfiles)
"
" Eric Williamson
"-----------------------------------------------------------------------------
set nocompatible
let &t_Co=256
"-----------------------------------------------------------------------------
"
" Markdown Syntax
"
"-----------------------------------------------------------------------------
au BufRead,BufNewFile *.md set filetype=markdown
"-----------------------------------------------------------------------------
" Vundle Config
"-----------------------------------------------------------------------------
" Setting up Vundle
" Found here: http://www.erikzaadi.com/2012/03/19/auto-installing-vundle-from-your-vimrc/
let has_vundle=1
let vundle_readme=expand('~/.dotfiles/vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle..."
echo ""
silent !mkdir -p ~/.dotfiles/vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.dotfiles/vim/bundle/vundle
let has_vundle=0
endif
" Vundle setup config
set rtp+=~/.dotfiles/vim/bundle/vundle/
call vundle#rc()
" Required Bundle
Bundle 'gmarik/vundle'
" Additional Bundles go here"
Bundle 'L9'
Bundle 'Gundo'
Bundle 'flazz/vim-colorschemes'
Bundle 'tpope/vim-surround'
" Vim file tree explorer
Bundle 'scrooloose/nerdtree'
" syntax checking plugin for Vim
"Bundle 'scrooloose/syntastic'
Plugin 'w0rp/ale'
" Syntax checking for puppet
Bundle 'rodjek/vim-puppet'
" Tabular
Bundle 'godlygeek/tabular'
" Indentation guide
Bundle 'nathanaelkane/vim-indent-guides'
" Coffeescript support
Bundle 'kchmck/vim-coffee-script'
" Airline
"Bundle 'bling/vim-airline'
Bundle 'tpope/vim-fugitive'
" theme
Plugin 'jacoborus/tender'
Plugin 'itchyny/lightline.vim'
" Markdown / Writing plugins
Plugin 'plasticboy/vim-markdown'
Plugin 'junegunn/goyo.vim'
" react / JS
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'skywind3000/asyncrun.vim'
" Installing plugins the first time
" If exists, skip
if has_vundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
syntax enable
filetype plugin indent on
" Gundo mapping
nnoremap <silent> <C-U> :GundoToggle<CR>
"-----------------------------------------------------------------------------
" Color scheme
"-----------------------------------------------------------------------------
"colorscheme 256_jungle
colorscheme tender
let g:tender_lightline = 1
let g:lightline = { 'colorscheme': 'tender' }
"-----------------------------------------------------------------------------
" Encoding and general usability
"-----------------------------------------------------------------------------
nnoremap <Space> :
set splitbelow
set splitright
set modeline
set ls=2
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/#important-vimrc-lines
set encoding=utf-8
set scrolloff=3
set showmode
set showcmd
"set wildmenu
"set wildmode=list:longest
set ttyfast
set ruler
set backspace=indent,eol,start
" Line numbering
set number
set nofoldenable " disable folding
" Vim window stuff
set guifont=Monaco:h15
" Show tabs and trailing whitespace visually
if (&termencoding == "utf-8") || has("gui_running")
if v:version >= 700
set list listchars=tab:»·,trail:·,extends:…,nbsp:‗
else
set list listchars=tab:»·,trail:·,extends:…
endif
else
if v:version >= 700
set list listchars=tab:>-,trail:.,extends:>,nbsp:_
else
set list listchars=tab:>-,trail:.,extends:>
endif
endif
"-----------------------------------------------------------------------------
" Search, highlight, spelling, etc.
"-----------------------------------------------------------------------------
" Improved searching
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
" Enable syntax highlighting, if one exists
if has("syntax")
syntax on
endif
set background=dark
" Auto reload vim config anytime i make changes
autocmd! BufWritePost *vimrc source %
" Omnifunction
set omnifunc=syntaxcomplete#Complete
" Enable spell check for markdown, git commits
autocmd BufRead,BufNewFile *.md setlocal spell
autocmd FileType gitcommit setlocal spell
"-----------------------------------------------------------------------------
" Spacing
"-----------------------------------------------------------------------------
set autoindent
set smartindent
set tabstop=2 shiftwidth=2 expandtab
" Set line width to 90 when writing markdown
autocmd BufRead,BufNewFile *.md setlocal tw=80
"autocmd VimEnter * :IndentGuidesEnable
"let g:indent_guides_auto_colors = 0
"autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=234
"autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=235
"-----------------------------------------------------------------------------
" Buffers
"-----------------------------------------------------------------------------
" Delete all buffers with \da
nmap <silent> <leader>da :exec "1," . bufnr('$') . "bd"<cr>
noremap <buffer> <silent> k gk
noremap <buffer> <silent> j gj
noremap <buffer> <silent> 0 g0
noremap <buffer> <silent> $ g$
" Map for omnicomplete
inoremap <F8> <C-X><C-O>
" Access .vimrc with \vi
nmap <silent> <leader>vi :e $MYVIMRC<CR>
nmap <silent> <leader>vh :e ~/Documents/References/vim.txt<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
"-----------------------------------------------------------------------------
" NERD Tree
"-----------------------------------------------------------------------------
" Invoke NERD Tree with \nt
nmap <leader>nt :NERDTree<CR>
" Toggle the NERD Tree on an off with F7
nmap <F7> :NERDTreeToggle<CR>
" Close the NERD Tree with Shift-F7
nmap <S-F7> :NERDTreeClose<CR>
" Auto show NERD Tree
let NERDTreeShowHidden=1
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
"-----------------------------------------------------------------------------
" Custom commands
"-----------------------------------------------------------------------------
" typing :w!! will auto exapnd to :w !sudo tee % so you can save a readonly file
cmap w!! w !sudo tee >/dev/null %
command! -nargs=1 -range TabFirst exec <line1> . ',' . <line2> . 'Tabularize /^[^' . escape(<q-args>, '\^$.[?*~') . ']*\zs' . escape(<q-args>, '\^$.[?*~')
augroup Puppet
autocmd! BufEnter *.pp set filetype=puppet tabstop=2 sts=2 shiftwidth=2
augroup end
let g:puppet_align_hashes=0
" Autoline JS files on save
autocmd BufWritePost *.js AsyncRun -post=checktime ./node_modules/.bin/eslint --fix %
" Disable backup of crontab so we can edit it on osx
autocmd filetype crontab setlocal nobackup nowritebackup