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