mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-05-10 19:10:59 +08:00
The full-column ColorColumn was visually overwhelming on every line, especially with default vim's LightRed (kicked in silently when solarized8 wasn't installed). Replace it with an OverLength match that only highlights characters past the buffer's textwidth. - editing.vim: OverLength matchadd, refreshed on FileType/BufWinEnter/OptionSet - languages.vim: drop colorcolumn from per-filetype autocmds (textwidth still set) - ui.vim: VertSplit/CursorLine/CursorLineNr/SignColumn override via ColorScheme autocmd; fillchars for vert and eob; timer-based warning if solarized8 missing
69 lines
2.9 KiB
VimL
69 lines
2.9 KiB
VimL
" editing.vim — EasyMotion, yank highlight, search auto-clear, undotree
|
|
|
|
" ── EasyMotion ──────────────────────────────────────────────────────────────
|
|
|
|
let g:EasyMotion_do_mapping = 0
|
|
let g:EasyMotion_smartcase = 1
|
|
|
|
if exists('g:plugs["vim-easymotion"]')
|
|
nmap s <Plug>(easymotion-overwin-f2)
|
|
nmap <Leader>j <Plug>(easymotion-j)
|
|
nmap <Leader>k <Plug>(easymotion-k)
|
|
endif
|
|
|
|
" ── UndoTree ────────────────────────────────────────────────────────────────
|
|
|
|
if exists('g:plugs["undotree"]')
|
|
nnoremap <F5> :UndotreeToggle<CR>
|
|
nnoremap <leader>u :UndotreeToggle<CR>
|
|
endif
|
|
|
|
" ── Yank Highlight ──────────────────────────────────────────────────────────
|
|
|
|
if exists('##TextYankPost') && has('timers')
|
|
function! s:YankHighlight() abort
|
|
if v:event.operator !=# 'y' | return | endif
|
|
let l:m = matchadd('IncSearch',
|
|
\ printf('\%%>%dl\%%<%dl', line("'[") - 1, line("']") + 1))
|
|
call timer_start(150, {-> execute('silent! call matchdelete(' . l:m . ')')})
|
|
endfunction
|
|
augroup ChopstickYankHL
|
|
autocmd!
|
|
autocmd TextYankPost * call s:YankHighlight()
|
|
augroup END
|
|
endif
|
|
|
|
" ── Blank Line Insertion (replaces vim-unimpaired) ──────────────────────────
|
|
|
|
nnoremap <silent> [<Space> :<C-u>put! =repeat(nr2char(10), v:count1)<CR>'[
|
|
nnoremap <silent> ]<Space> :<C-u>put =repeat(nr2char(10), v:count1)<CR>
|
|
|
|
" ── Auto-Clear Search Highlight ─────────────────────────────────────────────
|
|
|
|
augroup ChopstickSearchHL
|
|
autocmd!
|
|
autocmd CursorHold * if get(v:, 'hlsearch', 0) | let v:hlsearch = 0 | endif
|
|
augroup END
|
|
|
|
" ── Overlength Highlight (only chars past textwidth, not the whole column) ─
|
|
|
|
function! s:OverLengthApply() abort
|
|
if exists('w:overlength_match')
|
|
silent! call matchdelete(w:overlength_match)
|
|
unlet w:overlength_match
|
|
endif
|
|
if &textwidth <= 0 || &buftype !=# '' | return | endif
|
|
let w:overlength_match = matchadd('OverLength', '\%>' . &textwidth . 'v.\+', -1)
|
|
endfunction
|
|
|
|
function! s:OverLengthDefineHL() abort
|
|
hi default OverLength ctermbg=52 ctermfg=NONE guibg=#3a1f1f guifg=NONE
|
|
endfunction
|
|
|
|
augroup ChopstickOverLength
|
|
autocmd!
|
|
autocmd ColorScheme * call s:OverLengthDefineHL()
|
|
autocmd OptionSet textwidth call s:OverLengthApply()
|
|
autocmd BufWinEnter,WinEnter,FileType * call s:OverLengthApply()
|
|
augroup END
|
|
call s:OverLengthDefineHL()
|