From ba1f099db5afeedb323c05127df1cc34df85ec85 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Wed, 9 Oct 2019 20:17:28 +0200 Subject: Further refactored statusline and splash --- doc/shortcuts.txt | 1 + plugin/max-splash.vim | 2 +- plugin/statusline.vim | 79 ++++++++++++++++++++++++++------------------------- 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/doc/shortcuts.txt b/doc/shortcuts.txt index 4d58590..5e911ea 100644 --- a/doc/shortcuts.txt +++ b/doc/shortcuts.txt @@ -57,6 +57,7 @@ command line mode begins with : and has its own key mappings starting with c lik :only = 'maximize' current buffer = auto completion with the word under the cursor (interesting with incsearch) + = expand pattern from command line (e.g. *.txt) [navigation] diff --git a/plugin/max-splash.vim b/plugin/max-splash.vim index 6b5e70d..bc578e1 100644 --- a/plugin/max-splash.vim +++ b/plugin/max-splash.vim @@ -19,7 +19,7 @@ if empty(argv()) \ map(copy(v:oldfiles), \ {_, p->expand(p)}), 'v:val =~ "'.getcwd().'/"'), 'filereadable(v:val)'), \ {_, p->{'filename': fnamemodify(p, ':.')}}) - \ }) | lopen | only | setfiletype qf + \ }) | exec ':lopen '.getloclist(0, {'size' : 1}).size | setfiletype qf | wincmd w endif " http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:caddexpr diff --git a/plugin/statusline.vim b/plugin/statusline.vim index db2bc28..dc98a71 100644 --- a/plugin/statusline.vim +++ b/plugin/statusline.vim @@ -1,3 +1,5 @@ +scriptencoding utf-8 + augroup MAX_FANCYLINE set noshowmode | " mode would otherwise be shown twice- in lightline and below. We want to deactivate one. set laststatus=2 | " required by AirLine and Lightline, without status line does not appear until a window split @@ -9,28 +11,28 @@ augroup MAX_FANCYLINE let g:symbol_branch = '' let g:symbol_screen_edge = '░' - if &term == "linux" - let g:group_active = "StatusLineTerm" - let g:group_inactive = "StatusLineTermNC" - let g:group_tabline = "StatusLineTerm" + if &term ==? 'linux' + let g:group_active = 'StatusLineTerm' + let g:group_inactive = 'StatusLineTermNC' + let g:group_tabline = 'StatusLineTerm' else - let g:group_active = "StatusLine" - let g:group_inactive = "StatusLineNC" - " let g:group_tabline = "TabLine" - let g:group_tabline = "StatusLine" + let g:group_active = 'StatusLine' + let g:group_inactive = 'StatusLineNC' + " let g:group_tabline = 'TabLine' + let g:group_tabline = 'StatusLine' endif " this function reverts foreground color and background color of a given " highlight group and returns the name of a newly created _invert group function! CreateInvertGroup(highlight_group) - if(synIDattr(hlID(a:highlight_group), "reverse")==1) - let w:color=synIDattr(hlID(a:highlight_group), "fg#") + 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#") + let w:color=synIDattr(hlID(a:highlight_group), 'bg#') endif let l:retval=a:highlight_group.'_invert' - if(exists('w:color') && w:color == '') + if(exists('w:color') && w:color ==# '') let w:color = 'NONE' endif silent! exec 'highlight '.l:retval.' guifg='.w:color.' ctermfg='.w:color @@ -44,7 +46,7 @@ augroup MAX_FANCYLINE \ 'i' : 'insert', \ 'R' : 'replace', \ 'v' : 'visual', - \ "V" : 'visual line', + \ 'V' : 'visual line', \ "\" : 'visual block', \ 'c' : 'command', \ 's' : 'select', @@ -53,33 +55,35 @@ augroup MAX_FANCYLINE \ 't' : 'terminal' \ }, mode(), mode()) return '' - \ ."%#StatusLineHighlight#" - \ ."%#".a:highlight_group."#" - \ .g:symbol_screen_edge.' ' - \ ."%{(&readonly\ ?\ '\ \ 🔒'\ :\ '')}" - \ ."%{(&modified\ ?\ '\ \ 💾'\ :\ '')}" - \ ."%(%w%h%q%)".l:mode.' '.g:status_sym_sep_start - \ ."%{(argc()>1\ ?\ ' '.(argidx()+1).':'.argc().' '.g:status_sym_sep_start:'')}" - \ ."%{(haslocaldir() ?\ fnamemodify(getcwd(),\ ':.').'/ '\ \:'')}\ " - \ ."%{winbufnr(0).': '}" - \ ."%{bufname('%')==''?'':substitute(bufname('%'),\ '^'.getcwd(-1).'/*',\ '',\ '')}" - \ ."%{(&titlestring\ ?\ has('nvim')?b:term_title:expand(&titlestring):'')\ }" + \ .'%#StatusLineHighlight#' + \ .'%#'.a:highlight_group.'#' + \ .g:symbol_screen_edge + \ .'%(%w%h%q%)'.' '.l:mode.' '.g:status_sym_sep_start + \ .'%{argc() > 1 ? " ".(argidx() + 1).":".argc()." ".g:status_sym_sep_start : ""}' + \ .'%{haslocaldir() ? fnamemodify(getcwd(), ":.:~")." " :""}' + \ .'%{&readonly ? " 🔒" : ""}' + \ .'%{&modified ? " 💾 " : ""}' + \ .'%{winbufnr(0)." "}' + \ .'%{bufname("%") == "" ? "" : fnamemodify(expand("%"), ":~:.")}' + \ .'%{&titlestring ? has("nvim") ? b:term_title:expand(&titlestring) : "" }' + \ .'%{exists("w:quickfix_title") ? w:quickfix_title : ""}' \ .' ' - \ ."%#".l:invert_group."#" + \ .'%#'.l:invert_group.'#' \ .g:status_sym_end \ .'%<' \ .'' - \ ."%=" + \ .'%=' \ .'' - \ ."%#".l:invert_group."#" + \ .'%#'.l:invert_group.'#' \ .g:status_sym_start - \ ."%#".a:highlight_group."#".' ' - \ ."%{&buftype==''?'':&buftype.' '.g:status_sym_sep_end.' '}" - \ ."%{&filetype==''?'':&filetype.' '.g:status_sym_sep_end.' '}" - \ ."%{(&spell\ ?\ &spelllang.' '.g:status_sym_sep_end\ :\ '')}" - \ ."%{(&fileencoding=~'^$\\|^utf\-8$'?'':&fileencoding.' '.g:status_sym_sep_end.' ')}" - \ ."%{(&fileformat=~'^$\\|^unix$'?'':&fileformat.' '.g:status_sym_sep_end)}" - \ ."%cx%-l: " + \ .'%#'.a:highlight_group.'#'.' ' + \ .'%{&buftype == "" ? "" : &buftype." ".g:status_sym_sep_end." "}' + \ .'%{&filetype == "" ? "" :&filetype." ".g:status_sym_sep_end." "}' + \ .'%{&spell ? &spelllang." ".g:status_sym_sep_end : ""}' + \ .'%{&fileencoding =~ "^$\\|^utf\-8$" ? "" : &fileencoding." ".g:status_sym_sep_end." "}' + \ .'%{&fileformat =~ "^$\\|^unix$" ? "" : &fileformat." ".g:status_sym_sep_end}' + \ .' ' + \ .'%cx%-l: ' \ .g:status_sym_sep_end \ .' ' \ .'%p%% ' @@ -95,9 +99,9 @@ augroup MAX_FANCYLINE \ .' ' \ .'%#'.a:highlight_group.'#' \ .'%-2( %)' - \ .'%{getcwd(-1)}' + \ .'%{fnamemodify(getcwd(-1), ":~")}' \ .' ' - \ ."%{FugitiveHead()==''?'':g:status_sym_sep_start.' '.g:symbol_branch.' '.FugitiveHead()}" + \ .'%{FugitiveHead() == "" ? "" : g:status_sym_sep_start." ".g:symbol_branch." ".FugitiveHead()}' \ .' ' \ .'%#'.l:invert_group.'#' \ .g:status_sym_end @@ -116,8 +120,7 @@ augroup MAX_FANCYLINE \ .'%{tabpagenr()}/%{tabpagenr()}' \ .' ' \ .g:symbol_screen_edge - \ ."%##" - \ ."" " end + \ .'%##' endfunction function! ApplyColorScheme() -- cgit v1.2.3