-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
executable file
·341 lines (274 loc) · 8.87 KB
/
Copy path.vimrc
File metadata and controls
executable file
·341 lines (274 loc) · 8.87 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
set nocompatible
" Vundle
if !isdirectory(expand("~/.vim/bundle/vundle"))
silent !git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
let s:setupvundle=1
endif
filetype off " will be turned back on later
set rtp+=~/.vim/bundle/vundle/
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
" My plugins
Plugin 'sargon2/git-wip'
" Syntastic seems to hang when I :w java files
" Plugin 'scrooloose/syntastic'
Plugin 'desert256.vim'
Plugin 'Raimondi/YAIFA'
Plugin 'openssl.vim'
Plugin 'cmdalias.vim'
Plugin 'davidhalter/jedi-vim'
Plugin 'tpope/vim-fugitive'
Plugin 'kien/ctrlp.vim'
Plugin 'VOoM'
Plugin 'elzr/vim-json'
Plugin 'fatih/vim-go'
" Plugin 'klen/python-mode'
" TODO: automatically run vundle on startup? is it fast enough? surely at least BundleClean is...
call vundle#end()
filetype plugin indent on
if exists('s:setupvundle') && s:setupvundle
unlet s:setupvundle
PluginInstall
quitall
endif
let g:vim_json_syntax_conceal = 0 " don't conceal quotes in json highlighting
" jedi config
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#goto_assignments_command = "<F3>"
" pymode config
" let g:pymode_rope_organize_imports_bind = '<C-c>ro'
" let g:pymode_rope_autoimport_bind = '<C-c>ra' " Should be enabled 'g:pymode_rope_autoimport'
" let g:pymode_rope_module_to_package_bind = '<C-c>r1p'
" let g:pymode_rope_use_function_bind = '<C-c>ru'
" let g:pymode_rope_move_bind = '<C-c>rv'
" let g:pymode_rope_change_signature_bind = '<C-c>rs'
let g:pymode_options = 0 " Turn off 79-col max, etc
let g:pymode_lint = 0
let g:pymode_lint_write = 0
let g:pymode_rope = 1
let g:pymode_rope_rename_bind = '<F2>'
" let g:pymode_rope_rename_module_bind = '<F2>'
let g:pymode_rope_goto_definition_bind = '<F3>'
let g:pymode_rope_goto_definition_cmd = 'new' " e, new, vnew
let g:pymode_rope_extract_method_bind = '<F4>'
let g:pymode_rope_extract_variable_bind = '<F5>'
" invoke git-wip
so ~/.vim/bundle/git-wip/vim/plugin/git-wip.vim
set mouse=a
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
set hidden
set ruler
set incsearch
set hlsearch
set nobackup
set noswapfile
set showcmd
" Set timeout. If this is too low, I get strange characters on startup.
set timeout
set timeoutlen=300
set ttimeout
set ttimeoutlen=100
set ignorecase
set infercase
set backspace=indent,eol,start
set nowrap
set scrolloff=5
set modeline " warning, there are weird security vulnerabilities with modelines
set cm=blowfish2
set display+=lastline
set clipboard=unnamed " on mac, use the system clipboard TODO choose automatically
" Make tab completion for files work like bash (for :e etc)
set nowildmenu
set wildmode=longest,list
set t_Co=256
colorscheme desert256
if &term =~ '256color'
" Disable Background Color Erase (BCE) so that color schemes
" work properly when Vim is used inside tmux and GNU screen.
set t_ut=
endif
syntax on
" If we're in the middle of a word, tab-complete it, otherwise insert a tab
function! CleverTab()
" if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\S'
return "\<Tab>"
else
return "\<C-X>\<C-O>"
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
set completeopt=longest,menuone
" highlight trailing whitespace (from http://vim.wikia.com/wiki/Highlight_unwanted_spaces)
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" color for line numbers
highlight LineNr ctermfg=darkgrey
au BufRead,BufNewFile *.txt set filetype=text
" YAIFA breaks on go.
autocmd BufRead,BufNewFile *.go let yaifa_disabled=1
" disable annoying auto-wrap for text files
autocmd FileType text setlocal textwidth=0
autocmd FileType text set wrap
" parse .xhtml as .html
au BufRead,BufNewFile *.xhtml set filetype=html
au BufRead,BufNewFile *.xhtml set indentexpr=
autocmd BufRead,BufNewFile *.as set filetype=actionscript
autocmd BufRead,BufNewFile *.mxml set filetype=mxml
" inform 7
autocmd BufRead,BufNewFile *.ni set filetype=inform7
autocmd BufRead,BufNewFile *.i7x set filetype=inform7
autocmd FileType inform7 set wrap
autocmd FileType inform7 set nu
" LaTeX
autocmd FileType tex set wrap
autocmd FileType plaintex set wrap
" 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).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Change yank to not affect the current cursor position (the default is to
" move it to the start of the selection)
vnoremap y myyg`y
" If you select lines, then paste over them, it shouldn't copy what you replaced.
vnoremap p "0p
set linebreak
au BufEnter * call MyLastWindow()
function! MyLastWindow()
" if the window is quickfix go on
if &buftype=="quickfix"
" if this window is last on screen quit without warning
if winbufnr(2) == -1
quit!
endif
endif
endfunction
map <s-down> j
map <s-up> k
"make alt+# swap buffers
nmap <esc>1 :b 1<CR>
nmap <esc>2 :b 2<CR>
nmap <esc>3 :b 3<CR>
nmap <esc>4 :b 4<CR>
nmap <esc>5 :b 5<CR>
nmap <esc>6 :b 6<CR>
nmap <esc>7 :b 7<CR>
nmap <esc>8 :b 8<CR>
nmap <esc>9 :b 9<CR>
"mac: make opt+# swap buffers
nmap ¡ :b 1<CR>
nmap ™ :b 2<CR>
nmap £ :b 3<CR>
nmap ¢ :b 4<CR>
nmap ∞ :b 5<CR>
nmap § :b 6<CR>
nmap ¶ :b 7<CR>
nmap • :b 8<CR>
nmap ª :b 9<CR>
" This breaks moving up and down in macros, so I commented it out.
" "make alt+arrow move lines up or down
" nnoremap <esc><down> :m+<CR>
" nnoremap <esc><up> :m-2<CR>
" inoremap <esc><down> <Esc>:m+<CR>gi
" inoremap <esc><up> <Esc>:m-2<CR>gi
" vnoremap <esc><down> :m'>+<CR>gv
" vnoremap <esc><up> :m-2<CR>gv
"make ctrl-d quit, and save undo
map <c-d> <ESC>:qa!<CR>
map! <c-d> <ESC>:qa!<CR>
"disable ex-mode
map Q <Nop>
"make regular expressions more sane
nnoremap / /\v
" TODO: make this work for :%s/.../.../g -- it doesn't work because timeout is set to zero
cnoremap s/ s/\v
"make :W save with sudo (kind of, doesn't mark the file as written)
command W w !sudo tee % > /dev/null
" Input Director sends weird keystrokes if putty has focus when I move machines.
map <ESC>OP <Nop>
map! <ESC>OP <Nop>
autocmd VimEnter * Alias q qa
autocmd VimEnter * Alias wq wqa
set expandtab
set tabstop=4
set shiftwidth=4
set encoding=utf-8
setglobal fileencoding=utf-8
"setglobal bomb " byte order marks aren't actually used
set fileencodings=utf-8,latin1
" pip install ropevim
if filereadable("/usr/local/share/vim/plugin/ropevim.vim")
source /usr/local/share/vim/plugin/ropevim.vim
endif
"make vimdiff more readable
:highlight! link DiffChange Normal
:highlight! link DiffText CursorLine
:highlight! link DiffAdd TabLine
:highlight! link DiffDelete Ignore
" TODO: make vimdiff not fold things by default
"make omnicompletion more readable
:highlight Pmenu ctermbg=238 gui=bold
" Remove whitespace at the end of lines for some file types
autocmd BufWritePre *.cpp,*.c,*.hpp,*.h,*.java,*.py %s/\s\+$//ge
set foldlevelstart=99
" Change the way folding works for plain text files
function! MyFoldLevel(lnum)
" There are N cases:
" Line 1 <-- fold starts
" Line 2
"
" Line 1 <-- no fold starts
" Line 2
"
" Line 1 <-- fold ends
" Line 2
"
" Line 1 <-- 2 folds end
" Line 2
if getline(a:lnum) =~ '^\s*$'
return -1 " should this be '='?
endif
let ind = (indent(a:lnum)/&shiftwidth)
let next_ind = (indent(a:lnum+1)/&shiftwidth)
" let prev_ind = (indent(a:lnum-1)/&shiftwidth)
if ind < next_ind
return '>'.next_ind
endif
return ind
endfunction
autocmd FileType text setlocal foldmethod=expr
autocmd FileType text setlocal foldexpr=MyFoldLevel(v:lnum)
autocmd FileType text set foldtext=getline(v:foldstart)
autocmd FileType text set fillchars=fold:\ "(there's a space after that \)
" We can't do this with a normal set because it gets overridden by filetype
" plugins
autocmd FileType * setlocal formatoptions=tcqnj
" Persistent undo
silent !mkdir -p ~/.vim/undodir >/dev/null 2>&1
set undodir=~/.vim/undodir
set undofile
" Allow the cursor off the end of the line to the right.
" Also allows it 'inside' tab characters
set virtualedit=all
" This breaks something in macros, so I commented it out.
"
" Don't move the cursor left one when existing insert mode
" http://vim.wikia.com/wiki/Prevent_escape_from_moving_the_cursor_one_character_to_the_left
" let CursorColumnI = 0 "the cursor column position in INSERT
" autocmd InsertEnter * let CursorColumnI = col('.')
" autocmd CursorMovedI * let CursorColumnI = col('.')
" autocmd InsertLeave * if col('.') != CursorColumnI | call cursor(0, col('.')+1) | endif
"
let g:go_null_module_warning = 0