blob: 29701aef0ed1fb88006b87cff685b6b1f4064b86 (
plain)
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
" -----------------------------------------------------------------------------
" Last Modification Date: 2014.12.23
" -----------------------------------------------------------------------------
" ------------------ Generic -------------------------------------------------
" ----------------------------------------------------------------------------
syntax on
colorscheme ir_black_dragon
match ErrorMsg /\s\+$/
set ts=4 sts=4 sw=4 expandtab
set smarttab
set autoindent
set number
set encoding=utf-8
set cursorline
set laststatus=2
set incsearch
set listchars=tab:▸\ ,eol:¬
set hidden
set ignorecase
set modeline
" If the root is using this vimrc, change colorscheme for safety.
if $USER == "root"
colorscheme default
highlight LineNr ctermfg=red
set backupdir=/tmp
endif
" ----------------------------------------------------------------------------
" ------------------ Plugins -------------------------------------------------
" ----------------------------------------------------------------------------
" Plugins with Vundle -> https://github.com/gmarik/Vundle.vim
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/vundle'
Plugin 'scrooloose/nerdtree'
Plugin 'majutsushi/tagbar'
Plugin 'tpope/vim-fugitive'
Plugin 'bling/vim-airline'
Plugin 'tmux-plugins/vim-tmux'
Plugin 'rdnetto/YCM-Generator'
Plugin 'Valloric/YouCompleteMe'
Plugin 'jeaye/color_coded'
Plugin 'easymotion/vim-easymotion'
Plugin 'beloglazov/vim-online-thesaurus'
call vundle#end()
filetype plugin indent on
" ----------------------------------------------------------------------------
" ------------------ My bindings ---------------------------------------------
" ----------------------------------------------------------------------------
" using @ is painful
nmap \\ @
nmap >> <C-]>
nmap << <C-t>
nmap i>> :vsplit<CR><C-]><CR>
nmap o>> :split<CR><C-]><CR>
nmap <leader>s :set spell!<CR>
nmap <leader>pt :set spelllang=pt<CR>
nmap <leader>en :set spelllang=en<CR>
nmap <S-w> <C-w>
nmap <S-t>l :tabnext<CR>
nmap <S-t>h :tabprevious<CR>
nmap <leader>g :Gstatus \| :help fugitive-:Gstatus<CR>
nmap <leader>t :TagbarToggle<CR>
nmap <leader>n :NERDTreeToggle<CR>
nmap <leader>l :set list!<CR>
" should be for mail only
imap <leader>1 <C-R>="Acked-by: Victor Toso <victortoso@redhat.com>"<CR>
imap <leader>2 <C-R>="Reviewed-by: Victor Toso <victortoso@redhat.com>"<CR>
" Trick to get shortcut for 'last active tab in vim.
let g:lasttab = 1
nmap bt :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" ----------------------------------------------------------------------------
" ------------------ EasyMotion ----------------------------------------------
" ----------------------------------------------------------------------------
nmap <leader>f <Plug>(easymotion-overwin-f)
map <leader>j <Plug>(easymotion-j)
map <leader>k <Plug>(easymotion-k)
" ----------------------------------------------------------------------------
" ------------------ Online Thesaurus ----------------------------------------
" ----------------------------------------------------------------------------
let g:online_thesaurus_map_keys = 0
nnoremap <leader>w :OnlineThesaurusCurrentWord<CR>
" ----------------------------------------------------------------------------
" ------------------ CSCOPE --------------------------------------------------
" ----------------------------------------------------------------------------
if has("cscope")
set cscopeprg=/bin/cscope
set cscopetag
set cscopetagorder=0 " cscope db before tags
set nocscopeverbose " *dont* show msg when any other cscope db added
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
" 's' symbol: find all references to the token under cursor
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor
" 't' text: find all instances of the text under cursor
" 'e' egrep: egrep search for the word under cursor
" 'f' file: open the filename under cursor
" 'i' includes: find files that include the filename under cursor
" 'd' called: find functions that function under cursor calls
nmap <C-f>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-f>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-f>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-f>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-f>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-f>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-f>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-f>d :cs find d <C-R>=expand("<cword>")<CR><CR>
endif
" ----------------------------------------------------------------------------
" ------------------ Vimdiff -------------------------------------------------
" ----------------------------------------------------------------------------
if &diff
" next change
nmap >> ]c
" previous change
nmap << [c
" get changes from other buffer
nmap get do
" put changes into other buffer
nmap put dp
" quit all buffers
nmap <leader>q :qall!<CR>
" toggle Read-Only
nmap <leader>r :set noro!<CR>
endif
" ----------------------------------------------------------------------------
" ------------------ Vala ----------------------------------------------------
" ----------------------------------------------------------------------------
" from: https://wiki.gnome.org/Projects/Vala/Vim
let vala_ignore_valadoc = 1 " Disable valadoc syntax highlight
let vala_comment_strings = 1 " Enable comment strings
let vala_space_errors = 1 " Highlight space errors
let vala_no_trail_space_error = 1 " Disable trailing space errors
let vala_no_tab_space_error = 1 " Disable space-tab-space errors
let vala_minlines = 120 " Minimum lines used for comment syncing (default 50)
" ----------------------------------------------------------------------------
" ------------------ Vim Functions -------------------------------------------
" ----------------------------------------------------------------------------
" from: http://vimcasts.org/episodes/tabs-and-spaces/
" Set tabstop, softtabstop and shiftwidth to the same value
command! -nargs=* Stab call Stab()
function! Stab()
let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ')
if l:tabstop > 0
let &l:sts = l:tabstop
let &l:ts = l:tabstop
let &l:sw = l:tabstop
endif
call SummarizeTabs()
endfunction
function! SummarizeTabs()
try
echohl ModeMsg
echon 'tabstop='.&l:ts
echon ' shiftwidth='.&l:sw
echon ' softtabstop='.&l:sts
if &l:et
echon ' expandtab'
else
echon ' noexpandtab'
endif
finally
echohl None
endtry
endfunction
|