Browse Source

add fancy status for AsyncRun make

master
dummy 8 years ago
parent
commit
887b35c47d
  1. 115
      vim/.vimrc

115
vim/.vimrc

@ -26,13 +26,16 @@ Plugin 'plasticboy/vim-markdown'
" All of your Plugins must be added before the following line " All of your Plugins must be added before the following line
call vundle#end() " required call vundle#end() " required
filetype plugin indent on " required "filetype plugin indent on " required
" "
" End Vundle config " End Vundle config
" "
"filetype plugin indent on "------------------
" some general vim settings
"
filetype plugin indent on
syntax on syntax on
colorscheme deus colorscheme deus
@ -69,27 +72,22 @@ set ttimeoutlen=10
" line numbering gutter " line numbering gutter
set nonu 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 " airline plugin stuffs
set laststatus=2 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_a = airline#section#create(['mode',' ','branch'])
let g:airline_section_b = airline#section#create(['hunks', '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_theme='bubblegum'
let g:airline_left_sep = '' let g:airline_left_sep = ''
let g:airline_left_alt_sep = '' let g:airline_left_alt_sep = ''
let g:airline_right_sep = '' let g:airline_right_sep = ''
let g:airline_right_altsep = '' let g:airline_right_altsep = ''
"let g:airline_section_warning = '' " disable whitespace warnings
"let g:airline_powerline_fonts = 1
let g:airline_symbols.maxlinenr = '' let g:airline_symbols.maxlinenr = ''
"------------------
" custom keybinds " custom keybinds
" C-PageUp/Down conflicts with xfce-terminal, so there is a trick to fixing " 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 " https://unix.stackexchange.com/questions/159979/xfce4-terminal-disable-individual-shortcut
@ -101,19 +99,50 @@ nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H> nnoremap <C-H> <C-W><C-H>
" override default paste behavior " override default paste behavior
xnoremap p pgvy xnoremap p pgvy
map <F6> :ccl<CR>
map <F2> :cn<CR> map <F2> :cn<CR>
nmap <F4> :bp\|bd #<CR> nmap <F4> :bp\|bd #<CR>
"------------------
" AsyncRun " AsyncRun
" https://github.com/skywind3000/asyncrun.vim let g:qf_toggle = ''
" map <F5> :AsyncRun -cwd=<root> -save=2 make<CR> let g:win_save = ''
map <F5> :AsyncRun -cwd=<root> -save=2 make -j4<CR> 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=<root> ctags -R ./src/
:AsyncRun -cwd=<root> -save=2 make -j4
endfunction
let g:asyncrun_timer = 250
map <F5> :call RunMake()<cr>
noremap <F6> :call QfToggle() <cr>
"------------------
" autocommands
augroup vimrc augroup vimrc
" remove all vimrc autocommands " remove all vimrc autocommands
autocmd! 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 " Don't screw up folds when inserting text that might affect them, until
" " leaving insert mode. Foldmethod is local to the window. Protect against " " leaving insert mode. Foldmethod is local to the window. Protect against
@ -126,11 +155,12 @@ augroup vimrc
autocmd BufWinEnter *.* silent loadview autocmd BufWinEnter *.* silent loadview
augroup END augroup END
"------------------
" fix keycodes when running inside tmux " fix keycodes when running inside tmux
" http://tmux-users.narkive.com/M9tIqoa0/c-pageup-and-c-pagedown-seems-not-to-work-in-tmux " http://tmux-users.narkive.com/M9tIqoa0/c-pageup-and-c-pagedown-seems-not-to-work-in-tmux
if &term =~ '^screen' && exists('$TMUX') if &term =~ '^screen' && exists('$TMUX')
" Mouse mode " Mouse mode
" set mouse+=a
set ttymouse=xterm2 set ttymouse=xterm2
" tmux sends xterm-style keys when xterm-keys option is on " tmux sends xterm-style keys when xterm-keys option is on
@ -158,3 +188,52 @@ if &term =~ '^screen' && exists('$TMUX')
execute "set <F12>=\e[24;*~" execute "set <F12>=\e[24;*~"
endif 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}'])
"-------------------------------------

Loading…
Cancel
Save