1 "==============================================================================
3 "==============================================================================
11 "==============================================================================
13 "==============================================================================
14 source ~/.vim/comment.vim
16 call plug#begin('~/.vim/plugged')
18 Plug 'airblade/vim-gitgutter'
21 Plug 'justinmk/vim-syntax-extra'
22 Plug 'morhetz/gruvbox'
26 Plug 'ap/vim-css-color'
27 Plug 'mechatroner/rainbow_csv'
28 Plug 'MTDL9/vim-log-highlighting'
31 Plug 'vim-airline/vim-airline'
32 Plug 'vim-airline/vim-airline-themes'
33 Plug 'ryanoasis/vim-devicons'
36 Plug 'maralla/completor.vim'
37 Plug 'vim-syntastic/syntastic'
41 "==============================================================================
42 " Tabs & Invisible characters
43 "==============================================================================
45 set listchars=tab:>—,nbsp:␣,trail:.
48 set clipboard=unnamedplus
52 "==============================================================================
54 "==============================================================================
59 let g:gruvbox_italic =1
60 let g:gruvbox_contrast_dark='hard'
73 hi CursorLine ctermbg=232
74 hi CursorLineNR cterm=bold ctermbg=232 ctermfg=166
79 autocmd FileType gitcommit set colorcolumn=50,51,72,73
80 autocmd FileType gitrebase set colorcolumn=63,64
81 hi ColorColumn ctermbg=232
84 hi Comment ctermfg=241 cterm=italic
85 hi SpecialKey ctermfg=236 ctermbg=0
86 hi TODO ctermfg=red ctermbg=0 cterm=bold
87 hi NonText ctermfg=235
91 hi GitGutterAdd ctermfg=green ctermbg=232
92 hi GitGutterChange ctermfg=darkyellow ctermbg=232 cterm=bold
93 hi GitGutterDelete ctermfg=red ctermbg=232 cterm=bold
94 hi GitGutterChangeDelete ctermfg=darkyellow ctermbg=232 cterm=bold
96 " hi Statement ctermfg=3
97 hi VertSplit ctermfg=8 ctermbg=0
98 filetype plugin indent on
100 set wildmode=list:full,full
101 set splitbelow splitright
104 set ignorecase "search case insensitive
105 set smartcase "if uppercase case sensitive
107 "==============================================================================
109 "==============================================================================
110 "copy to global clipboard
111 vmap <C-c> y:call system("xclip -i -selection clipboard", getreg("\""))<cr>:call system("xclip -i", getreg("\""))<cr>
113 " replace word with yanked
114 nnoremap <C-p> cw<C-r>0<ESC>
117 nnoremap <C-c> :set invpaste paste?<CR>
118 set pastetoggle=<C-c>
121 "Move lines up and down with controle + k or j
122 nnoremap <silent> <C-j> :move +1 <CR>
123 nnoremap <silent> <C-k> :move -2 <CR>
125 "Disable keys in Normal mode
138 "Disable keys in Insert mode
152 " Go (start|end) of line
157 nnoremap <Leader><CR> <Esc>:vsplit
159 nnoremap <silent> <Leader>= :vertical resize +1<CR>
160 nnoremap <silent> <Leader>- :vertical resize -1<CR>
161 nnoremap <silent> <Leader>0 :vertical resize 87<CR>
163 nnoremap <Leader>j <C-w>j
164 nnoremap <Leader>k <C-w>k
165 nnoremap <Leader>l <C-w>l
166 nnoremap <Leader>h <C-w>h
169 nnoremap <Leader>L <C-w>L
170 nnoremap <Leader>H <C-w>H
171 nnoremap <Leader>J <C-w>J
172 nnoremap <Leader>K <C-w>K
175 nnoremap <Leader>f :set hlsearch<CR>/^[a-z].*(.*)$<CR>
176 nnoremap <Leader>o :set hlsearch!<CR>/\%80v.\+/<CR>
177 nnoremap <Leader>s :set hlsearch!<CR>
182 " inoremap ( ()<Left>
183 " inoremap { {}<Left>
184 " inoremap [ []<Left>
185 " inoremap " ""<Left>
186 " inoremap ' ''<Left>
189 nnoremap <Leader>q :qa!<CR>
192 nnoremap za :set foldmethod=syntax<CR>za
193 nnoremap <Leader>z :set foldmethod=syntax<CR>zM
194 nnoremap <Leader>Z :set foldmethod=syntax<CR>zR
197 nnoremap <Leader>a :SyntasticCheck<CR>
198 nnoremap <Leader>n :lnext<CR>
201 nnoremap <Leader>c :call Clean_file()<CR><CR>
207 " Insert current date
208 map <Leader>i "=strftime("%d %m %Y")<CR>p
211 " command! -range=% HighlightRepeats <line1>,<line2>call HighlightRepeats()
214 "==============================================================================
216 "==============================================================================
217 let g:airline_powerline_fonts = 1
218 " let g:airline_theme = "badwolf"
219 let g:airline_theme = 'minimalist'
220 let g:airline#extensions#hunks#enabled= 0
221 let g:airline#extensions#branch#enabled = 1
223 let g:airline_symbols = {}
224 let g:airline_section_a = ''
225 let g:airline_section_b = ''
226 let g:airline_section_x = ''
227 let g:airline_section_y = ''
228 let g:airline_symbols.linenr = ''
230 "==============================================================================
232 "==============================================================================
233 let g:syntastic_python_checkers = ['pylint']
234 let g:syntastic_c_checkers = ["splint"]
235 let g:syntastic_c_splint_args = "-checks -DVERSION=\\\"VERSION\\\""
237 set statusline+=%#warningmsg#
238 set statusline+=%{SyntasticStatuslineFlag()}
241 let g:syntastic_check_on_wq = 0
242 let g:syntastic_auto_loc_list = 0
243 let g:syntastic_check_on_open = 1
244 let g:syntastic_enable_highlighting= 0 "underline word
245 let g:syntastic_always_populate_loc_list = 1
246 let g:syntastic_auto_jump = 0
248 hi link SyntasticErrorLine error
249 hi SyntasticErrorLineNr ctermbg=red ctermfg=black
252 hi SyntasticWarningSign cterm=italic ctermbg=232 ctermfg=226
253 hi SyntasticErrorSign cterm=italic ctermbg=232 ctermfg=red
256 let g:syntastic_error_symbol = ''
257 let g:syntastic_warning_symbol = ''
258 let g:syntastic_style_error_symbol = ''
259 let g:syntastic_style_warning_symbol = ''
261 "==============================================================================
263 "==============================================================================
265 set foldmethod=syntax
267 hi Folded ctermbg=232 ctermfg=90
269 function! MyFoldText() " {{{
270 let line = getline(v:foldstart)
271 let nucolwidth = &fdc + &number * &numberwidth
272 let windowwidth = winwidth(0) - nucolwidth - 3
273 let foldedlinecount = v:foldend - v:foldstart
274 let onetab = strpart(' ', 0, &tabstop)
275 let line = substitute(line, '\t', onetab, 'g')
276 let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
277 let fillcharcount = 81 - len(line) - len(foldedlinecount)
278 let rest = windowwidth - fillcharcount
279 return line . repeat(" ",fillcharcount) . foldedlinecount .' ' . repeat(" ", rest)
282 set foldtext=MyFoldText()
284 "==============================================================================
285 " File type highlight
286 "==============================================================================
288 augroup filetypedetect
289 autocmd BufNewFile,BufRead *.h set filetype=c
290 autocmd BufNewFile,BufRead *.csv set filetype=csv
291 autocmd BufNewFile,BufRead *.gpg set filetype=gpg
292 autocmd BufNewFile,BufRead LICENSE set filetype=text
293 autocmd BufNewFile,BufRead README set filetype=markdown
297 let g:rcsv_colorpairs = [
305 \['darkgreen', 'darkgreen'],
306 \['darkmagenta', 'darkmagenta'],
307 \['darkcyan', 'darkcyan']]
309 "==============================================================================
311 "==============================================================================
312 let g:completor_auto_trigger = 1
313 let g:completor_clang_binary = '/usr/bin/clang'
314 let g:completor_complete_options = 'menuone,noselect,preview'
316 inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
317 inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
319 "==============================================================================
320 " Remove characters function
321 "==============================================================================
322 function! Clean_file()
324 let save_pos = getpos(".")
325 " Remove spaces from begin & end of line
326 " Remove spaces after tab
328 " Remove file last line if empty
329 " Remove more than 2 empty lines
334 \%s/\($\n\)\+\%$//e |
336 " Return to saved cursor
337 call setpos(".", save_pos)
340 "==============================================================================
342 "==============================================================================
343 let g:filename = expand("%:r")
344 let g:filename_ext = expand("%:e")
345 let g:upperfilename = toupper(filename)
347 autocmd BufNewFile *.sh exe "normal!ggi#!/usr/bin/env bash
\r"
348 autocmd BufNewFile *.h :call TempH()
349 autocmd BufNewFile *.c :call TempC()
352 exe "normal!ggi/* See LICENSE file for copyright and license details. */
\r"
353 exe "normal!o#ifndef ".g:upperfilename."_H"
354 exe "normal!o#define ".g:upperfilename."_H"
355 exe "normal!o
\r\r\r#endif /* ".g:upperfilename."_H */"
360 exe "normal!ggi/* See LICENSE file for copyright and license details. */
\r"
361 exe "normal!o/* macros */"
362 exe "normal!o/* typedef */"
363 exe "normal!o/* function declarations */"
364 exe "normal!o/* function implementations */
\r"
365 exe "normal!oint
\rmain(void)
\r{
\r\rreturn 0;
\r}"