-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.vimrc
More file actions
321 lines (263 loc) · 8.8 KB
/
.vimrc
File metadata and controls
321 lines (263 loc) · 8.8 KB
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
314
315
316
317
318
319
320
321
"
" Author: Iouri Goussev <i.gouss+vimrc@gmail.com>
"
set nocompatible
" Behaviour
set backup
set backupcopy=yes
set incsearch
set mouse=a
set backspace=2
set history=50
" Visual
syntax on
"colorscheme delek
"colorscheme black_angus
set background=light
set ruler
set showcmd
set cmdheight=2
set laststatus=2
"set number
set showmatch
set mat=5 " how many tenths of a second to blink matching brackets for
set novisualbell
set noerrorbells
set showmode
set cursorline
set hlsearch
set statusline=[%l,%c\ %P%M]\ %f\ %r%h%w
set title
set icon
set autoread
"These two options, when set together, will make /-style searches
"case-sensitive only if there is a capital letter in the search expression.
"*-style searches continue to be consistently case-sensitive
set ignorecase
set smartcase
set wildmenu
set wildmode=list:longest
"When the cursor is moved outside the viewport of the current window, the
"buffer is scrolled by a single line. Setting the option below will start the
"scrolling three lines before the border, keeping more context around where
"you’re working.
set scrolloff=3
set virtualedit=all
" allow ESC-sequenzes in 'insert-mode'
set esckeys
set showtabline=2
set directory=~/tmp/
set shortmess=atI " shortens messages to avoid 'press a key' prompt
let g:netrw_browse_split=3
let g:netrw_hide=1
let g:netrw_fastbrowse=0
" Folding
set foldenable
" set foldlevel=3
" set foldmethod=indent
set guioptions-=m
set guioptions-=T
"Clojure
let clj_highlight_builtins = 1
let clj_highlight_contrib = 1
let clj_parent_rainbow = 1
let clj_want_gorilla = 1
let vimclojure#NailgunClient = "/Users/elendal/opt/nailgun/ng"
"
" File detection and indenting
filetype on
filetype plugin indent on
runtime ftplugin/man.vim
"The % key will switch between opening and closing brackets. By sourcing
"matchit.vim, it can also switch among e.g. if/elsif/else/end, between opening
"and closing XML tags, and more.
runtime macros/matchit.vim
set tabstop=4
set shiftwidth=4
set expandtab
" disable arrow keys
"inoremap <Left> <NOP>
"inoremap <Right> <NOP>
"inoremap <Up> <NOP>
"inoremap <Down> <NOP>
"autocmd {event} {path} {ex commands and options}
"autocmd BufRead,BufNewFile *.java set expandtab
autocmd BufRead,BufNewFile todo.txt,*.todo.txt,recur.txt,*.todo set filetype=todo
autocmd FileType ruby setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd BufNewFile,BufRead *.rhtml setlocal ft=eruby
autocmd BufNewFile * :exe("0r! ~/.vim/skeleton.rb %:p " . &filetype)
autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit
" When editing a file, always jump to the last cursor position.
autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
autocmd BufNewFile,BufRead *.groovy setf groovy
if did_filetype()
finish
endif
if getline(1) =~ '^#!.*[/\\]groovy\>'
setf groovy
endif
let g:explHideFiles='^\.,\.~$,*swp$,\.DS_Store$'
let g:explDetailedHelp=0
let g:explDirsFirst=-1
let g:explDetailedHelp=0
inoremap <C-Space> <C-X><C-O>
map :Texplore<CR>
map <C-PageUp> <Esc>:tabnew<CR>
map <C-Left> :tabprev<CR>
map <c-Right> <Esc>:tabnext<CR>
map <C-PageDown> <Esc>:tabclose<CR>
map <F1> <esc>
"nnoremap <Tab> <Esc>:tabnext<CR>
"nnoremap <S-Tab> <Esc>:tabprev<CR>
map <c-l> <Esc>:nohlsearch<CR>
" remap Ctrl-W to delerte current word
"map <C-W> bdwA
"imap <C-W> <Esc>bdwA
" indent whole buffer
noremap <F8> gg=G``
set pastetoggle=<F5>
nmap :W :w
nmap :Q :q
nmap :WQ :wq
"map <F5> :set paste<CR>
"map <F6> :set nopaste<CR>
"nmap <leader>rci :%!ruby-code-indenter<cr>
highlight TabLineSel guifg=White guibg=Red ctermfg=White ctermbg=Red
highlight TabLine ctermfg=Black ctermbg=White
highlight TabLineFill ctermfg=Black ctermbg=White
"highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen
"highlight ExtraWhitespace ctermbg=red guibg=red
"highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
"autocmd BufWinEnter * match ExtraWhitespace /^\s* \s*\|\s\+$/
"highlight LeadingTab ctermbg=blue guibg=blue
"highlight LeadingSpace ctermbg=darkgreen guibg=darkgreen
"highlight EvilSpace ctermbg=darkred guibg=darkred
"au Syntax * syn match LeadingTab /^\t\+/
"au Syntax * syn match LeadingSpace /^\ \+/
"au Syntax * syn match EvilSpace /\(^\t*\)\@<!\t\+/ " tabs not preceeded by tabs
"au Syntax * syn match EvilSpace /[ \t]\+$/ " trailing space
"display trailing whitespace and tabs
highlight SpecialKey ctermfg=DarkGray
set list listchars=tab:\|_,trail:.
set statusline=%<[%n]\ %F\ \ Filetype=\%Y\ \ %r\ %1*%m%*%w%=%(Line:\ %l%)%4(%)Column:\ %5(%c%V/%{strlen(getline(line('.')))}%)\ %4(%)%p%%
" set statusline=[%n]\ %<%f\ %((%1*%M%*%R%Y)%)\ %=%-19(\LINE\ [%3l/%3L]\ COL\ [%02c%03V]%)\ %P
" set statusline=\ %m%r\ \ (Vim\ %{Version()})\ [%02n]\ %t\ [%{Fileformat()}]\ %=(%Y)\ L:%l/%L\ C:%c\ P:%p\ \ \ [%{strftime\(\"\%R\"\)}]\%<\ \ \
" set statusline=-%m%r-----(Vim\ %{Version()})\ [%02n]\ %t\ %=(%Y)\ %l/%L,%c\ \ [%{strftime\(\"\%R\"\)}]\%<---------
" set statusline=[%n]\ %<%f\ %((%1*%M%*%R%Y)%)\ %=%-19(\LINE\ [%3l/%3L]\ COL\ [%02c%03V]%)\ ascii['%02b']\ %P
" set statusline=%<[%n]\ %F\ \ Filetype=\%Y\ \ Fileformat=%{Fileformat()}\ \ %r\ %1*%m%*%w%=%(Column:\ %c%V%)%4(%)%-10(Line:\ %l%)\ %4(%)%p%%
" set statusline=%4*%m%3*%<%F%3*%=Christian\ Schneider\ %5*\ Line\et
function! GuiTabLabel()
" add the tab number
let label = '['.tabpagenr()
" modified since the last save?
let buflist = tabpagebuflist(v:lnum)
for bufnr in buflist
if getbufvar(bufnr, '&modified')
let label .= '*'
break
endif
endfor
" count number of open windows in the tab
let wincount = tabpagewinnr(v:lnum, '$')
if wincount > 1
let label .= ', '.wincount
endif
let label .= '] '
" add the file name without path information
let n = bufname(buflist[tabpagewinnr(v:lnum) - 1])
let label .= fnamemodify(n, ':t')
return label
endfunction
function! s:SID_PREFIX()
return matchstr(expand('<sfile>'), '<SNR>\d\+_')
endfunction
function! s:GetTabVar(tabnr, varname)
" Wrapper for non standard (my own) built-in function gettabvar().
return exists('*gettabvar') ? gettabvar(a:tabnr, a:varname) : ''
endfunction
" VCS branch name "{{{2
" Returns the name of the current branch of the given directory.
" BUGS: git is only supported.
let s:_vcs_branch_name_cache = {} " dir_path = [branch_name, key_file_mtime]
function! s:vcs_branch_name(dir)
let cache_entry = get(s:_vcs_branch_name_cache, a:dir, 0)
if cache_entry is 0
\ || cache_entry[1] < getftime(s:_vcs_branch_name_key_file(a:dir))
unlet cache_entry
let cache_entry = s:_vcs_branch_name(a:dir)
let s:_vcs_branch_name_cache[a:dir] = cache_entry
endif
return cache_entry[0]
endfunction
function! s:_vcs_branch_name_key_file(dir)
return a:dir . '/.git/HEAD'
endfunction
function! s:_vcs_branch_name(dir)
let head_file = s:_vcs_branch_name_key_file(a:dir)
let branch_name = ''
if filereadable(head_file)
let ref_info = s:first_line(head_file)
if ref_info =~ '^\x\{40}$'
let remote_refs_dir = a:dir . '/.git/refs/remotes/'
let remote_branches = split(glob(remote_refs_dir . '**'), "\n")
call filter(remote_branches, 's:first_line(v:val) ==# ref_info')
if 1 <= len(remote_branches)
let branch_name = 'remote: '. remote_branches[0][len(remote_refs_dir):]
endif
else
let branch_name = matchlist(ref_info, '^ref: refs/heads/\(\S\+\)$')[1]
if branch_name == ''
let branch_name = ref_info
endif
endif
endif
return [branch_name, getftime(head_file)]
endfunction
function! s:first_line(file)
let lines = readfile(a:file, '', 1)
return 1 <= len(lines) ? lines[0] : ''
endfunction
function! s:MyTabLine() "{{{
let s = ''
for i in range(1, tabpagenr('$'))
let bufnrs = tabpagebuflist(i)
let curbufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears
let no = (i <= 10 ? i-1 : '#') " display 0-origin tabpagenr.
let mod = len(filter(bufnrs, 'getbufvar(v:val, "&modified")')) ? '+' : ' '
let title = s:GetTabVar(i, 'title')
let title = len(title) ? title : fnamemodify(s:GetTabVar(i, 'cwd'), ':t')
let title = len(title) ? title : fnamemodify(bufname(curbufnr),':t')
let title = len(title) ? title : '[No Name]'
let s .= '%'.i.'T'
let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#'
let s .= no
let s .= mod
let s .= title
let s .= '%#TabLineFill#'
let s .= ' '
endfor
let s .= '%#TabLineFill#%T'
let s .= '%=%#TabLine#'
let s .= '| '
let s .= '%999X'
let branch_name = s:vcs_branch_name(getcwd())
let s .= (branch_name != '' ? branch_name : '?')
let s .= '%X'
return s
endfunction "}}}
let &tabline = '%!' . s:SID_PREFIX() . 'MyTabLine()'
" Scroll one page forward
noremap <script> <Space> :call <SID>NextPage()<CR><SID>L
fun! s:NextPage()
if line(".") == line("$")
if argidx() + 1 >= argc()
quit
endif
next
1
else
exe "normal! \<C-F>"
endif
endfun
" Quitting
noremap q :q<CR>