-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
291 lines (235 loc) · 8.59 KB
/
.vimrc
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
" setup vim
" see for the original that contained many of these settings
" http://www.pixelbeat.org/settings/.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
"finish
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
if has('win32') || has('win64')
exec 'set runtimepath=$HOME/.vim,' . escape(&runtimepath, ' ')
endif
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
set backupdir=~/.vim/backups
endif
set history=1000 " keep 1000 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Set terminal title to filename
"set titlestring = \"%t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}"
"set title
"let &titleold = getcwd()
" Title can break some terminal windows, so disable by default unless you
" don't mid the mangling effect it has on the window title.
set notitle
" This is necessary to allow pasting from outside vim. It turns off auto stuff.
" You can tell you are in paste mode when the ruler is not visible
set pastetoggle=<F2>
" generally don't care about case when searching most text
set ignorecase
" Show menu with possible tab completions
set wildmenu
" Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,.git,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif
" for pathogen plugins
if has("autocmd")
call pathogen#infect()
silent! call pathogen\#helptags()
silent! call pathogen\#runtime_append_all_bundles()
" for vim-flake8
let g:flake8_max_line_length = 99
endif
" Some general configuration
scriptencoding utf-8
set shortmess+=filmnrxoOtT
set viewoptions=folds,options,cursor,unix,slash
set spell " enable spell checking
helptags ~/.vim/doc
set shellslash
let g:tex_flavor='latex'
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'JamshedVesuna/vim-markdown-preview'
Plugin 'fatih/vim-go'
Plugin 'mzlogin/vim-markdown-toc'
Plugin 'vim-ruby/vim-ruby'
" Provided by xenial
"Plugin 'Valloric/YouCompleteMe'
" All of your Plugins must be added before the following line
call vundle#end() " required
let vim_markdown_preview_github=1 " use grip for github flavour markdown
let vim_markdown_preview_browser='Mozilla Firefox' " bugfix for window name searching
let vim_markdown_preview_toggle=1 " display on Ctrl+P with images
let vim_markdown_preview_use_xdg_open=1
" 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).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" enable minibufexplorer
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
let g:miniBufExplForceSyntaxEnable = 1
map <F4> :TlistToggle<CR>
map <F5> :MiniBufExplorer<CR>
""""""""""""""""""""""""""""""""""""""""""""""""
" Indenting
""""""""""""""""""""""""""""""""""""""""""""""""
"
" Default to autoindenting of C like languages
" This is overridden per filetype below
set noautoindent smartindent
set smarttab
set tabstop=8
set softtabstop=4
set nojoinspaces
set shiftwidth=4
set shiftround
""""""""""""""""""""""""""""""""""""""""""""""""
" Dark background
""""""""""""""""""""""""""""""""""""""""""""""""
"
" set personal preferences
set background=dark
colorscheme elflord
" set highlight plugin colors
let g:lcolor_bg = "magenta,green,magenta,lightred,lightgreen,lightblue,darkmagenta,darkmagenta"
let g:pcolor_bg = "yellow,blue,green,magenta,cyan,brown,yellow,red"
""""""""""""""""""""""""""""""""""""""""""""""""
" Key bindings
""""""""""""""""""""""""""""""""""""""""""""""""
" Note <leader> is the user modifier key (like g is the vim modifier key)
" One can change it from the default of \ using: let mapleader = ","
" \n to turn off search highlighting
nmap <silent> <leader>n :silent :nohlsearch<CR>
" \l to toggle visible whitespace
nmap <silent> <leader>l :set list!<CR>
" Shift-tab to insert a hard tab
imap <silent> <S-tab> <C-v><tab>
" <home> toggles between start of line and start of text
imap <khome> <home>
nmap <khome> <home>
inoremap <silent> <home> <C-O>:call Home()<CR>
nnoremap <silent> <home> :call Home()<CR>
function! Home()
let curcol = wincol()
normal ^
let newcol = wincol()
if newcol == curcol
normal 0
endif
endfunction
" <end> goes to end of screen before end of line
imap <kend> <end>
nmap <kend> <end>
inoremap <silent> <end> <C-O>:call End()<CR>
nnoremap <silent> <end> :call End()<CR>
function! End()
let curcol = wincol()
normal g$
let newcol = wincol()
if newcol == curcol
normal $
endif
" The following is to work around issue for insert mode only.
" normal g$ doesn't go to pos after last char when appropriate.
" More details and patch here:
" http://www.pixelbeat.org/patches/vim-7.0023-eol.diff
if virtcol(".") == virtcol("$") - 1
normal $
endif
endfunction
" Ctrl-{up,down} to scroll.
" The following only works in gvim?
" Also vim doesn't have default C-{home,end} bindings?
if has("gui_running")
nmap <C-up> <C-y>
imap <C-up> <C-o><C-y>
nmap <C-down> <C-e>
imap <C-down> <C-o><C-e>
endif
""""""""""""""""""""""""""""""""""""""""""""""""
" file type handling
""""""""""""""""""""""""""""""""""""""""""""""""
if has("autocmd")
" override defaults for subsets of filetypes
au BufRead,BufNewFile *.json set shiftwidth=2 softtabstop=4 tabstop=8 expandtab
au BufRead,BufNewFile *.sh set shiftwidth=4 softtabstop=4 tabstop=8 expandtab
au BufRead,BufNewFile *.bash set shiftwidth=4 softtabstop=4 tabstop=8 expandtab
" then add custom settings
augroup tcl
au!
au FileType tcl set shiftwidth=2 softtabstop=4 tabstop=8 expandtab
augroup END
augroup Ruby
au!
au FileType ruby set shiftwidth=2 softtabstop=4 tabstop=8 expandtab
au FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
au FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
au FileType ruby,eruby let g:rubycomplete_rails = 1
" <C-x><C-o> to autocomplete
au FileType ruby,eruby set omnifunc=rubycomplete#Complete
" Don't show docs in preview window
au FileType ruby,eruby set completeopt-=preview
augroup END
augroup Python
" See $VIMRUNTIME/ftplugin/python.vim
au!
" smart indent really only for C like languages
" See $VIMRUNTIME/indent/python.vim
au FileType python set nosmartindent autoindent
au FileType python set expandtab
" Allow gf command to open files in $PYTHONPATH
au FileType python let &path = &path . "," . substitute($PYTHONPATH, ';', ',', 'g')
if v:version >= 700
" See $VIMRUNTIME/autoload/pythoncomplete.vim
" <C-x><C-o> to autocomplete
au FileType python set omnifunc=pythoncomplete#Complete
" Don't show docs in preview window
au FileType python set completeopt-=preview
endif
augroup END
au BufWritePre * let &bex = '-' . strftime("%Y%m%d-%H%M%S") . '.vimbackup'
autocmd ColorScheme,BufWinEnter * highlight ExtraWhitespace ctermbg=red guibg=red
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$\|\t\+/
autocmd InsertLeave,BufRead,BufNewFile * match ExtraWhitespace /\s\+$\|\t\+/
autocmd BufWinLeave * call clearmatches()
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$\|\t\+/
endif