-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.local
310 lines (251 loc) · 9.39 KB
/
vimrc.local
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
" An excellent PHP Web Application Developers vimrc file.
"
" Maintainer: Christopher Hopper <christopherjfhopper[at]gmail[dot]com>
" Attribution: Bram Moolenaar <Bramd[at]vim[dot]org>
" Source Code: https://github.com/christopher-hopper/vimfiles
" Git Remote: [email protected]:christopher-hopper/vimfiles.git
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" Add bundled vim plug-ins to the runtime path.
execute pathogen#infect('bundle/{}')
execute pathogen#helptags()
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set history=1000
set nobackup " do not keep a backup file
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" Auto-wrap text using textwidth.
set formatoptions+=t
" Allow formatting of long lines in insert mode.
set formatoptions-=l
" Set the <leader> used in mappings.
let mapleader=","
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" Indentation settings
set expandtab "Use softtabstop spaces instead of tab characters for indentation
set shiftwidth=4 "Indent by 4 spaces when using >>, <<, == etc.
set softtabstop=4 "Indent by 4 spaces when pressing <TAB>
set autoindent "Keep indentation from previous line
" Gutter settings.
set number "Show line number in the left gutter
set relativenumber "Show the number of lines relative to the cursor
" javascript-libraries-syntax - othree/javascript-libraries-syntax.vim
let g:used_javascript_libs = 'jquery,angularjs'
" JSON settings
let g:vim_json_syntax_conceal = 1
" Syntastic settings
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_aggregate_errors = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_style_error_symbol = '✗'
let g:syntastic_style_warning_symbol = '⚠'
" Set the default font
if has('gui_running')
set guifont=DejaVu\ Sans\ Mono\ 11
if has('gui_win32')
set guifont=DejaVu_Sans_Mono:h10:cANSI
elseif has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
endif
endif
if has('macunix')
" OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
if has('mouse') && has('gui_running')
" Enable mouse by default for gVim only.
set mouse=a
" Turn-off Tear-off menus
set guioptions-=t
endif
" Only do this part when the terminal options enable support for more
" than two colors.
if &t_Co > 2 || has('gui_running')
" Switch syntax highlighting on.
syntax on
" Highlight the last used search pattern.
set hlsearch
" Set the color scheme.
" See $VIMRUNTIME/colors/*.vim for available color schemes.
colorscheme solarized
set background=dark
if !has('gui_running')
" Solarized terminal emulator colours not defined.
" Degrade solarized to 256 terminal colours.
let g:solarized_termcolors=256
endif
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Change the cursor (shape, colour) in different modes
if &term =~ '^xterm'
" Use a solid underscore cursor in insert mode
let &t_SI = "\<Esc>[4 q"
" Use a solid block cursor in insert mode
let &t_SI = "\<Esc>[1 q"
" 0 -> block blinking
" 1 -> block blinking
" 2 -> block solid
" 3 -> underscore blinking
" 4 -> underscore solid
endif
" *** Mappings ***
" For when you forget to sudo, really Write the file.
cmap w!! w !sudo tee % >/dev/null
" Turn off search highlight with ESC until next search.
nnoremap <esc> :noh<return><esc>
nnoremap <esc>^[ <esc>^[
" *** Functions ***
" Highlight all instances of the word under the cursor, when idle.
" Map <F8> key to toggle Auto Highlighting.
nnoremap <f8> :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR>
function! AutoHighlightToggle()
let @/ = ''
if exists('#auto_highlight')
au! auto_highlight
augroup! auto_highlight
setl updatetime=4000
echo 'Highlight current word: disabled'
return 0
else
augroup auto_highlight
au!
au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>'
augroup end
setl updatetime=800
echo 'Highlight current word: enabled'
return 1
endif
endfunction
" Turn on Line Numbering with safe Visual line selection.
" Map <F12> to enable the mouse and turn on line numbering.
noremap <f12> :call ToggleNumber() <CR>
function! ToggleNumber()
if &number
set nonumber
if has('mouse') && ! has('gui_running')
" Turn off mouse
set mouse=
endif
echo "Line numbering: disabled"
else
set number
if has('mouse') && ! has('gui_running')
" Turn on mouse so line numbers aren't selected
set mouse=a
endif
echo "Line numbering: enabled"
endif
endfunction
"" Opens an edit command with the path of the currently edited file.
noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
"" Opens a tab edit command with the path of the currently edited file.
noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
if has('win32')
" Convert slashes to backslashes for Windows.
nmap <Leader>cs :let @*=substitute(expand("%"), "/", "\\", "g")<CR>
nmap <Leader>cl :let @*=substitute(expand("%:p"), "/", "\\", "g")<CR>
" This will copy the path in 8.3 short format, for DOS and Windows 9x
nmap <Leader>c8 :let @*=substitute(expand("%:p:8"), "/", "\\", "g")<CR>
else
nmap <Leader>cs :let @*=expand("%")<CR>
nmap <Leader>cl :let @*=expand("%:p")<CR>
endif
" *** Plugin Options ***
" Set Plugin Options after all plugins are loaded.
function! SetPluginOptionsNow()
" Has statusline
if has("statusline")
" Most useful statusline.
" Statusline: File name
set statusline=%<%f\ " File name
set statusline+=%w%h%m%r " Flags
if exists('*fugitive#statusline')
set statusline+=%{fugitive#statusline()} " Fugitive Git info
endif
if exists('*SyntasticStatuslineFlag')
set statusline+=%#warningmsg# " Warning colours
set statusline+=%{SyntasticStatuslineFlag()} " Syntastic info
set statusline+=%* " Reset colors
endif
set statusline+=%= " Right align
set statusline+=%y " File type
set statusline+=[%{(&ff)}] " File format
set statusline+=[
set statusline+=%{(&fenc==\"\"?&enc:&fenc)} " File encoding
" Byte Order Mark
set statusline+=%{(exists(\"+bomb\")\ &&\ &bomb)?\"\ B,\":\"\"}
set statusline+=]
set statusline+=%k\ %-14.(%l,%c%V%)\ %P " Navigation
" show statusline always
set laststatus=2
" turn off ruler
set noruler
endif
endfunction
" On the VimEnter event, call the SetPluginOptionsNow function.
" This happens when starting a new vim session, but after all
" plugins are loaded.
au VimEnter * call SetPluginOptionsNow()
" NERDtree Options
"
" Toggle the NERDTree window.
map <C-n> :NERDTreeToggle %<CR>
" Open NERDTree showing the current file.
nnoremap <silent> <Leader>v :NERDTreeFind<CR>
if has("autocmd")
" Exit vim if NERDTree is the only split left open.
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
endif