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