Created
August 9, 2012 09:01
-
-
Save adragomir/3302496 to your computer and use it in GitHub Desktop.
Taverius' _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
| " _vimrc @ (c) Leonardo Valeri Manera, 2010, 2011 | |
| " Contains code from Ciaran McCreesh's .vimrc | |
| " Contains code from amix the lucky stiff's .vimrc | |
| " Contains code from Dominique Pelle's .vimrc | |
| " Contains code from Henning Hasemann's .vimrc | |
| " Contains code from Matthew Woznisky's .vimrc | |
| cd $HOME | |
| let g:skip_loading_mswin = 1 | |
| if v:progname =~? "evim" | |
| finish | |
| endif | |
| set nocompatible " Don't be compatible with Vi. | |
| " *************** " | |
| " Vundle " | |
| " *************** " | |
| filetype off " Required | |
| set runtimepath+=$HOME\vimfiles\bundle\vundle | |
| call vundle#rc($HOME.'\vimfiles\bundle\') | |
| " Let Vundle manage Vundle | |
| " Required! | |
| Bundle 'gmarik/vundle' | |
| " Headlights | |
| " Bundle 'Headlights' | |
| Bundle 'mbadran/headlights' | |
| " Libraries | |
| Bundle 'repeat.vim' | |
| Bundle 'tomtom/tlib_vim' | |
| " File Explorer | |
| if has('ruby') | |
| Bundle 'LustyExplorer' | |
| else | |
| Bundle 'scrooloose/nerdtree' | |
| endif | |
| " Buffer Explorer | |
| Bundle 'jeetsukumaran/vim-buffergator' | |
| " Completion | |
| Bundle 'neocomplcache' | |
| Bundle 'ujihisa/neco-ruby' | |
| " Tags | |
| Bundle 'xolox/vim-easytags' | |
| " Plugins | |
| Bundle 'tpope/vim-abolish' | |
| Bundle 'Align' | |
| Bundle 'dterei/VimBookmarking' | |
| Bundle 'mrmargolis/dogmatic.vim' | |
| Bundle 'matchit.zip' | |
| Bundle 'netrw.vim' | |
| Bundle 'tomtom/tcomment_vim' | |
| Bundle 'ReplaceWithRegister' | |
| Bundle 'ciaranm/securemodelines' | |
| Bundle 'sessionman.vim' | |
| Bundle 'shell.vim--Odding' | |
| Bundle 'tpope/vim-surround' | |
| Bundle 'majutsushi/tagbar' | |
| Bundle 'tomtom/tmru_vim' | |
| Bundle 'YankRing.vim' | |
| if has('python') | |
| Bundle 'Gundo' | |
| endif | |
| " Vim Lint | |
| Bundle 'dahu/VimLint' | |
| " Ruby | |
| Bundle 'depuracao/vim-rdoc' | |
| if has('ruby') | |
| Bundle 'vim-ruby/vim-ruby' | |
| endif | |
| Bundle 'ri-viewer' | |
| " PHP | |
| Bundle 'Taverius/Vim-PHP-Stuff' | |
| Bundle '2072/PHP-Indenting-for-VIm' | |
| Bundle 'phpcomplete.vim' | |
| " LISP | |
| if has('python') | |
| Bundle 'slimv.vim' | |
| endif | |
| " Clojure | |
| " Bundle 'VimClojure' | |
| " C# | |
| Bundle 'sharp-Indent' | |
| Bundle 'Compiler-Plugin-for-msbuild-csc' | |
| Bundle 'cscomment.vim' | |
| " Misc | |
| Bundle 'Taverius/Better-CSS-Syntax-for-Vim' | |
| Bundle 'JSON.vim' | |
| Bundle 'nono/jquery.vim' | |
| " Bundle 'hallison/vim-markdown' | |
| " Bundle 'plasticboy/vim-markdown' | |
| " Bundle 'tpope/vim-markdown' | |
| " Bundle 'robertwahler/vim-markdown' | |
| Bundle 'bdesham/vim-markdown' | |
| Bundle 'NSIS-syntax-highlighting' | |
| if has('ruby') | |
| Bundle 'greyblake/vim-preview' | |
| endif | |
| Bundle 'jiangmiao/simple-javascript-indenter' | |
| " Colorscheme Utilities | |
| Bundle 'CSApprox' | |
| Bundle 'guicolorscheme.vim' | |
| Bundle 'colorsupport.vim' | |
| " Colorschemes | |
| Bundle 'Ambient-Color-Scheme' | |
| Bundle 'candyman.vim' | |
| Bundle 'mgutz/vim-colors' | |
| " chance-of-storm, southwest-fog | |
| Bundle 'CodeFactory' | |
| Bundle 'darkburn' | |
| Bundle 'darkspectrum' | |
| Bundle 'desertEx' | |
| Bundle 'geetarista/ego.vim' | |
| Bundle 'ekini-dark-colorscheme' | |
| Bundle 'herald.vim' | |
| Bundle 'Taverius/ir_black' | |
| Bundle 'nanotech/jellybeans.vim' | |
| Bundle 'guns/jellyx.vim' | |
| Bundle 'kiss.vim' | |
| Bundle 'Liquid-Carbon' | |
| Bundle 'Lucius' | |
| Bundle 'manuscript' | |
| Bundle 'mdark.vim' | |
| Bundle 'tomasr/molokai' | |
| Bundle 'moria' | |
| Bundle 'mrpink' | |
| Bundle 'Nazca' | |
| Bundle 'obsidian' | |
| Bundle 'peaksea' | |
| Bundle 'pf_earth.vim' | |
| Bundle 'Taverius/Royal-Colorschemes' | |
| " Royalking | |
| Bundle 'Selenitic' | |
| Bundle 'altercation/vim-colors-solarized' | |
| Bundle 'Sorcerer' | |
| Bundle 'twilight' | |
| Bundle 'kossnocorp/up.vim' | |
| Bundle 'vilight.vim' | |
| Bundle 'void' | |
| Bundle 'werks.vim' | |
| Bundle 'Wombat' | |
| Bundle 'xorium.vim' | |
| Bundle 'Zenburn' | |
| Bundle 'zenesque.vim' | |
| " *************** " | |
| " Simple options. " | |
| " *************** " | |
| set relativenumber " Show relative line numbers. | |
| set shiftwidth=4 " Indent 4 spaces by default. | |
| set softtabstop=4 " Use 4 spaces instead of a Tab. | |
| set shiftround " Round indent (<,>) to multiples of 'shiftwidth' | |
| set expandtab " Convert tabs to spaces. | |
| set lazyredraw " Avoid redrawing the screen mid-command | |
| set visualbell " Visual bell. | |
| set t_bv= " Reset terminal code for visual bell. | |
| set backspace=2 " Backspace like normal apps. | |
| set cmdheight=2 " Set command window height to two lines. | |
| set confirm " Instead of failing because of unsaved changes, | |
| " raise a dialogue | |
| set pastetoggle=F2 " Use <F2> to toggle between "paste" and "nopaste" | |
| set whichwrap+=b,s,<,>,h,l,[,] | |
| " Make left & right wrap around lines. | |
| set showmatch " Highlight matching parens. | |
| set matchtime=2 " for .2 seconds. | |
| set matchpairs+=<:> " Add <> to highlighted matches. | |
| set showfulltag " Show full tags when doing search completion. | |
| set switchbuf=useopen,usetab | |
| " Allow changing windows/tabs for quickfix/:sb/etc | |
| set scrolloff=3 " Try to show at least three lines. | |
| set sidescrolloff=2 " and two columns of context when scrolling. | |
| set history=500 " Big history. | |
| set autoindent " Autoindent is good. | |
| set textwidth=0 " Don't wrap pasted text | |
| set nostartofline " Keep same position in line for some commands ... | |
| set wrap " Show long lines as wrapped. | |
| set undolevels=10000 " 10000 undos. | |
| set ignorecase infercase smartcase | |
| " Make Vim case-insensitive but smart about it. | |
| set hidden " Don't complain about hiding dirty buffers. | |
| set timeout timeoutlen=2000 ttimeoutlen=100 | |
| " Don't wait 1s when pressing <esc>. | |
| set updatetime=10000 " Idle time for swapfilewrite and CursorHold trigger | |
| set report=0 " : commands always print changed line count. | |
| set shortmess+=a " Use [+]/[RO]/[w] for modified/readonly/written. | |
| set display=lastline,uhex | |
| " Show as much as possible of last line, | |
| " Show unprintable characters as <xx>. | |
| if empty(glob($HOME.'/vimfiles/swap')) | |
| echomsg "Swap directory vimfiles\swap doesn't exist!" | |
| endif " Warn if swapdir does not exist | |
| set directory^=$HOME\vimfiles\swap// | |
| " Build swap filename from path | |
| try | |
| language en_GB " Try to set language. | |
| catch | |
| endtry | |
| set fileformats=unix,dos,mac | |
| " default file type. | |
| " ******************** " | |
| " Conditional options. " | |
| " ******************** " | |
| " Generic function to check if a buffer is backed by a file | |
| function! BufferHasFileCheck() | |
| if has('quickfix') && &buftype =~? 'nofile' | |
| " Buffer is marked as not a file | |
| return 0 | |
| endif | |
| if empty(glob(expand('%:p'))) | |
| " File does not exist on disk | |
| return 0 | |
| endif | |
| return 1 | |
| endfunction | |
| " Avoid command-line redraw on every entered character by turning off Arabic | |
| " shaping (which is implemented poorly). | |
| if has('arabic') | |
| set noarabicshape | |
| endif | |
| if has('multi_byte') | |
| set encoding=utf8 " Set to UTF-8. | |
| endif | |
| if has('autocmd') | |
| augroup vimrcCursorHighlight | |
| autocmd! | |
| autocmd WinLeave * set nocursorline nocursorcolumn | |
| autocmd WinEnter * set cursorline cursorcolumn | |
| augroup end | |
| set cursorline | |
| set cursorcolumn | |
| endif | |
| if exists('+autochdir') | |
| set autochdir | |
| endif | |
| if has('windows') | |
| if !&readonly " If we're not in RO mode ... | |
| set showtabline=2 " Always show tab line. | |
| else | |
| set showtabline=0 | |
| endif | |
| endif | |
| if has('cmdline_info') | |
| set ruler " Always show cursor position. | |
| set showcmd " Show us the command we're typing. | |
| endif | |
| if has('eval') && has('autocmd') | |
| filetype plugin indent on " Enable filetype settings. | |
| endif | |
| if has('gui_running') | |
| "set guifont=Andale_Mono:h10:cDEFAULT | |
| "set guifont=Anonymous_Pro:h11:cDEFAULT | |
| set guifont=Consolas:h10:cDEFAULT | |
| "set guifont=DejaVu_Sans_Mono:h10:cDEFAULT | |
| "set guifont=Droid_Sans_Mono_Slashed:h10:cDEFAULT | |
| "set guifont=Envy_Code_R:h10:cDEFAULT | |
| "set guifont=Terminus:h11:cDEFAULT | |
| "set guifont=Monofur:h11:cDEFAULT | |
| " Default font. | |
| set clipboard=unnamed | |
| " Clipboard is the unnamed register. | |
| set guioptions-=T " Remove the button bar. | |
| if &readonly " GView | |
| set guioptions-=m " Remove the menu bar | |
| endif | |
| endif | |
| if has('folding') | |
| set foldenable " Enable folding. | |
| set foldmethod=syntax | |
| set foldlevelstart=99 | |
| set foldcolumn=2 | |
| nnoremap <silent> <C-Space> @=(foldlevel('.')?'za':'l')<CR> | |
| vnoremap <silent> <C-Space> @=(foldlevel('.')?'za':'l')<CR> | |
| inoremap <silent> <C-Space> <C-o>@=(foldlevel('.')?'za':'l')<CR> | |
| if has('autocmd') | |
| augroup vimrcFoldInsert | |
| autocmd! | |
| " Don't screw up folds when inserting text that might affect them, until | |
| " leaving insert mode. Foldmethod is local to the window. Protect against | |
| " screwing up folding when switching between windows. | |
| autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif | |
| autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif | |
| augroup end | |
| endif | |
| endif | |
| if has('linebreak') | |
| set numberwidth=2 " Set minimum number column width to 1 digit + space. | |
| endif | |
| if has('printing') | |
| set popt+=syntax:y " Syntax when printing. | |
| endif | |
| if has('syntax') | |
| syntax on " Syntax always on. | |
| endif | |
| if has('virtualedit') | |
| set virtualedit=block,onemore | |
| " Enable virtual edit in vblock mode, and one past the end. | |
| endif | |
| if has('extra_search') | |
| set hlsearch " Highlight search. | |
| set incsearch " Incremental search. | |
| endif | |
| if has('insert_expand') && has('eval') | |
| set completeopt=menu,preview,longest | |
| endif | |
| if has('wildmenu') | |
| set wildmenu " Enable tab-complete menu. | |
| set wildmode=longest:full | |
| endif | |
| if has('viminfo') | |
| set viminfo=!,'1000,f1,:1000,/1000,h,s100,% | |
| " Enable a nice big viminfo file. | |
| endif | |
| if has('persistent_undo') | |
| set undodir=$HOME\vimfiles\undo | |
| if has('autocmd') | |
| augroup vimrcUndoFile | |
| autocmd! | |
| " Only set undofile for buffers backed by a file | |
| autocmd BufWritePost ?* if BufferHasFileCheck() | setlocal undofile | endif | |
| autocmd BufWinEnter ?* if BufferHasFileCheck() | setlocal undofile | endif | |
| augroup end | |
| else | |
| set undofile | |
| endif | |
| endif | |
| if has('conceal') | |
| set concealcursor=nc | |
| set conceallevel=2 | |
| endif | |
| if has('mksession') | |
| set viewdir=$HOME\vimfiles\view | |
| set viewoptions=cursor,folds,options,slash,unix | |
| set sessionoptions=buffers,curdir,help,tabpages,winsize | |
| let g:skipview_files = [ | |
| \ '[Vundle] Installer' | |
| \ ] | |
| function! MakeViewCheck() | |
| " Filter out undesirables | |
| if !BufferHasFileCheck() | |
| " Buffer is not backed by a file | |
| return 0 | |
| endif | |
| if len($TEMP) && expand('%:p:h') == $TEMP | |
| " We're in a temp dir | |
| return 0 | |
| endif | |
| if len($TMP) && expand('%:p:h') == $TMP | |
| return 0 | |
| endif | |
| if index(g:skipview_files, expand('%'), 0, 1) >= 0 | |
| " File is in skip list | |
| return 0 | |
| endif | |
| return 1 | |
| endfunction | |
| if has('autocmd') | |
| augroup vimrcAutoView | |
| autocmd! | |
| " Autosave & Load Views. | |
| autocmd BufWritePost,BufLeave,WinLeave ?* if MakeViewCheck() | mkview | endif | |
| autocmd BufWinEnter ?* if MakeViewCheck() | silent loadview | endif | |
| augroup end | |
| endif | |
| endif | |
| if has('autocmd') | |
| augroup vimrcSaveOnFocusLost | |
| autocmd! | |
| " When Vim loses focus, save the file | |
| autocmd FocusLost * silent! :wall | |
| augroup end | |
| endif | |
| " ***** " | |
| " Maps. " | |
| " ***** " | |
| let mapleader = "," " With a map leader it's possible to do extra key combinations. | |
| let g:mapleader = "," " like <leader>w saves the current file. | |
| nnoremap ;; ; | |
| vnoremap ;; ; | |
| nnoremap ; : | |
| vnoremap ; : | |
| nnoremap <A-;> ; | |
| vnoremap <A-;> ; | |
| nnoremap q; q: | |
| vnoremap q; q: | |
| " Pure genius. | |
| " Let Control-S be 'save' as it is in most other editors | |
| " Bug: this puts you into insert mode if you where in overwrite mode before | |
| noremap <C-s> :w<CR> | |
| inoremap <C-s> <C-o>:w<CR> | |
| map <leader>e :e! $MYVIMRC<CR> | |
| " Fast editing of the .vimrc. | |
| noremap <S-cr> <Esc> | |
| " Shift-Enter = ESC. | |
| nnoremap <CR> :noh<CR><CR> | |
| " Clears search pattern | |
| " Tabwidth. | |
| map <leader>t2 :setlocal shiftwidth=2<CR> | |
| map <leader>t4 :setlocal shiftwidth=4<CR> | |
| map <leader>t8 :setlocal shiftwidth=8<CR> | |
| " :cope. | |
| map <leader>cc :botright cope<CR> | |
| map <leader>n :cn<CR> | |
| map <leader>p :cp<CR> | |
| " Remove the Windows ^M - when the encodings gets messed up. | |
| noremap <leader>m mmHmt:%s/<C-V><CR>//ge<CR>'tzt'm | |
| " This mapping allows to stay in visual mode when indenting with < and > | |
| vnoremap > >gv | |
| vnoremap < <gv | |
| " DONT USE TEH ARROWS!!!one | |
| " map <up> <nop> | |
| " map <down> <nop> | |
| " map <left> <nop> | |
| " map <right> <nop> | |
| " inoremap <up> <nop> | |
| " inoremap <down> <nop> | |
| " inoremap <left> <nop> | |
| " inoremap <right> <nop> | |
| " cnoremap <up> <up> | |
| " cnoremap <down> <down> | |
| " cnoremap <left> <left> | |
| " cnoremap <right> <right> | |
| " These mappings are useful in long wrapped lines when pressing j or k | |
| noremap j gj | |
| noremap k gk | |
| noremap <c-]> g<c-]> | |
| noremap <c-g> g<c-g> | |
| " Kill F1 | |
| noremap <F1> <nop> | |
| " Map toggles to F-Keys | |
| noremap <silent> <F2> :ToggleBookmark<CR> | |
| inoremap <silent> <F2> <C-o>:ToggleBookmark<CR> | |
| noremap <silent> <F3> :NextBookmark<CR> | |
| inoremap <silent> <F3> <C-o>:NextBookmark<CR> | |
| noremap <silent> <F4> :PreviousBookmark<CR> | |
| inoremap <silent> <F4> <C-o>:PreviousBookmark<CR> | |
| noremap <silent> <F5> :YRShow<CR> | |
| inoremap <silent> <F5> <C-o>:YRShow<CR> | |
| if has('python') | |
| noremap <silent> <C-F5> :GundoToggle<CR> | |
| inoremap <silent> <C-F5> <C-o>:GundoToggle<CR> | |
| endif | |
| function! ToggleNumber() | |
| if &number | |
| set nonumber | |
| set relativenumber | |
| elseif &relativenumber | |
| set number | |
| set norelativenumber | |
| else | |
| set number | |
| endif | |
| endfunction | |
| noremap <silent> <F6> :call ToggleNumber()<CR> | |
| inoremap <silent> <F6> <C-o>:call ToggleNumber()<CR> | |
| if has('spell') | |
| set nospell | |
| if has('eval') | |
| " Rotate through languages of spelling checker. | |
| let g:my_lang_codes = [ 'en_gb', 'it' ] | |
| if !exists('g:MY_LANG_IDX') || ( g:MY_LANG_IDX + 1 < len(g:my_lang_codes) ) | |
| let g:MY_LANG_IDX = 0 | |
| endif | |
| function! MySpellLang() | |
| exec "setlocal" "spell" "spelllang=".get(g:my_lang_codes, g:MY_LANG_IDX) | |
| let g:MY_LANG_IDX = ( g:MY_LANG_IDX + 1 < len(g:my_lang_codes) ) ? g:MY_LANG_IDX + 1 : 0 | |
| endfunction | |
| noremap <silent> <F7> :setlocal spell!<CR> | |
| inoremap <silent> <F7> <C-o>:setlocal spell!<CR> | |
| noremap <silent> <C-F7> :call MySpellLang()<CR> | |
| inoremap <silent> <C-F7> <C-o>:call MySpellLang()<CR> | |
| endif | |
| endif | |
| noremap <silent> <F8> :TagbarToggle<CR> | |
| inoremap <silent> <F8> <C-o>:TagbarToggle<CR> | |
| noremap <F9> :set list!<CR>:set list?<CR> | |
| inoremap <F9> <C-o>:set list!<CR><C-O>:set list?<CR> | |
| if has('ruby') | |
| noremap <silent> <F10> :LustyFilesystemExplorerFromHere<CR> | |
| inoremap <silent> <F10> <C-o>:LustyFilesystemExplorerFromHere<CR> | |
| else | |
| noremap <silent> <F10> :NERDTreeToggle<CR> | |
| inoremap <silent> <F10> <C-o>:NERDTreeToggle<CR> | |
| endif | |
| " Function used to display syntax group. | |
| function! SyntaxItem() | |
| return synIDattr(synID(line("."),col("."),1),"name") | |
| endfunction | |
| " Function used to display utf-8 sequence. | |
| function! ShowUtf8Sequence() | |
| try | |
| let p = getpos('.') | |
| redir => utfseq | |
| sil normal! g8 | |
| redir End | |
| call setpos('.', p) | |
| return substitute(matchstr(utfseq, '\x\+ .*\x'), '\<\x', '0x&', 'g') | |
| catch | |
| return '?' | |
| endtry | |
| endfunction | |
| function! CmdLine(str) | |
| exe "menu Foo.Bar :" . a:str | |
| emenu Foo.Bar | |
| unmenu Foo | |
| endfunction | |
| " From an idea by Michael Naumann. | |
| function! VisualSearch(direction) range | |
| let l:saved_reg = @" | |
| execute "normal! vgvy" | |
| let l:pattern = escape(@", '\\/.*$^~[]') | |
| let l:pattern = substitute(l:pattern, "\n$", "", "") | |
| if a:direction ==# 'b' | |
| execute "normal ?" . l:pattern . "^M" | |
| elseif a:direction ==# 'gv' | |
| call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') | |
| elseif a:direction ==# 'f' | |
| execute "normal /" . l:pattern . "^M" | |
| endif | |
| let @/ = l:pattern | |
| let @" = l:saved_reg | |
| endfunction | |
| " Really useful! | |
| " In visual mode when you press * or # to search for the current selection. | |
| vnoremap <silent> * :call VisualSearch('f')<CR> | |
| vnoremap <silent> # :call VisualSearch('b')<CR> | |
| " Pressing an 'enter visual mode' key while in visual mode changes mode. | |
| vmap <C-V> <ESC>`<<C-v>`> | |
| vmap V <ESC>`<V`> | |
| vmap v <ESC>`<v`> | |
| " Y behaves like D rather than like dd | |
| nnoremap Y y$ | |
| " When you press gv you vimgrep after the selected text. | |
| vnoremap <silent> gv :call VisualSearch('gv')<CR> | |
| map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left> | |
| " Smart way to move btw. windows. | |
| map <C-j> <C-W>j | |
| map <C-k> <C-W>k | |
| map <C-h> <C-W>h | |
| map <C-l> <C-W>l | |
| " Close the current buffer. | |
| map <leader>bd :Bclose<CR> | |
| " Close all the buffers. | |
| map <leader>ba :1,300 bd!<CR> | |
| " Use the arrows to something usefull. | |
| map <silent> <C-right> :tabnext<CR> | |
| map <silent> <C-left> :tabprevious<CR> | |
| " Tab configuration. | |
| map <leader>tn :tabnew %<CR> | |
| map <leader>te :tabedit | |
| map <leader>tc :tabclose<CR> | |
| map <leader>tm :tabmove | |
| function! <SID>BufcloseCloseIt() | |
| let l:currentBufNum = bufnr("%") | |
| let l:alternateBufNum = bufnr("#") | |
| if buflisted(l:alternateBufNum) | |
| buffer # | |
| else | |
| bnext | |
| endif | |
| if bufnr("%") == l:currentBufNum | |
| new | |
| endif | |
| if buflisted(l:currentBufNum) | |
| execute("bdelete! ".l:currentBufNum) | |
| endif | |
| endfunction | |
| command! Bclose call <SID>BufcloseCloseIt() | |
| " Specify the behavior when switching between buffers. | |
| try | |
| set switchbuf=usetab | |
| set stal=2 | |
| catch | |
| endtry | |
| " ************ " | |
| " Window Size. " | |
| " ************ " | |
| if has('gui_running') | |
| " GUI is running or is about to start. | |
| " Set GVim window to this size. | |
| if &lines < 50 | |
| set lines=50 | |
| endif | |
| if &columns < 100 | |
| set columns=100 | |
| endif | |
| else | |
| " This is console Vim. | |
| if exists('+lines') | |
| set lines=50 | |
| endif | |
| if exists('+columns') | |
| set columns=100 | |
| endif | |
| endif | |
| " ************** " | |
| " Colour scheme. " | |
| " ************** " | |
| set background=dark | |
| let g:moria_style = "dark" | |
| let g:molokai_original = 1 | |
| let g:zenesque_colors = 3 | |
| let g:lucius_style = "dark" | |
| let g:solarized_termcolors = 256 | |
| let g:solarized_style = "dark" | |
| let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' } | |
| let g:CSApprox_use_showrgb = 1 | |
| let g:my_colourschemes = [ "ambient", "candyman", "chance-of-storm", "codefactory", "darkburn", "darkspectrum", "desertEx", "ego", "ekinivim", "herald", "ir_black", "jellybeans", "jellyx", "kiss", "liquidcarbon", "lucius", "manuscript", "mdark", "molokai", "moria", "mrpink", "nazca", "obsidian", "peaksea", "pf_earth", "royalking", "selenitic", "solarized", "sorcerer", "twilight", "up", "vilight", "void", "werks", "wombat", "xorium", "zenburn", "zenesque" ] | |
| if has('eval') | |
| " Setup some highlight links | |
| function! ColourSchemeColumns() | |
| highlight clear SignColumn | |
| highlight link SignColumn LineNr | |
| highlight clear FoldColumn | |
| highlight link FoldColumn LineNr | |
| endfunction | |
| " Loader function | |
| function! LoadColourScheme(scheme) | |
| if has('gui_running') || (&t_Co != 88 && &t_Co != 256) | |
| exe 'colorscheme' a:scheme | |
| elseif (&t_Co == 88 || &t_Co == 256) | |
| if exists(':CSApproxSnapshot') == 2 | |
| exe 'colorscheme' a:scheme | |
| elseif exists(':GuiColorScheme') == 2 | |
| exe 'GuiColorScheme' a:scheme | |
| else | |
| exe 'colorscheme' a:scheme | |
| endif | |
| else | |
| exe 'colorscheme' a:scheme | |
| endif | |
| if !has('autocmd') | |
| call ColourSchemeColumns() | |
| endif | |
| endfunction | |
| function! TryColourScheme() | |
| let l:scheme_index = 0 | |
| while l:scheme_index + 1 < len(g:my_colourschemes) | |
| let l:scheme = get(g:my_colourschemes, g:MY_COLOURSCHEME_IDX) | |
| try | |
| call LoadColourScheme(l:scheme) | |
| let g:MY_COLOURSCHEME_NAME = l:scheme | |
| break | |
| catch | |
| let g:MY_COLOURSCHEME_IDX = ( g:MY_COLOURSCHEME_IDX + 1 < len(g:my_colourschemes) ) ? g:MY_COLOURSCHEME_IDX + 1 : 0 | |
| let l:scheme_index += 1 | |
| endtry | |
| endwhile | |
| endfunction | |
| " Rotate through colour schemes. | |
| function! RotateColourScheme() | |
| let g:MY_COLOURSCHEME_IDX = ( g:MY_COLOURSCHEME_IDX + 1 < len(g:my_colourschemes) ) ? g:MY_COLOURSCHEME_IDX + 1 : 0 | |
| call TryColourScheme() | |
| endfunction | |
| map <silent> <F11> :call RotateColourScheme()<CR> | |
| imap <silent> <F11> <C-o>:call RotateColourScheme()<CR> | |
| function! InitColourScheme() | |
| if !exists('g:MY_COLOURSCHEME_IDX') || (g:MY_COLOURSCHEME_IDX >= len(g:my_colourschemes)) | |
| let g:MY_COLOURSCHEME_IDX = 0 | |
| endif | |
| if !exists('g:MY_COLOURSCHEME_NAME') || (index(g:my_colourschemes, g:MY_COLOURSCHEME_NAME) == -1) | |
| let g:MY_COLOURSCHEME_NAME = get(g:my_colourschemes, g:MY_COLOURSCHEME_IDX) | |
| endif | |
| let g:MY_COLOURSCHEME_IDX = index(g:my_colourschemes, g:MY_COLOURSCHEME_NAME) | |
| call TryColourScheme() | |
| call ColourSchemeColumns() | |
| endfunction | |
| if has('autocmd') | |
| augroup vimrcColorScheme | |
| autocmd! | |
| autocmd ColorScheme * call ColourSchemeColumns() | |
| autocmd VimEnter * call InitColourScheme() | |
| augroup end | |
| else | |
| call InitColourScheme() | |
| endif | |
| endif | |
| " ********** " | |
| " Statusbar. " | |
| " ********** " | |
| set laststatus=2 | |
| set statusline= | |
| set statusline+=%2*%-3.3n%0*\ " buffer number | |
| set statusline+=%f\ " file name | |
| set statusline+=%h%1*%m%r%w%0* " Flags. | |
| set statusline+=\[%{strlen(&ft)?&ft:'none'}, " Filetype. | |
| set statusline+=%{&encoding}, " Encoding. | |
| set statusline+=%{&fileformat}] " File format. | |
| "set statusline+=%{VCSCommandGetStatusLine()} | |
| if has('eval') | |
| function! ColorSchemeInfo() | |
| return exists('g:colors_name') ? g:colors_name : 'none' | |
| endfunction | |
| set statusline+=\ %{ColorSchemeInfo()} | |
| endif | |
| if has('spell') | |
| function! SpellLangInfo() | |
| let l:spell_enabled = ( &spell ) ? ':e' : ':d' | |
| return get(g:my_lang_codes, g:MY_LANG_IDX, "none").l:spell_enabled | |
| endfunction | |
| set statusline+=\ %{SpellLangInfo()} | |
| endif | |
| set statusline+=%= " Right align. | |
| set statusline+=%2*0x%-8B\ " current char | |
| set statusline+=%-14.(%l,%c%V%)\ %<%P " Offset. | |
| if has('autocmd') " Special statusbar for special windows. | |
| function! <SID>FixMiniBufExplorerTitle() | |
| if "-MiniBufExplorer-" ==? bufname("%") | |
| setlocal statusline=%2*%-3.3n%0* | |
| setlocal statusline+=\[Buffers\] | |
| setlocal statusline+=%=%2*\ %<%P | |
| endif | |
| endfunction | |
| augroup vimrcStatusBar | |
| autocmd! | |
| autocmd FileType qf | |
| \ if &buftype ==? "quickfix" | | |
| \ setlocal statusline=%2*%-3.3n%0* | | |
| \ setlocal statusline+=\ \[Compiler\ Messages\] | | |
| \ setlocal statusline+=%=%2*\ %<%P | | |
| \ endif | |
| autocmd BufWinEnter * | |
| \ let oldwinnr=winnr() | | |
| \ windo call <SID>FixMiniBufExplorerTitle() | | |
| \ exec oldwinnr.' wincmd w' | |
| augroup end | |
| endif | |
| " ************* " | |
| " Window title. " | |
| " ************* " | |
| if has('title') && (has('gui_running') || &title) | |
| set titlestring= | |
| set titlestring+=%f\ " file name | |
| set titlestring+=%h%m%r%w " flags | |
| set titlestring+=\ -\ %{v:progname} " program name | |
| set titlestring+=\ -\ %{substitute(getcwd(),\ $HOME,\ '~',\ '')} " working directory | |
| endif | |
| " *********** " | |
| " Linebreaks. " | |
| " *********** " | |
| if has('linebreak') | |
| if (&termencoding ==? "utf-8") || has('gui_running') | |
| if has('gui_running') | |
| set showbreak=… | |
| else | |
| set showbreak=» | |
| endif | |
| else | |
| set showbreak=> | |
| endif | |
| endif | |
| " ******************************* " | |
| " Tabs, trailing whitespace, etc. " | |
| " ******************************* " | |
| if (&termencoding ==? "utf-8") || has('gui_running') | |
| if v:version >= 700 | |
| if has('gui_running') | |
| set list listchars=tab:»·,trail:·,extends:…,precedes:…,nbsp:= | |
| else | |
| " XTerm + Terminus hates these. | |
| set list listchars=tab:»·,trail:·,extends:>,precedes:<,nbsp:_ | |
| endif | |
| else | |
| set list listchars=tab:»·,trail:·,extends:…,precedes:… | |
| endif | |
| else | |
| if v:version >= 700 | |
| set list listchars=tab:>-,trail:.,extends:>,precedes:<,nbsp:_ | |
| else | |
| set list listchars=tab:>-,trail:.,extends:>,precedes:< | |
| endif | |
| endif | |
| set fillchars=fold:- | |
| " ****************** " | |
| " Language-specific. " | |
| " ****************** " | |
| " C | |
| if has('eval') | |
| let g:c_gnu = 1 | |
| let g:c_space_errors = 1 | |
| let g:ch_syntax_for_h = 1 | |
| endif | |
| " C# | |
| if has('eval') && has('autocmd') | |
| augroup vimrcCSharp | |
| autocmd! | |
| autocmd FileType cs set omnifunc=syntaxcomplete#Complete | |
| autocmd FileType cs set foldmethod=marker | |
| autocmd FileType cs set foldmarker={,} | |
| autocmd FileType cs set foldtext=substitute(getline(v:foldstart),'{.*','{...}',) | |
| autocmd FileType cs set foldlevelstart=2 | |
| augroup end | |
| endif | |
| " CSS | |
| if has('eval') && has('autocmd') | |
| augroup vimrcCSS | |
| autocmd! | |
| autocmd FileType css set omnifunc=csscomplete#CompleteCSS | |
| augroup end | |
| endif | |
| " JavaScript | |
| if has('eval') && has('autocmd') | |
| function! JavaScriptFold() | |
| setl foldmethod=syntax | |
| setl foldlevelstart=1 | |
| syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend | |
| function! FoldText() | |
| return substitute(getline(v:foldstart), '{.*', '{...}', '') | |
| endfunction | |
| setl foldtext=FoldText() | |
| endfunction | |
| augroup vimrcJavaScript | |
| autocmd! | |
| autocmd FileType javascript call JavaScriptFold() | |
| autocmd FileType javascript setl fen | |
| autocmd FileType javascript setl nocindent | |
| autocmd FileType javascript imap <c-t> AJS.log();<esc>hi | |
| autocmd FileType javascript imap <c-a> alert();<esc>hi | |
| autocmd FileType javascript inoremap <buffer> $r return | |
| autocmd FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi | |
| augroup end | |
| endif | |
| " jQuery | |
| if has('eval') && has('autocmd') | |
| augroup vimrcjQuery | |
| autocmd! | |
| autocmd BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery | |
| augroup end | |
| endif | |
| " LISP | |
| if has('eval') | |
| let g:lisp_rainbow = 1 | |
| endif | |
| " PHP | |
| if has('eval') | |
| " Syntax | |
| let g:php_sql_query = 1 | |
| let g:php_html_in_strings = 1 | |
| let g:php_folding = 1 | |
| " Indent | |
| let g:PHP_outdentphpescape = 0 | |
| let g:PHP_vintage_case_default_indent = 1 | |
| endif | |
| " Python | |
| let g:python_highlight_all = 1 | |
| if has('eval') && has('autocmd') | |
| function! DeleteTrailingWS() | |
| exe "normal mz" | |
| %s/\s\+$//ge | |
| exe "normal `z" | |
| endfunction | |
| augroup vimrcPython | |
| autocmd! | |
| autocmd FileType python set nocindent | |
| autocmd FileType python syn keyword pythonDecorator True None False self | |
| autocmd BufNewFile,BufRead *.jinja set syntax=htmljinja | |
| autocmd BufNewFile,BufRead *.mako set ft=mako | |
| autocmd FileType python inoremap <buffer> $r return | |
| autocmd FileType python inoremap <buffer> $i import | |
| autocmd FileType python inoremap <buffer> $p print | |
| autocmd FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi | |
| autocmd FileType python map <buffer> <leader>1 /class | |
| autocmd FileType python map <buffer> <leader>2 /def | |
| autocmd FileType python map <buffer> <leader>C ?class | |
| autocmd FileType python map <buffer> <leader>D ?def | |
| autocmd BufWrite *.py :call DeleteTrailingWS() | |
| augroup end | |
| endif | |
| " Ruby | |
| if has('eval') && has('autocmd') | |
| augroup vimrcRuby | |
| autocmd! | |
| autocmd FileType ruby setl shiftwidth=2 | |
| autocmd FileType ruby setl softtabstop=2 | |
| augroup end | |
| endif | |
| " Scheme | |
| if has('eval') | |
| let g:is_chicken = 1 | |
| endif | |
| " SQL | |
| if has('eval') | |
| let g:sql_type_default = 'mysql' | |
| endif | |
| " Vimscript | |
| if has('eval') | |
| let g:vimsyn_folding = 'afmpPrt' | |
| endif | |
| " ******** " | |
| " Plugins. " | |
| " ******** " | |
| if has('eval') | |
| " Bookmarking | |
| if has('signs') | |
| function! SetBookmarkStyle() | |
| if has('gui_running') || (&termencoding ==? 'utf-8') | |
| sign define bookmark text=»» texthl=FoldColumn | |
| else | |
| sign define bookmark text=>> texthl=FoldColumn | |
| endif | |
| endfunction | |
| if has('autocmd') | |
| augroup vimrcBookmarking | |
| autocmd! | |
| autocmd VimEnter * call SetBookmarkStyle() | |
| augroup end | |
| else | |
| call SetBookmarkStyle() | |
| endif | |
| endif | |
| " Clojure | |
| let vimclojure#ParenRainbow = 1 | |
| let vimclojure#WantNailgun = 0 | |
| " Easytags | |
| let g:easytags_cmd = 'C:\Dev\Ctags\ctags.exe' | |
| let g:easytags_ignored_filetypes = '^\(bat|vba|tex|viki\)$' | |
| let g:easytags_by_filetype = $HOME.'\vimfiles\easytags' | |
| let g:easytags_python_enabled = 1 | |
| " Format | |
| let g:format_ShowProgress = 2 | |
| " LustyExplorer | |
| let g:LustyExplorerAlwaysShowDotFiles = 1 | |
| " NeoComplCache | |
| let g:neocomplcache_enable_at_startup = 1 | |
| let g:neocomplcache_enable_smart_case = 1 | |
| let g:neocomplcache_enable_camel_case_completion = 1 | |
| let g:neocomplcache_enable_underbar_completion = 1 | |
| " Recommended key-mappings. | |
| " <CR>: close popup and save indent. | |
| inoremap <expr><CR> neocomplcache#smart_close_popup() ."\<CR>" | |
| " <TAB>: completion. | |
| inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" | |
| " <C-h>, <BS>: close popup and delete backword char. | |
| inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>" | |
| inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>" | |
| inoremap <expr><C-y> neocomplcache#close_popup() | |
| inoremap <expr><C-e> neocomplcache#cancel_popup() | |
| " Enable omni completion. | |
| if !exists('g:neocomplcache_omni_patterns') | |
| let g:neocomplcache_omni_patterns = {} | |
| endif | |
| let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' | |
| if has('autocmd') | |
| augroup vimrcNeocomplcache | |
| autocmd! | |
| autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS | |
| autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags | |
| autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS | |
| autocmd FileType python setlocal omnifunc=pythoncomplete#Complete | |
| autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags | |
| autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP | |
| autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete | |
| autocmd FileType cs setlocal omnifunc=syntaxcomplete#Complete | |
| augroup end | |
| endif | |
| " Ctags | |
| let g:neocomplcache_ctags_program = 'C:\Dev\Ctags\ctags.exe' | |
| " TagBar | |
| let g:tagbar_ctags_bin = 'C:\Dev\Ctags\ctags.exe' | |
| let g:tagbar_left = 0 | |
| let g:tagbar_width = 40 | |
| let g:tagbar_usearrows = 1 | |
| " Netrw | |
| let g:netrw_browse_split = 3 | |
| let g:netrw_liststyle = 2 | |
| let g:netrw_special_syntax = 1 | |
| let g:netrw_http_cmd = 'C:\Dev\Curl\curl.exe -o' | |
| " Shell | |
| let g:shell_mappings_enabled = 0 | |
| " SLIMV | |
| let g:slimv_lisp = 'C:\Dev\Clojure\CLR\Clojure.Main.exe' | |
| " TOhtml | |
| let g:html_number_lines = 1 | |
| let g:html_use_css = 1 | |
| let g:html_dynamic_folds = 1 | |
| let g:html_use_encoding = 'UTF-8' | |
| endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment