refactoring
This commit is contained in:
parent
21b3126ad4
commit
f44cb29b3f
|
@ -10,3 +10,5 @@ wal_example-dark.vim
|
|||
wal_example-light.vim
|
||||
vim/autoload/plug.vim
|
||||
.is-dev
|
||||
.vimrc-config
|
||||
.vimrc-overrides
|
||||
|
|
251
vimrc
251
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 {{{
|
||||
if empty(glob('~/.vim/autoload/plug.vim'))"{{{
|
||||
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
||||
|
@ -13,7 +27,6 @@ if !has('nvim')
|
|||
|
||||
Plug '~/.config/vim/vim/bundle/vim-learnxiny'
|
||||
|
||||
|
||||
" #Ctrlp {{{
|
||||
Plug 'ctrlpvim/ctrlp.vim'
|
||||
" :h ctrlp-commands
|
||||
|
@ -70,22 +83,6 @@ let g:mta_filetypes = {
|
|||
\ ['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 {{{
|
||||
Plug 'mbbill/undotree'
|
||||
|
@ -139,7 +136,7 @@ Plug 'studio-vx/vim-qlist'
|
|||
|
||||
"}}}
|
||||
|
||||
if filereadable(expand('.is-dev'))
|
||||
if g:vimrc_load_dev_plugins
|
||||
" #ALE {{{
|
||||
" https://github.com/w0rp/ale
|
||||
Plug 'w0rp/ale'
|
||||
|
@ -537,18 +534,6 @@ runtime macros/matchit.vim
|
|||
"----------------------------------------------------------------------------}}}
|
||||
" #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"{{{
|
||||
|
||||
if &background ==? 'dark'
|
||||
|
@ -972,14 +957,11 @@ command! ScratchVertical vnew | setlocal buftype=nofile | setlocal bufhidden=hid
|
|||
"}}}
|
||||
" #settings {{{
|
||||
scriptencoding utf-8
|
||||
set ttyfast
|
||||
|
||||
if &term ==? 'xterm-256color'
|
||||
set termguicolors
|
||||
endif
|
||||
|
||||
syntax on
|
||||
set background=light
|
||||
" set fillchars=stl:\ ,stlnc:\ ,vert:│
|
||||
set fillchars=stl:\ ,stlnc:\ ,vert:┃
|
||||
colorscheme monotonous-dark
|
||||
|
@ -991,14 +973,10 @@ set updatetime=100
|
|||
set timeoutlen=500
|
||||
set lazyredraw
|
||||
|
||||
set backupdir=~/.vimtmp
|
||||
set directory=~/.vimtmp
|
||||
|
||||
" the ;/home/ray tells vim to stop searching at /home/ray
|
||||
set tags+=./.tags,.tags,./tags-py,.tags-py;/home/ray/
|
||||
|
||||
" persisitent undo file
|
||||
set undodir=/home/ray/.vim/undodir
|
||||
set undofile
|
||||
|
||||
set viewoptions-=options
|
||||
|
@ -1027,8 +1005,6 @@ set completeopt=longest,menuone
|
|||
|
||||
set nospell
|
||||
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
|
||||
|
||||
|
@ -1234,22 +1210,22 @@ iabbrev ct'' content-type: '';
|
|||
" #autocommands {{{
|
||||
|
||||
" persistent folds {{{
|
||||
augroup AutoSaveFolds
|
||||
augroup AutoSaveFolds
|
||||
autocmd!
|
||||
" autocmd BufWinLeave ?* mkview
|
||||
autocmd BufWrite ?* mkview
|
||||
" autocmd BufWinEnter ?* silent loadview
|
||||
autocmd BufRead ?* silent! loadview
|
||||
augroup END
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
" }}}
|
||||
" Show trailing whitepace and spaces before a tab: {{{
|
||||
augroup whitespaceerrors
|
||||
augroup whitespaceerrors
|
||||
autocmd!
|
||||
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL
|
||||
augroup END
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
" }}}
|
||||
" automatically reload if color scheme file written {{{
|
||||
" augroup coloreload
|
||||
" autocmd!
|
||||
|
@ -1257,9 +1233,9 @@ augroup END
|
|||
" augroup end
|
||||
"
|
||||
|
||||
"}}}
|
||||
" }}}
|
||||
" line numbering {{{
|
||||
augroup linenumbering
|
||||
augroup linenumbering
|
||||
autocmd!
|
||||
autocmd InsertEnter * :set norelativenumber
|
||||
autocmd InsertLeave * :set number relativenumber
|
||||
|
@ -1268,55 +1244,59 @@ augroup linenumbering
|
|||
autocmd CmdlineEnter * :redraw | :set norelativenumber
|
||||
autocmd CmdlineLeave * :set number relativenumber
|
||||
" see 'mapping nnoremap :' for setting norelative number.
|
||||
augroup END
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
" WinEnter, WinLeave {{{
|
||||
augroup windowenteringleaving
|
||||
" }}}
|
||||
" 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
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
" InsertEnter, InsertLeave {{{
|
||||
augroup insertenterleave
|
||||
au!
|
||||
au InsertEnter * call DoInsertEnter()
|
||||
au InsertLeave * call DoInsertLeave()
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
" Automatically reload .vimrc if chanaged {{{
|
||||
augroup myvimrc
|
||||
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
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
" " Open qfix after grepping {{{
|
||||
" }}}
|
||||
" Open qfix after grepping {{{
|
||||
" augroup qfixopen
|
||||
" autocmd!
|
||||
" autocmd QuickFixCmdPost *grep* botright cwindow
|
||||
" augroup END
|
||||
|
||||
"}}}
|
||||
"Open quickfix window{{{
|
||||
augroup QuickFixAutoload
|
||||
" }}}
|
||||
" Open quickfix window{{{
|
||||
augroup QuickFixAutoload
|
||||
autocmd!
|
||||
autocmd QuickFixCmdPost [^l]* nested botright cwindow
|
||||
autocmd QuickFixCmdPost l* nested botright lwindow
|
||||
augroup END
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
" }}}
|
||||
|
||||
"----------------------------------------------------------------------------}}}
|
||||
" #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:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
|
||||
let l:separator = '%#StatusLineSeparator# '
|
||||
|
@ -1333,7 +1313,7 @@ function! GetStatus(isactive) abort "{{{
|
|||
let l:statusline .= '%#StatusLineBufferNr#'
|
||||
endif
|
||||
let l:statusline .= ' %n ' . l:separator
|
||||
"}}}
|
||||
"}}}
|
||||
|
||||
" file percentage {{{
|
||||
if a:isactive
|
||||
|
@ -1351,7 +1331,7 @@ function! GetStatus(isactive) abort "{{{
|
|||
let l:statusline .= l:normal . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineNormalNoText#"
|
||||
endif
|
||||
let l:statusline .= "%{&buftype == '' ? '' : ' '}%s"
|
||||
"}}}
|
||||
"}}}
|
||||
|
||||
" right/left divider {{{
|
||||
let l:statusline.=l:separator
|
||||
|
@ -1385,7 +1365,7 @@ function! GetStatus(isactive) abort "{{{
|
|||
" let l:statusline.=' %{&spelllang} '
|
||||
let l:statusline .= l:separator
|
||||
endif
|
||||
"}}}
|
||||
"}}}
|
||||
|
||||
" path/filename.extension {{{
|
||||
if a:isactive
|
||||
|
@ -1472,7 +1452,7 @@ function! GetStatus(isactive) abort "{{{
|
|||
" info
|
||||
let l:statusline .= "%#LinterInfo#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
|
||||
endif
|
||||
"}}}
|
||||
"}}}
|
||||
|
||||
let l:statusline .= ' ' . l:separator
|
||||
|
||||
|
@ -1482,83 +1462,77 @@ function! GetStatus(isactive) abort "{{{
|
|||
|
||||
return l:statusline
|
||||
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction
|
||||
"}}}
|
||||
|
||||
" highlight groups {{{
|
||||
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 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
|
||||
hi def link StatusLineNoiseActive StatusLineNormal
|
||||
hi def link StatusLineNoise StatusLineNormal
|
||||
hi def link StatusLineNoiseActive StatusLineNormal
|
||||
|
||||
hi def link StatusLineBufferNr StatusLineNormal
|
||||
hi def link StatusLineBufferNrActive StatusLineActive
|
||||
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 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 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 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 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 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 LinterDash Normal
|
||||
hi def link LinterDashActive Normal
|
||||
|
||||
hi def link LinterError Normal
|
||||
hi def link LinterErrorActive ErrorMsg
|
||||
hi def link LinterError Normal
|
||||
hi def link LinterErrorActive ErrorMsg
|
||||
|
||||
hi def link LinterErrorStyle Normal
|
||||
hi def link LinterErrorStyleActive SpellBad
|
||||
hi def link LinterErrorStyle Normal
|
||||
hi def link LinterErrorStyleActive SpellBad
|
||||
|
||||
hi def link LinterWarning Normal
|
||||
hi def link LinterWarningActive SpellCap
|
||||
hi def link LinterWarning Normal
|
||||
hi def link LinterWarningActive SpellCap
|
||||
|
||||
hi def link LinterWarningStyle Normal
|
||||
hi def link LinterWarningStyleActive LinterWarningActive
|
||||
hi def link LinterWarningStyle Normal
|
||||
hi def link LinterWarningStyleActive LinterWarningActive
|
||||
|
||||
hi def link LinterInfo Normal
|
||||
hi def link LinterInfoActive SpellRare
|
||||
"}}}
|
||||
hi def link LinterInfo Normal
|
||||
hi def link LinterInfoActive SpellRare
|
||||
"}}}
|
||||
|
||||
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
|
||||
"}}}
|
||||
endif
|
||||
" TODO set statusline if not using custom statusline
|
||||
|
||||
"----------------------------------------------------------------------------}}}
|
||||
" #tabline {{{
|
||||
if exists('+showtabline')
|
||||
if exists('+showtabline') && g:vimrc_enable_tabline
|
||||
|
||||
" Rename tabs to show tab number.
|
||||
" based on:
|
||||
|
@ -1638,8 +1612,13 @@ if exists('+showtabline')
|
|||
hi def link TabLineNum TabLine
|
||||
hi def link TabLineNumSel TabLineSel
|
||||
|
||||
endif " exists("+showtabline")
|
||||
endif
|
||||
"----------------------------------------------------------------------------}}}
|
||||
|
||||
if filereadable(expand('.vimrc-overrides'))"{{{
|
||||
source .vimrc-overrides
|
||||
endif
|
||||
"}}}
|
||||
|
||||
|
||||
" vim: set foldmethod=marker:
|
||||
|
|
Loading…
Reference in New Issue