0oAstro / silicon.lua

Beautiful code snippet images right in the most epic editor :chef_kiss:
The Unlicense
150 stars 10 forks source link

How to specify folder to save screenshot to? #4

Closed lsshawn closed 2 years ago

lsshawn commented 2 years ago

At the moment, all screenshot is generated to the working directory.

How can I configure the default saving location?

0oAstro commented 2 years ago
require("silicon").setup({
        output = string.format( 
                 "/home/astro/Pictures/SILICON_%s-%s-%s_%s-%s.png", 
                 os.date("%Y"), 
                 os.date("%m"), 
                 os.date("%d"), 
                 os.date("%H"), 
                 os.date("%M") 
         ),
})

It should be absolute path

aslak01 commented 2 years ago

I've configured the output dir as follows, but it appears to still save with the default name to cwd:

      { "narutoxy/silicon.lua", requires = "nvim-lua/plenary.nvim",
        config = function()
          require("silicon").setup({
            output = string.format(
              "/Users/as/Pictures/code/SS_%s-%s-%s_%s-%s.png",
              os.date("%Y"),
              os.date("%m"),
              os.date("%d"),
              os.date("%H"),
              os.date("%M")
            ),
            font = "JetBrainsMono Nerd Font Regular"
          })
        end
      }

Font specification statement below works correctly tho.

0oAstro commented 2 years ago

Strange, it should have worked.

Does the notification states correct location or it also states default one?

aslak01 commented 2 years ago

The notification only mentions the default filename.

aslak01 commented 2 years ago

I found out why it didn't work, there's some caching of the settings call going on. Not sure if it's on my end, maybe due to Astrovim or what, but some combination of restarting vim and running :PackerSync clears the cache and applies the config.

0oAstro commented 2 years ago

Pro Tip: Always do :PackerSync when changing anything.

It was on your end as packer compiled old config function and hence the output setting wasn't being applied.

aslak01 commented 2 years ago

@NarutoXY Yeah, I noticed my astrovim config is not really compatible with this add-on. It also seems to cache the timestamp to whenever I last ran packer sync, so making new screenshots doesn't work as expected.