Skip to content

Commit 94539fa

Browse files
committed
Add plugin_languages_aliases options lowlighter#343
1 parent aa4225f commit 94539fa

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

source/plugins/languages/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ For better results, it's advised to add either your surnames and eventually no-r
4848
with:
4949
# ... other options
5050
plugin_languages: yes
51-
plugin_languages_ignored: html, css # List of languages to ignore
52-
plugin_languages_skipped: my-test-repo # List of repositories to skip
53-
plugin_languages_colors: "0:orange, javascript:#ff0000, ..." # Make most used languages orange and JavaScript red
54-
plugin_languages_details: bytes-size, percentage # Additionally display total bytes size and percentage
55-
plugin_languages_threshold: 2% # Hides all languages less than 2%
56-
plugin_languages_limit: 8 # Display up to 8 languages
57-
plugin_languages_sections: most-used, recently-used # Display most used and recently used languages stats
58-
plugin_languages_indepth: no # Get indepth stats (see documentation before enabling)
59-
plugin_languages_recent_load: 500 # Load up to 500 events to compute recently used stats
60-
plugin_languages_recent_days: 7 # Limit recently used stats to last week
61-
commits_authoring: lowlighter@users.noreply.github.com # Surnames or email addresses used to identify your commits
51+
plugin_languages_ignored: html, css # List of languages to ignore
52+
plugin_languages_skipped: my-test-repo # List of repositories to skip
53+
plugin_languages_colors: "0:orange, javascript:#ff0000, ..." # Make most used languages orange and JavaScript red
54+
plugin_languages_aliases: "JavaScript:JS, TypeScript:TS, ..." # Customize languages names with aliases
55+
plugin_languages_details: bytes-size, percentage # Additionally display total bytes size and percentage
56+
plugin_la nguages_threshold: 2% # Hides all languages less than 2%
57+
plugin_languages_limit: 8 # Display up to 8 languages
58+
plugin_languages_sections: most-used, recently-used # Display most used and recently used languages stats
59+
plugin_languages_indepth: no # Get indepth stats (see documentation before enabling)
60+
plugin_languages_recent_load: 500 # Load up to 500 events to compute recently used stats
61+
plugin_languages_recent_days: 7 # Limit recently used stats to last week
62+
commits_authoring: lowlighter@users.noreply.github.com # Surnames or email addresses used to identify your commits
6263
```

source/plugins/languages/index.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ export default async function({login, data, imports, q, rest, account}, {enabled
1717
}
1818

1919
//Load inputs
20-
let {ignored, skipped, colors, details, threshold, limit, indepth, sections, "recent.load":_recent_load, "recent.days":_recent_days} = imports.metadata.plugins.languages.inputs({data, account, q})
20+
let {ignored, skipped, colors, aliases, details, threshold, limit, indepth, sections, "recent.load":_recent_load, "recent.days":_recent_days} = imports.metadata.plugins.languages.inputs({data, account, q})
2121
threshold = (Number(threshold.replace(/%$/, "")) || 0) / 100
2222
skipped.push(...data.shared["repositories.skipped"])
2323
if (!limit)
2424
limit = Infinity
25+
console.log(aliases, aliases.split(",").filter(alias => /^[\s\S]+:[\s\S]+$/.test(alias)).map(alias => alias.trim().split(":")))
26+
aliases = Object.fromEntries(aliases.split(",").filter(alias => /^[\s\S]+:[\s\S]+$/.test(alias)).map(alias => alias.trim().split(":")).map(([key, value]) => [key.toLocaleLowerCase(), value]))
2527

2628
//Custom colors
2729
const colorsets = JSON.parse(`${await imports.fs.readFile(`${imports.__module(import.meta.url)}/colorsets.json`)}`)
@@ -77,6 +79,13 @@ export default async function({login, data, imports, q, rest, account}, {enabled
7779
}
7880
}
7981

82+
console.log(aliases)
83+
//Apply aliases
84+
for (const section of ["favorites", "recent"])
85+
for (const language of languages[section])
86+
if (language.name.toLocaleLowerCase() in aliases)
87+
language.name = aliases[language.name.toLocaleLowerCase()]
88+
8089
//Results
8190
return languages
8291
}

source/plugins/languages/metadata.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,18 @@ inputs:
6161
type: array
6262
format:
6363
- comma-separated
64-
- /((?<index>[0-9])|(?<language>[-+a-z0-9#])):(?<color>#?[-a-z0-9]+)/
64+
- /((?<index>[0-9])|(?<language>[-+a-z0-9#]+)):(?<color>#?[-a-z0-9]+)/
6565
default: github
6666
example: javascript:red, 0:blue, 1:#ff00aa
6767

68+
# Overrides default languages name
69+
# Use `${language}:${alias}` to change the name of language (e.g. "javascript:JS" to make JavaScript render as "JS", case of left operand ignored)
70+
plugin_languages_aliases:
71+
description: Custom languages names
72+
type: string
73+
default: ""
74+
example: javascript:JS typescript:TS
75+
6876
# Languages additional details
6977
plugin_languages_details:
7078
description: Additional details

0 commit comments

Comments
 (0)