Skip to content

Commit 89640f7

Browse files
committed
chore: add script to Makefile to check for missing filetypes
1 parent c1a86a2 commit 89640f7

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VIM_COLORTEMPLATE_VERSION = 2.2.3
22

3-
all: colors style-check lint
3+
all: colors style-check lint filetypes
44

55
colors: vim-colortemplate
66
nvim \
@@ -26,7 +26,10 @@ style-fix:
2626
lint:
2727
luacheck lua scripts
2828

29+
filetypes:
30+
./scripts/filetypes.sh
31+
2932
clean:
3033
rm -rf vim-colortemplate
3134

32-
.PHONY: all colors style-check style-fix lint
35+
.PHONY: all colors style-check style-fix lint filetypes

scripts/filetypes.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# Iterate over the elements of icons_by_file_extension and check if there are missed filetypes.
4+
5+
in_section=false
6+
7+
while IFS= read -r line; do
8+
if [[ $line =~ ^local\ icons_by_file_extension\ =\ \{$ ]]; then
9+
in_section=true
10+
elif [[ $line =~ ^\}$ ]]; then
11+
in_section=false
12+
fi
13+
14+
if $in_section && [[ $line =~ \[\"(.+)\"\] ]]; then
15+
key="${BASH_REMATCH[1]}"
16+
# Search for the key in the main file
17+
line=$(grep -F "\"$key\"" "lua/nvim-web-devicons.lua")
18+
if [ -n "$line" ]; then
19+
continue
20+
else
21+
[ -f "/usr/share/nvim/runtime/syntax/$key.vim" ] &&
22+
echo -e "\e[33mPlease add \"$key\" to filetypes Lua table.\e[0m"
23+
fi
24+
fi
25+
done <"lua/nvim-web-devicons/icons-default.lua"

0 commit comments

Comments
 (0)