1
0
mirror of https://github.com/jiriks74/presence.nvim synced 2024-11-23 20:37:50 +01:00

Support more files and update default asset

- Use `code` instead of `file` as default asset
- Check filename before extension in file asset assignment
- Support a lot more files and file extensions
This commit is contained in:
Andrew Kwon 2021-04-04 17:22:53 -07:00
parent c61fd0f7ae
commit 41c1221cad
2 changed files with 62 additions and 2 deletions

@ -1,42 +1,91 @@
-- Discord application asset file names (name, key[, description]) by file extension
return {
COMMIT_EDITMSG = { "git", "git" },
Makefile = { "Makefile", "config" },
[".dockercfg"] = { "Docker", "docker" },
[".dockerfile"] = { "Docker", "docker" },
[".dockerignore"] = { "Docker", "docker" },
[".eslintrc.cjs"] = { "ESLint", "eslint" },
[".eslintrc.js"] = { "ESLint", "eslint" },
[".eslintrc.json"] = { "ESLint", "eslint" },
[".eslintrc.yaml"] = { "ESLint", "eslint" },
[".eslintrc.yml"] = { "ESLint", "eslint" },
[".gitattributes"] = { "git", "git" },
[".gitconfig"] = { "git", "git" },
[".gitignore"] = { "git", "git" },
[".gitmodules"] = { "git", "git" },
[".prettierrc"] = { "Prettier", "prettier" },
[".prettierrc.cjs"] = { "Prettier", "prettier" },
[".prettierrc.js"] = { "Prettier", "prettier" },
[".prettierrc.json"] = { "Prettier", "prettier" },
[".prettierrc.json5"] = { "Prettier", "prettier" },
[".prettierrc.toml"] = { "Prettier", "prettier" },
[".prettierrc.yaml"] = { "Prettier", "prettier" },
[".prettierrc.yml"] = { "Prettier", "prettier" },
[".tmux.conf"] = { "tmux", "tmux" },
[".vimrc"] = { ".vimrc", "vim" },
["Dockerfile"] = { "Docker", "docker" },
["docker-compose.yaml"] = { "Docker", "docker" },
["docker-compose.yml"] = { "Docker", "docker" },
["nginx"] = { "NGINX", "nginx" },
["nginx.conf"] = { "NGINX", "nginx" },
["prettier.config.cjs"] = { "Prettier", "prettier" },
["prettier.config.js"] = { "Prettier", "prettier" },
["webpack.config.js"] = { "Webpack", "webpack" },
abookrc = { "abook", "abook" },
addressbook = { "abook", "abook" },
ahk = { "Autohotkey", "autohotkey" },
applescript = { "Applescript", "applescript" },
bash = { "Shell", "shell" },
c = { "C ", "c" },
cc = { "C++", "c_plus_plus" },
cf = { "Configuration file", "config" },
cfg = { "Configuration file", "config" },
clj = { "Clojure", "clojure" },
cljs = { "ClojureScript", "clojurescript" },
cnf = { "Configuration file", "config" },
coffee = { "CoffeeScript", "coffeescript" },
conf = { "Configuration file", "config" },
config = { "Configuration file", "config" },
cpp = { "C++", "c_plus_plus" },
cr = { "Crystal", "crystal" },
cs = { "C#", "c_sharp" },
css = { "CSS", "css" },
cxx = { "C++", "c_plus_plus" },
dart = { "Dart", "dart" },
elm = { "Elm", "elm" },
erl = { "Erlang", "erlang" },
ex = { "Elixir", "elixir" },
fs = { "F#", "f_sharp" },
go = { "Go", "go" },
gql = { "GraphQL", "graphql" },
graphql = { "GraphQL", "graphql" },
h = { "C header file", "c" },
hack = { "Hack", "hack" },
hpp = { "C++ header file", "c_plus_plus" },
hs = { "Haskell", "haskell" },
html = { "HTML", "html" },
hx = { "Haxe", "haxe" },
hxx = { "C++ header file", "c_plus_plus" },
ini = { "Configuration file", "config" },
java = { "Java", "java" },
jl = { "Julia", "julia" },
js = { "JavaScript", "javascript" },
json = { "JSON", "json" },
jsx = { "React", "react" },
kt = { "Kotlin", "kotlin" },
less = { "Less", "less" },
log = { "Log file", "code" },
lua = { "Lua", "lua" },
markdown = { "Markdown", "markdown" },
md = { "Markdown", "markdown" },
mjs = { "JavaScript", "javascript" },
nim = { "Nim", "nim" },
nix = { "Nix", "nix" },
pcss = { "PostCSS", "postcss" },
php = { "PHP", "php" },
pl = { "Perl", "perl" },
postcss = { "PostCSS", "postcss" },
ps1 = { "PowerShell", "powershell" },
purs = { "PureScript", "purescript" },
py = { "Python", "python" },
@ -44,16 +93,24 @@ return {
rb = { "Ruby", "ruby" },
re = { "Reason", "reason" },
rs = { "Rust", "rust" },
sass = { "Sass", "sass" },
scala = { "Scala", "scala" },
scss = { "Sass", "scss" },
sh = { "Shell", "shell" },
snap = { "Jest Snapshot", "jest" },
svelte = { "Svelte", "svelte" },
svg = { "SVG", "markup" },
swift = { "Swift", "swift" },
tex = { "TeX", "tex" },
text = { "Text file", "text" },
toml = { "TOML", "toml" },
ts = { "TypeScript", "typescript" },
tsx = { "React", "react" },
txt = { "Text file", "text" },
vim = { "Vim", "vim" },
viml = { "Vim", "vim" },
vue = { "Vue", "vue" },
xml = { "XML", "markup" },
yaml = { "YAML", "yaml" },
yml = { "YAML", "yaml" },
zsh = { "Shell", "shell" },

@ -392,13 +392,16 @@ function Presence:update_for_buffer(buffer, should_debounce)
local extension = self.get_file_extension(filename)
local parent_dirpath = self.get_dir_path(buffer)
self.log:debug(string.format("Parsed filename %s with %s extension", filename, extension or "no"))
-- Determine image text and asset key
local name = filename
local asset_key = "file"
local asset_key = "code"
local description = filename
local file_asset = extension and file_assets[extension] or file_assets[filename]
local file_asset = file_assets[filename] or file_assets[extension]
if file_asset then
name, asset_key, description = unpack(file_asset)
self.log:debug(string.format("Using file asset: %s", vim.inspect(file_asset)))
end
local file_text = description or name