Last active
December 10, 2015 05:18
-
-
Save bonau/4386879 to your computer and use it in GitHub Desktop.
my current .vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| syntax on | |
| set sts=2 | |
| set sw=2 | |
| set ts=2 | |
| set et | |
| set autoindent | |
| set nocindent | |
| set smarttab | |
| set nowrap | |
| set number | |
| filetype plugin on | |
| set ruler | |
| set fencs=utf-8,big5,gb2312 | |
| if has("autocmd") | |
| filetype indent on | |
| endif | |
| augroup JumpCursorOnEdit | |
| au! | |
| autocmd BufReadPost * | |
| \ if expand("<afile>:p:h") !=? $TEMP | | |
| \ if line("'\"") > 1 && line("'\"") <= line("$") | | |
| \ let JumpCursorOnEdit_foo = line("'\"") | | |
| \ let b:doopenfold = 1 | | |
| \ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) | | |
| \ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | | |
| \ let b:doopenfold = 2 | | |
| \ endif | | |
| \ exe JumpCursorOnEdit_foo | | |
| \ endif | | |
| \ endif | |
| " Need to postpone using "zv" until after reading the modelines. | |
| autocmd BufWinEnter * | |
| \ if exists("b:doopenfold") | | |
| \ exe "normal zv" | | |
| \ if(b:doopenfold > 1) | | |
| \ exe "+".1 | | |
| \ endif | | |
| \ unlet b:doopenfold | | |
| \ endif | |
| augroup END | |
| filetype plugin on | |
| fun! EnsureVamIsOnDisk(vam_install_path) | |
| " windows users may want to use http://mawercer.de/~marc/vam/index.php | |
| " to fetch VAM, VAM-known-repositories and the listed plugins | |
| " without having to install curl, 7-zip and git tools first | |
| " -> BUG [4] (git-less installation) | |
| let is_installed_c = "isdirectory(a:vam_install_path.'/vim-addon-manager/autoload')" | |
| if eval(is_installed_c) | |
| return 1 | |
| else | |
| if 1 == confirm("Clone VAM into ".a:vam_install_path."?","&Y\n&N") | |
| " I'm sorry having to add this reminder. Eventually it'll pay off. | |
| call confirm("Remind yourself that most plugins ship with ". | |
| \"documentation (README*, doc/*.txt). It is your ". | |
| \"first source of knowledge. If you can't find ". | |
| \"the info you're looking for in reasonable ". | |
| \"time ask maintainers to improve documentation") | |
| call mkdir(a:vam_install_path, 'p') | |
| execute '!git clone --depth=1 git://github.com/MarcWeber/vim-addon-manager '.shellescape(a:vam_install_path, 1).'/vim-addon-manager' | |
| " VAM runs helptags automatically when you install or update | |
| " plugins | |
| exec 'helptags '.fnameescape(a:vam_install_path.'/vim-addon-manager/doc') | |
| endif | |
| return eval(is_installed_c) | |
| endif | |
| endf | |
| fun! SetupVAM() | |
| " Set advanced options like this: | |
| " let g:vim_addon_manager = {} | |
| " let g:vim_addon_manager['key'] = value | |
| " Pipe all output into a buffer which gets written to disk | |
| " let g:vim_addon_manager['log_to_buf'] =1 | |
| " Example: drop git sources unless git is in PATH. Same plugins can | |
| " be installed from www.vim.org. Lookup MergeSources to get more control | |
| " let g:vim_addon_manager['drop_git_sources'] = !executable('git') | |
| " let g:vim_addon_manager.debug_activation = 1 | |
| " VAM install location: | |
| let vam_install_path = expand('$HOME') . '/.vim/vim-addons' | |
| if !EnsureVamIsOnDisk(vam_install_path) | |
| echohl ErrorMsg | |
| echomsg "No VAM found!" | |
| echohl NONE | |
| return | |
| endif | |
| exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager' | |
| " Tell VAM which plugins to fetch & load: | |
| call vam#ActivateAddons([], {'auto_install' : 0}) | |
| " sample: call vam#ActivateAddons(['pluginA','pluginB', ...], {'auto_install' : 0}) | |
| " Addons are put into vam_install_path/plugin-name directory | |
| " unless those directories exist. Then they are activated. | |
| " Activating means adding addon dirs to rtp and do some additional | |
| " magic | |
| " How to find addon names? | |
| " - look up source from pool | |
| " - (<c-x><c-p> complete plugin names): | |
| " You can use name rewritings to point to sources: | |
| " ..ActivateAddons(["github:foo", .. => github://foo/vim-addon-foo | |
| " ..ActivateAddons(["github:user/repo", .. => github://user/repo | |
| " Also see section "2.2. names of addons and addon sources" in VAM's documentation | |
| endfun | |
| call SetupVAM() | |
| " experimental [E1]: load plugins lazily depending on filetype, See | |
| " NOTES | |
| " experimental [E2]: run after gui has been started (gvim) [3] | |
| " option1: au VimEnter * call SetupVAM() | |
| " option2: au GUIEnter * call SetupVAM() | |
| " See BUGS sections below [*] | |
| " Vim 7.0 users see BUGS section [3] | |
| call vam#ActivateAddons(['vim-snippets']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment