Skip to content

Commit 61c03f2

Browse files
committed
refactor: adapt and simplify filetypes.sh
1 parent fcd2b7c commit 61c03f2

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ end_of_line = lf
77
[*.lua]
88
indent_style = space
99
indent_size = 2
10+
11+
[*.sh]
12+
indent_style = space
13+
indent_size = 2

scripts/filetypes.sh

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,22 @@
44
# $VIMRUNTIME specifies neovim runtime path, defaults to "/usr/share/nvim/runtime" if unset.
55

66
if [ -z "${VIMRUNTIME}" ]; then
7-
export VIMRUNTIME="/usr/share/nvim/runtime"
7+
export VIMRUNTIME="/usr/share/nvim/runtime"
88
fi
99

1010
exit_value=0
11-
in_section=false
1211

13-
while IFS= read -r line; do
14-
if [[ $line =~ ^local\ icons_by_file_extension\ =\ \{$ ]]; then
15-
in_section=true
16-
elif [[ $line =~ ^\}$ ]]; then
17-
in_section=false
18-
fi
12+
while read -r key; do
13+
# Search for the key in the main file
14+
line=$(grep -F "\"$key\"" "lua/nvim-web-devicons.lua")
15+
if [ -z "$line" ]; then
16+
[ -f "${VIMRUNTIME}/syntax/$key.vim" ] &&
17+
echo -e "\e[33mPlease add \"$key\" to filetypes Lua table.\e[0m" &&
18+
exit_value=1
19+
fi
20+
done < <(
21+
awk '/^local icons_by_file_extension /{flag=1; next} /^}/{flag=0} flag' lua/nvim-web-devicons/icons-default.lua |
22+
sed -r 's|.*\["(.*)"\].*|\1|'
23+
)
1924

20-
if $in_section && [[ $line =~ \[\"(.+)\"\] ]]; then
21-
key="${BASH_REMATCH[1]}"
22-
# Search for the key in the main file
23-
line=$(grep -F "\"$key\"" "lua/nvim-web-devicons.lua")
24-
if [ -n "$line" ]; then
25-
continue
26-
else
27-
[ -f "${VIMRUNTIME}/syntax/$key.vim" ] &&
28-
echo -e "\e[33mPlease add \"$key\" to filetypes Lua table.\e[0m" &&
29-
exit_value=1
30-
fi
31-
fi
32-
done <"lua/nvim-web-devicons/icons-default.lua"
3325
exit $exit_value

0 commit comments

Comments
 (0)