Skip to content

[audit] image.lua: preview_image() is dead code — complete or remove #175

Description

@stanfish06

What

lua/config/image.lua defines a preview_image() function that is never called, never exported from the module, and has commented-out window-creation code. The file is required from init.lua but contributes nothing at startup.

Where

lua/config/image.lua (full file, 12 lines):

local function preview_image(path)
    local id = vim.ui.img.set(
        vim.fn.readblob(path),
        { row = 0, col = 0, width = 100, height = 50, zindex = 0 }
    )
    return id
end

init.lua:7 — require("config.image") loads this file every startup.

Why it matters

  1. Silently non-functional: vim.ui.img.set() is an experimental Neovim 0.12 image API. The function is never invoked, so any API breakage goes undetected.
  2. Misleading require: The init.lua load implies something happens at startup, but nothing does.
  3. Incomplete feature: Commented-out window-creation code suggests a float-based image preview was planned but never finished.

Recommended action

Option A — Remove: Delete lua/config/image.lua and the require("config.image") line in init.lua:7 until the feature is ready.

Option B — Complete: Wire preview_image() to a :PreviewImage command or keymap that opens an image in a float. Guard with if vim.fn.has("nvim-0.12") == 1.

Option C — Mark as stub: Add a -- TODO comment and keep the file as a placeholder for when vim.ui.img stabilises.

Activity

  1. stanfish06 commented on Jun 20, 2026

    @stanfish06
    OwnerAuthor

    Additional context found during a later audit pass: the dead code extends one level further than image.lua itself. lua/lib/ui.lua's Window.create_tmp_float_window() exists solely to be called from image.lua's commented-out line (-- mod_ui.Window.create_tmp_float_window()), and has no other caller anywhere in the repo. Whichever option is chosen here (remove/complete/stub), lib/ui.lua should be handled in the same pass — Option A (remove) should also delete lib/ui.lua (and the require("lib.ui") in image.lua) since nothing else references it; Option B (complete) would actually wire that float-window helper up.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions