Skip to content

feat: add name_on_tag, suggest_name, and confirm_untag prompts to toggle()#200

Open
awerebea wants to merge 3 commits into
cbochs:mainfrom
awerebea:feat/toggle-prompts
Open

feat: add name_on_tag, suggest_name, and confirm_untag prompts to toggle()#200
awerebea wants to merge 3 commits into
cbochs:mainfrom
awerebea:feat/toggle-prompts

Conversation

@awerebea

@awerebea awerebea commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Add three opt-in boolean settings that make toggle() interactive: prompt for a tag
name on creation (optionally pre-filled), and ask for confirmation before removal.

New settings:

  • name_on_tag (boolean, default false): when true, toggle() shows a
    vim.ui.input prompt ("Tag name (optional):") before creating a tag. Empty
    input -> unnamed tag; <Esc> cancels without tagging.
  • suggest_name (boolean, default false): when true (and name_on_tag is
    also true), the name prompt is pre-filled with the file stem of the current
    buffer. Regular files lose their extension (my_file.txt -> my_file);
    hidden files keep their full name (.config -> .config). The suggestion is
    editable. Has no effect when name_on_tag is false.
  • confirm_untag (boolean, default false): when true, toggle() shows a
    vim.fn.confirm dialog before removing an existing tag. The default choice is
    No, so an accidental <CR> is safe.

Implementation notes:

  • Fast path: when all three settings are false, the original single
    enter_with_save code path is taken with zero overhead.
  • vim.ui.input is async (callback-based), so tag existence is checked first
    with enter_with_result, then the save is performed inside the appropriate
    sync or async branch.
  • Only toggle() is affected. tag() and untag() are unchanged.

No breaking changes. All settings default to false; existing behavior is
preserved exactly.

-- Example
require("grapple").setup({
    name_on_tag   = true,  -- prompt for a name when tagging
    suggest_name  = true,  -- pre-fill with file stem (e.g. "my_file")
    confirm_untag = true,  -- confirm before untagging
})

awerebea added 3 commits July 9, 2026 21:14
Add two opt-in settings that make the toggle() command interactive:

  name_on_tag (boolean, default false)
    When true, toggle() shows a vim.ui.input prompt before creating a
    new tag. Empty input creates an unnamed tag; Esc cancels silently.
    Respects any vim.ui.input override (snacks.nvim, dressing.nvim, etc).

  confirm_untag (boolean, default false)
    When true, toggle() shows a yes/no confirmation before removing an
    existing tag. Default choice is No so accidental <CR> is safe.

Both settings only affect toggle(). Direct tag() and untag() calls are
unchanged. The fast path (both settings false) preserves the original
synchronous implementation with no overhead.

Document both options in the settings block and in a dedicated
|grapple-toggle-prompts| help section with usage examples.
When suggest_name = true (requires name_on_tag = true), the vim.ui.input
prompt is pre-filled with the file stem of the current buffer:

  my_file.txt -> my_file
  .config     -> .config  (hidden files keep their full name)

The suggestion is editable; clearing it still creates an unnamed tag.
Has no effect when name_on_tag is false.
@awerebea awerebea changed the title feat: add name_on_tag and confirm_untag interactive prompts to toggle() feat: add name_on_tag, suggest_name, and confirm_untag prompts to toggle() Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant