summaryrefslogtreecommitdiffstats
path: root/.vimrc
blob: ce62a24aab23308fd7164fbc86c1d94d6a24b34f (plain)
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
" Author: Florian "Bluewind" Pritz <flo@xssn.at>

set nocompatible
set encoding=utf-8               " unicode encoding
if &term =~# '^\(screen\|rxvt*\)$' "tty blinks otherwise
  set t_Co=256
endif
set nobackup
set noexpandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set ruler                        " show me where the cursor is
set rulerformat=%l/%L(%p%%),%c   " a better ruler
set showmatch                    " show matching brackets
"set cindent
set number                       " show line numbers
set showmode                     " show mode at bottom of screen
set hlsearch                     " highlight all search results
set incsearch                    " increment search
set ignorecase                   " case-insensitive search
set smartcase                    " upper-case sensitive search
set laststatus=2
set mouse=a
set nopaste
set foldmethod=marker
"set smartindent
set scrolloff=3
set showcmd
set display=uhex
"set list
"set listchars=tab:>\ ,eol:$
set listchars=trail:·,precedes:«,extends:»,tab:▸\ ,eol:set hidden
set display+=lastline
if exists("+undofile")
	set undofile
endif

set wildmenu
set wildmode=full
set wildignore=*.o,*.a,*.class,*.mo,*.la,*.swp,*.jpg,*.png,*.xpm,*.gif,*.pyc,*~,.git,.svn,.hg,


let mapleader = ","

"call pathogen#infect()

let g:sudo_no_gui = 1

filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

Bundle 'scrooloose/syntastic'
"Bundle 'Valloric/YouCompleteMe'
Bundle 'Shougo/neocomplete.vim'
Bundle 'SirVer/ultisnips'
Bundle 'tpope/vim-unimpaired'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-repeat'
Bundle 'SudoEdit'

filetype plugin indent on

"aliases
cnorea w!! w !sudo tee "%" > /dev/null
cnorea qpd %!perl -pe 's/\=([0-9A-Fa-f]{2})/chr(hex($1))/ge; s/\=\n//;'
com -range=% Fb :exec "<line1>,<line2>w !fb -e " . &filetype . " -n " . expand("%:t")

syntax on

filetype plugin indent on

autocmd FileType text setlocal textwidth=78
autocmd BufReadPost *
  \ if line("'\"") > 1 && line("'\"") <= line("$") |
  \   exe "normal! g`\"" |
  \ endif

if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
	  \ | wincmd p | diffthis
endif

set runtimepath+=/usr/share/vim

let python_highlight_all = 1

" common save shortcuts
inoremap <C-s> <esc>:w<cr>a
nnoremap <C-s> :w<cr>
inoremap <C-c> <esc>:q<cr>
nnoremap <C-c> :q<cr>

" movement mappings
nnoremap <C-Right> <C-w>l
nnoremap <C-Left> <C-w>h
nnoremap <C-Down> <C-w>j
nnoremap <C-Up> <C-w>k
nnoremap <Up> gk
nnoremap <Down> gj
nnoremap j gj
nnoremap k gk

"au VimEnter * :NERDTreeToggle
noremap <F2> :NERDTreeToggle<CR>
inoremap <F2> <ESC>:NERDTreeToggle<CR>

noremap <C-f> :FufFile<CR>
inoremap <C-f> <ESC>:FufFile<CR>
"noremap <C-b> :FuzzyFinderBuffer<CR>
"inoremap <C-b> <ESC>:FuzzyFinderBuffer<CR>

noremap <C-h> :nohl<CR>
inoremap <C-h> <ESC>:nohl<CR>a

let g:UltiSnipsJumpForwardTrigger="<tab>"

let g:acp_enableAtStartup = 0
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 2

" <CR>: close popup and save indent.
"inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
"function! s:my_cr_function()
  "return neocomplcache#smart_close_popup() . "\<CR>"
  "" For no inserting <CR> key.
  ""return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
"endfunction
" <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()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplcache#close_popup() : "\<Space>"

" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
  let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'

" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::'

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 make setlocal noexpandtab
au FileType python set ts=4 sw=4 softtabstop=4 et
autocmd BufRead,BufNewFile PKGBUILD let is_bash=1 | set ft=sh

"colorscheme gardener
"colorscheme desert256
"colorscheme candycode
let g:jellybeans_background_color_256 = 'none'
let g:jellybeans_overrides = {
\    'SpecialKey': { 'guifg': 'b0b0b0', 'guibg': '000000'}
\}
colorscheme jellybeans
"colorscheme inkpot
"colorscheme mustang
"colorscheme wombat256
"colorscheme xoria256

" Toggle dark/light default colour theme for shitty terms
"map <F2> :let &background = ( &background == "dark" ? "light" : "dark" )<CR>

" Compile and run keymappings
au FileType php map <F10> :!php %<CR>
au FileType python map <F10> :!python %<CR>
au FileType perl map <F10> :!perl %<CR>
au FileType ruby map <F10> :!ruby %<CR>
au FileType lua map <F10> :!lua %<CR>
au FileType html,xhtml map <F10> :!firefox %<CR>
au FileType tex map <F10> :!texi2pdf -c %<CR>

" Get the commit responsible for the current line
nmap <c-b> :call BlameCurrentLine()<cr>
" Get the current line number & file name, view the git commit that inserted it
fun! BlameCurrentLine()
let lnum = line(".")
let file = @%
exec "!gitBlameFromLineNo " lnum file
endfun

map <F12> <ESC>ggg?G``" apply rot13 for people snooping over shoulder, good fun

highlight ExtraWhitespace ctermbg=red guibg=red
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL

if !has("gui_running")
  if &term == "screen"
    set <C-Right>=Oc
    set <C-Left>=Od
    imap <C-Right> <ESC>:bn<RETURN>
    imap <C-Left> <ESC>:bp<RETURN>
  endif
else
  set guifont=Dejavu\ Sans\ Mono\ 10
  "set guioptions-=m
  set guioptions-=T
  set lines=80 columns=125
endif