repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

perf: defer safe plugins to improve startup time

6de78558d6984bdf105c28d223d9b09dc876d061

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Deferred plugins are user-interaction driven and don't need to load at startup:
- diff, fuzzy_find, bookmarks, jump2d, key_preview
- move, navigation, patterns, search_and_replace
- fun, splitjoin, winbar, notify

Plugins kept eager (required early or have autocmds):
- autotag, colorizer, devicons, file_explorer, format
- surround, textobjects, suppress_warnings, autopairs

Also fixes d2.lua to gracefully handle missing d2 binary:
- Lazy detection on first use instead of blocking startup
- Shows warning message when d2 not found
- Bail early in render/validate if binary missing

Changed files (2)

neovim/init.lua

Modified
83 83 defer 'bugabinga.inlay'
84 84 defer 'bugabinga.d2'
87 --- Key changes
88 --- - 6 redundant keymaps removedj(gra/gri/grn/grr/grt/CTRL-S — Neovim 0.11 defaults)
89 --- - 8 keymaps moved to buffer-local (grd, grwl, grwa, grwr, grc, grC, grh, grH)
90 --- - 3 new keymaps added (grD, grs, grl)
91 --- - Document highlight added (CursorHold + clear on CursorMoved)
92 --- - Codelens support added (grl + auto-refresh)
93 --- - LspRestart now: no args=buffer-local, bang=global, args=named
94 --- - LspReload uses vim.lsp.enable instead of deprecated stop_client
95 --- - Nil guards added to LspCapabilities/LspConfig
96 --- - Buffer-scoped inlay hint toggle
98 86 -- Plugins handle deferred loading via puk.
99 87 -- No need to use `defer(...)`
103 91 require 'bugabinga.autotag'
104 92 require 'bugabinga.colorizer'
105 93 require 'bugabinga.devicons'
106 -require 'bugabinga.diff'
94 +defer 'bugabinga.diff'
107 95 require 'bugabinga.file_explorer'
108 96 require 'bugabinga.format'
109 -require 'bugabinga.fuzzy_find'
110 -require 'bugabinga.bookmarks'
111 -require 'bugabinga.jump2d'
112 -require 'bugabinga.key_preview'
113 -require 'bugabinga.move'
114 -require 'bugabinga.navigation'
115 -require 'bugabinga.patterns'
116 -require 'bugabinga.search_and_replace'
117 -require 'bugabinga.fun'
118 -require 'bugabinga.splitjoin'
97 +defer 'bugabinga.fuzzy_find'
98 +defer 'bugabinga.bookmarks'
99 +defer 'bugabinga.jump2d'
100 +defer 'bugabinga.key_preview'
101 +defer 'bugabinga.move'
102 +defer 'bugabinga.navigation'
103 +defer 'bugabinga.patterns'
104 +defer 'bugabinga.search_and_replace'
105 +defer 'bugabinga.fun'
106 +defer 'bugabinga.splitjoin'
119 107 require 'bugabinga.surround'
120 108 require 'bugabinga.textobjects'
121 -require 'bugabinga.winbar'
109 +defer 'bugabinga.winbar'
122 110 require 'bugabinga.suppress_warnings'
123 111 require 'bugabinga.autopairs'
124 -require 'bugabinga.notify'
112 +defer 'bugabinga.notify'
126 114 require 'bugabinga.incubator'

neovim/lua/bugabinga/d2.lua

Modified
9 9 local PREVIEW_AUGRP = 'd2_preview_autosave'
10 10 local preview_winnr = nil
12 -local d2_binary = vim.system({ 'd2', '--version' }, { text = true }):wait().code == 0
13 - and 'd2'
14 - or 'd2.exe'
12 +local d2_binary = nil
13 +local d2_checked = false
15 +local function check_d2_binary()
16 + if d2_checked then return d2_binary end
17 + d2_checked = true
19 + for _, name in ipairs({ 'd2', 'd2.exe' }) do
20 + local result = vim.system({ name, '--version' }, { text = true }):wait()
21 + if result.code == 0 then
22 + d2_binary = name
23 + return d2_binary
24 + end
25 + end
27 + vim.notify(
28 + '[bugabinga/d2] `d2` not found. Install from https://github.com/terrastruct/d2',
29 + vim.log.levels.WARN
30 + )
31 + return nil
32 +end
16 34 local preview_bufnr = function()
17 35 return vim.fn.bufnr(PREVIEW_BUF_NAME)
31 49 local render = function(bufnr)
50 + if not check_d2_binary() then return nil end
32 51 local input_file = vim.fn.tempname() .. '.d2'
33 52 local output_file = vim.fn.tempname() .. '.txt'
34 53 local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
147 166 local validate = function(args)
167 + if not check_d2_binary() then return end
148 168 local bufnr = (args and args.bufnr) or vim.api.nvim_get_current_buf()
149 169 local file = vim.api.nvim_buf_get_name(bufnr)
150 - if not d2_binary then
151 - vim.notify('d2 binary not found', vim.log.levels.ERROR)
152 - return
153 - end
154 170 if file == '' then
155 171 return