-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
313 lines (263 loc) · 8.88 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
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" set nocompatible " Set nocompatible mode on
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
syntax on " Turn on syntax highlighting
" Indent automatically depending on filetype
filetype plugin indent on
set autoindent
set smartindent
set cindent
set ruler " Turn on the ruler
set nu " Turn on line numbering. Turn it off with "set nonu"
set ic " Case insensitive search
set hls " Highlight search
set incsearch " Show incremental search results
set scs " Smart search - override 'ic' when pattern has uppercase characters
set showcmd " Show incomplete commands in the status area
set showmode " Show current mode in the status area
set lbr " Wrap text instead of being on one line
set tabstop=4 " Number of spaces for tab character
set shiftwidth=4 " Number of spaces for autoindent
set noexpandtab " Don't expand tabs into spaces
set novisualbell " Turn off the visual bell
set ttyfast " Smoother changes
set wrap " wrap lines
set anti " Antialias fonts
set selectmode=mouse,key " Use the mouse for selectmode
set selection=exclusive " Don't include the last character in the selection
set keymodel=startsel,stopsel
set completeopt=longest,menuone " Make completion menu match the longest common text
set switchbuf=usetab,useopen " Make vim open existing tabs/windows if a file is already open rather than opening a new one
set confirm " Prompt to save on destroying buffer with unsaved changes
set updatetime=100 " Set update time to 1/10 second
set wildmenu
set wildmode=list:longest,full
set showbreak=->
set listchars=tab:▸\ ,eol:¬
set tags=./tags;
" OS Specific
if has("unix")
" Configuration for both Cygwin and Linux
set shellcmdflag=-ic " Use an interactive shell for bang(!)
let g:vimhome = $HOME . "/.vim"
if has("win32unix")
" Configuration for Cygwin only
else
" Configuration for Linux only
endif
elseif has("win32")
" Configuration for Windows-native vim
" source $VIMRUNTIME/mswin.vim
let g:vimhome = $HOME . "/vimfiles"
else
echoerr "Unknown OS"
endif
" Set mapleader
let mapleader = ";"
" Set statusline
set laststatus=2
set statusline=%f
set statusline+=[%{&ff}]
set statusline+=%{fugitive#statusline()}
set statusline+=%{exists('g:loaded_rvm')?rvm#statusline():''}
set statusline+=%h
set statusline+=%y
set statusline+=%r
set statusline+=%m
set statusline+=%=
set statusline+=%c,
set statusline+=%l/%L
set statusline+=\ %P
let g:netrw_liststyle = 3
let g:jah_Quickfix_Win_Height = 10
let g:ragtag_global_maps = 1
" toggles the quickfix window.
command! -bang -nargs=? QFix call QFixToggle(<bang>0)
function! QFixToggle(forced)
if exists("g:qfix_win") && a:forced == 0
cclose
else
execute "copen " . g:jah_Quickfix_Win_Height
endif
endfunction
" Jekyll config
let g:jekyll_path = "~/Development/duckpuppy_blog"
let g:jekyll_post_suffix = "md"
let g:jekyll_post_published = "false"
" mapping to make movements operate on 1 screen line in wrap mode
function! ScreenMovement(movement)
if &wrap
return "g" . a:movement
else
return a:movement
endif
endfunction
onoremap <silent> <expr> j ScreenMovement("j")
onoremap <silent> <expr> k ScreenMovement("k")
onoremap <silent> <expr> 0 ScreenMovement("0")
onoremap <silent> <expr> ^ ScreenMovement("^")
onoremap <silent> <expr> $ ScreenMovement("$")
nnoremap <silent> <expr> j ScreenMovement("j")
nnoremap <silent> <expr> k ScreenMovement("k")
nnoremap <silent> <expr> 0 ScreenMovement("0")
nnoremap <silent> <expr> ^ ScreenMovement("^")
nnoremap <silent> <expr> $ ScreenMovement("$")
if has("autocmd")
augroup vimrc
autocmd!
au FileType eruby,ruby setlocal nocindent
au FileType eruby,ruby setlocal omnifunc=rubycomplete#Complete
au FileType eruby,ruby let g:rubycomplete_buffer_loading = 1
au FileType eruby,ruby let g:rubycomplete_classes_in_global = 1
au FileType eruby,ruby let g:rubycomplete_rails = 1
au FileType ruby setlocal foldmethod=syntax
au FileType ruby normal zR
au FileType java setlocal omnifunc=javacomplete#Complete
au FileType java setlocal completefunc=javacomplete#CompleteParamsInfo
au BufReadCmd *.epub call zip#Browse(expand("<amatch>"))
au BufRead,BufNewFile pom.xml set filetype=xml.maven
" Configure omnicomplete to use syntax completion if no other omnifunc exists
au FileType *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
augroup END
" used to track the quickfix window
augroup QFixToggle
autocmd!
autocmd BufWinEnter quickfix let g:qfix_win = bufnr("$")
autocmd BufWinLeave * if exists("g:qfix_win") && expand("<abuf>") == g:qfix_win | unlet! g:qfix_win | endif
augroup END
endif
" Configure Supertab
let g:SuperTabLongestEnhanced = 1
let g:SuperTabLongestHighlight = 1
" Configure taglist
let Tlist_Show_One_File = 1
"Configure tagbar
let g:tagbar_autofocus = 1
let g:tagbar_expand = 1
" Configure UltiSnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsListSnippets="<c-`>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsEditSplit="normal"
let g:UltiSnipsSnippetsDir=g:vimhome . "/after/UltiSnips"
" re-indent file
nnoremap <silent> <F4> :call <SID>ReindentFile()<CR>
function! <SID>ReindentFile()
" Save cursor position
let l = line(".")
let c = col(".")
" Reindent file
let cmd = "normal!" . "gg=G"
execute cmd
" Move cursor back to saved position
call cursor(l, c)
endfunction
" Key Mappings
" Jekyll
map <leader>jb :JekyllBuild<CR>
map <leader>jn :JekyllPost<CR>
map <leader>jl :JekyllList<CR>
" Make <CTRL>-L hide search hilights
nnoremap <silent> <C-L> :noh<CR><C-L>
" Insert mode cursor movement
inoremap <C-h> <C-o>h
inoremap <C-j> <C-o>j
inoremap <C-k> <C-o>k
inoremap <C-l> <C-o>l
" Make <tab> work more intuitively in visual mode
vmap <tab> >g
vmap <s-tab> <gv
" Change the working directory of this buffer to the location of the file in
" the buffer
map <Leader>cd :cd %:p:h<CR>:pwd<CR>
" QuickFix window
nmap <silent> <leader>` :QFix<CR>
map <C-n> :cn<CR>
map <C-p> :cp<CR>
" Toggle `set list`
nmap <leader>l :set list!<CR>
" Taglist
nnoremap <silent> <F8> :TlistToggle<CR>
" TagBar
nnoremap <silent> <F9> :TagbarToggle<CR>
" Copy filename to the clipboard
if has('win32')
nmap <silent> ,cs :let @*=substitute(expand("%"), "/", "\\", "g")<CR>:echo '<C-R>*'<CR>
nmap <silent> ,cl :let @*=substitute(expand("%:p"), "/", "\\", "g")<CR>:echo '<C-R>*'<CR>
nmap <silent> ,c8 :let @*=substitute(expand("%:p:8"), "/", "\\", "g")<CR>:echo '<C-R>*'<CR>
else
" These copy to both the Gnome and X Server clipboard
nmap <silent> ,cs :let @*=expand("%")<CR>:echo '<C-R>*'<CR> \| :let @+=expand("%")<CR>
nmap <silent> ,cl :let @*=expand("%:p")<CR>:echo '<C-R>*'<CR> \| :let @+=expand("%:p")<CR>
endif
nnoremap <C-o> :FufFile<CR>
nnoremap <C-b> :FufBuffer<CR>
nnoremap <silent> <C-e> :NERDTreeToggle<CR>
" Gtags mapping
map <C-\>] :GtagsCursor<CR>
" Command-T mappings
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
" Open files with <leader>f
map <leader>f :CommandTFlush<cr>\|:CommandT<cr>
" Open files, limited to the directory of the current file, with <leader>gf
map <leader>gf :CommandTFlush<cr>\|:CommandT %%<cr>
map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr>
map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr>
map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr>
map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr>
map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr>
map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr>
map <leader>gs :CommandTFlush<cr>\|:CommandT public/stylesheets<cr>
map <leader>gr :topleft :split config/routes.rb<cr>
map <leader>gg :topleft 100 :split Gemfile<cr>
function! ShowRoutes()
" Requires 'scratch' plugin
:topleft 100 :split __Routes__
" Make sure Vim doesn't write __Routes__ as a file
:set buftype=nofile
" Delete everything
:normal 1GdG
" Put routes output in buffer
:0r! rake -s routes
" Size window to number of lines (1 plus rake output length)
:exec ":normal " . line("$") . "_ "
" Move cursor to bottom
:normal 1GG
" Delete empty trailing line
:normal dd
endfunction
map <leader>gR :call ShowRoutes()<cr>
" Capture the output of a command to a new tab
function! Capture (cmd)
redir => message
silent execute a:cmd
redir END
tabnew
silent put=message
set nomodified
endfunction
command! -nargs=+ -complete=command Capture call Capture(<q-args>)
inoremap <c-u> <c-g>u<c-u>
inoremap <c-w> <c-g>u<c-w>
" AutoComplPop Configuration
let g:acp_enableAtStartup = 0
inoremap <expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
\ "\<lt>C-n>" :
\ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
\ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
\ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
imap <C-@> <C-Space>
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
" Abbreviations
" Change colorscheme from default to vilight
colorscheme railscasts