From a42c980d3e29118612acedcf7bfcc9a7e390dcec Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Wed, 22 Apr 2026 17:06:33 +0800 Subject: [PATCH] perf: remove ttyfast, add grepprg/diffopt, DRY FZF commands, conditional tmux-navigator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove deprecated `set ttyfast` (no-op since Vim 8) - Add grepprg=rg for :grep → quickfix integration - Add diffopt with histogram algorithm - Consolidate Rg/RgWord/GFiles (24 lines → 10, lazy preview) - Load vim-tmux-navigator only inside tmux, Ctrl+hjkl fallback outside --- CHANGELOG.md | 6 ++++++ modules/core.vim | 10 +++++++++- modules/navigation.vim | 43 ++++++++++++++++++++---------------------- modules/plugins.vim | 4 +++- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f604408..78e2ab0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ ### Changed - Skip 2 more built-in plugins: openPlugin, manpager (10 → 12 total) +- Remove deprecated `set ttyfast` (no-op since Vim 8) +- Add `grepprg=rg --vimgrep` — `:grep` now uses ripgrep + quickfix +- Add `diffopt` with histogram algorithm and indent-heuristic +- Consolidate FZF Rg/RgWord/GFiles commands (DRY refactor) +- vim-tmux-navigator: conditional load (only inside tmux), fallback `Ctrl+hjkl` mappings outside +- Add `Ctrl+hjkl` window navigation fallback when tmux-navigator not loaded ## 2.1.0 — 2025-04-22 diff --git a/modules/core.vim b/modules/core.vim index 2db7a13..25e2ab4 100644 --- a/modules/core.vim +++ b/modules/core.vim @@ -160,9 +160,13 @@ augroup END " ── Performance ───────────────────────────────────────────────────────────── set synmaxcol=200 -set ttyfast set lazyredraw set complete-=i + +if executable('rg') + set grepprg=rg\ --vimgrep\ --smart-case + set grepformat=%f:%l:%c:%m +endif set updatetime=300 set shortmess+=cI @@ -183,6 +187,10 @@ set exrc set secure set sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal +if has("patch-8.1.0360") + set diffopt=filler,internal,context:3,algorithm:histogram,indent-heuristic +endif + " ── Format Options ────────────────────────────────────────────────────────── augroup ChopstickFormatOptions diff --git a/modules/navigation.vim b/modules/navigation.vim index 28d7a30..35390de 100644 --- a/modules/navigation.vim +++ b/modules/navigation.vim @@ -72,30 +72,27 @@ else let g:fzf_preview_window = ['right:50%', 'ctrl-/'] endif -if g:is_tty - command! -bang -nargs=* Rg - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --smart-case -- ' - \ .shellescape(), 1, 0) - command! -bang GFiles call fzf#vim#gitfiles('', 0) -else - command! -bang -nargs=* Rg - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --smart-case -- ' - \ .shellescape(), 1, fzf#vim#with_preview(), 0) - command! -bang GFiles call fzf#vim#gitfiles('', fzf#vim#with_preview(), 0) -endif +function! s:Preview() abort + return g:is_tty ? {} : fzf#vim#with_preview() +endfunction -if g:is_tty - command! -bang -nargs=* RgWord - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --smart-case -F -- ' - \ .shellescape(expand('')), 1, 0) -else - command! -bang -nargs=* RgWord - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --smart-case -F -- ' - \ .shellescape(expand('')), 1, fzf#vim#with_preview(), 0) +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case -- ' + \ .shellescape(), 1, s:Preview(), 0) +command! -bang -nargs=* RgWord + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case -F -- ' + \ .shellescape(expand('')), 1, s:Preview(), 0) +command! -bang GFiles call fzf#vim#gitfiles('', s:Preview(), 0) + +" ── Window Navigation ─────────────────────────────────────────────────────── + +if empty($TMUX) + nnoremap h + nnoremap j + nnoremap k + nnoremap l endif " ── Window Maximize Toggle ────────────────────────────────────────────────── diff --git a/modules/plugins.vim b/modules/plugins.vim index 2876619..93d18f1 100644 --- a/modules/plugins.vim +++ b/modules/plugins.vim @@ -49,6 +49,8 @@ Plug 'fatih/vim-go', { 'for': 'go' } Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' } Plug 'mhinz/vim-startify' Plug 'lifepillar/vim-solarized8' -Plug 'christoomey/vim-tmux-navigator' +if !empty($TMUX) + Plug 'christoomey/vim-tmux-navigator' +endif call plug#end()