-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
305 lines (266 loc) · 12.1 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
"-------------------------------------------------------------------------------
" Use Vim settings, rather then Vi settings.
" This must be first, because it changes other options as a side effect.
"-------------------------------------------------------------------------------
set nocompatible
"-------------------------------------------------------------------------------
"run pathogen plugin for easy install and run of other plugins
"-------------------------------------------------------------------------------
execute pathogen#infect()
"-------------------------------------------------------------------------------
" Enable file type detection. Use the default filetype settings.
" Also load indent files, to automatically do language-dependent indenting.
"-------------------------------------------------------------------------------
filetype plugin on
filetype indent on
"-------------------------------------------------------------------------------
" Create fancy status line (replaced with airline plugin )
"-------------------------------------------------------------------------------
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
"set laststatus=2
"-------------------------------------------------------------------------------
" Create status line using vim airline plugin
"-------------------------------------------------------------------------------
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_powerline_fonts = 1
let g:airline_skip_empty_sections = 1
let g:airline_theme='wombat'
function! AirlineInit()
let g:airline_section_b = airline#section#create(['branch'])
let g:airline_section_c = '%F'
let g:airline_section_z = '%p%% %03l:%03v 0x%02.2B %03.3b'
endfunction
autocmd User AirlineAfterInit call AirlineInit()
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.crypt = '🔒'
let g:airline_symbols.linenr = '≡'
let g:airline_symbols.maxlinenr = '㏑'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.spell = 'Ꞩ'
let g:airline_symbols.notexists = 'Ɇ'
let g:airline_symbols.whitespace = 'Ξ'
" powerline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = '≡'
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.dirty='⚡'
"-------------------------------------------------------------------------------
" Switch syntax highlighting on.
"-------------------------------------------------------------------------------
syntax on
"-------------------------------------------------------------------------------
" Set color scheme
"-------------------------------------------------------------------------------
colorscheme space-vim-dark
set termguicolors
hi Normal ctermbg=NONE guibg=NONE
hi LineNr ctermbg=NONE guibg=NONE
hi SignColumn ctermbg=NONE guibg=NONE
hi ErrorMsg ctermbg=darkred guibg=DarkRed
"-------------------------------------------------------------------------------
" Set cursor column and row highlight
"-------------------------------------------------------------------------------
set cursorcolumn
set cursorline
"-------------------------------------------------------------------------------
" Various settings
"-------------------------------------------------------------------------------
set autoindent " copy indent from current line
set autoread " read open files again when changed outside Vim
set autowrite " write a modified buffer on each :next , ...
"set backspace=indent,eol,start " backspacing over everything in insert mode
"set backup " keep a backup file
set browsedir=current " which directory to use for the file browser
set complete+=k " scan the files given with the 'dictionary' option
set history=200 " keep 200 lines of command line history
set hlsearch " highlight the last used search pattern
set incsearch " do incremental searching
"set listchars=tab:>.,eol:\$ " strings to use in 'list' mode
"set mouse=a " enable the use of the mouse
set nowrap " do not wrap lines
set number relativenumber " enable line numbers
set numberwidth=4 " line numbers width set to 4
set popt=left:8pc,right:3pc " print options
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set showmatch " show matching braces
set spell " turn on spell check
set smartindent " smart autoindenting when starting a new line
set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions
set wildmenu " command-line completion in an enhanced mode
set scrolljump=20 " jump when end of screen is reached
set nocscopeverbose " suppress cscope duplicate database warning
set exrc " load any local .vimrc file found in working directory
set expandtab
set softtabstop=0
set shiftwidth=4
set tabstop=4
"-------------------------------------------------------------------------------
" Set quick escape from insert mode.
"-------------------------------------------------------------------------------
inoremap jj <esc>
inoremap Jj <esc>
inoremap jJ <esc>
inoremap JJ <esc>
"-------------------------------------------------------------------------------
" Set quick command mode from normal mode.
"-------------------------------------------------------------------------------
noremap ; :
"-------------------------------------------------------------------------------
"Turn off arrow keys
"-------------------------------------------------------------------------------
noremap <down> <Nop>
noremap <left> <Nop>
noremap <right> <Nop>
noremap <up> <Nop>
inoremap <down> <Nop>
inoremap <left> <Nop>
inoremap <right> <Nop>
inoremap <up> <Nop>
"-------------------------------------------------------------------------------
" Easier navigation through buffers
"-------------------------------------------------------------------------------
nnoremap <Leader>h :bd<CR>
nnoremap <Leader>j :bp<CR>
nnoremap <Leader>k :bn<CR>
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>1 :1b<CR>
nnoremap <Leader>2 :2b<CR>
nnoremap <Leader>3 :3b<CR>
nnoremap <Leader>4 :4b<CR>
nnoremap <Leader>5 :5b<CR>
nnoremap <Leader>6 :6b<CR>
nnoremap <Leader>7 :7b<CR>
nnoremap <Leader>8 :8b<CR>
nnoremap <Leader>9 :9b<CR>
nnoremap <Leader>0 :10b<CR>
"-------------------------------------------------------------------------------
" Remap function keys
"-------------------------------------------------------------------------------
noremap <silent> <F2> :TagbarToggle<CR>
noremap <silent> <F3> :UndotreeToggle<CR>
noremap <silent> <F4> :NERDTreeToggle<CR>
noremap <silent> <F5> :Magit<CR>
noremap <silent> <F9> :Make<CR>
noremap <silent> <F10> :Make install<CR>
inoremap <silent> <F2> <Esc>:TagbarToggle<CR>
inoremap <silent> <F3> <Esc>:UndotreeToggle<CR>
inoremap <silent> <F4> <Esc>:NERDTreeToggle<CR>
inoremap <silent> <F5> <Esc>:Magit<CR>
inoremap <silent> <F9> <Esc>:Make<CR>
inoremap <silent> <F10> <Esc>:Make install<CR>
"-------------------------------------------------------------------------------
" Map moving between screens in Vim
"-------------------------------------------------------------------------------
noremap <silent> <A-Up> :wincmd k<CR>
noremap <silent> <A-Down> :wincmd j<CR>
noremap <silent> <A-Left> :wincmd h<CR>
noremap <silent> <A-Right> :wincmd l<CR>
"-------------------------------------------------------------------------------
" Set doxygen style comments for c-support plugin
"-------------------------------------------------------------------------------
call mmtemplates#config#Add ( 'C', '~/.vim/bundle/vim-plugins/c-support/templates/doxygen.template', 'Doxygen', 'ntd' )
noremap <Leader>d :Dox<CR>
"-------------------------------------------------------------------------------
" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim
"-------------------------------------------------------------------------------
noremap <C-q> :wqall<CR>
"-------------------------------------------------------------------------------
" comma always followed by a space
"-------------------------------------------------------------------------------
inoremap , ,<Space>
"-------------------------------------------------------------------------------
" Set indent line plugin
"-------------------------------------------------------------------------------
let g:indentLine_char = '┆'
let g:indentLine_color_term=100
let g:indentLine_fileType = ['c','h','cpp', 'py']
set list lcs=tab:\┆\
"-------------------------------------------------------------------------------
" Conque GDB settings
"-------------------------------------------------------------------------------
let g:ConqueTerm_Color = 2
let g:ConqueTerm_CloseOnEnd = 1
let g:ConqueTerm_StartMessages = 0
"let g:ConqueGdb_GdbExe = '/usr/bin/arm-none-eabi-gdb'
function DebugSession()
silent make -o vimgdb -gcflags "-N -l"
redraw!
if (filereadable("vimgdb"))
ConqueGdb vimgdb
else
echom "Couldn't find debug file"
endif
endfunction
function DebugSessionCleanup(term)
if (filereadable("vimgdb"))
let ds=delete("vimgdb")
endif
endfunction
call conque_term#register_function("after_close", "DebugSessionCleanup")
"nmap <leader>d :call DebugSession()<CR>;
"-------------------------------------------------------------------------------
" CScope settings
"-------------------------------------------------------------------------------
if has("cscope")
set csprg=/usr/bin/cscope
" change this to 1 to search ctags DBs first
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
" Using 'CTRL-\' then a search type makes the vim window
" "shell-out", with search results displayed on the bottom
noremap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
noremap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
noremap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
noremap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
noremap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
noremap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
noremap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
noremap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
" Using 'CTRL-spacebar' then a search type makes the vim window
" split horizontally, with search result displayed in
" the new window.
noremap <C-[>s :scs find s <C-R>=expand("<cword>")<CR><CR>
noremap <C-[>g :scs find g <C-R>=expand("<cword>")<CR><CR>
noremap <C-[>c :scs find c <C-R>=expand("<cword>")<CR><CR>
noremap <C-[>t :scs find t <C-R>=expand("<cword>")<CR><CR>
noremap <C-[>e :scs find e <C-R>=expand("<cword>")<CR><CR>
noremap <C-[>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
noremap <C-[>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
noremap <C-[>d :scs find d <C-R>=expand("<cword>")<CR><CR>
" Hitting CTRL-space *twice* before the search type does a vertical
" split instead of a horizontal one
noremap <C-[><C-[>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
noremap <C-[><C-[>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
noremap <C-[><C-[>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
noremap <C-[><C-[>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
noremap <C-[><C-[>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
noremap <C-[><C-[>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
noremap <C-[><C-[>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
set ttimeoutlen=500
endif