breaking: remove lightline plugin + add custom statusline

remove `lightline` plugin from init.vim
add statusline.vim to configure the statusline
    -> change whether window is focus or not
This commit is contained in:
swy7ch 2020-05-07 18:55:05 +02:00
parent 1a03c0f1c1
commit a23217553a
No known key found for this signature in database
GPG Key ID: 38503F7F2A1C3EE8
4 changed files with 208 additions and 40 deletions

View File

@ -4,7 +4,7 @@
" Maintainer: David JULIEN <swy7ch@protonmail.com>
" Website: https://github.com/vim/vim/blob/master/src/syntax.c
" License: Vim License (see `:help license`)
" Last Updated: Thu 07 May 2020 12:50:21 PM CEST
" Last Updated: Fri 08 May 2020 12:15:14 PM CEST
" Generated by Colortemplate v2.0.0
@ -74,6 +74,8 @@ if (has('termguicolors') && &termguicolors) || has('gui_running')
hi DiffDelete guifg=#1d2021 guibg=#b73935 guisp=NONE gui=bold cterm=bold
hi DiffText guifg=#1d2021 guibg=#ea6962 guisp=NONE gui=bold cterm=bold
hi Directory guifg=#d3869b guibg=NONE guisp=NONE gui=NONE cterm=NONE
hi File guifg=#d3869b guibg=#1d2021 guisp=NONE gui=NONE cterm=NONE
hi FileType guifg=#7cafa3 guibg=#1d2021 guisp=NONE gui=NONE cterm=NONE
hi ErrorMsg guifg=#ffeca3 guibg=#b73935 guisp=NONE gui=bold cterm=bold
hi FoldColumn guifg=#f7a583 guibg=#458588 guisp=NONE gui=NONE cterm=NONE
hi Folded guifg=#f7a583 guibg=#458588 guisp=NONE gui=NONE cterm=NONE
@ -89,6 +91,8 @@ if (has('termguicolors') && &termguicolors) || has('gui_running')
hi Search guifg=#1d2021 guibg=#f7a583 guisp=NONE gui=NONE cterm=NONE
hi SignColumn guifg=NONE guibg=NONE guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi SpecialKey guifg=#ace5d7 guibg=NONE guisp=NONE gui=NONE cterm=NONE
hi Mode guifg=#1d2021 guibg=#89b594 guisp=NONE gui=bold cterm=bold
hi Column guifg=#7cafa3 guibg=#1d2021 guisp=NONE gui=NONE cterm=NONE
hi StatusLine guifg=#ebdbb2 guibg=#7c6f64 guisp=NONE gui=NONE cterm=NONE
hi StatusLineNC guifg=#ebdbb2 guibg=#1d2021 guisp=NONE gui=reverse cterm=reverse
hi TabLineFill guifg=NONE guibg=NONE guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
@ -112,6 +116,19 @@ if (has('termguicolors') && &termguicolors) || has('gui_running')
hi! link lCursor Cursor
hi ToolbarLine guifg=NONE guibg=#a89984 guisp=NONE gui=NONE cterm=NONE
hi ToolbarButton guifg=#1d2021 guibg=#a89984 guisp=NONE gui=bold cterm=bold
hi StatusLine guifg=NONE guibg=NONE guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi StatusLineTerm guifg=#1d2021 guibg=#89b594 guisp=NONE gui=bold cterm=bold
hi StatusLineNC guifg=#7c6f64 guibg=#1d2021 guisp=NONE gui=NONE cterm=NONE
hi Buffer guifg=#89b594 guibg=#1d2021 guisp=NONE gui=NONE cterm=NONE
hi NormalMode guifg=#1d2021 guibg=#89b594 guisp=NONE gui=bold cterm=bold
hi VisualMode guifg=#1d2021 guibg=#d3869b guisp=NONE gui=bold cterm=bold
hi InsertMode guifg=#1d2021 guibg=#ace5d7 guisp=NONE gui=bold cterm=bold
hi ReplaceMode guifg=#1d2021 guibg=#ea6962 guisp=NONE gui=bold cterm=bold
hi CommandMode guifg=#ebdbb2 guibg=#1d2021 guisp=NONE gui=bold cterm=bold
hi File guifg=#d3869b guibg=#1d2021 guisp=NONE gui=NONE cterm=NONE
hi FileType guifg=#7cafa3 guibg=#1d2021 guisp=NONE gui=NONE cterm=NONE
hi Percent guifg=#7c6f64 guibg=NONE guisp=NONE gui=NONE cterm=NONE
hi Column guifg=#7cafa3 guibg=#1d2021 guisp=NONE gui=NONE cterm=NONE
unlet s:t_Co
finish
endif
@ -140,6 +157,8 @@ if s:t_Co >= 256
hi DiffDelete ctermbg=160 cterm=NONE
hi DiffText ctermbg=203 cterm=bold
hi Directory ctermfg=181 ctermbg=NONE cterm=NONE
hi File ctermfg=181 cterm=NONE
hi FileType ctermfg=30 cterm=NONE
hi ErrorMsg ctermfg=230 ctermbg=160 cterm=bold
hi FoldColumn ctermfg=216 ctermbg=24 cterm=NONE
hi Folded ctermfg=216 ctermbg=24 cterm=NONE
@ -155,6 +174,8 @@ if s:t_Co >= 256
hi Search ctermbg=216 cterm=NONE
hi SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE
hi SpecialKey ctermfg=81 ctermbg=NONE cterm=NONE
hi Mode ctermbg=71 cterm=bold
hi Column ctermfg=30 cterm=NONE
hi StatusLine ctermfg=229 ctermbg=243 cterm=NONE
hi StatusLineNC ctermfg=229 cterm=reverse
hi TabLineFill ctermfg=NONE ctermbg=NONE cterm=NONE
@ -178,6 +199,19 @@ if s:t_Co >= 256
hi! link lCursor Cursor
hi ToolbarLine ctermfg=NONE ctermbg=239 cterm=NONE
hi ToolbarButton ctermbg=239 cterm=bold
hi StatusLine ctermfg=NONE ctermbg=NONE cterm=NONE
hi StatusLineTerm ctermbg=71 cterm=bold
hi StatusLineNC ctermfg=243 cterm=NONE
hi Buffer ctermfg=71 cterm=NONE
hi NormalMode ctermbg=71 cterm=bold
hi VisualMode ctermbg=181 cterm=bold
hi InsertMode ctermbg=81 cterm=bold
hi ReplaceMode ctermbg=203 cterm=bold
hi CommandMode ctermfg=229 cterm=bold
hi File ctermfg=181 cterm=NONE
hi FileType ctermfg=30 cterm=NONE
hi Percent ctermfg=243 ctermbg=NONE cterm=NONE
hi Column ctermfg=30 cterm=NONE
unlet s:t_Co
finish
endif
@ -206,6 +240,8 @@ if s:t_Co >= 8
hi DiffDelete ctermfg=Black ctermbg=DarkRed cterm=NONE
hi DiffText ctermfg=Black ctermbg=Red cterm=bold
hi Directory ctermfg=Magenta ctermbg=NONE cterm=NONE
hi File ctermfg=Magenta ctermbg=Black cterm=NONE
hi FileType ctermfg=DarkCyan ctermbg=Black cterm=NONE
hi ErrorMsg ctermfg=White ctermbg=DarkRed cterm=bold
hi FoldColumn ctermfg=LightRed ctermbg=DarkBlue cterm=NONE
hi Folded ctermfg=LightRed ctermbg=DarkBlue cterm=NONE
@ -221,6 +257,8 @@ if s:t_Co >= 8
hi Search ctermfg=Black ctermbg=LightRed cterm=NONE
hi SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE
hi SpecialKey ctermfg=LightBlue ctermbg=NONE cterm=NONE
hi Mode ctermfg=Black ctermbg=Green cterm=bold
hi Column ctermfg=DarkCyan ctermbg=Black cterm=NONE
hi StatusLine ctermfg=LightYellow ctermbg=Grey cterm=NONE
hi StatusLineNC ctermfg=LightYellow ctermbg=Black cterm=reverse
hi TabLineFill ctermfg=NONE ctermbg=NONE cterm=NONE
@ -244,6 +282,19 @@ if s:t_Co >= 8
hi! link lCursor Cursor
hi ToolbarLine ctermfg=NONE ctermbg=DarkGrey cterm=NONE
hi ToolbarButton ctermfg=Black ctermbg=DarkGrey cterm=bold
hi StatusLine ctermfg=NONE ctermbg=NONE cterm=NONE
hi StatusLineTerm ctermfg=Black ctermbg=Green cterm=bold
hi StatusLineNC ctermfg=Grey ctermbg=Black cterm=NONE
hi Buffer ctermfg=Green ctermbg=Black cterm=NONE
hi NormalMode ctermfg=Black ctermbg=Green cterm=bold
hi VisualMode ctermfg=Black ctermbg=Magenta cterm=bold
hi InsertMode ctermfg=Black ctermbg=LightBlue cterm=bold
hi ReplaceMode ctermfg=Black ctermbg=Red cterm=bold
hi CommandMode ctermfg=LightYellow ctermbg=Black cterm=bold
hi File ctermfg=Magenta ctermbg=Black cterm=NONE
hi FileType ctermfg=DarkCyan ctermbg=Black cterm=NONE
hi Percent ctermfg=Grey ctermbg=NONE cterm=NONE
hi Column ctermfg=DarkCyan ctermbg=Black cterm=NONE
unlet s:t_Co
finish
endif

View File

@ -15,9 +15,6 @@ call plug#begin('$HOME/.config/nvim/plugged')
""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom status bar
Plug 'itchyny/lightline.vim'
" Language highlighting packages
Plug 'sheerun/vim-polyglot'
@ -39,37 +36,6 @@ call plug#end()
" :PlugUpgrade - upgrades vim-plug
" :PlugClean - confirms removal of unused plugins; append `!` to auto-approve removal
" Lightline already shows the mode -> get rid of vim's default
set noshowmode
" Lightline customization
let g:lightline = {
\ 'colorscheme': 'Tomorrow_Night_Eighties',
\ 'active' : {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch' ],
\ [ 'filename', 'modified' ] ],
\ 'right': [ [ 'readonly' ],
\ [ 'column'],
\ [ 'filetype' ] ],
\ },
\ 'subseparator': { 'left': '-'},
\ 'component_function': {
\ 'gitbranch': 'fugitive#head',
\ 'modified': 'LightlineModified',
\ 'filetype': 'LightlineFiletype'
\ }
\ }
function! LightlineModified()
return &modifiable && &modified ? '[MO]' : ''
endfunction
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
" Indent Guides
let g:indent_guides_enable_on_vim_startup=1
@ -137,6 +103,20 @@ set termguicolors
" Colorscheme
colorscheme polyjuice
" Statusline
set noshowmode
source $XDG_CONFIG_HOME/nvim/statusline.vim
augroup statusline
autocmd!
autocmd VimEnter *
\ call UpdateInactiveWindows()
autocmd VimEnter,WinEnter,BufWinEnter *
\ call RefreshStatusLine('active')
autocmd WinLeave *
\ call RefreshStatusLine('inactive')
augroup END
"" Text, tab and indent
""""""""""""""""""""""""""""""""""""""""""""""""""
" Do not use spaces instead of tabs
@ -198,9 +178,5 @@ noremap <leader>pi :PlugInstall<CR>
noremap <leader>pc :PlugClean<CR>
noremap <leader>pu :PlugUpdate \| PlugUpgrade<CR>
" Fugitive
noremap <leader>gd :Gdiffsplit<CR>
noremap <leader>gb :Gblame<CR>
" Colorize
noremap <leader>cc :ColorizerToggle<CR>

View File

@ -99,11 +99,13 @@ DiffChange black orange
DiffDelete black darkred g=bold
DiffText black red bold
Directory magenta none
File magenta black
FileType darkcyan black
ErrorMsg yellow darkred bold
FoldColumn orange darkblue
Folded orange darkblue
IncSearch none none reverse
LineNr darkgrey none
LineNr darkgrey none
MatchParen none none reverse
ModeMsg none none bold
MoreMsg green none g=bold
@ -114,6 +116,8 @@ Question green none g=bold
Search black orange
SignColumn none none
SpecialKey cyan none
Mode black green bold
Column darkcyan black
StatusLine white darkgrey
StatusLineNC white black reverse
TabLineFill none none
@ -141,3 +145,18 @@ lCursor -> Cursor
ToolbarLine none grey
ToolbarButton black grey bold
# }}}
# Statusline
StatusLine none none
StatusLineTerm black green bold
StatusLineNC darkgrey black
Buffer green black
NormalMode black green bold
VisualMode black magenta bold
InsertMode black cyan bold
ReplaceMode black red bold
CommandMode white black bold
File magenta black
FileType darkcyan black
Percent darkgrey none
Column darkcyan black

122
.config/nvim/statusline.vim Normal file
View File

@ -0,0 +1,122 @@
function! CurrentMode()
let g:currentmode={
\ 'n' : '[ NORMAL ]',
\ 'v' : '[ VISUAL ]',
\ 'V' : '[ V·LINE ]',
\ '' : '[ V·BLOCK ]',
\ 'i' : '[ INSERT ]',
\ 'R' : '[ REPLACE ]',
\ 'Rv' : '[ V·REPLACE ]',
\ 'c' : '[ COMMAND ]',
\}
return g:currentmode[mode()]
endfunction
functio! ModeColor()
let g:modecolor={
\ 'n' : '%#NormalMode#',
\ 'v' : '%#VisualMode#',
\ 'V' : '%#VisualMode#',
\ '' : '%#VisualMode#',
\ 'i' : '%#InsertMode#',
\ 'R' : '%#ReplaceMode#',
\ 'Rv' : '%#ReplaceMode#',
\ 'c' : '%#CommandMode#',
\}
return g:modecolor[mode()]
endfunction
function! StatusLine()
let l:statusline=''
" Buffer number
let l:statusline.='%#Buffer#'
let l:statusline.='[%n]'
" Show current mode
let l:statusline.=ModeColor()
let l:statusline.=CurrentMode()
" File path, absolute or relative to ~/
let l:statusline.='%#File#'
let l:statusline.=' %F'
let l:statusline .= "%{&readonly?'!':''}"
let l:statusline .= "%{&modified?'*':''}"
" Truncate line here
let l:statusline.='%<'
" Separation point between left and right aligned items.
let l:statusline.='%='
let l:statusline.='%#SpellLocal#'
let l:statusline.="%{&spell?'[SPELL]\ ':'\ '}"
" Filetype
let l:statusline.='%#FileType#'
let l:statusline.="%{&filetype!=#''?&filetype.' ':'none '}"
" Encoding & Fileformat
let l:statusline.='%#WarningMsg#'
let l:statusline.="%{&fileencoding!='utf-8'?'['.&fileencoding.'] ':''}"
"setlocal statusline.=%#FileFormat#
"setlocal statusline.=\ %-7([%{&fileformat}]%)
let l:statusline.='%#Percent#'
let l:statusline.='%03.p%%'
" Location of cursor in line
let l:statusline.=' %#Column#'
let l:statusline.='-%c-'
return l:statusline
endfunction
function! StatusLineNC()
let l:statusline=''
" Buffer number
let l:statusline.='[%n]'
" File name
let l:statusline.=' %t'
let l:statusline .= "%{&readonly?'!':''}"
let l:statusline .= "%{&modified?'*':''}"
" Truncate line here
let l:statusline.='%<'
" Separation point between left and right aligned items.
let l:statusline.='%='
let l:statusline.='%#Percent#'
let l:statusline.='%03.p%%'
return l:statusline
endfunction
function! UpdateInactiveWindows()
for winnum in range(1, winnr('$'))
if winnum != winnr()
call setwinvar(winnum, '&statusline', '%!StatusLineNC()')
endif
endfor
endfunction
function! RefreshStatusLine(mode)
if a:mode == "active"
setlocal statusline=%!StatusLine()
else
setlocal statusline=%!StatusLineNC()
endif
endfunction