Thu, 29 May 2014 22:57:20 -0400
Windows-compatible vimrc
1 | 1 | set nocompatible |
2 | ||
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
3 | let on_windows=0 |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
4 | if has('win32') || has('win64') |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
5 | " vim in cygwin has win32 = 0 and win32unix = 1 |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
6 | let on_windows=1 |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
7 | end |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
8 | |
1 | 9 | " call pathogen#infect() |
10 | " call pathogen#helptags() | |
11 | ||
12 | " Setting up Vundle - the vim plugin bundler | |
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
13 | let installed_vundle=0 |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
14 | |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
15 | if on_windows == 0 |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
16 | let vundle_readme=expand('~/.vim/bundle/vundle/README.md') |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
17 | else |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
18 | let vundle_readme=expand('~/vimfiles/bundle/vundle/README.md') |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
19 | endif |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
20 | |
1 | 21 | if !filereadable(vundle_readme) |
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
22 | if !executable('git') |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
23 | echo "You probably want git installed and in PATH" |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
24 | quit |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
25 | endif |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
26 | |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
27 | let installed_vundle=1 |
1 | 28 | echo "Installing Vundle.." |
29 | echo "" | |
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
30 | if on_windows == 0 |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
31 | silent !mkdir -p ~/.vim/bundle |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
32 | silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
33 | else |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
34 | "windows is weird about args and quoting |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
35 | silent execute '!mkdir "'. $HOME .'\vimfiles\bundle"' |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
36 | silent execute '!git clone https://github.com/gmarik/vundle "'. $HOME .'\vimfiles\bundle\vundle"' |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
37 | endif |
1 | 38 | endif |
39 | ||
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
40 | if on_windows == 0 |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
41 | set rtp+=~/.vim/bundle/vundle/ |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
42 | else |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
43 | set rtp+=~/vimfiles/bundle/vundle/ |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
44 | endif |
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
45 | |
1 | 46 | call vundle#rc() |
47 | Plugin 'gmarik/vundle' | |
48 | ||
49 | Plugin 'altercation/vim-colors-solarized' | |
50 | Plugin 'bling/vim-airline' | |
51 | ||
52 | Plugin 'Shougo/vimproc.vim' | |
53 | Plugin 'Shougo/unite.vim' | |
54 | Plugin 'Shougo/vimshell.vim' | |
55 | Plugin 'sjl/gundo.vim' | |
56 | Plugin 'majutsushi/tagbar' | |
57 | Plugin 'godlygeek/tabular' | |
58 | Plugin 'tomtom/tcomment_vim' | |
59 | ||
60 | Plugin 'danchoi/ri.vim' | |
61 | Plugin 'tpope/vim-fugitive' | |
62 | Plugin 'ludovicchabant/vim-lawrencium' | |
63 | ||
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
64 | if installed_vundle == 1 |
1 | 65 | echo "Installing Plugins, please ignore key map error messages" |
66 | echo "" | |
67 | :PluginInstall | |
68 | endif | |
69 | " Setting up Vundle - the vim plugin bundler end | |
70 | ||
71 | ||
72 | syntax on | |
73 | filetype plugin indent on | |
74 | ||
75 | set enc=utf-8 | |
76 | ||
77 | set hlsearch | |
78 | set ic smartcase | |
79 | ||
80 | set lcs=tab:→·,trail:· | |
81 | ||
82 | set ve=block | |
83 | ||
84 | set autoindent | |
85 | set expandtab | |
86 | set shiftwidth=2 | |
87 | set softtabstop=2 | |
88 | " vim: enc=utf-8 et sts=2 sw=2 | |
89 | ||
90 | set backspace=indent,eol,start | |
91 | ||
92 | " set nu | |
93 | set scrolloff=2 | |
94 | set ruler | |
95 | set showcmd | |
96 | set wildmenu | |
97 | ||
98 | nmap <silent> <F1> :Unite buffer<CR> | |
99 | nmap <silent> <F2> :Unite file<CR> | |
100 | nmap <silent> <F3> :VimShell<CR> | |
101 | map <silent> <F4> :noh<CR> | |
102 | nmap <silent> <F5> :GundoToggle<CR> | |
103 | nmap <silent> <F8> :TagbarToggle<CR> | |
104 | ||
105 | " This is supposed to get a CtrlP workalike with fuzzy match | |
106 | " but i need to fix ignores and always chdir to a good place | |
107 | if has("win32") || has("win16") | |
108 | nmap <silent> <S-F2> :Unite -start-insert file_rec:!<CR> | |
109 | else | |
110 | nmap <silent> <S-F2> :Unite -start-insert file_rec/async:!<CR> | |
111 | endif | |
112 | ||
113 | " F-n keys call out to normal mode from insert mode | |
114 | imap <F1> <C-O><F1> | |
115 | imap <F2> <C-O><F2> | |
116 | " imap <F3> <C-O><F3> | |
117 | imap <F4> <C-O><F4> | |
118 | " imap <F5> <C-O><F5> | |
119 | " imap <F6> <C-O><F6> | |
120 | " imap <F7> <C-O><F7> | |
121 | imap <F8> <C-O><F8> | |
122 | ||
123 | " Don't assume to scan includes when autocompleting | |
124 | set cpt-=i | |
125 | ||
126 | " Never open with folds collapsed | |
127 | set nofoldenable | |
128 | ||
129 | set lbr | |
130 | set sbr=»\ | |
131 | ||
132 | set statusline=%f%m%r%h%w\ %y\ %=%l,%c\ %p%%\ %L | |
133 | set laststatus=2 | |
134 | ||
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
135 | if on_windows == 1 |
1 | 136 | let $MYVIM=$HOME.'/vimfiles' |
137 | ||
138 | if !filewritable( $MYVIM . '/var' ) | |
139 | silent execute '!mkdir "'.$HOME.'\vimfiles\var"' | |
140 | endif | |
141 | if !filewritable( $MYVIM. '/var/backup' ) | |
142 | silent execute '!mkdir "'.$HOME.'\vimfiles\var\backup"' | |
143 | endif | |
144 | if !filewritable( $MYVIM . '/var/tmp' ) | |
145 | silent execute '!mkdir "'.$HOME.'\vimfiles\var\tmp"' | |
146 | endif | |
147 | if !filewritable( $MYVIM . '/var/undo' ) | |
148 | silent execute '!mkdir "'.$HOME.'\vimfiles\var\undo"' | |
149 | endif | |
150 | ||
151 | set guifont=Consolas:h11 | |
152 | set guioptions-=t | |
153 | else | |
154 | let $MYVIM=$HOME.'/.vim' | |
155 | ||
156 | if !filewritable( $MYVIM . '/var/backup' ) | |
157 | silent execute '!mkdir -p "'.$MYVIM.'/var/backup"' | |
158 | endif | |
159 | if !filewritable( $MYVIM . '/var/tmp' ) | |
160 | silent execute '!mkdir "'.$MYVIM.'/var/tmp"' | |
161 | endif | |
162 | if !filewritable( $MYVIM . '/var/undo' ) | |
163 | silent execute '!mkdir "'.$MYVIM.'/var/undo"' | |
164 | endif | |
165 | ||
166 | set guifont=Droid\ Sans\ Mono\ Slashed\ 10 | |
167 | endif | |
168 | ||
169 | set backupdir=$MYVIM/var/backup//,. | |
170 | set directory=$MYVIM/var/tmp//,. | |
171 | ||
172 | set backup | |
173 | set autowrite | |
174 | " set hidden -- autowrite vs hidden, haven't decided. | |
175 | ||
176 | if has('persistent_undo') | |
177 | set undofile | |
178 | set undodir=$MYVIM/var/undo//,. | |
179 | end | |
180 | ||
181 | ||
182 | autocmd FileType text setlocal textwidth=78 | |
183 | ||
184 | ||
185 | " -- Perl stuff | |
186 | function! PerlSettings () | |
187 | setlocal keywordprg=perldoc\ -f | |
188 | setlocal makeprg=perl\ -c\ %\ $* | |
189 | setlocal errorformat=%m\ at\ %f\ line\ %l | |
190 | endfunction | |
191 | ||
192 | autocmd FileType perl call PerlSettings() | |
193 | ||
194 | " preload templates into new buffers by file extension | |
195 | " autocmd BuffNewFile * silent! 0r $MYVIM/templates/%:e.template | |
196 | ||
197 | " strip trailing whitespace on save | |
198 | " autocmd BufWritePre * :%s/\s+$//e | |
199 | ||
200 | "let perl_fold = 1 "perl fold scanning is slow | |
201 | let perl_include_pod = 1 | |
202 | ||
203 | " -- Gundo | |
204 | " I prefer python3 on windows if I have to use it. | |
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
205 | if on_windows == 1 |
1 | 206 | let g:gundo_prefer_python3=1 |
207 | endif | |
208 | ||
209 | " -- Tagbar | |
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
210 | if on_windows == 1 |
1 | 211 | let g:tagbar_ctags_bin = 'C:\Users\mhoward\bin\ctags.exe' |
212 | endif | |
213 | ||
214 | let g:tagbar_autoclose = 1 | |
215 | let g:tagbar_autofocus = 1 | |
216 | let g:tagbar_compact = 1 | |
217 | ||
218 | let g:tagbar_type_perl = { | |
219 | \ 'kinds' : [ | |
220 | \ 'p:packages:1:0', | |
221 | \ 'e:extends', | |
222 | \ 'r:roles', | |
223 | \ 'c:constants:0:0', | |
224 | \ 'f:formats:0:0', | |
225 | \ 'a:attributes', | |
226 | \ 's:subroutines', | |
227 | \ 'l:labels', | |
228 | \ ], | |
229 | \ 'deffile' : '$MYVIM/ctags/perl.cnf' | |
230 | \ } | |
231 | ||
232 | ||
233 | " -- Unite | |
234 | call unite#filters#matcher_default#use(['matcher_fuzzy']) | |
235 | call unite#filters#sorter_default#use(['sorter_rank']) | |
236 | let g:unite_source_history_yank_enable = 1 | |
237 | ||
238 | if executable('ag') | |
239 | let g:unite_source_grep_command = 'ag' | |
240 | let g:unite_source_grep_default_opts = '--nogroup --nocolor --column' | |
241 | let g:unite_source_grep_recursive_opt = '' | |
242 | endif | |
243 | ||
244 | " -- Airline | |
245 | let g:airline#extensions#whitespace#enabled = 0 | |
246 | ||
247 | ||
248 | " Local stuff | |
249 | try | |
10
e753144057b8
Windows-compatible vimrc
Meredith Howard <mhoward@roomag.org>
parents:
7
diff
changeset
|
250 | if on_windows == 1 |
1 | 251 | source ~/_vimrc.local |
252 | else | |
253 | source ~/.vimrc.local | |
254 | endif | |
255 | catch | |
256 | endtry | |
257 | ||
7
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
258 | if has('gui_running') |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
259 | set nu |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
260 | set bg=dark |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
261 | |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
262 | set columns=120 lines=40 |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
263 | |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
264 | colorscheme solarized |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
265 | else |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
266 | if &t_Co == 256 |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
267 | colorscheme jellybeans |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
268 | end |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
269 | end |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
270 | |
7e6e6ff35c4d
try to normalize my colorschemes more, vimrc.local can cover $TERM weirdness
Meredith Howard <mhoward@roomag.org>
parents:
1
diff
changeset
|
271 |