Advice on using custom assets.
Description
I don't know if this belongs here.. but, I was just looking for a better way of using custom assets... Currently, I'm using a hugeeeee table with external links to the assets.
--- NOTE: all list of language icons for presence.nvim, the discord-rpc client for neovim.
local function lambda(filename)
return {
[filename] = {
filename:sub(1, 1):upper() .. filename:sub(2),
"https://raw.githubusercontent.com/smokes/vscode-discord-assets/master/" .. filename .. ".png",
},
}
end
local wrapped = vim.tbl_map(lambda, {
"ahk",
"android",
"angular",
"applescript",
"appveyor",
"arduino",
"as",
"asp",
"assembly",
"autoit",
"babel",
"bat",
"bower",
"brainfuck",
"c",
"cargo",
"circleci",
"clojure",
"cmake",
"codeclimate",
"coffee",
"cpp",
"crystal",
"csharp",
"cshtml",
"css",
"cssmap",
"cuda",
"d",
"dart",
"debug",
"delphi",
"dm",
"docker",
"editorconfig",
"ejs",
"elixir",
"elm",
"env",
"erlang",
"eslint",
"firebase",
"flowconfig",
"fsharp",
"gatsbyjs",
"gemfile",
"git",
"go",
"gradle",
"graphql",
"gruntfile",
"gulp",
"handlebars",
"haskell",
"haxe",
"heroku",
"html",
"http",
"jar",
"java",
"jest",
"js",
"jsmap",
"json",
"jsx",
"julia",
"kotlin",
"less",
"lisp",
"livescript",
"log",
"lua",
"makefile",
"manifest",
"markdown",
"markdownx",
"marko",
"nim",
"nodemon",
"npm",
"objc",
"ocaml",
"pascal",
"pawn",
"perl",
"php",
"postcss",
"powershell",
"prettier",
"prisma",
"pug",
"purescript",
"python",
"r",
"README.md",
"reasonml",
"ruby",
"rust",
"scala",
"scss",
"shell",
"sql",
"stylus",
"svg",
"swift",
"tex",
"text",
"toml",
"travis",
"ts",
"tsx",
"twig",
"txt",
"typescript-def",
"vb",
"vba",
"vcxproj",
"vscode-big",
"vscode-insiders",
"vscode",
"vscodeignore",
"vue",
"wasm",
"webpack",
"xml",
"yaml",
"yarn",
})
local M = {}
for _, item in ipairs(wrapped) do
for lang, info in pairs(item) do
M[lang] = info
end
end
M["md"] = { "Markdown", "https://raw.githubusercontent.com/smokes/vscode-discord-assets/master/markdown.png" }
M["README.md"] = {
"Markdown",
"https://raw.githubusercontent.com/pagankeymaster/lambda-wallpapers/main/devicons/README.md.png",
}
M["[packer]"] = {
"PackerStatus",
"https://raw.githubusercontent.com/pagankeymaster/lambda-wallpapers/main/devicons/packer.png",
}
M["NvimTree_1"] = {
"NvimTree",
"https://raw.githubusercontent.com/pagankeymaster/lambda-wallpapers/main/devicons/nvimtree.png",
}
M["Python"] = {
"Python",
"https://raw.githubusercontent.com/pagankeymaster/lambda-wallpapers/main/devicons/python.png",
}
M["py"] = {
"Python",
"https://raw.githubusercontent.com/smokes/vscode-discord-assets/master/python.png",
}
M["yuck"] = {
"Yuck",
"https://raw.githubusercontent.com/pagankeymaster/lambda-wallpapers/main/devicons/yuck.png",
}
M["zsh"] = {
"Zsh",
"https://raw.githubusercontent.com/smokes/vscode-discord-assets/master/shell.png",
}
M["Bash"] = {
"Bash",
"https://raw.githubusercontent.com/smokes/vscode-discord-assets/master/shell.png",
}
M["Fish"] = {
"Fish",
"https://raw.githubusercontent.com/smokes/vscode-discord-assets/master/shell.png",
}
M["sh"] = {
"Sh",
"https://raw.githubusercontent.com/smokes/vscode-discord-assets/master/shell.png",
}
return M
Also, a common option for using the same asset for different filetypes would be nice.
-- Like this kinda? I don't know if it exists already...
local assets = {
{ filetypes = { "sh:Sh", "bash:Bash", "zsh:Zsh", "fish:Fish" }, source = "https://shorturl.at/kGKSX" },
{ filetypes = "lua:Lua", source = "https://shorturl.at/syFW0" },
}
Neovim version
NVIM v0.8.0-dev+57-gaf82eab94
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
OS information
Linux 5.17.4-arch1-1 x86_64
Steps to reproduce
Not applicable.
Logs
Not applicable.
Hi @pagankeymaster, sorry for the late response!
Unfortunately there isn't an alternative method of setting custom assets, as the table structure is what's used internally (see file_assets.lua) and the feature to support custom assets was simply an extension of it. I personally just use the default assets, so I didn't notice that it could be unwieldy if most if not all assets are to be configured with image URLs. I think these are valid and good suggestions!
I noted some potential opportunities for the plugin in this comment, I'm curious whether what you're looking for is to be able to create custom themes? Or maybe something like a config to set some custom asset repository? Any ideas for an API?