From 7b62c8e5fdbaadd4d377a3edf52870fc22909c28 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Wed, 1 Aug 2018 09:01:13 +0100 Subject: [vim] Improve statusline --- vim/.vimrc | 73 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/vim/.vimrc b/vim/.vimrc index f457698..09d2f96 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -17,7 +17,7 @@ Plug 'SirVer/ultisnips' Plug 'airblade/vim-gitgutter' Plug 'AndrewRadev/splitjoin.vim' Plug 'beloglazov/vim-online-thesaurus' -Plug 'critiqjo/lldb.nvim' +" Plug 'critiqjo/lldb.nvim' Plug 'easymotion/vim-easymotion' Plug 'holomorph/vim-freefem' Plug 'honza/vim-snippets' @@ -100,6 +100,7 @@ nnoremap cpr :IronRepl nnoremap cpn :NERDTreeToggle nnoremap cpt :TagbarToggle nnoremap cpu :GundoToggle +nnoremap cp Remembrall('cp') " Easy motion map gs (easymotion-prefix) @@ -114,8 +115,6 @@ nnoremap r :History nnoremap : :History: nnoremap / :History/ nnoremap l :BLines -nnoremap m :Marks -nnoremap t :Tags nnoremap a :Ag nnoremap :Buffers @@ -165,6 +164,8 @@ nnoremap cpd :OnlineThesaurusCurrentWord " Plug nnoremap ,pi :PlugInstall nnoremap ,pu :PlugUpdate +nnoremap ,pc :PlugClean +nnoremap ,p Remembrall(',p') " Ultisnips nnoremap cps :UltiSnipsEdit @@ -333,7 +334,7 @@ nnoremap :q nnoremap ,bd :ls:bd -nnoremap ,te :tabedit +nnoremap ,te :tabedit nnoremap ,tl :+tabmove nnoremap ,th :-tabmove nnoremap ,t0 :tabmove 0 @@ -386,31 +387,12 @@ nmap co yo " }}} "" Colorscheme {{{ -function! SaveColo(...) - execute 'set background='.a:1 - execute 'colorscheme' a:2 - execute 'silent !echo "set background='.a:1.'" > ~/.local/colors.vim' - execute 'silent !echo "colorscheme '.a:2.'" >> ~/.local/colors.vim' -endfunction -function! MyColo(colorscheme) - if a:colorscheme == "solarized-light" - call SaveColo("light","solarized") - elseif a:colorscheme == "solarized-dark" - call SaveColo("dark","solarized") - elseif a:colorscheme == "seoul" - call SaveColo("dark","seoul256") - elseif a:colorscheme == "nord" - call SaveColo("dark","nord") - endif -endfunction -if filereadable($HOME."/.local/colors.vim") - source ~/.local/colors.vim -endif -nnoremap ,c :call MyColo("") -nnoremap ,cl :call MyColo("solarized-light") -nnoremap ,cd :call MyColo("solarized-dark") -nnoremap ,cs :call MyColo("seoul") -nnoremap ,cn :call MyColo("nord") +nnoremap ,c :colorscheme +nnoremap ,cl :set background=light:colorscheme solarized +nnoremap ,cl :set background=dark:colorscheme solarized +nnoremap ,cs :colorscheme seoul256 +nnoremap ,cn :colorscheme nord +colo seoul256 " }}} "" Autocommands {{{ augroup vimrc @@ -502,26 +484,45 @@ nnoremap cof :let g:my_findprg=(g:my_findprg+1)%len(g:my_findprgs): " }}} "" Status line {{{ -set showtabline=2 -let g:tabprefix = "" -let g:tablabel = "%N%{flagship#tabmodified()} %{flagship#tabcwds('shorten',',')}" -let g:flagship_skip = 'FugitiveStatusline' - function! Mixed_indent() let l:spaces=search('\v(^ +)','n') let l:tabs=search('\v(^\t+)','n') return (l:spaces * l:tabs > 0) endfunction +function! GlobalCwd() + return getcwd(-1, -1) +endfunction + +function! TabCwd(number) + if haslocaldir(-1, a:number) + return getcwd(-1, a:number) + endif + return "" +endfunction + +function! WinCwd() + if haslocaldir(0) + return getcwd() + endif + return "" +endfunction + +set showtabline=2 +let g:tabprefix = "" +let g:tablabel = "%N%{flagship#tabmodified()} %{TabCwd(v:lnum) != '' ? pathshorten(TabCwd(v:lnum)) : ''}" +let g:flagship_skip = 'FugitiveStatusline' + augroup myflags autocmd! autocmd BufEnter,BufRead,BufWritePost * let b:trailing=search('\s\+$','n') autocmd BufEnter,BufRead,BufWritePost * let b:mixed=Mixed_indent() - autocmd User Flags call Hoist("buffer", "[%{FugitiveHead('')}]") + autocmd User Flags call Hoist("buffer", "%{FugitiveHead('') != '' ? '['.FugitiveHead('').']' : ''}") autocmd User Flags call Hoist("buffer", "%{b:trailing?'[tw]':''}") autocmd User Flags call Hoist("buffer", "%{b:mixed?'[mixed]':''}") autocmd User Flags call Hoist("buffer", "%{&paste?'[paste]':''}") - autocmd User Flags call Hoist("global", {"hl": "Statusline"}, "[%{g:my_searchprgs[g:my_searchprg]}, %{g:my_findprgs[g:my_findprg]}]") + autocmd User Flags call Hoist("window", "%{WinCwd() != '' ? '['.WinCwd().']' : ''}") + autocmd User Flags call Hoist("global", {"hl": "Statusline"}, "[%{pathshorten(GlobalCwd())}, %{g:my_searchprgs[g:my_searchprg]}, %{g:my_findprgs[g:my_findprg]}]") augroup END " }}} "" Neovim {{{ -- cgit v1.2.3