nvimConfig/plugin/27_image.lua
Daniel 3f2ab6ef96 fix: address R1 (image.nvim backend) + C4 (cat-gate consistency)
Tackles the two outstanding items from the post-fix consistency
pass on top of `df2f776`.

* R1 -- plugin/27_image.lua: removed the explicit `backend = "auto"`
  line. image.nvim's setup() does not accept "auto" / "none" as
  literal values; the practical default is to leave `backend` unset,
  letting image.nvim auto-detect the right graphics protocol
  (kitty / wezterm / iterm / sixel) at runtime and falling back to
  no rendering on unsupported terminals. Inline comment explains the
  omission so a future reader doesn't "fix" it back.

* C4 -- modules/module/specs/plugins.nix:
  - Removed `nvim-dap`, `nvim-dap-ui`, `nvim-dap-virtual-text`,
    and `image-nvim` from `config.specs.utils-lazy`. They are R- and
    Markdown-specific, not general utility plugins, so they should
    not depend on `utils=true`.
  - Added a new `config.specs.r-lazy` spec carrying those same four
    plugins, gated by `cats.r`. Users with `r=true` and `utils=false`
    now get a working R debugger (via vscDebugger) and in-buffer
    image rendering for plots.
  - Added `image-nvim` to the existing `config.specs.markdown-lazy`
    so users with `markdown=true` and no other cats still see inline
    plots in Quarto / Markdown documents. nixCats dedups packages
    by pname, so `image-nvim` appears once on the runtime path even
    when both `r` and `markdown` are on.

These two changes close the real correctness bugs surfaced by the
consistency review: `plugin/26_dap.lua` and `plugin/27_image.lua`'s
cat-gated `Config.add(...)` calls previously depended on
`utils=true` resolving the four packages, leaving `r=true` (or
`markdown=true`) only users without DAP / image-nvim even though the
Lua gate let the setup function proceed.

Files: 2 modified. Local verification (`nix flake check --no-build`)
still required before merging PR #12.
2026-07-26 06:47:58 +00:00

50 lines
1.5 KiB
Lua

local Config = require('config')
local later = MiniDeps.later
local nix = require('config.nix')
-- Only load image-nvim when a cat that benefits from in-buffer plots is on.
later(function()
if not nix.get_cat({ "r", "markdown" }, false) then
return
end
Config.add("image-nvim")
end)
later(function()
if not nix.get_cat({ "r", "markdown" }, false) then
return
end
local ok, image = pcall(require, "image")
if not ok then
vim.notify("image.nvim not available", vim.log.levels.DEBUG)
return
end
image.setup({
-- Backend is intentionally NOT set so image.nvim auto-detects the
-- graphics protocol (kitty / wezterm / iterm / sixel) at runtime and
-- falls back to no rendering on unsupported terminals. The literal
-- strings "auto" / "none" are not accepted by image.nvim.setup(), so
-- setting either would silently disable rendering everywhere.
integrations = {
markdown = {
enabled = true,
clear_in_insert_mode = false,
download_remote_images = true,
only_render_image_at_cursor = false,
filetypes = { "markdown", "quarto" },
},
},
max_width = nil,
max_height = nil,
max_width_window_percentage = nil,
max_height_window_percentage = 50,
window_overlap_clear_enabled = false,
window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs" },
editor_only_render_when_focused = false,
hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" },
})
end)