Skip to content

Conversation

jonboh
Copy link
Contributor

@jonboh jonboh commented Dec 30, 2024

This setting is almost identical to follow_url_func.
Currently if one tries to add this setting like this:

plugins.obsidian = {
  # ...
  settings = {
    follow_img_func = ''
    function(img)
      vim.fn.jobstart { "xdg-open", img }
    end
  ''; 
    follow_url_func = ''
      function(url)
        vim.fn.jobstart({"xdg-open", url})  -- linux
      end
  '';
}; 
}    

The generated configuration uses the literal string, and fails when used:

      follow_img_func = 'function(img)\n  vim.fn.jobstart({"xdg-open", img})  -- linux\nend\n',
      follow_url_func = function(url)
          vim.fn.jobstart({ "xdg-open", url }) -- linux
      end,

@khaneliman
Copy link
Contributor

This setting is almost identical to follow_url_func. Currently if one tries to add this setting like this:

plugins.obsidian = {
  # ...
  settings = {
    follow_img_func = ''
    function(img)
      vim.fn.jobstart { "xdg-open", img }
    end
  ''; 
    follow_url_func = ''
      function(url)
        vim.fn.jobstart({"xdg-open", url})  -- linux
      end
  '';
}; 
}    

The generated configuration uses the literal string, and fails when used:

      follow_img_func = 'function(img)\n  vim.fn.jobstart({"xdg-open", img})  -- linux\nend\n',
      follow_url_func = function(url)
          vim.fn.jobstart({ "xdg-open", url }) -- linux
      end,

This is a freeform module so you can supply whatever configuration you want. If you want it to be a raw lua string, you can just change your definition in your configuration:

     follow_img_func.__raw = ''
       function(img)
         vim.fn.jobstart { "xdg-open", img }
       end
     ''; 

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.

2 participants