[spacemacs] merge new template changes
[~bandali/configs] / vim / .vimrc
1 "set nocompatible " be iMproved, required
2 "filetype off " required
3
4 call plug#begin('~/.vim/plugged')
5
6 Plug 'kien/rainbow_parentheses.vim'
7 "Plug 'hsanson/vim-android'
8 Plug 'scrooloose/nerdcommenter'
9 Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
10 "Plug 'kien/ctrlp.vim'
11 "Plug 'tacahiroy/ctrlp-funky'
12 Plug 'Raimondi/delimitMate'
13 Plug 'Yggdroot/indentLine'
14 "Plug 'tpope/vim-fugitive'
15 Plug 'airblade/vim-gitgutter'
16 "Plug 'altercation/vim-colors-solarized'
17 Plug 'terryma/vim-multiple-cursors'
18 "Plug 'elzr/vim-json'
19 "Plug 'lervag/vim-latex'
20 Plug 'tpope/vim-surround'
21 Plug 'rust-lang/rust.vim'
22 Plug 'phildawes/racer'
23 Plug 'whatyouhide/vim-gotham'
24 "Plug 'tpope/vim-repeat' | Plug 'svermeulen/vim-easyclip'
25
26 call plug#end()
27
28
29 " Use the Solarized Dark theme
30 set background=dark
31 colorscheme gotham
32
33 " Make Vim more useful
34 set nocompatible
35 " Use the OS clipboard by default (on versions compiled with `+clipboard`)
36 set clipboard=unnamedplus
37 " Enhance command-line completion
38 set wildmenu
39 " Allow cursor keys in insert mode
40 set esckeys
41 " Allow backspace in insert mode
42 set backspace=indent,eol,start
43 " Optimize for fast terminal connections
44 set ttyfast
45 " Add the g flag to search/replace by default
46 set gdefault
47 " Use UTF-8 without BOM
48 set encoding=utf-8 nobomb
49 " Change mapleader
50 let mapleader=","
51 " Don’t add empty newlines at the end of files
52 set binary
53 set noeol
54 " Centralize backups, swapfiles and undo history
55 set backupdir=~/.vim/backups
56 set directory=~/.vim/swaps
57 if exists("&undodir")
58 set undodir=~/.vim/undo
59 endif
60 set undofile
61
62 " Don’t create backups when editing files in certain directories
63 set backupskip=/tmp/*,/private/tmp/*
64
65 " Respect modeline in files
66 set modeline
67 set modelines=4
68 " Enable per-directory .vimrc files and disable unsafe commands in them
69 set exrc
70 set secure
71 " Enable line numbers
72 set number
73 " Enable syntax highlighting
74 syntax on
75 " Highlight current line
76 "set cursorline
77 " Make tabs as wide as two spaces
78 set tabstop=4
79 " Show “invisible” characters
80 set lcs=tab:▸\ ,eol:\ \,nbsp:_
81 " set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_
82 set list
83 " Highlight searches
84 set hlsearch
85 " Ignore case of searches
86 set ignorecase
87 " Highlight dynamically as pattern is typed
88 set incsearch
89 " Always show status line
90 set laststatus=2
91 " Enable mouse in all modes
92 set mouse=a
93 " Disable error bells
94 set noerrorbells
95 " Don’t reset cursor to start of line when moving around.
96 set nostartofline
97 " Show the cursor position
98 set ruler
99 " Don’t show the intro message when starting Vim
100 set shortmess=atI
101 " Show the current mode
102 set showmode
103 " Show the filename in the window titlebar
104 set title
105 " Show the (partial) command as it’s being typed
106 set showcmd
107 " Use relative line numbers
108 "if exists("&relativenumber")
109 "set relativenumber
110 "au BufReadPost * set relativenumber
111 "endif
112 " Start scrolling three lines before the horizontal window border
113 set scrolloff=3
114
115 " Strip trailing whitespace (,ss)
116 function! 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)
122 endfunction
123 noremap <leader>ss :call StripWhitespace()<CR>
124 " Save a file as root (,w)
125 noremap <leader>w :w !sudo tee % > /dev/null<CR>
126
127 " Automatic commands
128 if 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
133 endif
134
135 " Enable pathogen
136 "execute pathogen#infect()
137
138 " swap ; and :
139 nnoremap ; :
140 nnoremap : ;
141 vnoremap ; :
142 vnoremap : ;
143
144 ":au FocusLost * :set number
145 ":au FocusGained * :set relativenumber
146 "autocmd InsertEnter * :set number
147 "autocmd InsertEnter * :set norelativenumber
148 "autocmd InsertLeave * :set relativenumber
149 "autocmd InsertLeave * :set nonumber
150
151 " Rainbow Parantheses
152 au Syntax * RainbowParenthesesLoadRound
153 au Syntax * RainbowParenthesesLoadSquare
154 au Syntax * RainbowParenthesesLoadBraces
155 noremap <leader>m :RainbowParenthesesToggle<CR>
156
157
158 " ==== <UltiSnips> ====
159 " Trigger configuration. Do not use <tab> if you use
160 " https://github.com/Valloric/YouCompleteMe.
161 let g:UltiSnipsExpandTrigger="<tab>"
162 "let g:UltiSnipsJumpForwardTrigger="<c-b>"
163 let g:UltiSnipsJumpForwardTrigger="<tab>"
164 "let g:UltiSnipsJumpBackwardTrigger="<c-z>"
165 let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
166 " ==== </UltiSnips> ====
167
168 " Spaces FTW
169 set shiftwidth=4
170 set expandtab
171
172 let g:ctrlp_map = '<space>'
173 "let g:ctrlp_map = '<leader>p'
174 set wildignore+=*/build/**
175 let g:android_sdk_path= '/Applications/Android\ Studio.app/sdk/'
176 let g:android_adb_tool= '/Applications/Android\ Studio.app/sdk/platform-tools/adb'
177 let gradle_path= '~/.gradle/'
178 let g:android_build_type= 'gradle'
179
180 let delimitMate_expand_space=1
181 let delimitMate_expand_cr=2
182
183 let g:indentLine_enabled=1
184 "let g:indentLine_color_term = 239
185 "let g:indentLine_color_gui = '#09AA08'
186 "let g:indentLine_char = '│'
187 let 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
228 if &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"
233 endif
234 " eliminite the delay when switching modes
235 set ttimeoutlen=0
236
237 set pastetoggle=<leader>p
238
239 "set conceallevel=0
240 "let g:vim_json_syntax_conceal = 0
241 "let g:indentLine_noConcealCursor=""
242 " latex mode settings
243 let g:Tex_DefaultTargetFormat = "pdf"
244
245 set hidden
246 let g:racer_cmd = "racer"
247 let $RUST_SRC_PATH=expand('~/misc/rs/rust/src/')
248
249 noremap \ :q<CR>
250