Makistos
10/28/2013 - 1:52 PM

My .vimrc. #vim #vimrc #viml

My .vimrc. #vim #vimrc #viml

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"  General {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	set nocompatible               " be iMproved
	filetype off                   " required!

	filetype plugin on
	filetype plugin indent on

	set clipboard=unnamedplus,autoselect

	" Intend and tab properties
	set noexpandtab
	set shiftwidth=8
	set tabstop=8
	set smarttab
	set backspace=eol,start,indent
	set t_Co=256

	" Show what's going on
	set showcmd

	" Always show status line
	set laststatus=2

	set lbr " line break
	set tw=78 " text width
	set history=300 " line history

	set ai " auto indent

	" Make pgup/down remember cursor position
	set nostartofline

	" Tab completion for file search
	set wildmode=longest,list,full
	set wildmenu
	set wildignore+=*.pyc,*.zip,*.gz,*.bz,*.tar,*.jpg,*.png,*.gif,*.avi,*.wmv,*.ogg,*.mp3,*.mov
	set wildignore+=*.bak,*.o,*.e,*~

	syntax on

	set foldmethod=indent
	set foldlevel=99

	" Global search by default
	set gdefault

	" Improved searching
	set ignorecase 
	set smartcase
	set showmatch
	set hlsearch
	set nowrap
	set incsearch "Make search act like search in modern browsers

	" Use undo file
	set undofile

	set backupdir=$HOME/.vim/_backup//
	set directory=$HOME/.vim/_temp//
	set browsedir=current           " which directory to use for the file browser

	" Set path to current directory and subdirectories - this will allow gf to
	" work better
	set path=$PWD/**

	set hidden " Switch between buffers without saving

	" No backups
	set nobackup
	set nowritebackup

	" Remove trailing whitespaces and ^M chars
	"autocmd FileType c,cpp,java,php,js,python,twig,xml,yml autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))

	" Save buffers when focus is lost
	"au FocusLost * :wa

	"autocmd bufwritepost .vimrc source $MYVIMRC " Source .vimrc after saving

	" Change working dir to current
	nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	set rtp+=~/.vim/bundle/Vundle.vim
	call vundle#begin()

	" let Vundle manage Vundle
	" required! 
	"
	" Brief help
	" :BundleList          - list configured bundles
	" :BundleInstall(!)    - install(update) bundles
	" :BundleSearch(!) foo - search(or refresh cache first) for foo
	" :BundleClean(!)      - confirm(or auto-approve) removal of unused bundles
	"
	" see :h vundle for more details or wiki for FAQ
	" NOTE: comments after Bundle command are not allowed..
	Plugin 'VundleVim/vundle.vim'

	Plugin 'scrooloose/nerdtree'
	Plugin 'scrooloose/nerdcommenter'
	Plugin 'airblade/vim-gitgutter'
	Plugin 'vim-scripts/c.vim'
	Plugin 'majutsushi/tagbar'
	Plugin 'vim-scripts/CCTree.git'
	Plugin 'bling/vim-airline'
	Plugin 'fholgado/minibufexpl.vim'
	Plugin 'vim-scripts/OmniCppComplete'
	Plugin 'ervandew/supertab'
	Plugin 'vim-scripts/bufkill.vim'
	Plugin 'kien/ctrlp.vim'
	Plugin 'vim-scripts/wombat256.vim'
	Plugin 'vim-scripts/EasyGrep'
	Plugin 'godlygeek/tabular'
	Plugin 'Chiel92/vim-autoformat'
	Plugin 'sjl/Gundo.vim'
	Plugin 'mileszs/ack.vim'
	Plugin 'wting/rust.vim'
	"Plugin 'tpope/vim-surround'
	Plugin 'msanders/snipmate.vim'
	"Plugin 'mtth/scratch'
	"Plugin 'YankRing.vim'
	Plugin 'xolox/vim-misc'
	Plugin 'xolox/vim-notes'
	Plugin 'tpope/vim-fugitive'
	"Bundle 'davidhalter/jedi-vim'
	Plugin 'dhruvasagar/vim-table-mode'
	Plugin 'pangloss/vim-javascript'
	Plugin 'moll/vim-node'

	call vundle#end()

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Common mappings {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	let mapleader=","

	" Toggle keys  
	" TODO Some of these could be context-sensitive?
	noremap <F2> :bprevious<CR>
	noremap <F3> :bnext<CR>
	noremap <F4> :GitGutterToggle<CR>
	noremap <F5> :NERDTreeToggle<CR>
	noremap <F6> :TagbarToggle<CR>
	"nnoremap <F7> :CCTreeWindowToggle<CR>
	" TODO make this a toggle:
	noremap <F8> :copen<CR>
	" F12 still available (F9 reserved by C plugin)
	noremap <F10> :GundoToggle<CR>
	noremap <F11> :!~/scripts/update_tags.sh ./cscope.dirs c++<CR>:cs reset<CR>

	" Previous compile problem
	noremap <silent><A-p> :cp<CR> 
	" Next compile problem
	noremap <silent><A-n> :cn<CR> 
	" Compile
	noremap <A-m> :make<CR>
	noremap <silent><A-P> :colder<CR>
	noremap <silent><A-N> :newer<CR>

	" Open $MYVIMRC for a quick edit
	nnoremap <leader>ev :vsplit $MYVIMRC<cr>

	" Make a vertical split
	nnoremap <leader>w :vsplit<CR>

	" Run last command again
	noremap <leader>r @:<CR>
	" Buffer kill
	noremap <leader>bd :BD<CR>
	" Save
	noremap <C-s> :w<CR>

	" Yank buffer with persistent data (=can paste the same string multiple times)
	" Uses the x register.
	noremap <leader>c "xy
	noremap <leader>v "xp

	" Use persistent buffer to replace words and lines
	noremap <leader>rw viw"xp:w<CR>
	noremap <leader>rl V"xp:w<CR>

	" Reselect text that was just pasted
	nnoremap <leader>v V`] 

	map <leader>rr :execute "vimgrep /" . expand("<cword>") . "/j **/*.c **/*.h" <CR> ciw

	map <leader>gc :execute "vimgrep /" . expand("<cword>") . "/j **/*.c **/*.h **/*.cpp **/*.hpp" <CR> 

	nnoremap <leader>a :Ack 
	nnoremap <leader>A :Ack <C-r><C-w> 

	" Switch between implementation and header
	"autocmd filetype cpp map <leader>s :e %:p:s,.hpp$,.X123X,:s,.cpp$,.hpp,:s,.X123X$,.cpp,<CR>
	autocmd filetype c map <leader>s :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR>
	"map <leader>s :e %:p:s,.hpp$,.X123X,:s,.cpp$,.hpp,:s,.X123X$,.cpp,<CR>

	" Add empty line (without changing to insert mode) below/above current line
	nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
	nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>

	" Use sane regexp
	nnoremap / /\v
	vnoremap / /\v

	" Make Vim select area when using %
	nnoremap % v%

	" Make fugitive :Glog feature work better: this makes it jump to the line 
	" where we were instead of top of file when browsing versions
	au! BufLeave  fugitive://*  let g:cursor=line(".")
	au! BufEnter  fugitive://*  exec g:cursor 

	" Make jk work as escape
	inoremap jk <esc>

	" Make backspace work properly in normal mode
	map <BS> i<BS>jkl

	" Make Home / End easier in scandic keyboard
	nnoremap ö 0
	nnoremap ä $
	nnoremap Ö ^  " First non-blank character
	nnoremap Ä g_ " Last non-blank character

	" Open link under cursor in browser
	"nnoremap <leader>x :!xdg-open <C-R>=escape("<C-R><C-F>", "#?&;\|%")<CR><CR>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Learning vim by disabling some keys {{{
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	nnoremap <Up>       <NOP>
	nnoremap <Down>     <NOP>
	nnoremap <Left>     <NOP>
	nnoremap <Right>    <NOP>
	"nnoremap <PageDown> <NOP>
	"nnoremap <PageUp>   <NOP>
	"inoremap <PageDown> <NOP>
	"inoremap <PageUp>   <NOP>
	nnoremap <Home>     <NOP>
	nnoremap <End>      <NOP>
	nnoremap <Esc>      <NOP>
	inoremap <Esc>      <NOP>
	vnoremap <Esc>      <NOP>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Look and feel {{{
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	if has("gui_running")
		"set lines=70 columns=170
		set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 11
	endif

	set wildignore+=*.pyc,*.zip,*.gz,*.bz,*.tar,*.jpg,*.png,*.gif,*.avi,*.wmv,*.ogg,*.mp3,*.mov
	set wildignore+=*.bak,*.o,*.e,*~

	colorscheme wombat256mod

	let NERDMenuMode = 1

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Functions {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

	function! CreateTags()
		exec ':!find . | egrep "\.[ch]p{0,2}$" > cscope.files'
		exec ':!while read dir do find $dir | egrep "\.[ch]{0,2}$" >> cscope.files done < cscope.dirs'
		exec ':!cscope -R -b'
		exec ':!/usr/bin/ctags -R -C++kinds=+p --fields=+iaS --extra=q -L cscope.files<CR>'
	endfunction

	function! HandleURL()
	  let s:uri = matchstr(getline("."), '[a-z]*:\/\/[^ >,;]*')
	  echo s:uri
	  if s:uri != ""
	    silent exec "!xdg-open '".s:uri."'"
	  else
	    echo "No URI found in line."
	  endif
	endfunction
	map <leader>x :call HandleURL()<cr>

	" Show tab number in tab list
	if exists("+showtabline")
			function! MyTabLine()
				let s = ''
				let t = tabpagenr()
				let i = 1
				while i <= tabpagenr('$')
					let buflist = tabpagebuflist(i)
					let winnr = tabpagewinnr(i)
					let s .= ' %*'
					let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
					let file = bufname(buflist[winnr - 1])
					let file = fnamemodify(file, ':p:t')
					if file == ''
						let file = '[No Name]'
					endif
					let s .= (getbufvar(buflist[winnr - 1], "&mod")?'*':'').file
					let i = i + 1
				endwhile
				let s .= '%T%#TabLineFill#%='
				let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
				return s
			endfunction
		set stal=2
		set tabline=%!MyTabLine()
	endif

	function! CScopeAdd()
		if filereadable("./cscope.out")
			cs add cscope.out
			echo 'cscope out'
			" else add database pointed to by environment
		elseif $CSCOPE_DB != ""
			cs add $CSCOPE_DB
			echo 'cscope db'
		endif
	endfunction

	function! CScopeUpdate()
		"    call system('echo "hello"')
		call system("find . -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' > cscope.files")
		call system('cscope -b -i cscope.files -f cscope.out')
		cs reset
	endfunction
" Remove default vim-autoformat parameters

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OmniCppComplete {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	let OmniCpp_NamespaceSearch = 1
	let OmniCpp_GlobalScopeSearch = 1
	let OmniCpp_ShowAccess = 1
	let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
	let OmniCpp_MayCompleteDot = 1 " autocomplete after .
	let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
	let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
	let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
	" automatically open and close the popup menu / preview window
	au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
	set completeopt=menuone,menu,longest,preview

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ctrlp {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	" Ignore some files
	if exists("g:ctrl_user_command")
	    unlet g:ctrlp_user_command
	endif
	let g:formatprg_args_c = ""

	set wildignore+=*.d,*.zip,*.obj

let g:formatprg_args_c = ""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Table mode {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	let g:table_mode_header_fillchar = '='
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-note 
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	let g:notes_directories = ['/mnt/poutima/Notes']

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Fugitive
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	" Make fugitive :Glog feature work better: this makes it jump to the line 
	" where we were instead of top of file when browsing versions
	au! BufLeave  fugitive://*  let g:cursor=line(".")
	au! BufEnter  fugitive://*  exec g:cursor 

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ack
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	" Fix for Ack < 2.0 
	let g:ack_default_options = " -H --nocolor --nogroup --column"

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Powerline {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	" For Powerline
	set encoding=utf-8

	let g:Powerline_symbols = 'fancy'

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CSCOPE settings for vim           
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" This file contains some boilerplate settings for vim's cscope interface,
" plus some keyboard mappings that I've found useful.
"
" USAGE: 
" -- vim 6:     Stick this file in your ~/.vim/plugin directory (or in a
"               'plugin' directory in some other directory that is in your
"               'runtimepath'.
"
" -- vim 5:     Stick this file somewhere and 'source cscope.vim' it from
"               your ~/.vimrc file (or cut and paste it into your .vimrc).
"
" NOTE: 
" These key maps use multiple keystrokes (2 or 3 keys).  If you find that vim
" keeps timing you out before you can complete them, try changing your timeout
" settings, as explained below.
"
" Happy cscoping,
"
" Jason Duell       jduell@alumni.princeton.edu     2002/3/7
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

	set tags+=./tags,tags

" This tests to see if vim was configured with the '--enable-cscope' option
" when it was compiled.  If it wasn't, time to recompile vim... 
if has("cscope")

	""""""""""""" Standard cscope/vim boilerplate

	" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
	set cscopetag

	" check cscope for definition of a symbol before checking ctags: set to 1
	" if you want the reverse search order.
	set csto=0

	" add any cscope database in current directory
	if filereadable("cscope.out")
		cs add cscope.out  
		" else add the database pointed to by environment variable 
	elseif $CSCOPE_DB != ""
		cs add $CSCOPE_DB
	endif

	" show msg when any other cscope db added
	set cscopeverbose  

	set cscopequickfix=s-,c-,d-,i-,t-,e-

	""""""""""""" My cscope/vim key mappings
	"
	" The following maps all invoke one of the following cscope search types:
	"
	"   's'   symbol: find all references to the token under cursor
	"   'g'   global: find global definition(s) of the token under cursor
	"   'c'   calls:  find all calls to the function name under cursor
	"   't'   text:   find all instances of the text under cursor
	"   'e'   egrep:  egrep search for the word under cursor
	"   'f'   file:   open the filename under cursor
	"   'i'   includes: find files that include the filename under cursor
	"   'd'   called: find functions that function under cursor calls
	"
	" Below are three sets of the maps: one set that just jumps to your
	" search result, one that splits the existing vim window horizontally and
	" diplays your search result in the new window, and one that does the same
	" thing, but does a vertical split instead (vim 6 only).
	"
	" I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
	" unlikely that you need their default mappings (CTRL-\'s default use is
	" as part of CTRL-\ CTRL-N typemap, which basically just does the same
	" thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
	" If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
	" of these maps to use other keys.  One likely candidate is 'CTRL-_'
	" (which also maps to CTRL-/, which is easier to type).  By default it is
	" used to switch between Hebrew and English keyboard mode.
	"
	" All of the maps involving the <cfile> macro use '^<cfile>$': this is so
	" that searches over '#include <time.h>" return only references to
	" 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
	" files that contain 'time.h' as part of their name).


	" To do the first type of search, hit 'CTRL-\', followed by one of the
	" cscope search types above (s,g,c,t,e,f,i,d).  The result of your cscope
	" search will be displayed in the current window.  You can use CTRL-T to
	" go back to where you were before the search.  
	"

	nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>	
	nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
	nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>	


	" Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
	" makes the vim window spEither make this a lit horizontally, with search result displayed in
	" the new window.
	"
	" (Note: earlier versions of vim may not have the :scs command, but it
	" can be simulated roughly via:
	"    nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>	

	nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>	
	nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>	
	nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>	
	nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>	

	" Hitting CTRL-space *twice* before the search type does a vertical 
	" split instead of a horizontal one (vim 6 and up only)
	"
	" (Note: you may wish to put a 'set splitright' in your .vimrc
	" if you prefer the new window on the right instead of the left

	nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
	nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
	nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
	nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
	nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
	nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>	
	nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>	
	nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>


	""""""""""""" key map timeouts
	"
	" By default Vim will only wait 1 second for each keystroke in a mapping.
	" You may find that too short with the above typemaps.  If so, you should
	" either turn off mapping timeouts via 'notimeout'.
	"
	set notimeout 
	"
	" Or, you can keep timeouts, by uncommenting the timeoutlen line below,
	" with your own personal favorite value (in milliseconds):
	"
	"set timeoutlen=4000
	"
	" Either way, since mapping timeout settings by default also set the
	" timeouts for multicharacter 'keys codes' (like <F1>), you should also
	" set ttimeout and ttimeoutlen: otherwise, you will experience strange
	" delays as vim waits for a keystroke after you hit ESC (it will be
	" waiting to see if the ESC is actually part of a key code like <F1>).
	"
	"set ttimeout 
	"
	" personally, I find a tenth of a second to work well for key code
	" timeouts. If you experience problems and have a slow terminal or network
	" connection, set it higher.  If you don't set ttimeoutlen, the value for
	" timeoutlent (default: 1000 = 1 second, which is sluggish) is used.
	"
	set ttimeoutlen=500

endif



"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" {{{ C settings
"

autocmd FileType c setlocal foldmethod=syntax
autocmd FileType cpp setlocal foldmethod=syntax

function! CScopeAdd()
	if filereadable("./cscope.out")
		cs add cscope.out
		echo 'cscope out'
		" else add database pointed to by environment
	elseif $CSCOPE_DB != ""
		cs add $CSCOPE_DB
		echo 'cscope db'
	endif
endfunction

function! CScopeUpdate()
	"    call system('echo "hello"')
	call system("find . -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' > cscope.files")
	call system('cscope -b -i cscope.files -f cscope.out')
	cs reset
endfunction

"au FileType c call CSettings()
"au FileType h call CSettings()
"au FileType cpp call CSettings()
"au FileType hpp call CSettings()

" vim-note settings
let g:notes_directories = ['/mnt/poutima/Notes']

function! CSettings()
	autocmd FileType c set omnifunc=ccomplete#CompleteCpp
	let OmniCpp_DisplayMode = 0
	let OmniCpp_ShowAccess = 1
	let OmniCpp_ShowScopeInAbbr = 1
	let OmniCpp_ShowPrototypeInAbbr = 1
	let OmniCpp_MayCompleteDot = 1 " auto complete after .
	let OmniCpp_MayCompleteArrow = 1 " auto complete after ->
	let OmniCpp_MayCompleteScope = 0 " no scopes in C
	let OmniCpp_SelectFirstItem = 1
	let OmniCpp_LocalSearchDecl = 1

	" automatically open and close the popup menu / preview window
	au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
	set completeopt=menuone,menu,longest,preview


	"-------------------------------------------------------------------------------
	" autocomplete parenthesis, brackets and braces
	"-------------------------------------------------------------------------------
	"inoremap ( ()<Left>
	"inoremap [ []<Left>
	inoremap { {}<Left>
	"
	"vnoremap ( s()<Esc>P<Right>%
	"vnoremap [ s[]<Esc>P<Right>%
	vnoremap { s{}<Esc>P<Right>%
	"
	"-------------------------------------------------------------------------------
	" autocomplete quotes (visual and select mode)
	"-------------------------------------------------------------------------------
	"xnoremap  '  s''<Esc>P<Right>
	"xnoremap  "  s""<Esc>P<Right>
	"xnoremap  `  s``<Esc>P<Right>

	set noexpandtab
	setl shiftwidth=8
	setl tabstop=8
	setl autoindent smartindent              " turn on auto/smart indenting
	setl smarttab                            " make <tab> and <backspace> smarter
	setl backspace=eol,start,indent          " allow backspacing over indent, eol, & start
	syn keyword cType uint ubyte ulong uint64_t uint32_t uint16_t uint8_t boolean_t int64_t int32_t int16_t int8_t u_int64_t u_int32_t u_int16_t u_int8_t
	syn keyword cOperator likely unlikely
	setl formatoptions=tcqlron
	set cinoptions=:0,l1,t0,g0

endfunction
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" {{{ Rust settings
"
au BufNewFile,BufRead *.rs set filetype=rust
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" {{{ Perl settings
"
autocmd FileType perl set shiftwidth=4
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" {{{ Tex settings
"
autocmd FileType tex set shiftwidth=2
autocmd FileType tex let g:tex_flavor = "latex"
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Python settings {{{
"
au FileType python call PythonSettings()
function! PythonSettings()
	set tabstop=8
	set expandtab
	set shiftwidth=4
	set softtabstop=4
	
	syntax on
	filetype indent on
	set foldmethod=indent
	
	map <buffer> <F11> :call Flake8()<CR>
"	set omnifunc=pythoncomplete#Complete
"	set nocindent
	
"	let python_highlight_all = 1
"	syn keyword pythonDecorator True None False self

"	inoremap <buffer> $r return
"	inoremap <buffer> $i import
"	inoremap <buffer> $p print
"	inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi
"	lmap <buffer> <leader>1 /class
"	lmap <buffer> <leader>2 /def
"	lmap <buffer> <leader>C ?class
"	lmap <buffer> <leader>D ?def
"	let g:pydiction_location = '$HOME/.vim/pydiction/complete-dict' 

	" python_fn mappings
	"   ]t      -- Jump to beginning of block
	map <leader>pt ]t
	"   ]c      -- Select current/previous class
	map <leader>c ]c
	"   ]e      -- Jump to end of block
	map <leader>pe ]e
	"   ]>      -- Shift block to right
	map <leader>> ]>
	"   ]<      -- Shift block to left
	map <leader>< ]<
	"   ]#      -- Comment selection
	map <leader># ]#
	"   ]v      -- Select (Visual Line Mode) block
	map <leader>pv ]v
	"   ]u      -- Uncomment selection
	map <leader>pu ]u
	"   ]d      -- Select current/previous function
	map <leader>pd ]d
	"   ]<up>   -- Jump to previous line with the same/lower indentation
	map <leader><up> ]<up>
	"   ]<down> -- Jump to next line with the same/lower indentation
	map <leader><down> ]<down>
	" Execute file being edited with <Shift> + e:
	map <buffer> <S-e> :w<CR>:!/usr/bin/env python % <CR>

	" delete trailing white space, useful for Python ;)
	func! DeleteTrailingWS()
		exe "normal mz"
		%s/\s\+$//ge
		exe "normal `z"
	endfunc
	autocmd BufWrite *.py :call DeleteTrailingWS()

	autocmd BufWrite *.py :call DeleteTrailingWS()

endfunction
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Makefiles {{{ 
"
au FileType make set noexpandtab " use real tabs
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" binary files {{{
"
augroup Binary " vim -b : edit binary using xxd-format!
	au!
	au BufReadPre  *.tgz,*.BIN,*.bin let &bin=1
	au BufReadPost *.tgz,*.BIN,*.bin if &bin | %!xxd
	au BufReadPost *.tgz,*.BIN,*.bin set ft=xxd | endif
	au BufWritePre *.tgz,*.BIN,*.bin if &bin | %!xxd -r
	au BufWritePre *.tgz,*.BIN,*.bin endif
	au BufWritePost *.tgz,*.BIN,*.bin if &bin | %!xxd
	au BufWritePost *.tgz,*.BIN,*.bin set nomod | endif
augroup END
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" JavaScript {{{
"
"javascript_enable_domhtmlcss = 1
"b:javascript_fold = 1
"}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"end of file