{"id":24466428,"url":"https://github.com/0oastro/silicon.lua","last_synced_at":"2025-04-05T09:04:49.034Z","repository":{"id":62099154,"uuid":"441508579","full_name":"0oAstro/silicon.lua","owner":"0oAstro","description":"Beautiful code snippet images right in the most epic editor :chef_kiss:","archived":false,"fork":false,"pushed_at":"2025-03-09T16:23:27.000Z","size":390,"stargazers_count":150,"open_issues_count":9,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T07:34:29.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0oAstro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-24T16:17:44.000Z","updated_at":"2025-03-10T03:36:21.000Z","dependencies_parsed_at":"2024-10-31T19:32:06.165Z","dependency_job_id":"ac88813f-c60a-41ef-bde1-9eb4591f8c2c","html_url":"https://github.com/0oAstro/silicon.lua","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fsilicon.lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fsilicon.lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fsilicon.lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0oAstro%2Fsilicon.lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0oAstro","download_url":"https://codeload.github.com/0oAstro/silicon.lua/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312068,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-21T06:14:39.013Z","updated_at":"2025-04-05T09:04:48.933Z","avatar_url":"https://github.com/0oAstro.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# silicon.lua\n\n**silicon** is a lua plugin for neovim to generate beautiful images of code snippet using [silicon](https://github.com/aloxaf/silicon) \n\n\u003cvideo src = \"https://user-images.githubusercontent.com/79555780/198016165-7a47ac6c-e329-4025-8d66-f9b34bd52658.mp4\"\u003e\u003c/video\u003e\n\n## ✨ Features\n\n- **beautiful** images of source code, saved to preferred place.\n- **copy** to clipboard\n\n## ⚡️ Requirements\n\n- Neovim \u003e= 0.6.0\n- [silicon](https://github.com/aloxaf/silicon)\n- [wl-clipboard](https://github.com/bugaevc/wl-clipboard) (on wayland)\n\n## 📦 Installation\n\nInstall the plugin with your preferred package manager:\n\n### [packer](https://github.com/wbthomason/packer.nvim)\n\n```lua\n-- Lua\nuse {\n  \"narutoxy/silicon.lua\",\n  requires = { \"nvim-lua/plenary.nvim\" },\n  config = function()\n    require('silicon').setup({})\n  end\n}\n```\n\n### [vim-plug](https://github.com/junegunn/vim-plug)\n\n```vim\n\" Vim Script\nPlug 'nvim-lua/plenary.nvim'\nPlug 'narutoxy/silicon.lua'\n\nlua require('silicon').setup({})\n```\n\n## ⚙️ Configuratioon\n\nsilicon comes with the following defaults:\n\n```lua\n{\n\ttheme = \"auto\",\n\toutput = \"SILICON_${year}-${month}-${date}_${time}.png\", -- auto generate file name based on time (absolute or relative to cwd)\n\tbgColor = vim.g.terminal_color_5,\n\tbgImage = \"\", -- path to image, must be png\n\troundCorner = true,\n\twindowControls = true,\n\tlineNumber = true,\n\tfont = \"monospace\",\n\tlineOffset = 1, -- from where to start line number\n\tlinePad = 2, -- padding between lines\n\tpadHoriz = 80, -- Horizontal padding\n\tpadVert = 100, -- vertical padding\n\tshadowBlurRadius = 10,\n\tshadowColor = \"#555555\",\n\tshadowOffsetX = 8,\n\tshadowOffsetY = 8,\n\tgobble = false, -- enable lsautogobble like feature\n\tdebug = false, -- enable debug output\n}\n```\n\n# 🚀 Usage\n\n## Keymaps\n\n```lua\n-- Generate image of lines in a visual selection\nvim.keymap.set('v', '\u003cLeader\u003es',  function() silicon.visualise_api({}) end )\n-- Generate image of a whole buffer, with lines in a visual selection highlighted\nvim.keymap.set('v', '\u003cLeader\u003ebs', function() silicon.visualise_api({to_clip = true, show_buf = true}) end )\n-- Generate visible portion of a buffer\nvim.keymap.set('n', '\u003cLeader\u003es',  function() silicon.visualise_api({to_clip = true, visible = true}) end )\n-- Generate current buffer line in normal mode\nvim.keymap.set('n', '\u003cLeader\u003es',  function() silicon.visualise_api({to_clip = true}) end )\n```\n\n## Command line\n\nCalling `silicon.visualise_api` with `lua` in command line doesn't work due to `lua` not supporting ranges.  \nThis means that the moment you hit enter, you leave visual mode before lua function is called. While this populates two registers, using them doesn't work with \"v\" mode maps.  \nA workaround has been implemented, and a shorthand that forces it is available as `.visualise_cmdline`:\n\n- Generate image of lines in a visual selection\n\n    ```lua\n    lua require('silicon').visualise_cmdline({})\n    ```\n\n- Generate image of a whole buffer, with lines in a visual selection highlighted\n\n    ```lua\n    lua require('silicon').visualise_cmdline({to_clip = true, show_buf = true})\n    ```\n\n- Generate visible portion of a buffer\n\n    ```lua\n    lua require('silicon').visualise_cmdline({to_clip = true, visible = true})\n    ```\n\n## Notes\n\n- The default path of image is the current working directory of the editor, but you can change it by\n\n    ```lua\n    require(\"silicon\").setup({\n            output = \"/home/astro/Pictures/SILICON_$year-$month-$date-$time.png\"),\n    })\n    ```\n\n## Colorscheme reloading\n\nAutogenerated silicon themes are unaware of dark/light variants.\nUtility functions had been exposed that allow regenerating theme on demand:\n\n- `require(\"silicon.utils\").build_tmTheme()` builds a new tmTheme file from current colorscheme\n- `require(\"silicon.utils\").reload_silicon_cache()` calls `silicon --build-cache`\n\nThis lets one regenerate theme when switching background setting or otherwise reloading `ColorScheme`:\n\n```lua\nvim.api.nvim_create_augroup('SiliconRefresh', { clear = true })\nvim.api.nvim_create_autocmd({ 'ColorScheme' },\n\t{\n\tgroup = 'SiliconRefresh',\n\tcallback = function()\n\t\tsilicon_utils.build_tmTheme()\n\t\tsilicon_utils.reload_silicon_cache({async = true})\n\tend,\n\tdesc = 'Reload silicon themes cache on colorscheme switch',\n\t}\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0oastro%2Fsilicon.lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0oastro%2Fsilicon.lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0oastro%2Fsilicon.lua/lists"}