diff --git a/vim/.vimrc b/vim/.vimrc index 4be4c81..4211de9 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -26,13 +26,16 @@ Plugin 'plasticboy/vim-markdown' " All of your Plugins must be added before the following line call vundle#end() " required -filetype plugin indent on " required +"filetype plugin indent on " required " " End Vundle config " -"filetype plugin indent on +"------------------ +" some general vim settings +" +filetype plugin indent on syntax on colorscheme deus @@ -69,27 +72,22 @@ set ttimeoutlen=10 " line numbering gutter set nonu -"set number -"set numberwidth=3 -"set cpoptions+=n " use gutter for wrapped lines -"highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE + +"------------------ " airline plugin stuffs set laststatus=2 -"let g:airline#extensions#tabline#enabled = 1 -"let g:airline#extensions#tabline#formatter = 'default' let g:airline_section_a = airline#section#create(['mode',' ','branch']) let g:airline_section_b = airline#section#create(['hunks', 'branch']) -"let g:airline_section_c = '%{getcwd()}' let g:airline_theme='bubblegum' let g:airline_left_sep = '' let g:airline_left_alt_sep = '' let g:airline_right_sep = '' let g:airline_right_altsep = '' -"let g:airline_section_warning = '' " disable whitespace warnings -"let g:airline_powerline_fonts = 1 let g:airline_symbols.maxlinenr = '' + +"------------------ " custom keybinds " C-PageUp/Down conflicts with xfce-terminal, so there is a trick to fixing " https://unix.stackexchange.com/questions/159979/xfce4-terminal-disable-individual-shortcut @@ -101,19 +99,50 @@ nnoremap nnoremap " override default paste behavior xnoremap p pgvy -map :ccl map :cn nmap :bp\|bd # +"------------------ " AsyncRun -" https://github.com/skywind3000/asyncrun.vim -" map :AsyncRun -cwd= -save=2 make -map :AsyncRun -cwd= -save=2 make -j4 - +let g:qf_toggle = '' +let g:win_save = '' +function QfToggle() + if (g:qf_toggle == '') + call QfJumpAndReturn() + else + let g:qf_toggle = '' + :ccl + call winrestview(g:win_save) + endif +endfunction + +function QfJumpAndReturn() + let g:qf_toggle = "open" + let g:win_save = winsaveview() + :copen 16 + :wincmd p +endfunction + +function RunMake() + " update ctags? + " trying to update ctags blocks AsyncRun, maybe need autocommands? + ":AsyncRun -cwd= ctags -R ./src/ + :AsyncRun -cwd= -save=2 make -j4 +endfunction + +let g:asyncrun_timer = 250 +map :call RunMake() +noremap :call QfToggle() + + +"------------------ +" autocommands augroup vimrc " remove all vimrc autocommands autocmd! - autocmd QuickFixCmdPost * copen 16 + + " custom copen + autocmd User AsyncRunStart call QfJumpAndReturn() " Don't screw up folds when inserting text that might affect them, until " " leaving insert mode. Foldmethod is local to the window. Protect against @@ -126,11 +155,12 @@ augroup vimrc autocmd BufWinEnter *.* silent loadview augroup END + +"------------------ " fix keycodes when running inside tmux " http://tmux-users.narkive.com/M9tIqoa0/c-pageup-and-c-pagedown-seems-not-to-work-in-tmux if &term =~ '^screen' && exists('$TMUX') " Mouse mode - " set mouse+=a set ttymouse=xterm2 " tmux sends xterm-style keys when xterm-keys option is on @@ -158,3 +188,52 @@ if &term =~ '^screen' && exists('$TMUX') execute "set =\e[24;*~" endif + +" Testing airline/asyncrun colors ------------------ + +" Define new accents +function! AirlineThemePatch(palette) + " [ guifg, guibg, ctermfg, ctermbg, opts ]. + " See "help attr-list" for valid values for the "opt" value. + " http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim + let a:palette.accents.running = [ '', '', '', '', '' ] + let a:palette.accents.success = [ '#00ff00', '' , 'green', '', '' ] + let a:palette.accents.failure = [ '#ff0000', '' , 'red', '', '' ] +endfunction +let g:airline_theme_patch_func = 'AirlineThemePatch' + + +" Change color of the relevant section according to g:asyncrun_status, a global variable exposed by AsyncRun +" 'running': default, 'success': green, 'failure': red +let g:async_status_old = '' +function! Get_asyncrun_running() + + let async_status = g:asyncrun_status + if async_status != g:async_status_old + + if async_status == 'running' + call airline#parts#define_accent('asyncrun_status', 'running') + elseif async_status == 'success' + call airline#parts#define_accent('asyncrun_status', 'success') + elseif async_status == 'failure' + call airline#parts#define_accent('asyncrun_status', 'failure') + endif + + let g:airline_section_x = airline#section#create(['asyncrun_status']) + "AirlineRefresh + let g:async_status_old = async_status + + endif + + return async_status + +endfunction + +call airline#parts#define_function('asyncrun_status', 'Get_asyncrun_running') +let g:airline_section_x = airline#section#create(['asyncrun_status']) + +"let g:asyncrun_status = '' +"let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}']) + +"------------------------------------- +