From 5ffd36adcb5e2aa352609a3d4e005b3e99173442 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Sun, 13 Oct 2019 13:47:17 +0200 Subject: Refactored 'splash' a lot & minor fixes in statusline --- plugin/max-splash.vim | 43 +++++++++++++++++++++++++------------------ plugin/statusline.vim | 12 +++++++----- 2 files changed, 32 insertions(+), 23 deletions(-) (limited to 'plugin') diff --git a/plugin/max-splash.vim b/plugin/max-splash.vim index bc578e1..3a23e60 100644 --- a/plugin/max-splash.vim +++ b/plugin/max-splash.vim @@ -3,24 +3,31 @@ " Shows recently used files from the current directory in a location list "======================================================================================================================= -" moved after VimEnter of statusline, so that it does not get overwritten any -" more -if empty(argv()) - - " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val})) - - " from the list of recent files: make absolute paths, filter out files not - " contained in cwd and finally filter out directories and non-files... - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if !exists("s:std_in") | call setloclist(0, [], 'r', - \ { - \ 'title':'Recently used files in directory: '.getcwd(), - \ 'items':map(filter(filter( - \ map(copy(v:oldfiles), - \ {_, p->expand(p)}), 'v:val =~ "'.getcwd().'/"'), 'filereadable(v:val)'), - \ {_, p->{'filename': fnamemodify(p, ':.')}}) - \ }) | exec ':lopen '.getloclist(0, {'size' : 1}).size | setfiletype qf | wincmd w -endif +" autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val})) +" from the list of recent files: make absolute paths, filter out files not +" contained in cwd and finally filter out directories and non-files... +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if !exists("s:std_in") && empty(argv()) + \ | call setloclist(0, []) + \ | :lopen + \ | setlocal nospell + \ | setlocal signcolumn=yes + \ | setfiletype qf + \ | call setloclist(0, [], 'r', { + \ 'title':'Recently used files in directory: '.getcwd(), + \ 'items':sort(map(filter(filter(map(copy(v:oldfiles[:100]), + \ {_, p->expand(p)}), + \ 'v:val =~ "'.getcwd().'/"'), + \ 'filereadable(v:val)'), + \ {_, p->{'filename': p, + \ 'module': printf("%s | %-*s ", + \ strftime("%F %H:%M", + \ getftime(p)), + \ winwidth(0) - wincol() - 20, + \ fnamemodify(p, ':.') + \ )}}), + \ {a1, a2 -> a1.module < a2.module}) + \ }) | wincmd w " http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:caddexpr " for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) + range(0,9) | let p = getpos("'".nr2char(c)) | if (p[1] > 0) | exec "sign define mark_".nr2char(c)." text=".nr2char(c)." linehl=linenr" | exec "sign place ".c." name=mark_".nr2char(c)." line=".p[1] | endif | endfor diff --git a/plugin/statusline.vim b/plugin/statusline.vim index dc98a71..e6f175d 100644 --- a/plugin/statusline.vim +++ b/plugin/statusline.vim @@ -58,12 +58,13 @@ augroup MAX_FANCYLINE \ .'%#StatusLineHighlight#' \ .'%#'.a:highlight_group.'#' \ .g:symbol_screen_edge - \ .'%(%w%h%q%)'.' '.l:mode.' '.g:status_sym_sep_start + \ .'%{&buftype != "" ? " ".&buftype : ""}' + \ .' '.l:mode.g:status_sym_sep_start \ .'%{argc() > 1 ? " ".(argidx() + 1).":".argc()." ".g:status_sym_sep_start : ""}' \ .'%{haslocaldir() ? fnamemodify(getcwd(), ":.:~")." " :""}' \ .'%{&readonly ? " 🔒" : ""}' \ .'%{&modified ? " 💾 " : ""}' - \ .'%{winbufnr(0)." "}' + \ .'%{" [".winbufnr(0)."] "}' \ .'%{bufname("%") == "" ? "" : fnamemodify(expand("%"), ":~:.")}' \ .'%{&titlestring ? has("nvim") ? b:term_title:expand(&titlestring) : "" }' \ .'%{exists("w:quickfix_title") ? w:quickfix_title : ""}' @@ -111,7 +112,7 @@ augroup MAX_FANCYLINE \ .g:status_sym_start \ .'%(%#'.a:highlight_group.'#%)' \ .' ' - \ .'%-3(%)' + \ .'%-2(%)' \ .'%(%#'.a:highlight_group.'#%)' \ .'%(%{v:servername} %{v:this_session}%)' \ .g:status_sym_sep_end.' ' @@ -136,10 +137,11 @@ augroup MAX_FANCYLINE highlight! StatusLine cterm=reverse " exec 'highlight! User3 guifg=#D2A032 guibg='.l:fgcolor endfunction + call ApplyColorScheme() + " apply colors from the loaded colorscheme... " when changing the colorscheme also apply new colors to the statusbar... - autocmd VimEnter,ColorScheme * call ApplyColorScheme() - + autocmd ColorScheme * call ApplyColorScheme() autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active) autocmd WinLeave * setlocal statusline< augroup END " MAX_FANCYLINE -- cgit v1.2.3