HakonHarnes / img-clip.nvim

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

Enter Description instead of Filename #76

Open Grueslayer opened 4 months ago

Grueslayer commented 4 months ago

Is your feature request related to a problem? Please describe.

No

Describe the solution you'd like

I would like to type the Description / Title of the image to paste to my markdown. And create the filename from that words (replacing invalid chars, in best case with a lua function callback)

e.g. „Preferences - AddOn Page“ is the title I enter and creates a file „preferences___addon_page.png“

In best case not as input, but directly as vim command, so I can use last call.

Describe alternatives you've considered

Keep using my own plugin

https://github.com/Grueslayer/vim-clipimg

Additional context -/-

HakonHarnes commented 4 months ago

This should be doable from within the plugin configuration:

  opts = {
    default = {
      file_name = function()
        local desctipion = vim.fn.input("Description: ")
        return desctipion:lower():gsub("[^a-z0-9]", "_")
      end,
      prompt_for_file_name = false,
    },
  },

Does that resolve your issue?

Grueslayer commented 4 months ago

Not completely, I than have to retype the same phrase in the markdown code again. Did you had a look at my PR #77, it’s a small one adding another placeholder $CAPTION, so you type the caption once, it’s used for the filename and inserted into the markup text.