1 "==============================================================================
3 "==============================================================================
11 "==============================================================================
13 "==============================================================================
14 source ~/.vim/my_config/comment.vim
16 call plug#begin('~/.vim/plugged')
18 Plug 'airblade/vim-gitgutter'
19 Plug 'tpope/vim-fugitive'
22 Plug 'morhetz/gruvbox'
23 Plug 'joshdick/onedark.vim'
24 Plug 'nanotech/jellybeans.vim'
25 Plug 'liuchengxu/space-vim-dark'
28 Plug 'ap/vim-css-color'
29 Plug 'justinmk/vim-syntax-extra'
30 Plug 'mechatroner/rainbow_csv'
31 Plug 'MTDL9/vim-log-highlighting'
34 Plug 'vim-airline/vim-airline'
35 Plug 'vim-airline/vim-airline-themes'
36 Plug 'ryanoasis/vim-devicons'
39 Plug 'tibabit/vim-templates'
40 Plug 'maralla/completor.vim'
41 Plug 'vim-syntastic/syntastic'
45 "==============================================================================
46 " Tabs & Invisible characters
47 "==============================================================================
49 set listchars=tab:>-,nbsp:␣,trail:.
56 "==============================================================================
58 "==============================================================================
62 let g:gruvbox_contrast_dark='hard'
63 " let g:space_vim_dark_background = 234
64 " let g:jellybeans_background_color_236=233
66 " let g:jellybeans_overrides = {
67 " \'background': { 'ctermbg': 'none', '256ctermbg': 'none' }}
72 " hi LineNr ctermfg=237
77 hi CursorLine ctermbg=235
78 hi CursorLineNR cterm=bold ctermbg=235 ctermfg=166
84 autocmd FileType gitcommit set colorcolumn=50,72
85 hi ColorColumn ctermbg=235
86 " highlight OverLength ctermbg=red ctermfg=white
87 " match OverLength /\%80v.\+/
91 hi Comment cterm=italic
92 hi SpecialKey ctermfg=24 ctermbg=NONE
93 hi TODO ctermfg=red cterm=bold
95 " hi Comment ctermfg=29,60,90
96 " hi Search ctermfg=29
97 " hi Comment ctermfg=59
98 " hi SpecialKey ctermfg=67
101 highlight clear SignColumn
102 highlight GitGutterAdd ctermfg=green ctermbg=235
103 highlight GitGutterChange ctermfg=darkyellow ctermbg=235 cterm=bold
104 highlight GitGutterDelete ctermfg=red ctermbg=235 cterm=bold
105 highlight GitGutterChangeDelete ctermfg=darkyellow ctermbg=235 cterm=bold
107 " hi Statement ctermfg=3
108 hi VertSplit ctermfg=8 ctermbg=0
109 set splitbelow splitright
110 filetype plugin indent on
112 set wildmode=list:full,full
117 "==============================================================================
119 "==============================================================================
120 "copy to global clipboard
121 "vnoremap <C-c> :w !xclip -i -sel c<CR><CR>
122 vmap <C-c> y:call system("xclip -i -selection clipboard", getreg("\""))<cr>:call system("xclip -i", getreg("\""))<cr>
124 "Move lines up and down with controle + k or j
125 nnoremap <silent> <C-j> :move +1 <CR>
126 nnoremap <silent> <C-k> :move -2 <CR>
128 "Disable keys in Normal mode
141 "Disable keys in Insert mode
152 nnoremap <silent><CR> :set paste<CR>m`o<Esc>``:set nopaste<CR>
154 " Run scripts (Controle Shift r)
155 autocmd FileType python nnoremap <C-S-r> <Esc>:w<CR>:!clear;python %<CR>
156 autocmd FileType sh nnoremap <C-S-r> <Esc>:w<CR>:!clear;sh %<CR>
157 autocmd FileType c nnoremap <C-S-r> <Esc>:w<CR>:!clear;make;./%:r<CR>
160 nnoremap <Leader><CR> <Esc>:vsplit
162 nnoremap <silent> <Leader>= :vertical resize +5<CR>
163 nnoremap <silent> <Leader>- :vertical resize -5<CR>
165 nnoremap <Leader>j <C-w>j
166 nnoremap <Leader>k <C-w>k
167 nnoremap <Leader>l <C-w>l
168 nnoremap <Leader>h <C-w>h
171 nnoremap <Leader>L <C-w>L
172 nnoremap <Leader>H <C-w>H
173 nnoremap <Leader>J <C-w>J
174 nnoremap <Leader>K <C-w>K
177 nnoremap <Leader>] gd
180 nnoremap <Leader>s :set hlsearch!<CR>
191 nnoremap <Leader>q :q!<CR>
194 nnoremap za :set foldmethod=syntax<CR>za
195 nnoremap <Leader>Z :set foldmethod=syntax<CR>zM "close all
197 "==============================================================================
199 "==============================================================================
203 "==============================================================================
205 "==============================================================================
206 let g:airline_powerline_fonts = 1
207 let g:airline_theme = "powerlineish"
208 let g:airline#extensions#hunks#enabled= 0
209 let g:airline#extensions#branch#enabled = 1
210 " let g:airline#extensions#tabline#enabled = 1
211 " let g:airline_skip_empty_sections = 1
213 "==============================================================================
215 "==============================================================================
216 ""let g:lightline = {
218 "" \'left':[['mode', 'paste'],
219 "" \['gitbranch','readonly','absolutepath'], ['modified']],
220 "" \'right':[['filetype'],['percent', 'lineinfo' ],
222 "" \'component_function':{'gitbranch': 'gitbranch#name'},
223 "" \'colorscheme': 'onedark',
225 " \['fileencoding'],['fileformat']
227 "==============================================================================
229 "==============================================================================
230 let g:tmpl_search_paths = ['/home/hassan/.vim/templates']
232 "==============================================================================
234 "==============================================================================
235 let g:syntastic_python_checkers = ['pylint']
236 let g:syntastic_c_checkers = ["gcc", "splint", "clang_tidy"]
238 set statusline+=%#warningmsg#
239 set statusline+=%{SyntasticStatuslineFlag()}
242 let g:syntastic_check_on_wq = 0
243 let g:syntastic_auto_loc_list = 0
244 let g:syntastic_check_on_open = 1
245 let g:syntastic_enable_highlighting= 0 "underline word
246 let g:syntastic_always_populate_loc_list = 0
248 highlight link SyntasticErrorLine error
249 " highlight link SyntasticWarningLine todo
251 "==============================================================================
253 "==============================================================================
255 set foldmethod=syntax
257 " hi Folded ctermbg=233 ctermfg=132
258 hi Folded ctermbg=233 ctermfg=90
260 function! MyFoldText() " {{{
261 let line = getline(v:foldstart)
262 let nucolwidth = &fdc + &number * &numberwidth
263 let windowwidth = winwidth(0) - nucolwidth - 3
264 let foldedlinecount = v:foldend - v:foldstart
265 let onetab = strpart(' ', 0, &tabstop)
266 let line = substitute(line, '\t', onetab, 'g')
267 let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
268 " let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
269 let fillcharcount = 84 - len(line) - len(foldedlinecount)
270 let rest = windowwidth - fillcharcount
271 " return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
272 return line . repeat(" ",fillcharcount) . foldedlinecount .' ' . repeat(" ", rest)
275 function! NeatFoldText()
276 let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
277 let lines_count = v:foldend - v:foldstart + 1
278 let lines_count_text = '| ' . printf("%10s", lines_count . ' lines') . ' |'
279 let foldchar = matchstr(&fillchars, 'fold:\zs.')
280 " let foldtextstart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
281 let foldtextstart = strpart( line, 0, (winwidth(0)*2)/3)
282 let foldtextend = lines_count_text . repeat(foldchar, 8)
283 let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
284 return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
288 set foldtext=MyFoldText()
289 " set foldtext=NeatFoldText()
290 "==============================================================================
291 " File type highlight
292 "==============================================================================
294 augroup filetypedetect
295 autocmd BufNewFile,BufRead *.h set filetype=c
296 autocmd BufNewFile,BufRead *.csv set filetype=csv
297 autocmd BufNewFile,BufRead *.gpg set filetype=gpg
298 autocmd BufNewFile,BufRead LICENSE set filetype=text
299 autocmd BufNewFile,BufRead README set filetype=markdown
303 let g:rcsv_colorpairs = [
311 \['darkgreen', 'darkgreen'],
312 \['darkmagenta', 'darkmagenta'],
313 \['darkcyan', 'darkcyan']]
315 "==============================================================================
317 "==============================================================================
318 let g:completor_auto_trigger = 1
319 let g:completor_clang_binary = '/usr/bin/clang'
321 inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
322 inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"