Vim 9.1+ config optimization: DX, cleanup, lazy-loading#10
Open
Vim 9.1+ config optimization: DX, cleanup, lazy-loading#10
Conversation
…ppings
why: <Leader>p mapped to both copy-path (line 27) and
bprevious (line 109), with bprevious silently winning;
multiple duplicate buffer navigation bindings existed
what:
- Keep <Leader>p for copy file path (restore original intent)
- Consolidate buffer nav to <Leader>]/[ only (nnoremap)
- Keep single <Leader><BS> for :BB (alt buffer)
- Remove duplicate <leader>3 format mapping (keep <leader>f)
- Remove commented-out arrow resize and nerdcommenter mappings
- Fix <Leader>]/[ from map to nnoremap (convention fix)
why: BufClose config references a removed plugin; version
guards and ttyfast are no-ops on Vim 9.1+;
javascript_enable_domhtmlcss is read by no installed
plugin or Vim 9.1 runtime file
what:
- Remove BufClose config from autocmd.vim (g:BufClose_AltBuffer,
cnoreabbr bq)
- Remove dead javascript_enable_domhtmlcss variable
- Remove commented-out gruvbox-material from plugins.vim
- Remove empty v:version >= 800 block from vimrc
- Remove no-op set ttyfast from vimrc
why: autochdir silently undoes vim-rooter's directory changes
on every buffer switch, breaking LSP working directory
expectations and making :Rg/:FZFRoot behavior
unpredictable
what:
- Remove set autochdir from vimrc
- vim-rooter (manual mode), <space> FZFRoot, and :Rooter
remain available for project-root navigation
why: lib#ColorSchemeExists executes 'colorscheme <name>' to
check existence, which fires ColorScheme autocommands
and pollutes highlight groups as a side effect; every
scheme in the fallback chain gets applied then discarded
what:
- Replace try/catch colorscheme with globpath-based check
- Remove gruvbox-material from fallback chain (plugin not
installed)
- Update test allowed colorscheme list
why: sonokai not in colorscheme fallback chain (dead weight);
ag.vim superseded by FZF+ripgrep (:Rg, :RG, <C-F>);
nvim-yarp/vim-hug-neovim-rpc unused since wilder.nvim
sets use_python_remote_plugin=0
what:
- Remove sonokai from plugin declarations
- Remove ag.vim from s:conditional_plugins
- Remove nvim-yarp and vim-hug-neovim-rpc from Vim 8 branch
- Update gated_plugins.vim test assertions
why: yats.vim is a superset of typescript-vim with TSX
support; loading both risks syntax highlight conflicts
what:
- Remove leafgarland/typescript-vim from node conditional
plugins
- Update gated_plugins.vim test assertions
why: Three formatting systems (ALE fix_on_save, coc-prettier,
vim-autoformat) could conflict; <leader>f used Vim's
primitive gg=G re-indent instead of LSP formatting
what:
- Remove vim-autoformat plugin (dprint JSON/TOML formatting)
- Add JSON/TOML to CoC formatOnSave scope in coc-settings
- Add b:biome_checked guard to avoid redundant findfile()
- Set b:coc_preferences_formatOnSave=false when Biome is
detected to prevent ALE+CoC double-format
- Remap <leader>f to CocActionAsync('format') for LSP-aware
formatting
why: No statusline means no visibility into git branch,
ALE diagnostics, or file state during editing
what:
- Add lightline.vim plugin with CoC-git and ALE integration
- Add LightlineGitStatus component using g:coc_git_status
and b:coc_git_status
- Add LightlineALE component showing E:/W: diagnostic counts
- Hook CocGitStatusChange and ALELintPost for live updates
- Remove manual rulerformat from settings.vim (lightline
handles statusline)
why: Version checks for Vim < 7.4 are dead code on Vim 9.1+;
fish shell fix targeted a Vim 7.4 bug that was patched
long ago
what:
- Flatten always-true has('autocmd') conditional
- Flatten always-true v:version > 703 formatoptions guard
- Remove always-false fish shell fix for Vim < 7.4.276
- Keep nvim compat guard, t_Co terminal check, matchit load
why: NERDTree loads on every startup but is only used
on-demand via <leader>e; lazy loading defers its cost
what:
- Add 'on' option to defer NERDTree until NERDTreeFocus,
NERDTreeToggle, or NERDTree commands are called
- g:NERDTreeShowHidden and g:NERDTreeIgnore are set eagerly
at startup via global vars (unaffected by lazy loading)
why: Copilot starts a Node.js process on VimEnter; deferring
to BufReadPost gives it time to initialize while the
user reads the file, avoiding startup cost
what:
- Use plug#load on BufReadPost ++once to lazy-load copilot
- g:copilot_filetypes config set eagerly (unaffected by
deferred loading)
- BufReadPost chosen over InsertEnter to front-load Node.js
initialization before user enters insert mode
why: Language plugins load on every startup but are only
needed when editing matching filetypes
what:
- Restructure s:conditional_plugins entries to support
[spec, opts] lists alongside plain strings
- Add type() dispatch in loop to pass opts to PlugIfCommand
- Add 'for' lazy-load option to Dockerfile, yats, vue, mdx,
jsx-improve, html-template-literals, rust, terraform, and
elixir plugins
- vim-plug loads ftdetect/ even for lazy plugins, so
filetype detection is unaffected
why: Provide comprehensive coverage of vim-rooter behavior
across auto/manual modes, non-project fallbacks, and
autochdir interactions before changing rooter config
what:
- Add 11 parametrized scenarios via pytest + generated
Vimscript suites exercising FindRootDirectory() and cwd
- Cover auto-rooter with .git, Pipfile, deep nesting,
non-project current/empty fallback, manual :Rooter,
autochdir interactions, and multiple root markers
- Note autochdir limitation in Vim headless Ex mode
why: With autochdir removed (commit ec78fa8), enable vim-rooter auto mode for LazyVim-like project root DX; 'current' fallback preserves :e relative-to-file behavior for non-project files (the original 2018 autochdir motivation from commit 5e7996d) what: - Set g:rooter_manual_only = 0 (was 1) - Set g:rooter_change_directory_for_non_project_files to 'current' for autochdir-like fallback
why: With g:rooter_manual_only = 0, the BufEnter autocmd
changes cwd before any manual :Rooter invocation;
the old manual-mode assertion is now invalid
what:
- Rename Test_rooter_command_changes_to_project_root to
Test_rooter_auto_changes_to_project_root
- Assert cwd equals project root immediately after
VimTestOpen (no explicit :Rooter needed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive optimization of the Vim configuration targeting DX ergonomics, dead code removal, architecture fixes, and startup performance. Each commit is atomic and independently revertible.
Bug Fixes
<Leader>pconflict:<Leader>pwas mapped to both copy-path (line 27) and:bprevious(line 109), with bprevious silently winning. Restored copy-path intent, consolidated buffer nav to<Leader>]/[onlyautochdirvsvim-rooterconflict:autochdirsilently undoes vim-rooter's directory changes on every buffer switch, breaking LSP and FZF working directory expectationslib#ColorSchemeExistsside effect: replacedcolorscheme <name>try/catch (which applies every scheme in the fallback chain) with side-effect-freeglobpath()checkDead Code Removal
javascript_enable_domhtmlcss(no consumer),set ttyfast(always-on in Vim 9.1), emptyv:version >= 800block, commented-out gruvbox-materialhas('autocmd'),v:version > 703, fish shell fix for Vim < 7.4.276)Plugin Audit
use_python_remote_plugin=0)New Features
CocGitStatusChangeandALELintPosthooks<leader>fremapped from primitivegg=Gre-indent toCocActionAsync('format')for LSP-aware formattingformatOnSavescope (replaces vim-autoformat's dprint)b:biome_checkedguard +b:coc_preferences_formatOnSave=falseprevents ALE+CoC double-format when Biome is detectedStartup Performance
NERDTreeFocus/NERDTreeToggle/NERDTree)BufReadPost ++once(front-loads Node.js init while user reads file)Stats
Test plan
just test— 13 passed (hermetic core + startup suites)just test-integration— 2 passed (gated plugins + project root)<Leader>pcopies path,<Leader>]/[navigate buffers.tsfile with/without biome.json, verify single formatter<leader>eopens NERDTree (lazy-loaded)