mirror of
https://github.com/nvim-tree/nvim-web-devicons
synced 2024-09-16 13:44:06 +02:00
4970f75b05
* add stylua, luacheck, luarc, editorconfig, pre-commit hooks * add stylua, luacheck, luarc, editorconfig, pre-commit hooks * add comments before icons_by_filename and icons_by_file_extension * stylua nit for generated light * correct luacheck stylua order in contributing.md * add stylua/luacheck OS package notes * use make instead of pre-commit hooks * document prerequisites * remove setup-hooks.sh * ci: add pre-commit configuration and GHA (#233) * ci: add pre-commit configuration * ci: add GHA to autoupdate pre-commit hooks --------- Co-authored-by: gegoune <69750637+gegoune@users.noreply.github.com>
68 lines
1.5 KiB
Bash
Executable file
68 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
## Credit: @B0o (Maddison Hellstrom)
|
|
|
|
set -euo pipefail
|
|
|
|
function get_icon_names() {
|
|
curl 'https://raw.githubusercontent.com/kyazdani42/nvim-web-devicons/master/lua/nvim-web-devicons.lua' |
|
|
lua -e '
|
|
pats={}
|
|
for name in pairs(dofile().get_icons()) do
|
|
table.insert(pats, name)
|
|
end
|
|
table.sort(pats)
|
|
print(table.concat(pats, "\n"))
|
|
'
|
|
}
|
|
|
|
function main() {
|
|
local tmp
|
|
tmp="$(mktemp -d)"
|
|
# shellcheck disable=2064
|
|
trap "rmdir '$tmp'" EXIT
|
|
cd "$tmp"
|
|
local file
|
|
local -A filetypes=()
|
|
local -a missing=()
|
|
while read -r pat; do
|
|
echo "$pat" >&2
|
|
if [[ "$pat" =~ ^\. ]]; then
|
|
file="$pat"
|
|
else
|
|
file="test.$pat"
|
|
fi
|
|
touch "./$file"
|
|
local ft
|
|
ft="$(/usr/bin/nvim -u NORC --noplugin --headless "./$file" +'lua
|
|
local ok, err = pcall(vim.fn.writefile, { vim.bo.filetype }, "/dev/stdout")
|
|
if not ok then
|
|
print(err .. "\n")
|
|
vim.cmd "cquit"
|
|
end
|
|
vim.cmd "quit"
|
|
')"
|
|
rm "./$file"
|
|
if [[ -n "$ft" ]]; then
|
|
if [[ -v filetypes["$ft"] ]]; then
|
|
filetypes["$ft"]="${filetypes["$ft"]}, '$pat'"
|
|
else
|
|
filetypes["$ft"]="'$pat'"
|
|
fi
|
|
else
|
|
missing+=("$pat")
|
|
fi
|
|
done < <(get_icon_names)
|
|
|
|
echo "local filetypes = {"
|
|
for ft in "${!filetypes[@]}"; do
|
|
echo " ['$ft'] = { ${filetypes[$ft]} },"
|
|
done
|
|
echo "}"
|
|
echo
|
|
echo "local missing = {"
|
|
printf " '%s',\n" "${missing[@]}"
|
|
echo "}"
|
|
}
|
|
|
|
main "$@"
|