refactoring

This commit is contained in:
ManjaroOne666 2018-12-02 22:33:19 +00:00
parent 21b3126ad4
commit f44cb29b3f
2 changed files with 307 additions and 326 deletions

2
.gitignore vendored
View File

@ -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

251
vimrc
View File

@ -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
@ -1234,22 +1210,22 @@ iabbrev ct'' content-type: '';
" #autocommands {{{ " #autocommands {{{
" persistent folds {{{ " persistent folds {{{
augroup AutoSaveFolds augroup AutoSaveFolds
autocmd! autocmd!
" autocmd BufWinLeave ?* mkview " autocmd BufWinLeave ?* mkview
autocmd BufWrite ?* mkview autocmd BufWrite ?* mkview
" autocmd BufWinEnter ?* silent loadview " autocmd BufWinEnter ?* silent loadview
autocmd BufRead ?* silent! loadview autocmd BufRead ?* silent! loadview
augroup END augroup END
"}}} " }}}
" Show trailing whitepace and spaces before a tab: {{{ " Show trailing whitepace and spaces before a tab: {{{
augroup whitespaceerrors augroup whitespaceerrors
autocmd! autocmd!
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL
augroup END augroup END
"}}} " }}}
" automatically reload if color scheme file written {{{ " automatically reload if color scheme file written {{{
" augroup coloreload " augroup coloreload
" autocmd! " autocmd!
@ -1257,9 +1233,9 @@ augroup END
" augroup end " augroup end
" "
"}}} " }}}
" line numbering {{{ " line numbering {{{
augroup linenumbering augroup linenumbering
autocmd! autocmd!
autocmd InsertEnter * :set norelativenumber autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set number relativenumber autocmd InsertLeave * :set number relativenumber
@ -1268,55 +1244,59 @@ augroup linenumbering
autocmd CmdlineEnter * :redraw | :set norelativenumber autocmd CmdlineEnter * :redraw | :set norelativenumber
autocmd CmdlineLeave * :set number relativenumber autocmd CmdlineLeave * :set number relativenumber
" see 'mapping nnoremap :' for setting norelative number. " see 'mapping nnoremap :' for setting norelative number.
augroup END augroup END
"}}} " }}}
" WinEnter, WinLeave {{{ " auto_window_settings {{{
augroup windowenteringleaving if g:vimrc_auto_window_settings
augroup auto_window_settings
autocmd! autocmd!
autocmd WinEnter * call SetColorColumn() autocmd WinEnter * call SetColorColumn()
autocmd WinEnter * set cursorline | set cursorcolumn autocmd WinEnter * set cursorline | set cursorcolumn
autocmd WinLeave * setlocal colorcolumn=0 autocmd WinLeave * setlocal colorcolumn=0
autocmd WinLeave * set nocursorline | set nocursorcolumn autocmd WinLeave * set nocursorline | set nocursorcolumn
augroup END augroup END
"}}} endif
" InsertEnter, InsertLeave {{{ " }}}
augroup insertenterleave " Automatically reload .vimrc if changed {{{
au! augroup myvimrc
au InsertEnter * call DoInsertEnter()
au InsertLeave * call DoInsertLeave()
augroup END
"}}}
" Automatically reload .vimrc if chanaged {{{
augroup myvimrc
autocmd! autocmd!
autocmd BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif autocmd BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END augroup END
"}}} " }}}
" " Open qfix after grepping {{{ " Open qfix after grepping {{{
" augroup qfixopen " augroup qfixopen
" autocmd! " autocmd!
" autocmd QuickFixCmdPost *grep* botright cwindow " autocmd QuickFixCmdPost *grep* botright cwindow
" augroup END " augroup END
"}}} " }}}
"Open quickfix window{{{ " Open quickfix window{{{
augroup QuickFixAutoload augroup QuickFixAutoload
autocmd! autocmd!
autocmd QuickFixCmdPost [^l]* nested botright cwindow autocmd QuickFixCmdPost [^l]* nested botright cwindow
autocmd QuickFixCmdPost l* nested botright lwindow autocmd QuickFixCmdPost l* nested botright lwindow
augroup END augroup END
"}}} " }}}
"----------------------------------------------------------------------------}}} "----------------------------------------------------------------------------}}}
" #statusline {{{ " #statusline {{{
set statusline=%!GetStatus(1) if g:vimrc_enable_statusline
set statusline=%!GetStatus(1)
function! GetStatus(isactive) abort "{{{ augroup status "{{{
autocmd!
autocmd WinNew,WinEnter * setlocal statusline=%!GetStatus(1)
autocmd WinLeave * setlocal statusline=%!GetStatus(0)
" autocmd WinNew * setlocal statusline=%!GetStatus(1)
" autocmd InsertChange * setlocal statusline=%!GetStatus(1)
augroup END
"}}}
function! GetStatus(isactive) abort "{{{
" let l:linter = ale#statusline#Count(bufnr('')) " let l:linter = ale#statusline#Count(bufnr(''))
let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >' let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
let l:separator = '%#StatusLineSeparator# ' let l:separator = '%#StatusLineSeparator# '
@ -1333,7 +1313,7 @@ function! GetStatus(isactive) abort "{{{
let l:statusline .= '%#StatusLineBufferNr#' let l:statusline .= '%#StatusLineBufferNr#'
endif endif
let l:statusline .= ' %n ' . l:separator let l:statusline .= ' %n ' . l:separator
"}}} "}}}
" file percentage {{{ " file percentage {{{
if a:isactive if a:isactive
@ -1351,7 +1331,7 @@ function! GetStatus(isactive) abort "{{{
let l:statusline .= l:normal . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineNormalNoText#" let l:statusline .= l:normal . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineNormalNoText#"
endif endif
let l:statusline .= "%{&buftype == '' ? '' : ' '}%s" let l:statusline .= "%{&buftype == '' ? '' : ' '}%s"
"}}} "}}}
" right/left divider {{{ " right/left divider {{{
let l:statusline.=l:separator let l:statusline.=l:separator
@ -1385,7 +1365,7 @@ function! GetStatus(isactive) abort "{{{
" let l:statusline.=' %{&spelllang} ' " let l:statusline.=' %{&spelllang} '
let l:statusline .= l:separator let l:statusline .= l:separator
endif endif
"}}} "}}}
" path/filename.extension {{{ " path/filename.extension {{{
if a:isactive if a:isactive
@ -1472,7 +1452,7 @@ function! GetStatus(isactive) abort "{{{
" info " info
let l:statusline .= "%#LinterInfo#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}" let l:statusline .= "%#LinterInfo#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
endif endif
"}}} "}}}
let l:statusline .= ' ' . l:separator let l:statusline .= ' ' . l:separator
@ -1482,83 +1462,77 @@ function! GetStatus(isactive) abort "{{{
return l:statusline return l:statusline
endfunction endfunction
"}}} "}}}
" highlight groups {{{ " highlight groups {{{
hi def link StatusLineSeparator Ignore hi def link StatusLineSeparator Ignore
hi def link StatusLineNormal StatusLineNC hi def link StatusLineNormal StatusLineNC
hi def link StatusLineActive StatusLine hi def link StatusLineActive StatusLine
hi def link StatusLineNormalNoText TabLineFill hi def link StatusLineNormalNoText TabLineFill
hi def link StatusLineActiveNoText TabLineFill hi def link StatusLineActiveNoText TabLineFill
hi def link StatusLineNoise StatusLineNormal hi def link StatusLineNoise StatusLineNormal
hi def link StatusLineNoiseActive StatusLineNormal hi def link StatusLineNoiseActive StatusLineNormal
hi def link StatusLineBufferNr StatusLineNormal hi def link StatusLineBufferNr StatusLineNormal
hi def link StatusLineBufferNrActive StatusLineActive hi def link StatusLineBufferNrActive StatusLineActive
hi def link StatusLinePercent StatusLineNormal hi def link StatusLinePercent StatusLineNormal
hi def link StatusLinePercentActive StatusLineActive hi def link StatusLinePercentActive StatusLineActive
hi def link StatusLineLinecount StatusLinePercent hi def link StatusLineLinecount StatusLinePercent
hi def link StatusLineLinecountActive StatusLinePercentActive hi def link StatusLineLinecountActive StatusLinePercentActive
hi DivActive ctermbg=darkgray ctermfg=darkgray guibg=#666666 guifg=#666666 hi DivActive ctermbg=darkgray ctermfg=darkgray guibg=#666666 guifg=#666666
hi DivMod ctermbg=darkred ctermfg=darkred guibg=#660000 guifg=#660000 hi DivMod ctermbg=darkred ctermfg=darkred guibg=#660000 guifg=#660000
hi DivModActive ctermbg=red ctermfg=red guibg=#aa0000 guifg=#aa0000 hi DivModActive ctermbg=red ctermfg=red guibg=#aa0000 guifg=#aa0000
hi DivInput ctermbg=darkblue ctermfg=darkblue guibg=#000022 guifg=#000022 hi DivInput ctermbg=darkblue ctermfg=darkblue guibg=#000022 guifg=#000022
hi def link StatusLineDiv TabLineFill hi def link StatusLineDiv TabLineFill
hi def link StatusLineDivActive DivActive hi def link StatusLineDivActive DivActive
hi def link StatusLineDivMod DivMod hi def link StatusLineDivMod DivMod
hi def link StatusLineDivModActive DivModActive hi def link StatusLineDivModActive DivModActive
hi def link StatusLineDivInput DivInput hi def link StatusLineDivInput DivInput
hi def link StatusLineFileInfo StatusLineActive hi def link StatusLineFileInfo StatusLineActive
hi def link StatusLineFile StatusLineNormal hi def link StatusLineFile StatusLineNormal
hi def link StatusLineFileActive StatusLineActive hi def link StatusLineFileActive StatusLineActive
hi def link StatusLineDir StatusLineFile hi def link StatusLineDir StatusLineFile
hi def link StatusLineDirActive StatusLineFileActive hi def link StatusLineDirActive StatusLineFileActive
hi def link StatusLineDot StatusLineDir hi def link StatusLineDot StatusLineDir
hi def link StatusLineDotActive StatusLineDirActive hi def link StatusLineDotActive StatusLineDirActive
hi def link StatusLineExt StatusLineDir hi def link StatusLineExt StatusLineDir
hi def link StatusLineExtActive StatusLineDirActive hi def link StatusLineExtActive StatusLineDirActive
hi def link StatusLineFileReadOnlyActive WarningMsg hi def link StatusLineFileReadOnlyActive WarningMsg
hi def link StatusLineWarning StatusLineNormal hi def link StatusLineWarning StatusLineNormal
hi def link StatusLineWarningActive WarningMsg hi def link StatusLineWarningActive WarningMsg
hi def link LinterDash Normal hi def link LinterDash Normal
hi def link LinterDashActive Normal hi def link LinterDashActive Normal
hi def link LinterError Normal hi def link LinterError Normal
hi def link LinterErrorActive ErrorMsg hi def link LinterErrorActive ErrorMsg
hi def link LinterErrorStyle Normal hi def link LinterErrorStyle Normal
hi def link LinterErrorStyleActive SpellBad hi def link LinterErrorStyleActive SpellBad
hi def link LinterWarning Normal hi def link LinterWarning Normal
hi def link LinterWarningActive SpellCap hi def link LinterWarningActive SpellCap
hi def link LinterWarningStyle Normal hi def link LinterWarningStyle Normal
hi def link LinterWarningStyleActive LinterWarningActive hi def link LinterWarningStyleActive LinterWarningActive
hi def link LinterInfo Normal hi def link LinterInfo Normal
hi def link LinterInfoActive SpellRare hi def link LinterInfoActive SpellRare
"}}} "}}}
augroup status "{{{ endif
autocmd! " TODO set statusline if not using custom statusline
autocmd WinNew,WinEnter * setlocal statusline=%!GetStatus(1)
autocmd WinLeave * setlocal statusline=%!GetStatus(0)
" autocmd WinNew * setlocal statusline=%!GetStatus(1)
" autocmd InsertChange * setlocal statusline=%!GetStatus(1)
augroup END
"}}}
"----------------------------------------------------------------------------}}} "----------------------------------------------------------------------------}}}
" #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: