HakonHarnes / img-clip.nvim

Effortlessly embed images into any markup language, like LaTeX, Markdown or Typst
MIT License
443 stars 7 forks source link

Prompt for caption and create filename from it #77

Open Grueslayer opened 3 months ago

Grueslayer commented 3 months ago

Related issue

Can be a possible solution for #76

Summary of changes

New option prompt_for_caption shows a prompt, creates a filename from it and replaces $CAPTION in template. If prompt_for_file_name is also given, the suggested filename is already available in prompt.

This works fine for me:

      require("img-clip").setup({
        default = {
          relative_to_current_file = true,
          prompt_for_caption = true,
          prompt_for_file_name = true,
          show_dir_path_in_prompt = true,
        },
        filetypes = {
          markdown = {
            url_encode_path = true,
            template = "![$CAPTION]($FILE_PATH)$CURSOR",
            download_images = false,
          },
        },
      })
HakonHarnes commented 2 months ago

Thanks for the PR. I like the idea of the caption.

I think the caption and file name are too tightly coupled at the moment. The idea of computing the file name directly from the caption in a non-configurable (and opinionated) way is not flexible enough. This should be configurable by the user.

I suggest you make the following changes:

This approach should allow more or less full flexibility to the user.

Let me know if you have any questions or if there's anything else I can assist with. I'm definitely open to merging this PR if you make the above changes!