-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
232 lines (181 loc) · 7.17 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
""
"" Thanks:
"" Gary Bernhardt <destroyallsoftware.com>
"" Drew Neil <vimcasts.org>
"" Tim Pope <tbaggery.com>
"" Janus <github.com/carlhuda/janus>
""
set nocompatible
set encoding=utf-8
set exrc " load vimrc from current directory
call pathogen#infect()
filetype plugin indent on
runtime macros/matchit.vim " enables % to cycle through `if/else/endif`
syntax enable
filetype plugin on " enable markdown preview
set background=dark
color gruvbox
set synmaxcol=800 " don't try to highlight long lines
set number " line numbers aren't needed
set ruler " show the cursor position all the time
set cursorline " highlight the line of the cursor
set showcmd " show partial commands below the status line
set shell=bash " avoids munging PATH under zsh
let g:is_bash=1 " default shell syntax
set history=1000 " remember more Ex commands
set scrolloff=3 " have some context around the current line always on screen
" Enable CSS autocomplete
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
" Allow backgrounding buffers without writing them, and remember marks/undo
" for backgrounded buffers
set hidden
" Auto-reload buffers when file changed on disk
set autoread
" Disable swap files; systems don't crash that often these days
set updatecount=0
" Make Vim able to edit crontab files again.
set backupskip=/tmp/*,/private/tmp/*"
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 " a tab is two spaces
set shiftwidth=2 " an autoindent (with <<) is two spaces
set softtabstop=2 " use tabs when deleting empty space
set expandtab " use spaces, not tabs
set list " Show invisible characters
set backspace=indent,eol,start " backspace through everything in insert mode
" Joining lines
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment char when joining commented lines
endif
set nojoinspaces " Use only 1 space after "." when joining lines, not 2
" Indicator chars
set listchars=tab:▸\ ,trail:•,extends:❯,precedes:❮
set showbreak=↪\
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
set gdefault " have :s///g flag by default on
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set notimeout
set ttimeout
set ttimeoutlen=100
" Ragel syntax (default to ruby as host language)
let g:ragel_default_subtype='ruby'
function! s:setupWrapping()
set wrap
set wrapmargin=2
set textwidth=80
endfunction
augroup vimrcEx
" Clear all autocmds in the group
autocmd!
" Avoid showing trailing whitespace when in insert mode
au InsertEnter * :set listchars-=trail:•
au InsertLeave * :set listchars+=trail:•
" Some file types use real tabs
au FileType {make,gitconfig} set noexpandtab
" Make sure all markdown files have the correct filetype set and setup wrapping
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt} setf markdown | call s:setupWrapping()
" Treat JSON files like JavaScript
au BufNewFile,BufRead *.json setf javascript
" https://github.com/sstephenson/bats
au BufNewFile,BufRead *.bats setf sh
au BufNewFile,BufRead *.rl setfiletype ragel
" make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
" mark Jekyll YAML frontmatter as comment
au BufNewFile,BufRead *.{md,markdown,html,xml} sy match Comment /\%^---\_.\{-}---$/
" magic markers: enable using `H/S/J/C to jump back to
" last HTML, stylesheet, JS or Ruby code buffer
au BufLeave *.{erb,html} exe "normal! mH"
au BufLeave *.{css,scss,sass} exe "normal! mS"
au BufLeave *.{js,coffee} exe "normal! mJ"
au BufLeave *.{rb} exe "normal! mC"
augroup END
" don't use Ex mode, use Q for formatting
map Q gq
" toggle the current fold
:nnoremap <Space> za
let mapleader=","
" clear the search buffer
noremap <leader>h :nohlsearch<CR>
" yank to system clipboard
map <leader>y "*y
" paste lines from unnamed register and fix indentation
nmap <leader>p pV`]=
nmap <leader>P PV`]=
" expand %% to current directory in command-line mode
" http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>gl :CommandT lib<cr>
map <leader>gt :CommandTTag<cr>
map <leader>f :CommandT<cr>
map <leader>F :CommandT %%<cr>
let g:CommandTMatchWindowAtTop=1
let g:CommandTMaxHeight=20
let g:CommandTMinHeight=2
" Open a new tab and search for something.
nmap <leader>a :tab split<CR>:Ack ""<Left>
" Immediately search for the word under the cursor in a new tab.
nmap <leader>A :tab split<CR>:Ack "\W<C-r><C-w>\W"<CR>
" In command-line mode, C-a jumps to beginning (to match C-e)
cnoremap <C-a> <Home>
" <Tab> indents if at the beginning of a line; otherwise does completion
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
" ignore Rubinius, Sass cache files
set wildignore+=tmp/**,*.rbc,.rbx,*.scssc,*.sassc
" ignore Bundler standalone/vendor installs & gems
set wildignore+=bundle/**,vendor/bundle/**,vendor/cache/**,vendor/gems/**
set wildignore+=node_modules/**
" toggle between last open buffers
nnoremap <leader><leader> <c-^>
command! GdiffInTab tabedit %|vsplit|Gdiff
nnoremap <leader>d :GdiffInTab<cr>
nnoremap <leader>D :tabclose<cr>
command! KillWhitespace :normal :%s/ *$//g<cr><c-o><cr>
" populate arglist with files from the quickfix list
command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames()
function! QuickfixFilenames()
" Building a hash ensures we get each buffer only once
let buffer_numbers = {}
for quickfix_item in getqflist()
let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
endfor
return join(map(values(buffer_numbers), 'fnameescape(v:val)'))
endfunction
set splitright
set splitbelow
" disable cursor keys in normal mode
map <Left> :echo "no!"<cr>
map <Right> :echo "no!"<cr>
map <Up> :echo "no!"<cr>
map <Down> :echo "no!"<cr>
if has("statusline") && !&cp
set laststatus=2 " always show the status bar
set statusline=%<%1*\ %f\ %* " filename
set statusline+=%2*%m%r%* " modified, readonly
set statusline+=\ %3*%y%* " filetype
set statusline+=\ %4*%{fugitive#head()}%0*
set statusline+=%= " left-right separation point
set statusline+=\ %5*%l%*/%L[%p%%] " current line/total lines
set statusline+=\ %5*%v%*[0x%B] " current column [hex char]
endif
" Nerd Tree
inoremap <f2> <esc>:NERDTreeToggle<cr>
nnoremap <f2> <esc>:NERDTreeToggle<cr>