-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
executable file
·247 lines (209 loc) · 6.56 KB
/
vimrc
File metadata and controls
executable file
·247 lines (209 loc) · 6.56 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
call pathogen#runtime_append_all_bundles()
set nocompatible
" system stuff
set history=1000
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set hidden " switch buffers without saving
set switchbuf=useopen,usetab
set mouse=a
runtime macros/matchit.vim
" searching
set incsearch
set ignorecase
set smartcase
" tab and backspace
set wildignore=.git,env,*.pyc,*.egg-info,_build,node_modules,pyenv
set wildmenu " make tab completion work like bash
set backspace=indent,eol,start
set autoindent
set expandtab
set tabstop=4
set shiftwidth=4
if v:version >= 704
set softtabstop=-1
else
set softtabstop=4
endif
" Remap the tab key to do autocompletion or indentation depending on the
" context (from http://www.vim.org/tips/tip.php?tip_id=102)
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>
" Map key to toggle opt
function MapToggle(key, opt)
let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>"
exec 'nnoremap '.a:key.' '.cmd
exec 'inoremap '.a:key." \<C-O>".cmd
endfunction
command -nargs=+ MapToggle call MapToggle(<f-args>)
" display setup
set ruler " show cusor position
set showcmd " display incomplete commands
set scrolloff=3
set cmdheight=2
set winwidth=84
set winheight=25
set winminheight=10
set number " turn on line numbering
set relativenumber
set list " show invisibles
MapToggle <f2> number
MapToggle <f3> relativenumber
MapToggle <f4> list
set laststatus=2 " always show status line
set statusline=
set statusline+=%-3.3n\ " buffer number
set statusline+=%f\ " filename
set statusline+=%h%m%r%w " status flags
set statusline+=\[%{strlen(&ft)?&ft:'none'}] " file type
set statusline+=%= " right align remainder
set statusline+=0x%-8B " character value
set statusline+=%-14(%l,%c%V%) " line, character
set statusline+=%<%P " file position
colorscheme grb256
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
set guioptions-=m
set guioptions-=T
endif
"set cursorline # higlight current line
" customize tab labels
function! MyTabLabel(n)
let label = '[' . (a:n)
let buflist = tabpagebuflist(a:n)
for bufnr in buflist
if getbufvar(bufnr, '&modified')
let label .= '*'
break
endif
endfor
let label .= ']'
let m = bufname(buflist[tabpagewinnr(a:n) - 1])
let label .= fnamemodify(m, ':t')
return label
endfunction
function! MyTabLine()
let s = ''
for i in range(tabpagenr('$'))
" select the highlighting
if i + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif
" set the tab page number (for mouse clicks)
let s .= '%' . (i + 1) . 'T'
" the label is made by MyTabLabel()
let s .= ' %{MyTabLabel(' . (i + 1) . ')} |'
endfor
" after the last tab fill with TabLineFill and reset tab page nr
let s .= '%#TabLineFill#%T'
" right-align the label to close the current tab page
if tabpagenr('$') > 1
let s .= '%=%#TabLine#%999X X'
endif
return s
endfunction
set tabline=%!MyTabLine()
hi TabLine cterm=underline ctermbg=none
hi TabLineFill cterm=underline
hi TabLineSel cterm=underline ctermbg=0*
" save and restore window state when switching buffers
if v:version >= 700
au BufLeave * let b:winview = winsaveview()
au BufEnter * if(exists('b:winview')) | call winrestview(b:winview) | endif
endif
" keys and mappings
let mapleader=","
map <leader>\dontstealmymapsmakegreen :w\|:call MakeGreen('spec')<cr>
nnoremap <cr> :nohlsearch<cr>/<bs>
nnoremap <leader><leader> <C-^>
vnoremap <leader>y "*y
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
nnoremap <c-n> :let &wh = (&wh == 999 ? 10 : 999)<CR><C-W>=
if &diff
nmap <c-h> :diffget LOCAL<cr>
nmap <c-l> :diffget REMOTE<cr>
nmap <c-k> [cz.
nmap <c-j> ]cz.
set nonumber
endif
" Make <leader>' switch between ' and "
nnoremap <leader>' ""yls<c-r>={'"': "'", "'": '"'}[@"]<cr><esc>
" edit file named under cursor (possibly nonexistent)
nnoremap <leader>cf :e %:h/<cfile><cr>
command! W :w
command! Wq :wq
command! Wqa :wqa
command! Tabnew :tabnew
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'))
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
" file types
if has("autocmd")
filetype plugin indent on
au BufRead,BufNewFile triage.txt set ft=cstriage
au BufRead,BufNewFile *.tac set ft=python
au BufRead,BufNewFile *.json set filetype=json
au BufRead,BufNewFile *.pde set filetype=arduino
au BufRead,BufNewFile *.ino set filetype=arduino
au FileType text setlocal textwidth=78
augroup arduino_autocmd
autocmd!
autocmd FileType arduino setlocal cindent
autocmd FileType arduino setlocal shiftwidth=2
augroup END
augroup js_autocmd
autocmd!
autocmd FileType javascript setlocal autoindent
autocmd FileType javascript setlocal formatoptions+=l
autocmd FileType javascript setlocal textwidth=78
autocmd FileType javascript setlocal shiftwidth=2
augroup END
augroup json_autocmd
autocmd!
autocmd FileType json setlocal autoindent
autocmd FileType json setlocal formatoptions+=l
autocmd FileType json setlocal textwidth=78
autocmd FileType json setlocal shiftwidth=2
augroup END
augroup cucumber_autocmd
autocmd!
autocmd FileType cucumber setlocal autoindent
autocmd FileType cucumber setlocal textwidth=78
autocmd FileType cucumber setlocal shiftwidth=2
augroup END
augroup yaml_autocmd
autocmd!
autocmd FileType yaml setlocal shiftwidth=2
augroup END
endif
" syntastic options
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_python_checkers=['flake8']
" markdown options
let g:vim_markdown_folding_disabled = 1
" jsonnet options
let g:jsonnet_fmt_options = ' -i -n 2 --string-style d --comment-style h --no-sort-imports '