1 "==============================================================================
3 "==============================================================================
10 set backspace=indent,eol,start
12 "==============================================================================
14 "==============================================================================
15 source ~/.vim/comment.vim
17 call plug#begin('~/.vim/plugged')
19 Plug 'airblade/vim-gitgutter'
22 Plug 'justinmk/vim-syntax-extra'
23 Plug 'morhetz/gruvbox'
27 Plug 'ap/vim-css-color'
28 Plug 'mechatroner/rainbow_csv'
29 Plug 'MTDL9/vim-log-highlighting'
32 Plug 'vim-airline/vim-airline'
33 Plug 'vim-airline/vim-airline-themes'
34 Plug 'ryanoasis/vim-devicons'
37 Plug 'maralla/completor.vim'
38 Plug 'vim-syntastic/syntastic'
42 "==============================================================================
43 " Tabs & Invisible characters
44 "==============================================================================
46 set listchars=tab:>—,nbsp:␣,trail:.
50 " filetype plugin indent on
53 "==============================================================================
55 "==============================================================================
60 let g:gruvbox_italic =1
61 let g:gruvbox_contrast_dark='hard'
67 autocmd FileType gitcommit set colorcolumn=50,51,72,73
68 autocmd FileType gitrebase set colorcolumn=63,64
69 hi ColorColumn ctermbg=232
76 hi LineNr ctermfg=236 ctermbg=232
79 hi CursorLine ctermbg=232
80 hi CursorLineNR ctermfg=166 ctermbg=232 cterm=bold
84 hi Comment ctermfg=241 ctermbg=0 cterm=italic
85 hi SpecialKey ctermfg=236 ctermbg=0
86 hi TODO ctermfg=red ctermbg=0 cterm=bold
87 hi NonText ctermfg=235 ctermbg=0
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
95 " hi Statement ctermfg=3
97 hi VertSplit ctermfg=8 ctermbg=0
98 set splitbelow splitright
101 set wildmode=list:full,full
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 " delete all exept pattern
218 "==============================================================================
220 "==============================================================================
221 let g:airline_powerline_fonts = 1
222 let g:airline_theme = 'minimalist'
223 let g:airline#extensions#hunks#enabled = 0
224 let g:airline#extensions#branch#enabled = 1
226 let g:airline_symbols = {}
227 let g:airline_section_a = ''
228 let g:airline_section_b = ''
229 let g:airline_section_x = ''
230 let g:airline_section_y = ''
231 let g:airline_symbols.linenr = ''
233 "==============================================================================
235 "==============================================================================
236 let g:syntastic_python_checkers = ['pylint']
237 let g:syntastic_sh_checkers = ["bash"]
238 let g:syntastic_c_checkers = ["splint"]
239 let g:syntastic_c_splint_args = "-checks -DVERSION=\\\"VERSION\\\""
241 set statusline+=%#warningmsg#
242 set statusline+=%{SyntasticStatuslineFlag()}
245 let g:syntastic_check_on_wq = 0
246 let g:syntastic_auto_loc_list = 0
247 let g:syntastic_check_on_open = 1
248 let g:syntastic_enable_highlighting = 0 "underline word
249 let g:syntastic_always_populate_loc_list = 1
250 let g:syntastic_auto_jump = 0
252 hi link SyntasticErrorLine error
253 hi SyntasticErrorLineNr ctermfg=black ctermbg=red
256 hi SyntasticWarningSign ctermfg=226 ctermbg=232 cterm=italic
257 hi SyntasticErrorSign ctermfg=red ctermbg=232 cterm=italic
260 let g:syntastic_error_symbol = ''
261 let g:syntastic_warning_symbol = ''
262 let g:syntastic_style_error_symbol = ''
263 " let g:syntastic_style_warning_symbol = ''
264 let g:syntastic_style_warning_symbol = '!'
266 "==============================================================================
268 "==============================================================================
270 set foldmethod=syntax
272 hi Folded ctermfg=90 ctermbg=232 cterm=italic
274 function! MyFoldText() " {{{
275 let line = getline(v:foldstart)
276 let nucolwidth = &fdc + &number * &numberwidth
277 let windowwidth = winwidth(0) - nucolwidth - 3
278 let foldedlinecount = v:foldend - v:foldstart
279 let onetab = strpart(' ', 0, &tabstop)
280 let line = substitute(line, '\t', onetab, 'g')
281 let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
282 let fillcharcount = 81 - len(line) - len(foldedlinecount)
283 let rest = windowwidth - fillcharcount
284 return line . repeat(" ",fillcharcount) . foldedlinecount .' ' . repeat(" ", rest)
287 set foldtext=MyFoldText()
289 "==============================================================================
290 " File type highlight
291 "==============================================================================
293 augroup filetypedetect
294 autocmd BufNewFile,BufRead *.h set filetype=c
295 autocmd BufNewFile,BufRead *.csv set filetype=csv
296 autocmd BufNewFile,BufRead *.gpg set filetype=gpg
297 autocmd BufNewFile,BufRead LICENSE set filetype=text
298 autocmd BufNewFile,BufRead README set filetype=markdown
302 let g:rcsv_colorpairs = [
310 \['darkgreen', 'darkgreen'],
311 \['darkmagenta', 'darkmagenta'],
312 \['darkcyan', 'darkcyan']]
314 "==============================================================================
316 "==============================================================================
317 let g:completor_auto_trigger = 1
318 let g:completor_clang_binary = '/usr/bin/clang'
319 let g:completor_complete_options = 'menuone,noselect,preview'
321 inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
322 inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
324 "==============================================================================
325 " Remove characters function
326 "==============================================================================
327 function! Clean_file()
329 let save_pos = getpos(".")
330 " Remove spaces from begin & end of line
331 " Remove spaces after tab
333 " Remove file last line if empty
334 " Remove more than 2 empty lines
339 \%s/\($\n\)\+\%$//e |
341 " Return to saved cursor
342 call setpos(".", save_pos)
345 "==============================================================================
347 "==============================================================================
348 let g:filename = expand("%:r")
349 let g:filename_ext = expand("%:e")
350 let g:upperfilename = toupper(filename)
352 autocmd BufNewFile *.sh exe "normal!ggi#!/usr/bin/env bash
\r"
353 autocmd BufNewFile *.py exe "normal!ggi#!/usr/bin/env python3
\r"
354 autocmd BufNewFile *.h :call TempH()
355 autocmd BufNewFile *.c :call TempC()
358 exe "normal!ggi/* See LICENSE file for copyright and license details. */
\r"
359 exe "normal!o#ifndef ".g:upperfilename."_H"
360 exe "normal!o#define ".g:upperfilename."_H"
361 exe "normal!o
\r\r\r#endif /* ".g:upperfilename."_H */"
366 exe "normal!ggi/* See LICENSE file for copyright and license details. */
\r"
367 exe "normal!o/* macros */"
368 exe "normal!o/* typedef */"
369 exe "normal!o/* function declarations */"
370 exe "normal!o/* function implementations */
\r"
371 exe "normal!oint
\rmain(void)
\r{
\r\rreturn 0;
\r}"