refactoring
This commit is contained in:
parent
21b3126ad4
commit
f44cb29b3f
|
@ -10,3 +10,5 @@ wal_example-dark.vim
|
||||||
wal_example-light.vim
|
wal_example-light.vim
|
||||||
vim/autoload/plug.vim
|
vim/autoload/plug.vim
|
||||||
.is-dev
|
.is-dev
|
||||||
|
.vimrc-config
|
||||||
|
.vimrc-overrides
|
||||||
|
|
631
vimrc
631
vimrc
|
@ -1,5 +1,19 @@
|
||||||
" ●
|
" ●
|
||||||
|
|
||||||
|
if filereadable(expand('.vimrc-config'))"{{{
|
||||||
|
source .vimrc-config
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:vimrc_load_dev_plugins = exists('g:vimrc_load_dev_plugins')
|
||||||
|
\ ? g:vimrc_load_dev_plugins : 0
|
||||||
|
let g:vimrc_enable_statusline = exists('g:vimrc_enable_statusline')
|
||||||
|
\ ? g:vimrc_enable_statusline : 0
|
||||||
|
let g:vimrc_enable_tabline = exists('g:vimrc_enable_tabline')
|
||||||
|
\ ? g:vimrc_enable_tabline : 0
|
||||||
|
let g:vimrc_auto_window_settings = exists('g:vimrc_auto_window_settings')
|
||||||
|
\ ? g:vimrc_auto_window_settings : 0
|
||||||
|
"}}}
|
||||||
|
|
||||||
" #plugins {{{
|
" #plugins {{{
|
||||||
if empty(glob('~/.vim/autoload/plug.vim'))"{{{
|
if empty(glob('~/.vim/autoload/plug.vim'))"{{{
|
||||||
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
||||||
|
@ -13,7 +27,6 @@ if !has('nvim')
|
||||||
|
|
||||||
Plug '~/.config/vim/vim/bundle/vim-learnxiny'
|
Plug '~/.config/vim/vim/bundle/vim-learnxiny'
|
||||||
|
|
||||||
|
|
||||||
" #Ctrlp {{{
|
" #Ctrlp {{{
|
||||||
Plug 'ctrlpvim/ctrlp.vim'
|
Plug 'ctrlpvim/ctrlp.vim'
|
||||||
" :h ctrlp-commands
|
" :h ctrlp-commands
|
||||||
|
@ -70,22 +83,6 @@ let g:mta_filetypes = {
|
||||||
\ ['relative', 'absolute', 'fixed']
|
\ ['relative', 'absolute', 'fixed']
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
"}}}
|
|
||||||
" #switch {{{
|
|
||||||
"https://github.com/AndrewRadev/switch.vim
|
|
||||||
Plug 'AndrewRadev/switch.vim'
|
|
||||||
|
|
||||||
let g:switch_mapping = '<space>-'
|
|
||||||
let g:switch_custom_definitions = [
|
|
||||||
\ ['0', '1'],
|
|
||||||
\ ['ease-in', 'ease-out', 'ease-in-out', 'linear'],
|
|
||||||
\ ['auto', 'none'],
|
|
||||||
\ ['left', 'right'],
|
|
||||||
\ ['top', 'bottom'],
|
|
||||||
\ ['row', 'column'],
|
|
||||||
\ ['relative', 'absolute', 'fixed']
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
" #undotree {{{
|
" #undotree {{{
|
||||||
Plug 'mbbill/undotree'
|
Plug 'mbbill/undotree'
|
||||||
|
@ -139,7 +136,7 @@ Plug 'studio-vx/vim-qlist'
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
if filereadable(expand('.is-dev'))
|
if g:vimrc_load_dev_plugins
|
||||||
" #ALE {{{
|
" #ALE {{{
|
||||||
" https://github.com/w0rp/ale
|
" https://github.com/w0rp/ale
|
||||||
Plug 'w0rp/ale'
|
Plug 'w0rp/ale'
|
||||||
|
@ -537,18 +534,6 @@ runtime macros/matchit.vim
|
||||||
"----------------------------------------------------------------------------}}}
|
"----------------------------------------------------------------------------}}}
|
||||||
" #functions {{{
|
" #functions {{{
|
||||||
|
|
||||||
function! DoInsertEnter() "{{{
|
|
||||||
" call SetColor('LineNr', '#262626', '', '#cccccc', '', '')
|
|
||||||
" call SetColor('CursorLineNr', '#bcbcbc', '', '#999999', '', 'bold')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
function! DoInsertLeave() "{{{
|
|
||||||
" call SetColor('LineNr', '#3a3a3a', '', '#999999', '', '')
|
|
||||||
" call SetColor('CursorLineNr', '#767676', '', '#777777', '', 'bold')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
function! SetColor(name, fg, bg, fg_l, bg_l, style) abort"{{{
|
function! SetColor(name, fg, bg, fg_l, bg_l, style) abort"{{{
|
||||||
|
|
||||||
if &background ==? 'dark'
|
if &background ==? 'dark'
|
||||||
|
@ -972,14 +957,11 @@ command! ScratchVertical vnew | setlocal buftype=nofile | setlocal bufhidden=hid
|
||||||
"}}}
|
"}}}
|
||||||
" #settings {{{
|
" #settings {{{
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
set ttyfast
|
|
||||||
|
|
||||||
if &term ==? 'xterm-256color'
|
if &term ==? 'xterm-256color'
|
||||||
set termguicolors
|
set termguicolors
|
||||||
endif
|
endif
|
||||||
|
|
||||||
syntax on
|
syntax on
|
||||||
set background=light
|
|
||||||
" set fillchars=stl:\ ,stlnc:\ ,vert:│
|
" set fillchars=stl:\ ,stlnc:\ ,vert:│
|
||||||
set fillchars=stl:\ ,stlnc:\ ,vert:┃
|
set fillchars=stl:\ ,stlnc:\ ,vert:┃
|
||||||
colorscheme monotonous-dark
|
colorscheme monotonous-dark
|
||||||
|
@ -991,14 +973,10 @@ set updatetime=100
|
||||||
set timeoutlen=500
|
set timeoutlen=500
|
||||||
set lazyredraw
|
set lazyredraw
|
||||||
|
|
||||||
set backupdir=~/.vimtmp
|
|
||||||
set directory=~/.vimtmp
|
|
||||||
|
|
||||||
" the ;/home/ray tells vim to stop searching at /home/ray
|
" the ;/home/ray tells vim to stop searching at /home/ray
|
||||||
set tags+=./.tags,.tags,./tags-py,.tags-py;/home/ray/
|
set tags+=./.tags,.tags,./tags-py,.tags-py;/home/ray/
|
||||||
|
|
||||||
" persisitent undo file
|
" persisitent undo file
|
||||||
set undodir=/home/ray/.vim/undodir
|
|
||||||
set undofile
|
set undofile
|
||||||
|
|
||||||
set viewoptions-=options
|
set viewoptions-=options
|
||||||
|
@ -1027,8 +1005,6 @@ set completeopt=longest,menuone
|
||||||
|
|
||||||
set nospell
|
set nospell
|
||||||
set spelllang=en_gb
|
set spelllang=en_gb
|
||||||
set dictionary+=/usr/share/dict/brit-a-z.txt,/usr/share/dict/britcaps.txt
|
|
||||||
set thesaurus+=/usr/share/dict/mthesaur.txt
|
|
||||||
|
|
||||||
set diffopt+=vertical
|
set diffopt+=vertical
|
||||||
|
|
||||||
|
@ -1233,332 +1209,330 @@ iabbrev ct'' content-type: '';
|
||||||
"----------------------------------------------------------------------------}}}
|
"----------------------------------------------------------------------------}}}
|
||||||
" #autocommands {{{
|
" #autocommands {{{
|
||||||
|
|
||||||
" persistent folds {{{
|
" persistent folds {{{
|
||||||
augroup AutoSaveFolds
|
augroup AutoSaveFolds
|
||||||
autocmd!
|
|
||||||
" autocmd BufWinLeave ?* mkview
|
|
||||||
autocmd BufWrite ?* mkview
|
|
||||||
" autocmd BufWinEnter ?* silent loadview
|
|
||||||
autocmd BufRead ?* silent! loadview
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
" Show trailing whitepace and spaces before a tab: {{{
|
|
||||||
augroup whitespaceerrors
|
|
||||||
autocmd!
|
|
||||||
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
" automatically reload if color scheme file written {{{
|
|
||||||
" augroup coloreload
|
|
||||||
" autocmd!
|
|
||||||
" autocmd BufWritePost customred256.vim so $MYVIMRC
|
|
||||||
" augroup end
|
|
||||||
"
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
" line numbering {{{
|
|
||||||
augroup linenumbering
|
|
||||||
autocmd!
|
|
||||||
autocmd InsertEnter * :set norelativenumber
|
|
||||||
autocmd InsertLeave * :set number relativenumber
|
|
||||||
autocmd WinEnter * :set number relativenumber
|
|
||||||
autocmd WinLeave * set norelativenumber
|
|
||||||
autocmd CmdlineEnter * :redraw | :set norelativenumber
|
|
||||||
autocmd CmdlineLeave * :set number relativenumber
|
|
||||||
" see 'mapping nnoremap :' for setting norelative number.
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
" WinEnter, WinLeave {{{
|
|
||||||
augroup windowenteringleaving
|
|
||||||
autocmd!
|
|
||||||
autocmd WinEnter * call SetColorColumn()
|
|
||||||
autocmd WinEnter * set cursorline | set cursorcolumn
|
|
||||||
autocmd WinLeave * setlocal colorcolumn=0
|
|
||||||
autocmd WinLeave * set nocursorline | set nocursorcolumn
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
" InsertEnter, InsertLeave {{{
|
|
||||||
augroup insertenterleave
|
|
||||||
au!
|
|
||||||
au InsertEnter * call DoInsertEnter()
|
|
||||||
au InsertLeave * call DoInsertLeave()
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
" Automatically reload .vimrc if chanaged {{{
|
|
||||||
augroup myvimrc
|
|
||||||
autocmd!
|
|
||||||
autocmd BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
" " Open qfix after grepping {{{
|
|
||||||
" augroup qfixopen
|
|
||||||
" autocmd!
|
|
||||||
" autocmd QuickFixCmdPost *grep* botright cwindow
|
|
||||||
" augroup END
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
"Open quickfix window{{{
|
|
||||||
augroup QuickFixAutoload
|
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd QuickFixCmdPost [^l]* nested botright cwindow
|
" autocmd BufWinLeave ?* mkview
|
||||||
autocmd QuickFixCmdPost l* nested botright lwindow
|
autocmd BufWrite ?* mkview
|
||||||
augroup END
|
" autocmd BufWinEnter ?* silent loadview
|
||||||
|
autocmd BufRead ?* silent! loadview
|
||||||
|
augroup END
|
||||||
|
|
||||||
"}}}
|
" }}}
|
||||||
|
" Show trailing whitepace and spaces before a tab: {{{
|
||||||
|
augroup whitespaceerrors
|
||||||
|
autocmd!
|
||||||
|
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" }}}
|
||||||
|
" automatically reload if color scheme file written {{{
|
||||||
|
" augroup coloreload
|
||||||
|
" autocmd!
|
||||||
|
" autocmd BufWritePost customred256.vim so $MYVIMRC
|
||||||
|
" augroup end
|
||||||
|
"
|
||||||
|
|
||||||
|
" }}}
|
||||||
|
" line numbering {{{
|
||||||
|
augroup linenumbering
|
||||||
|
autocmd!
|
||||||
|
autocmd InsertEnter * :set norelativenumber
|
||||||
|
autocmd InsertLeave * :set number relativenumber
|
||||||
|
autocmd WinEnter * :set number relativenumber
|
||||||
|
autocmd WinLeave * set norelativenumber
|
||||||
|
autocmd CmdlineEnter * :redraw | :set norelativenumber
|
||||||
|
autocmd CmdlineLeave * :set number relativenumber
|
||||||
|
" see 'mapping nnoremap :' for setting norelative number.
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" }}}
|
||||||
|
" auto_window_settings {{{
|
||||||
|
if g:vimrc_auto_window_settings
|
||||||
|
augroup auto_window_settings
|
||||||
|
autocmd!
|
||||||
|
autocmd WinEnter * call SetColorColumn()
|
||||||
|
autocmd WinEnter * set cursorline | set cursorcolumn
|
||||||
|
autocmd WinLeave * setlocal colorcolumn=0
|
||||||
|
autocmd WinLeave * set nocursorline | set nocursorcolumn
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
endif
|
||||||
|
" }}}
|
||||||
|
" Automatically reload .vimrc if changed {{{
|
||||||
|
augroup myvimrc
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" }}}
|
||||||
|
" Open qfix after grepping {{{
|
||||||
|
" augroup qfixopen
|
||||||
|
" autocmd!
|
||||||
|
" autocmd QuickFixCmdPost *grep* botright cwindow
|
||||||
|
" augroup END
|
||||||
|
|
||||||
|
" }}}
|
||||||
|
" Open quickfix window{{{
|
||||||
|
augroup QuickFixAutoload
|
||||||
|
autocmd!
|
||||||
|
autocmd QuickFixCmdPost [^l]* nested botright cwindow
|
||||||
|
autocmd QuickFixCmdPost l* nested botright lwindow
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" }}}
|
||||||
|
|
||||||
"----------------------------------------------------------------------------}}}
|
"----------------------------------------------------------------------------}}}
|
||||||
" #statusline {{{
|
" #statusline {{{
|
||||||
set statusline=%!GetStatus(1)
|
if g:vimrc_enable_statusline
|
||||||
|
set statusline=%!GetStatus(1)
|
||||||
|
|
||||||
function! GetStatus(isactive) abort "{{{
|
augroup status "{{{
|
||||||
" let l:linter = ale#statusline#Count(bufnr(''))
|
autocmd!
|
||||||
let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
|
autocmd WinNew,WinEnter * setlocal statusline=%!GetStatus(1)
|
||||||
let l:separator = '%#StatusLineSeparator# '
|
autocmd WinLeave * setlocal statusline=%!GetStatus(0)
|
||||||
let l:normal = '%#StatusLineNormal#'
|
" autocmd WinNew * setlocal statusline=%!GetStatus(1)
|
||||||
let l:active = '%#StatusLineActive#'
|
" autocmd InsertChange * setlocal statusline=%!GetStatus(1)
|
||||||
let l:linterdash = '%#LinterDash#·'
|
augroup END
|
||||||
let l:linterdashactive = '%#LinterDashActive#·'
|
|
||||||
let l:statusline = l:separator
|
|
||||||
|
|
||||||
"buffer number {{{
|
|
||||||
if a:isactive
|
|
||||||
let l:statusline .= '%#StatusLineBufferNrActive#'
|
|
||||||
else
|
|
||||||
let l:statusline .= '%#StatusLineBufferNr#'
|
|
||||||
endif
|
|
||||||
let l:statusline .= ' %n ' . l:separator
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" file percentage {{{
|
function! GetStatus(isactive) abort "{{{
|
||||||
if a:isactive
|
" let l:linter = ale#statusline#Count(bufnr(''))
|
||||||
let l:statusline .= '%#StatusLinePercentActive#'
|
let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
|
||||||
let l:statusline .= ' %P %#StatusLineNoiseActive#of %#StatusLineLinecountActive#%L '
|
let l:separator = '%#StatusLineSeparator# '
|
||||||
else
|
let l:normal = '%#StatusLineNormal#'
|
||||||
let l:statusline .= '%#StatusLinePercent#'
|
let l:active = '%#StatusLineActive#'
|
||||||
let l:statusline .= ' %P %#StatusLineNoise#of %#StatusLineLinecount#%L '
|
let l:linterdash = '%#LinterDash#·'
|
||||||
endif"}}}
|
let l:linterdashactive = '%#LinterDashActive#·'
|
||||||
|
let l:statusline = l:separator
|
||||||
|
|
||||||
" non-empty buftype (help, quickfix, etc) {{{
|
"buffer number {{{
|
||||||
if a:isactive
|
if a:isactive
|
||||||
let l:statusline .= l:active . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineActiveNoText#"
|
let l:statusline .= '%#StatusLineBufferNrActive#'
|
||||||
else
|
|
||||||
let l:statusline .= l:normal . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineNormalNoText#"
|
|
||||||
endif
|
|
||||||
let l:statusline .= "%{&buftype == '' ? '' : ' '}%s"
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" right/left divider {{{
|
|
||||||
let l:statusline.=l:separator
|
|
||||||
" modified version
|
|
||||||
let l:color = 'StatusLineDivMod' . (a:isactive?'Active':'')
|
|
||||||
let l:statusline .= GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider)
|
|
||||||
|
|
||||||
" unmodified version
|
|
||||||
let l:color = 'StatusLineDiv' . (a:isactive?'Active':'')
|
|
||||||
let l:statusline .= GetStatusFrag("!&modified && mode() != 'i'", l:color, '%<', l:divider)
|
|
||||||
|
|
||||||
" input mode version
|
|
||||||
if a:isactive
|
|
||||||
let l:statusline .= GetStatusFrag("mode() == 'i'", 'StatusLineDivInput', '%<', l:divider)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:statusline.= l:separator . '%*%='
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" file info{{{
|
|
||||||
if a:isactive == 1
|
|
||||||
" let l:statusline.=l:active
|
|
||||||
let l:statusline.='%#StatusLineFileInfo#'
|
|
||||||
" let l:statusline.=" %{strlen(&ft)?&ft:'none'} "
|
|
||||||
" let l:statusline.=l:separator . l:active
|
|
||||||
let l:statusline.='%{strlen(&fenc)?&fenc:&enc}'
|
|
||||||
" let l:statusline.=l:separator . l:active
|
|
||||||
let l:statusline.=' %{&fileformat}'
|
|
||||||
let l:statusline.="%{strlen(expand('%:e')) > 1?' ' . expand('%:e'):''}"
|
|
||||||
" let l:statusline.=l:separator . l:active
|
|
||||||
" let l:statusline.=' %{&spelllang} '
|
|
||||||
let l:statusline .= l:separator
|
|
||||||
endif
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" path/filename.extension {{{
|
|
||||||
if a:isactive
|
|
||||||
if &readonly
|
|
||||||
let l:statusline .= '%#StatusLineWarningActive# %r '
|
|
||||||
let l:statusline .= '%#StatusLineFileReadOnlyActive#'
|
|
||||||
" let l:statusline.='%#StatusLineDirActive# '
|
|
||||||
let l:statusline.="%{expand('%:p:h:t')}/"
|
|
||||||
" let l:statusline.='%#StatusLineFileActive#'
|
|
||||||
|
|
||||||
let l:statusline.="%{expand('%:t:r')}"
|
|
||||||
|
|
||||||
" let l:statusline.='%#StatusLineDotActive#'
|
|
||||||
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
|
|
||||||
" let l:statusline.='%#StatusLineExtActive#'
|
|
||||||
let l:statusline.="%{expand('%:e')} "
|
|
||||||
else
|
else
|
||||||
let l:statusline.='%#StatusLineDirActive# '
|
let l:statusline .= '%#StatusLineBufferNr#'
|
||||||
let l:statusline.="%{expand('%:p:h:t')}/"
|
|
||||||
let l:statusline.='%#StatusLineFileActive#'
|
|
||||||
|
|
||||||
let l:statusline.="%{expand('%:t:r')}"
|
|
||||||
|
|
||||||
let l:statusline.='%#StatusLineDotActive#'
|
|
||||||
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
|
|
||||||
let l:statusline.='%#StatusLineExtActive#'
|
|
||||||
let l:statusline.="%{expand('%:e')} "
|
|
||||||
endif
|
endif
|
||||||
else
|
let l:statusline .= ' %n ' . l:separator
|
||||||
let l:statusline .= ' %#StatusLineWarning#%r'
|
|
||||||
let l:statusline.='%#StatusLineDir# '
|
|
||||||
let l:statusline.="%{fnamemodify(expand('%:p:h'),':~')}/"
|
|
||||||
let l:statusline.='%#StatusLineFile#'
|
|
||||||
|
|
||||||
let l:statusline.="%{expand('%:t:r')}"
|
|
||||||
|
|
||||||
let l:statusline.='%#StatusLineDot#'
|
|
||||||
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
|
|
||||||
let l:statusline.='%#StatusLineExt#'
|
|
||||||
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')} "
|
|
||||||
endif
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
let l:statusline.='%*' . l:separator
|
" file percentage {{{
|
||||||
|
if a:isactive
|
||||||
|
let l:statusline .= '%#StatusLinePercentActive#'
|
||||||
|
let l:statusline .= ' %P %#StatusLineNoiseActive#of %#StatusLineLinecountActive#%L '
|
||||||
|
else
|
||||||
|
let l:statusline .= '%#StatusLinePercent#'
|
||||||
|
let l:statusline .= ' %P %#StatusLineNoise#of %#StatusLineLinecount#%L '
|
||||||
|
endif"}}}
|
||||||
|
|
||||||
" linter status {{{
|
" non-empty buftype (help, quickfix, etc) {{{
|
||||||
if a:isactive
|
if a:isactive
|
||||||
" errors
|
let l:statusline .= l:active . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineActiveNoText#"
|
||||||
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('error') == 0?'-':'')}"
|
else
|
||||||
let l:statusline .= "%#LinterErrorActive#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
|
let l:statusline .= l:normal . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineNormalNoText#"
|
||||||
" style errors
|
endif
|
||||||
let l:statusline .= l:linterdashactive
|
let l:statusline .= "%{&buftype == '' ? '' : ' '}%s"
|
||||||
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('style_error') == 0?'-':'')}"
|
"}}}
|
||||||
let l:statusline .= "%#LinterErrorStyleActive#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
|
|
||||||
|
|
||||||
" warnings
|
" right/left divider {{{
|
||||||
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('warning') == 0?'-':'')}"
|
let l:statusline.=l:separator
|
||||||
let l:statusline .= "%#LinterWarningActive#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
|
" modified version
|
||||||
" style warnings
|
let l:color = 'StatusLineDivMod' . (a:isactive?'Active':'')
|
||||||
let l:statusline .= l:linterdashactive
|
let l:statusline .= GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider)
|
||||||
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('style_warning') == 0?'-':'')}"
|
|
||||||
let l:statusline .= "%#LinterWarningStyleActive#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
|
|
||||||
|
|
||||||
" info
|
" unmodified version
|
||||||
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('info') == 0?'-':'')}"
|
let l:color = 'StatusLineDiv' . (a:isactive?'Active':'')
|
||||||
let l:statusline .= "%#LinterInfoActive#%{(GetLinterStatus('info') == 0?'':GetLinterStatus('info'))}"
|
let l:statusline .= GetStatusFrag("!&modified && mode() != 'i'", l:color, '%<', l:divider)
|
||||||
else
|
|
||||||
" errors
|
|
||||||
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('error') == 0?'-':'')}"
|
|
||||||
let l:statusline .= "%#LinterError#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
|
|
||||||
" style errors
|
|
||||||
let l:statusline .= l:linterdash
|
|
||||||
let l:statusline .= "%{(GetLinterStatus('style_error') == 0?'-':'')}"
|
|
||||||
let l:statusline .= "%#LinterErrorStyle#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
|
|
||||||
|
|
||||||
" warnings
|
" input mode version
|
||||||
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('warning') == 0?'-':'')}"
|
if a:isactive
|
||||||
let l:statusline .= "%#LinterWarning#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
|
let l:statusline .= GetStatusFrag("mode() == 'i'", 'StatusLineDivInput', '%<', l:divider)
|
||||||
" style warnings
|
endif
|
||||||
let l:statusline .= l:linterdash
|
|
||||||
let l:statusline .= "%{(GetLinterStatus('style_warning') == 0?'-':'')}"
|
|
||||||
let l:statusline .= "%#LinterWarningStyle#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
|
|
||||||
|
|
||||||
" info
|
let l:statusline.= l:separator . '%*%='
|
||||||
let l:statusline .= "%#LinterInfo#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
|
"}}}
|
||||||
endif
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
let l:statusline .= ' ' . l:separator
|
" file info{{{
|
||||||
|
if a:isactive == 1
|
||||||
|
" let l:statusline.=l:active
|
||||||
|
let l:statusline.='%#StatusLineFileInfo#'
|
||||||
|
" let l:statusline.=" %{strlen(&ft)?&ft:'none'} "
|
||||||
|
" let l:statusline.=l:separator . l:active
|
||||||
|
let l:statusline.='%{strlen(&fenc)?&fenc:&enc}'
|
||||||
|
" let l:statusline.=l:separator . l:active
|
||||||
|
let l:statusline.=' %{&fileformat}'
|
||||||
|
let l:statusline.="%{strlen(expand('%:e')) > 1?' ' . expand('%:e'):''}"
|
||||||
|
" let l:statusline.=l:separator . l:active
|
||||||
|
" let l:statusline.=' %{&spelllang} '
|
||||||
|
let l:statusline .= l:separator
|
||||||
|
endif
|
||||||
|
"}}}
|
||||||
|
|
||||||
if exists('gutentags#statusline')
|
" path/filename.extension {{{
|
||||||
let l:statusline .= '%#StatusLineWarning#%{gutentags#statusline("", "", "☢")}'
|
if a:isactive
|
||||||
endif
|
if &readonly
|
||||||
|
let l:statusline .= '%#StatusLineWarningActive# %r '
|
||||||
|
let l:statusline .= '%#StatusLineFileReadOnlyActive#'
|
||||||
|
" let l:statusline.='%#StatusLineDirActive# '
|
||||||
|
let l:statusline.="%{expand('%:p:h:t')}/"
|
||||||
|
" let l:statusline.='%#StatusLineFileActive#'
|
||||||
|
|
||||||
return l:statusline
|
let l:statusline.="%{expand('%:t:r')}"
|
||||||
|
|
||||||
endfunction
|
" let l:statusline.='%#StatusLineDotActive#'
|
||||||
"}}}
|
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
|
||||||
|
" let l:statusline.='%#StatusLineExtActive#'
|
||||||
|
let l:statusline.="%{expand('%:e')} "
|
||||||
|
else
|
||||||
|
let l:statusline.='%#StatusLineDirActive# '
|
||||||
|
let l:statusline.="%{expand('%:p:h:t')}/"
|
||||||
|
let l:statusline.='%#StatusLineFileActive#'
|
||||||
|
|
||||||
" highlight groups {{{
|
let l:statusline.="%{expand('%:t:r')}"
|
||||||
hi def link StatusLineSeparator Ignore
|
|
||||||
hi def link StatusLineNormal StatusLineNC
|
|
||||||
hi def link StatusLineActive StatusLine
|
|
||||||
hi def link StatusLineNormalNoText TabLineFill
|
|
||||||
hi def link StatusLineActiveNoText TabLineFill
|
|
||||||
|
|
||||||
hi def link StatusLineNoise StatusLineNormal
|
let l:statusline.='%#StatusLineDotActive#'
|
||||||
hi def link StatusLineNoiseActive StatusLineNormal
|
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
|
||||||
|
let l:statusline.='%#StatusLineExtActive#'
|
||||||
|
let l:statusline.="%{expand('%:e')} "
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
let l:statusline .= ' %#StatusLineWarning#%r'
|
||||||
|
let l:statusline.='%#StatusLineDir# '
|
||||||
|
let l:statusline.="%{fnamemodify(expand('%:p:h'),':~')}/"
|
||||||
|
let l:statusline.='%#StatusLineFile#'
|
||||||
|
|
||||||
hi def link StatusLineBufferNr StatusLineNormal
|
let l:statusline.="%{expand('%:t:r')}"
|
||||||
hi def link StatusLineBufferNrActive StatusLineActive
|
|
||||||
|
|
||||||
hi def link StatusLinePercent StatusLineNormal
|
let l:statusline.='%#StatusLineDot#'
|
||||||
hi def link StatusLinePercentActive StatusLineActive
|
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
|
||||||
hi def link StatusLineLinecount StatusLinePercent
|
let l:statusline.='%#StatusLineExt#'
|
||||||
hi def link StatusLineLinecountActive StatusLinePercentActive
|
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')} "
|
||||||
|
endif
|
||||||
|
"}}}
|
||||||
|
|
||||||
hi DivActive ctermbg=darkgray ctermfg=darkgray guibg=#666666 guifg=#666666
|
let l:statusline.='%*' . l:separator
|
||||||
hi DivMod ctermbg=darkred ctermfg=darkred guibg=#660000 guifg=#660000
|
|
||||||
hi DivModActive ctermbg=red ctermfg=red guibg=#aa0000 guifg=#aa0000
|
|
||||||
hi DivInput ctermbg=darkblue ctermfg=darkblue guibg=#000022 guifg=#000022
|
|
||||||
hi def link StatusLineDiv TabLineFill
|
|
||||||
hi def link StatusLineDivActive DivActive
|
|
||||||
hi def link StatusLineDivMod DivMod
|
|
||||||
hi def link StatusLineDivModActive DivModActive
|
|
||||||
hi def link StatusLineDivInput DivInput
|
|
||||||
|
|
||||||
hi def link StatusLineFileInfo StatusLineActive
|
" linter status {{{
|
||||||
|
if a:isactive
|
||||||
|
" errors
|
||||||
|
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('error') == 0?'-':'')}"
|
||||||
|
let l:statusline .= "%#LinterErrorActive#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
|
||||||
|
" style errors
|
||||||
|
let l:statusline .= l:linterdashactive
|
||||||
|
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('style_error') == 0?'-':'')}"
|
||||||
|
let l:statusline .= "%#LinterErrorStyleActive#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
|
||||||
|
|
||||||
hi def link StatusLineFile StatusLineNormal
|
" warnings
|
||||||
hi def link StatusLineFileActive StatusLineActive
|
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('warning') == 0?'-':'')}"
|
||||||
hi def link StatusLineDir StatusLineFile
|
let l:statusline .= "%#LinterWarningActive#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
|
||||||
hi def link StatusLineDirActive StatusLineFileActive
|
" style warnings
|
||||||
hi def link StatusLineDot StatusLineDir
|
let l:statusline .= l:linterdashactive
|
||||||
hi def link StatusLineDotActive StatusLineDirActive
|
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('style_warning') == 0?'-':'')}"
|
||||||
hi def link StatusLineExt StatusLineDir
|
let l:statusline .= "%#LinterWarningStyleActive#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
|
||||||
hi def link StatusLineExtActive StatusLineDirActive
|
|
||||||
|
|
||||||
hi def link StatusLineFileReadOnlyActive WarningMsg
|
" info
|
||||||
hi def link StatusLineWarning StatusLineNormal
|
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('info') == 0?'-':'')}"
|
||||||
hi def link StatusLineWarningActive WarningMsg
|
let l:statusline .= "%#LinterInfoActive#%{(GetLinterStatus('info') == 0?'':GetLinterStatus('info'))}"
|
||||||
|
else
|
||||||
|
" errors
|
||||||
|
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('error') == 0?'-':'')}"
|
||||||
|
let l:statusline .= "%#LinterError#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
|
||||||
|
" style errors
|
||||||
|
let l:statusline .= l:linterdash
|
||||||
|
let l:statusline .= "%{(GetLinterStatus('style_error') == 0?'-':'')}"
|
||||||
|
let l:statusline .= "%#LinterErrorStyle#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
|
||||||
|
|
||||||
hi def link LinterDash Normal
|
" warnings
|
||||||
hi def link LinterDashActive Normal
|
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('warning') == 0?'-':'')}"
|
||||||
|
let l:statusline .= "%#LinterWarning#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
|
||||||
|
" style warnings
|
||||||
|
let l:statusline .= l:linterdash
|
||||||
|
let l:statusline .= "%{(GetLinterStatus('style_warning') == 0?'-':'')}"
|
||||||
|
let l:statusline .= "%#LinterWarningStyle#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
|
||||||
|
|
||||||
hi def link LinterError Normal
|
" info
|
||||||
hi def link LinterErrorActive ErrorMsg
|
let l:statusline .= "%#LinterInfo#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
|
||||||
|
endif
|
||||||
|
"}}}
|
||||||
|
|
||||||
hi def link LinterErrorStyle Normal
|
let l:statusline .= ' ' . l:separator
|
||||||
hi def link LinterErrorStyleActive SpellBad
|
|
||||||
|
|
||||||
hi def link LinterWarning Normal
|
if exists('gutentags#statusline')
|
||||||
hi def link LinterWarningActive SpellCap
|
let l:statusline .= '%#StatusLineWarning#%{gutentags#statusline("", "", "☢")}'
|
||||||
|
endif
|
||||||
|
|
||||||
hi def link LinterWarningStyle Normal
|
return l:statusline
|
||||||
hi def link LinterWarningStyleActive LinterWarningActive
|
|
||||||
|
|
||||||
hi def link LinterInfo Normal
|
endfunction
|
||||||
hi def link LinterInfoActive SpellRare
|
"}}}
|
||||||
"}}}
|
|
||||||
|
|
||||||
augroup status "{{{
|
" highlight groups {{{
|
||||||
autocmd!
|
hi def link StatusLineSeparator Ignore
|
||||||
autocmd WinNew,WinEnter * setlocal statusline=%!GetStatus(1)
|
hi def link StatusLineNormal StatusLineNC
|
||||||
autocmd WinLeave * setlocal statusline=%!GetStatus(0)
|
hi def link StatusLineActive StatusLine
|
||||||
" autocmd WinNew * setlocal statusline=%!GetStatus(1)
|
hi def link StatusLineNormalNoText TabLineFill
|
||||||
" autocmd InsertChange * setlocal statusline=%!GetStatus(1)
|
hi def link StatusLineActiveNoText TabLineFill
|
||||||
augroup END
|
|
||||||
"}}}
|
hi def link StatusLineNoise StatusLineNormal
|
||||||
|
hi def link StatusLineNoiseActive StatusLineNormal
|
||||||
|
|
||||||
|
hi def link StatusLineBufferNr StatusLineNormal
|
||||||
|
hi def link StatusLineBufferNrActive StatusLineActive
|
||||||
|
|
||||||
|
hi def link StatusLinePercent StatusLineNormal
|
||||||
|
hi def link StatusLinePercentActive StatusLineActive
|
||||||
|
hi def link StatusLineLinecount StatusLinePercent
|
||||||
|
hi def link StatusLineLinecountActive StatusLinePercentActive
|
||||||
|
|
||||||
|
hi DivActive ctermbg=darkgray ctermfg=darkgray guibg=#666666 guifg=#666666
|
||||||
|
hi DivMod ctermbg=darkred ctermfg=darkred guibg=#660000 guifg=#660000
|
||||||
|
hi DivModActive ctermbg=red ctermfg=red guibg=#aa0000 guifg=#aa0000
|
||||||
|
hi DivInput ctermbg=darkblue ctermfg=darkblue guibg=#000022 guifg=#000022
|
||||||
|
hi def link StatusLineDiv TabLineFill
|
||||||
|
hi def link StatusLineDivActive DivActive
|
||||||
|
hi def link StatusLineDivMod DivMod
|
||||||
|
hi def link StatusLineDivModActive DivModActive
|
||||||
|
hi def link StatusLineDivInput DivInput
|
||||||
|
|
||||||
|
hi def link StatusLineFileInfo StatusLineActive
|
||||||
|
|
||||||
|
hi def link StatusLineFile StatusLineNormal
|
||||||
|
hi def link StatusLineFileActive StatusLineActive
|
||||||
|
hi def link StatusLineDir StatusLineFile
|
||||||
|
hi def link StatusLineDirActive StatusLineFileActive
|
||||||
|
hi def link StatusLineDot StatusLineDir
|
||||||
|
hi def link StatusLineDotActive StatusLineDirActive
|
||||||
|
hi def link StatusLineExt StatusLineDir
|
||||||
|
hi def link StatusLineExtActive StatusLineDirActive
|
||||||
|
|
||||||
|
hi def link StatusLineFileReadOnlyActive WarningMsg
|
||||||
|
hi def link StatusLineWarning StatusLineNormal
|
||||||
|
hi def link StatusLineWarningActive WarningMsg
|
||||||
|
|
||||||
|
hi def link LinterDash Normal
|
||||||
|
hi def link LinterDashActive Normal
|
||||||
|
|
||||||
|
hi def link LinterError Normal
|
||||||
|
hi def link LinterErrorActive ErrorMsg
|
||||||
|
|
||||||
|
hi def link LinterErrorStyle Normal
|
||||||
|
hi def link LinterErrorStyleActive SpellBad
|
||||||
|
|
||||||
|
hi def link LinterWarning Normal
|
||||||
|
hi def link LinterWarningActive SpellCap
|
||||||
|
|
||||||
|
hi def link LinterWarningStyle Normal
|
||||||
|
hi def link LinterWarningStyleActive LinterWarningActive
|
||||||
|
|
||||||
|
hi def link LinterInfo Normal
|
||||||
|
hi def link LinterInfoActive SpellRare
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
endif
|
||||||
|
" TODO set statusline if not using custom statusline
|
||||||
|
|
||||||
"----------------------------------------------------------------------------}}}
|
"----------------------------------------------------------------------------}}}
|
||||||
" #tabline {{{
|
" #tabline {{{
|
||||||
if exists('+showtabline')
|
if exists('+showtabline') && g:vimrc_enable_tabline
|
||||||
|
|
||||||
" Rename tabs to show tab number.
|
" Rename tabs to show tab number.
|
||||||
" based on:
|
" based on:
|
||||||
|
@ -1638,8 +1612,13 @@ if exists('+showtabline')
|
||||||
hi def link TabLineNum TabLine
|
hi def link TabLineNum TabLine
|
||||||
hi def link TabLineNumSel TabLineSel
|
hi def link TabLineNumSel TabLineSel
|
||||||
|
|
||||||
endif " exists("+showtabline")
|
endif
|
||||||
"----------------------------------------------------------------------------}}}
|
"----------------------------------------------------------------------------}}}
|
||||||
|
|
||||||
|
if filereadable(expand('.vimrc-overrides'))"{{{
|
||||||
|
source .vimrc-overrides
|
||||||
|
endif
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
|
||||||
" vim: set foldmethod=marker:
|
" vim: set foldmethod=marker:
|
||||||
|
|
Loading…
Reference in New Issue