-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
171 lines (140 loc) · 4.62 KB
/
.vimrc
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
set nocompatible " required
filetype off " required
set number
set modeline
set background=dark
syntax on
filetype indent plugin on
set autoindent
imap jj <Esc>
set cursorline
set mouse=a
set ttyfast
" Detect number of CPU cores on linux/osx
if !empty($NUMBER_OF_PROCESSORS)
let cores = $NUMBER_OF_PROCESSORS + 0
elseif filereadable('/proc/cpuinfo')
let cores = system('grep -c ^processor /proc/cpuinfo') + 0
elseif system("uname") == "Darwin\n"
let cores = system('sysctl -n hw.ncpu') + 0
else
let cores = 1
endif
" Highlight search, unhighlight on double esc
set hlsearch
nnoremap <esc><esc> :silent! nohls<cr>
" allow toggling between hard and soft tabs, or setting using argument
function TabToggle(...)
if a:0 > 0
let tabtype = a:1 " 0: switch to soft tabs, 1: switch to hard tabs
else
let tabtype = &expandtab
endif
if tabtype
set shiftwidth=8
set softtabstop=0
set noexpandtab
echo "Tabs: HARD"
:highlight MixedIndent ctermbg=red guibg=red
:2match MixedIndent /^\t*\zs \+/
else
set shiftwidth=4
set softtabstop=4
set expandtab
echo "Tabs: SOFT"
:highlight MixedIndent ctermbg=red guibg=red
:2match MixedIndent /^[[:space:]]*\t/
endif
endfunction
nmap <F9> mz:execute TabToggle()<CR>'z
"Set tab mode to soft:
autocmd VimEnter * :execute TabToggle(0)
" Shortcut for reformatting
map <F7> mzgg=G`z
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Change filesystem to read-write
function SetReadWrite()
!sudo mount -o remount,rw /
:set noreadonly
endfunction
command ReadWrite exec SetReadWrite()
" Workaround for vim memory leak caused by calling match command
if version >= 702
autocmd BufWinLeave * call clearmatches()
endif
let g:minimap_highlight='Visual'
" START - Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/Vundle.vim/README.md')
if !filereadable(vundle_readme)
if executable('git')
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
let iCanHazVundle=0
else
echo "Git not found. Skipping vundle install."
endif
endif
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin)
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/nerdtree'
Plugin 'morhetz/gruvbox'
Plugin 'vim-airline/vim-airline'
if cores > 1
Plugin 'severin-lemaignan/vim-minimap'
Plugin 'kien/ctrlp.vim'
if has('python2') && (executable('catkin') || executable('catkin_make'))
Plugin 'taketwo/vim-ros'
endif
endif
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
if iCanHazVundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:PluginInstall
endif
colorscheme gruvbox
let g:airline#extensions#tabline#enabled = 1
"let g:airline_right_alt_sep = ''
"let g:airline_right_sep = ''
"let g:airline_left_alt_sep= ''
"let g:airline_left_sep = ''
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#buffer_nr_show = 1
" Show hard/soft tab status in bottom bar
:let g:airline_section_b = '%{airline#util#wrap(airline#extensions#hunks#get_hunks(),0)}%{airline#util#wrap(airline#extensions#branch#get_head(),0)}%{ &expandtab?" Tab:S":" Tab:H"}'
" Highlight trailing whitespace
:highlight ExtraWhitespace ctermbg=red guibg=red
:match ExtraWhitespace /\s\+\%#\@<!$/
:au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
:au InsertLeave * match ExtraWhitespace /\s\+$/
" Performance enhancements for slow machines:
if cores < 2
set lazyredraw
let g:airline_highlighting_cache=1 " Performance boost?
let g:airline_extensions = ['tabline']
endif
if !&diff " Actions to perform at start (except when opened as vimdiff)
" Start NERDTree and Minimap on startup
autocmd VimEnter * if exists(':NERDTree') | NERDTree | endif
if cores > 1
autocmd VimEnter * Minimap
endif
" Go to previous (last accessed) window.
autocmd VimEnter * wincmd w
" Remap q to qa for quickly exiting
cnoremap q qa
endif