fix(ui): drop noisy colorcolumn, polish highlights, warn on missing colorscheme

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
This commit is contained in:
m1ngsama 2026-04-27 18:08:28 +08:00
parent 4fd9a09948
commit 28e4ed3794
3 changed files with 64 additions and 8 deletions

View file

@ -44,3 +44,26 @@ augroup ChopstickSearchHL
autocmd! autocmd!
autocmd CursorHold * if get(v:, 'hlsearch', 0) | let v:hlsearch = 0 | endif autocmd CursorHold * if get(v:, 'hlsearch', 0) | let v:hlsearch = 0 | endif
augroup END 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()

View file

@ -47,23 +47,23 @@ augroup ChopstickFiletype
\ if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif \ if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
autocmd FileType python autocmd FileType python
\ setlocal expandtab shiftwidth=4 tabstop=4 textwidth=88 colorcolumn=+1 \ setlocal expandtab shiftwidth=4 tabstop=4 textwidth=88
autocmd FileType javascript,typescript autocmd FileType javascript,typescript
\ setlocal expandtab shiftwidth=2 tabstop=2 textwidth=100 colorcolumn=+1 \ setlocal expandtab shiftwidth=2 tabstop=2 textwidth=100
autocmd FileType go autocmd FileType go
\ setlocal noexpandtab shiftwidth=4 tabstop=4 textwidth=120 colorcolumn=+1 \ setlocal noexpandtab shiftwidth=4 tabstop=4 textwidth=120
autocmd FileType rust autocmd FileType rust
\ setlocal expandtab shiftwidth=4 tabstop=4 textwidth=100 colorcolumn=+1 \ setlocal expandtab shiftwidth=4 tabstop=4 textwidth=100
autocmd FileType c,cpp autocmd FileType c,cpp
\ setlocal expandtab shiftwidth=4 tabstop=4 textwidth=80 colorcolumn=+1 \ setlocal expandtab shiftwidth=4 tabstop=4 textwidth=80
autocmd FileType html,css autocmd FileType html,css
\ setlocal expandtab shiftwidth=2 tabstop=2 \ setlocal expandtab shiftwidth=2 tabstop=2
autocmd FileType yaml autocmd FileType yaml
\ setlocal expandtab shiftwidth=2 tabstop=2 \ setlocal expandtab shiftwidth=2 tabstop=2
autocmd FileType markdown autocmd FileType markdown
\ setlocal wrap linebreak spell textwidth=0 colorcolumn=0 conceallevel=2 \ setlocal wrap linebreak spell textwidth=0 conceallevel=2
autocmd FileType sh autocmd FileType sh
\ setlocal expandtab shiftwidth=2 tabstop=2 textwidth=80 colorcolumn=+1 \ setlocal expandtab shiftwidth=2 tabstop=2 textwidth=80
autocmd FileType make autocmd FileType make
\ setlocal noexpandtab shiftwidth=8 tabstop=8 \ setlocal noexpandtab shiftwidth=8 tabstop=8
autocmd FileType json autocmd FileType json

View file

@ -10,16 +10,49 @@ endif
set background=dark set background=dark
function! s:WarnSolarized8Missing(...) abort
echohl WarningMsg
echom 'chopsticks: solarized8 not installed — run :PlugInstall'
echohl None
endfunction
if !g:is_tty if !g:is_tty
try try
colorscheme solarized8 colorscheme solarized8
catch catch /^Vim\%((\a\+)\)\=:E185/
colorscheme default colorscheme default
if has('timers')
call timer_start(500, function('s:WarnSolarized8Missing'))
else
augroup ChopstickColorschemeWarn
autocmd!
autocmd VimEnter * call s:WarnSolarized8Missing()
augroup END
endif
endtry endtry
else else
colorscheme default colorscheme default
endif endif
" ── Window separators, fillchars, cursorline visibility ────────────────────
if !g:is_tty
set fillchars+=vert:│,eob:\
endif
function! s:UIPolish() abort
hi VertSplit ctermbg=234 ctermfg=240 guibg=#002b36 guifg=#586e75 cterm=NONE gui=NONE
hi CursorLine ctermbg=235 guibg=#0c4452 cterm=NONE gui=NONE
hi CursorLineNr ctermbg=235 ctermfg=136 guibg=#0c4452 guifg=#b58900 cterm=bold gui=bold
hi SignColumn ctermbg=234 guibg=#002b36
endfunction
augroup ChopstickUIPolish
autocmd!
autocmd ColorScheme * call s:UIPolish()
augroup END
if !g:is_tty | call s:UIPolish() | endif
if has("gui_running") if has("gui_running")
if has("gui_gtk2") || has("gui_gtk3") if has("gui_gtk2") || has("gui_gtk3")
set guifont=Hack\ 12,Source\ Code\ Pro\ 12,Monospace\ 12 set guifont=Hack\ 12,Source\ Code\ Pro\ 12,Monospace\ 12