From 039bbf24263aa5782d290410206eedfb9354b237 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Sun, 13 May 2018 18:36:47 +0200 Subject: Dropped lightline, now using a custom statusline It displays everything what lightline did before, but I took special care to make it compatible with all colorschemes I am using. --- vimrc-full | 176 +++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 136 insertions(+), 40 deletions(-) (limited to 'vimrc-full') diff --git a/vimrc-full b/vimrc-full index 3b9cdd6..a4fb101 100644 --- a/vimrc-full +++ b/vimrc-full @@ -746,22 +746,7 @@ nnoremap :TagbarToggle| " bind TagBar to hotkey F9 set noshowmode | " mode will be shown twice, in lightline and below, so we want to deactivate one set laststatus=2 | " required by AirLine and Lightline, without status line does not appear until a window split -set statusline= -set statusline+=%{(&modified?nr2char(0xF0C7):'')} -set statusline+=%{(&readonly\ ?\ ''\ :\ '')} -set statusline+=%{fnamemodify(getcwd(),':~')} -set statusline+=%{nr2char(0x20)} -set statusline+=%{nr2char(0xE0B1)} -set statusline+=%{nr2char(0x20)} -set statusline+=%f -set statusline+=%*%= -set statusline+=%l:%c(%p%%) -" set statusline+=%t%m -" set statusline+=%{TagInStatusLine()} -" set statusline+=%#warningmsg# -" set statusline+=%{SyntasticStatuslineFlag()} - -Plug 'itchyny/lightline.vim' +" Plug 'itchyny/lightline.vim' " lightline-buffer ui settings " replace these symbols with ASCII characters if your environment does not support unicode @@ -933,8 +918,8 @@ if has("python") let g:ale_sign_warning = '' else Plug 'scrooloose/syntastic' - set statusline+=%#warningmsg# - set statusline+=%{SyntasticStatuslineFlag()} + " set statusline+=%#warningmsg# + " set statusline+=%{SyntasticStatuslineFlag()} let g:LatexBox_latexmk_preview_continuously = 1 let g:LatexBox_viewer = "evince" let g:syntastic_always_populate_loc_list = 1 @@ -1011,6 +996,28 @@ let g:netrw_winsize = 20 | " window size in percent " ====================================================================================================================== function! ExtendColorTheme() + " let g:status_fg=synIDattr(hlID('Cursor'), 'fg#') + " let g:status_bg=synIDattr(hlID('Cursor'), 'bg#') + " let g:status_sel=synIDattr(hlID('Text'), 'fg#') + " let g:status_sel='#ffffff' + let g:status_fg='#00aa00' + let g:status_bg='#000000' + let g:status_sel='#ffff00' + + " execute 'highlight! StatusLine' + " \ .' guibg=NONE' + " \ .' guifg='.g:status_bg + " \ .' gui=inverse' + + " " execute 'highlight! User1 gui=NONE' + " execute 'highlight! User1 guibg='.g:status_sel + " execute 'highlight! User1 guifg='.g:status_fg + + " execute 'highlight! User2 gui=NONE' + " execute 'highlight! User2 guibg='.g:status_sel + " execute 'highlight! User2 guifg=NONE' + + filetype on filetype plugin on filetype indent on @@ -1033,7 +1040,7 @@ function! ExtendColorTheme() highlight! PmenuThumb cterm=inverse highlight! MoreMsg cterm=inverse highlight! link Folded LineNr - highlight! Cursor guibg=#729fcf ctermbg=yellow + " highlight! Cursor guibg=#729fcf ctermbg=yellow highlight! link VertSplit LineNr " highlight! SpellBad ctermbg=none highlight! SpecialKey ctermfg=19 @@ -1082,9 +1089,7 @@ function! ExtendColorTheme() " if argc() == 0 " rv " autocmd VimEnter * split +bro\ ol -" endif -" - + " endif endfunction autocmd! ColorScheme * call ExtendColorTheme() @@ -1092,24 +1097,6 @@ autocmd! ColorScheme * call ExtendColorTheme() set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incompatible with nvim " set t_ut= -if filereadable(expand("~/.vimrc_background")) && filereadable(expand("~/.config/base16-shell/colortest")) - let g:base16_shell_path="~/.config/base16-shell/scripts" - let base16colorspace=256 - let syntax_cmd="skip" " vim internal, use base16 and no default colors - set background=dark - source ~/.vimrc_background -else - let g:PaperColor_Theme_Options = { - \ 'theme': { - \ 'default': { - \ 'transparent_background': 1 - \ } - \ } - \ } - set background=dark - colorscheme PaperColor -endif - " ====================================================================================================================== " CONVENIENCE: " ====================================================================================================================== @@ -1163,3 +1150,112 @@ autocmd VimEnter,WinEnter * exec ':set scrolljump='.winheight(0)/2 map h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') " call setqflist( map(systemlist("git show --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}})) +" +if filereadable(expand("~/.vimrc_background")) && filereadable(expand("~/.config/base16-shell/colortest")) + let g:base16_shell_path="~/.config/base16-shell/scripts" + let base16colorspace=256 + let syntax_cmd="skip" " vim internal, use base16 and no default colors + set background=dark + source ~/.vimrc_background +else + let g:PaperColor_Theme_Options = { + \ 'theme': { + \ 'default': { + \ 'transparent_background': 1 + \ } + \ } + \ } + set background=dark + colorscheme PaperColor +endif + +augroup status + function! CreateInvertGroup(highlight_group) + if(synIDattr(hlID(a:highlight_group), "reverse")==1) + let w:color=synIDattr(hlID(a:highlight_group), "fg#") + else + let w:color=synIDattr(hlID(a:highlight_group), "bg#") + endif + + let l:retval=a:highlight_group.'_invert' + if(exists('w:color') && w:color == '') + let w:color = 'NONE' + endif + exec 'highlight '.retval.' gui=NONE guifg='.w:color + return l:retval + endfunction + + function! UpdateStatus(highlight_group) + let l:invert_group = CreateInvertGroup(a:highlight_group) + return + \ "%#StatusLineHighlight#" . + \ "%#".a:highlight_group."#" . + \ "%{(&readonly\ ?\ '\ \ \ '\ :\ '')}" . + \ "%{(&modified\ ?\ nr2char(0xF0C7).'\ '\ :\ '')}" . + \ "%(%w%h%q\ %-8{mode(1)}%)" . + \ "%{nr2char(0xe621)}" . + \ "%(\ %{fnamemodify(getcwd(),\ ':~')}\ %)" . + \ "%{nr2char(0xf44a)}" . + \ "%(\ %f\ %)" . + \ "%#".l:invert_group."#" . + \ "%{nr2char(0xE0B4)\ }" . + \ '' . + \ "%=" . + \ '' . + \ "%#".l:invert_group."#" . + \ "%{nr2char(0xE0B6)}" . + \ "%#".a:highlight_group."#" . + \ "%1(%)" . + \ "%{\ &filetype}" . + \ "%(\ %{nr2char(0xe621)}\ %)" . + \ "%{&fileencoding}" . + \ "%(\ %{nr2char(0xe621)}\ %)" . + \ "%{&fileformat}" . + \ "%(\ %{nr2char(0xe621)}\ %)" . + \ "%4l:%-4c" . + \ "%-3p%%" . + \ '' " end ^ + endfunction + + function! UpdateTabline(highlight_group) + let l:invert_group = CreateInvertGroup(a:highlight_group) + return + \ "%#".a:highlight_group."#" . + \ "%3(\ %)" . + \ "%{nr2char(0xe621)}" . + \ "%(%{v:servername}\ %{v:this_session}%)" . + \ "%#".l:invert_group."#" . + \ "%{nr2char(0xE0B4)\ }" . + \ '' . + \ "%=" . + \ '' . + \ "%#".l:invert_group."#" . + \ "%{nr2char(0xE0B6)}" . + \ "%#".a:highlight_group."#" . + \ "%(\ \ %{fugitive#head()}\ %)" . + \ "%{nr2char(0xe621)}" . + \ "%(\ \ %{tabpagenr()}/%{tabpagenr('$')}\ %)" . + \ "%##" . + \ "" " end ^ + endfunction + + let g:group_active = "StatusLine" + let g:group_inactive = "StatusLineNC" + let g:group_tabline = "TabLineSel" + + function ApplyColorScheme() + " set up statusline, global and current window individually + set statusline=%!UpdateStatus(g:group_inactive) + setlocal statusline=%!UpdateStatus(g:group_active) + " set up the tabline (match colors) + set tabline=%!UpdateTabline(g:group_tabline) + endfunction + " apply colors from the loaded colorscheme... + call ApplyColorScheme() + + " when changing the colorscheme also apply new colors to the statusbar... + autocmd ColorScheme * call ApplyColorScheme() + + autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active) + autocmd WinLeave * setlocal statusline< +augroup END -- cgit v1.2.3