add zsh configs
[~bandali/configs] / vim / .vimrc
CommitLineData
debd020d
AB
1" ==== <Vundle> ====
2set nocompatible " be iMproved, required
3filetype off " required
4
5" set the runtime path to include Vundle and initialize
6set rtp+=~/.vim/bundle/Vundle.vim
7call vundle#begin()
8
9" let Vundle manage Vundle, required
10Plugin 'gmarik/Vundle.vim'
11Plugin 'kien/rainbow_parentheses.vim'
12Plugin 'hsanson/vim-android'
13Plugin 'scrooloose/nerdcommenter'
14Plugin 'SirVer/ultisnips'
15Plugin 'honza/vim-snippets'
16Plugin 'kien/ctrlp.vim'
17Plugin 'tacahiroy/ctrlp-funky'
18Plugin 'Raimondi/delimitMate'
19Plugin 'Yggdroot/indentLine'
20"Plugin 'tpope/vim-fugitive'
21Plugin 'airblade/vim-gitgutter'
22"Plugin 'altercation/vim-colors-solarized'
23Plugin 'terryma/vim-multiple-cursors'
24call vundle#end() " required
25" ==== </Vundle> ====
26
27" Use the Solarized Dark theme
28set background=dark
29"colorscheme solarized
30
31" Make Vim more useful
32set nocompatible
33" Use the OS clipboard by default (on versions compiled with `+clipboard`)
34set clipboard=unnamed
35" Enhance command-line completion
36set wildmenu
37" Allow cursor keys in insert mode
38set esckeys
39" Allow backspace in insert mode
40set backspace=indent,eol,start
41" Optimize for fast terminal connections
42set ttyfast
43" Add the g flag to search/replace by default
44set gdefault
45" Use UTF-8 without BOM
46set encoding=utf-8 nobomb
47" Change mapleader
48let mapleader=","
49" Don’t add empty newlines at the end of files
50set binary
51set noeol
52" Centralize backups, swapfiles and undo history
53set backupdir=~/.vim/backups
54set directory=~/.vim/swaps
55if exists("&undodir")
56 set undodir=~/.vim/undo
57endif
58set undofile
59
60" Don’t create backups when editing files in certain directories
61set backupskip=/tmp/*,/private/tmp/*
62
63" Respect modeline in files
64set modeline
65set modelines=4
66" Enable per-directory .vimrc files and disable unsafe commands in them
67set exrc
68set secure
69" Enable line numbers
70set number
71" Enable syntax highlighting
72syntax on
73" Highlight current line
74"set cursorline
75" Make tabs as wide as two spaces
76set tabstop=4
77" Show “invisible” characters
78set lcs=tab:▸\ ,eol:\ \,nbsp:_
79" set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_
80set list
81" Highlight searches
82set hlsearch
83" Ignore case of searches
84set ignorecase
85" Highlight dynamically as pattern is typed
86set incsearch
87" Always show status line
88set laststatus=2
89" Enable mouse in all modes
90set mouse=a
91" Disable error bells
92set noerrorbells
93" Don’t reset cursor to start of line when moving around.
94set nostartofline
95" Show the cursor position
96set ruler
97" Don’t show the intro message when starting Vim
98set shortmess=atI
99" Show the current mode
100set showmode
101" Show the filename in the window titlebar
102set title
103" Show the (partial) command as it’s being typed
104set showcmd
105" Use relative line numbers
106if exists("&relativenumber")
107 set relativenumber
108 au BufReadPost * set relativenumber
109endif
110" Start scrolling three lines before the horizontal window border
111set scrolloff=3
112
113" Strip trailing whitespace (,ss)
114function! StripWhitespace()
115 let save_cursor = getpos(".")
116 let old_query = getreg('/')
117 :%s/\s\+$//e
118 call setpos('.', save_cursor)
119 call setreg('/', old_query)
120endfunction
121noremap <leader>ss :call StripWhitespace()<CR>
122" Save a file as root (,W)
123noremap <leader>W :w !sudo tee % > /dev/null<CR>
124
125" Automatic commands
126if has("autocmd")
127 " Enable file type detection
128 filetype plugin indent on
129 " Treat .json files as .js
130 autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
131endif
132
133" Enable pathogen
134"execute pathogen#infect()
135
136" swap ; and :
137 nnoremap ; :
138 nnoremap : ;
139 vnoremap ; :
140 vnoremap : ;
141
142" relative line number stuff
143function! NumberToggle()
144 if(&relativenumber == 1)
145 set number
146 else
147 set relativenumber
148 endif
149endfunc
150nnoremap <leader>n :call NumberToggle()<cr>
151":au FocusLost * :set number
152":au FocusGained * :set relativenumber
153autocmd InsertEnter * :set number
154autocmd InsertEnter * :set norelativenumber
155autocmd InsertLeave * :set relativenumber
156"autocmd InsertLeave * :set nonumber
157
158" Rainbow Parantheses
159au Syntax * RainbowParenthesesLoadRound
160au Syntax * RainbowParenthesesLoadSquare
161au Syntax * RainbowParenthesesLoadBraces
162noremap <leader>m :RainbowParenthesesToggle<CR>
163
164
165" ==== <UltiSnips> ====
166" Trigger configuration. Do not use <tab> if you use
167" https://github.com/Valloric/YouCompleteMe.
168let g:UltiSnipsExpandTrigger="<tab>"
169"let g:UltiSnipsJumpForwardTrigger="<c-b>"
170let g:UltiSnipsJumpForwardTrigger="<tab>"
171"let g:UltiSnipsJumpBackwardTrigger="<c-z>"
172let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
173" ==== </UltiSnips> ====
174
175" Spaces FTW
176set shiftwidth=4
177set expandtab
178
179"let g:ctrlp_map = '<space>'
180let g:ctrlp_map = '<leader>p'
181set wildignore+=*/build/**
182let g:android_sdk_path= '/Applications/Android\ Studio.app/sdk/'
183let g:android_adb_tool= '/Applications/Android\ Studio.app/sdk/platform-tools/adb'
184let gradle_path= '~/.gradle/'
185let g:android_build_type= 'gradle'
186
187let delimitMate_expand_space=1
188let delimitMate_expand_cr=2
189
190let g:indentLine_enabled=1
191"let g:indentLine_color_term = 239
192"let g:indentLine_color_gui = '#09AA08'
193"let g:indentLine_char = '│'
194let g:indentLine_char = '¦'
195
196 " ctrlp {
197 if isdirectory(expand("~/.vim/bundle/ctrlp.vim/"))
198 let g:ctrlp_working_path_mode = 'ra'
199 nnoremap <silent> <D-t> :CtrlP<CR>
200 nnoremap <silent> <D-r> :CtrlPMRU<CR>
201 let g:ctrlp_custom_ignore = {
202 \ 'dir': '\.git$\|\.hg$\|\.svn$',
203 \ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$' }
204
205" On Windows use "dir" as fallback command.
206 if executable('ag')
207 let s:ctrlp_fallback = 'ag %s --nocolor -l -g ""'
208 elseif executable('ack-grep')
209 let s:ctrlp_fallback = 'ack-grep %s --nocolor -f'
210 elseif executable('ack')
211 let s:ctrlp_fallback = 'ack %s --nocolor -f'
212 else
213 let s:ctrlp_fallback = 'find %s -type f'
214 endif
215 let g:ctrlp_user_command = {
216 \ 'types': {
217 \ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
218 \ 2: ['.hg', 'hg --cwd %s locate -I .'],
219 \ },
220 \ 'fallback': s:ctrlp_fallback
221 \ }
222
223 if isdirectory(expand("~/.vim/bundle/ctrlp-funky/"))
224" CtrlP extensions
225 let g:ctrlp_extensions = ['funky']
226
227"funky
228 nnoremap <Leader>fu :CtrlPFunky<Cr>
229 endif
230 endif
231"}
232"
233
234" change cursor shape based on mode
235let &t_SI = "\<Esc>]50;CursorShape=1\x7"
236let &t_EI = "\<Esc>]50;CursorShape=0\x7"
237
238set pastetoggle=<leader>t
239