Skip to content

Commit cddb56f

Browse files
committed
docs(#2934): harden gen and lint scripts, moving things out of nvim-tree source to prevent luals upset
1 parent a0662de commit cddb56f

File tree

4 files changed

+91
-60
lines changed

4 files changed

+91
-60
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353

5454
env:
5555
VIMRUNTIME: /home/runner/nvim-${{ matrix.nvim_version }}/share/nvim/runtime
56-
NVIM_SRC: src/neovim-${{ matrix.nvim_version }}
56+
DIR_NVIM_SRC: /home/runner/src/neovim-${{ matrix.nvim_version }}
5757

5858
steps:
5959
- name: checkout
@@ -81,7 +81,7 @@ jobs:
8181
run: |
8282
mkdir -p src
8383
curl -L "https://github.com/neovim/neovim/archive/refs/tags/${{ matrix.nvim_version }}.tar.gz" | tar zx --directory src
84-
cd "${NVIM_SRC}"
84+
cd "${DIR_NVIM_SRC}"
8585
make
8686
8787
- run: make help-check

scripts/gen_vimdoc.sh

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,62 @@
1010

1111
set -e
1212

13-
if [ ! -d "${NVIM_SRC}" ]; then
13+
# unset to ensure no collisions with system installs etc.
14+
unset VIMRUNTIME
15+
16+
# Use a directory outside of nvim_tree source. Adding lua files inside will (rightly) upset luals.
17+
DIR_NVT="${PWD}"
18+
DIR_WORK="/tmp/nvim-tree-gen_vimdoc"
19+
DIR_NVIM_SRC_DEF="/tmp/src/neovim-stable"
20+
21+
if [ ! -f "${DIR_NVT}/scripts/gen_vimdoc.sh" ]; then
22+
echo "Must be run from nvim-tree root"
23+
exit 1
24+
fi
25+
26+
if [ -z "${DIR_NVIM_SRC}" ] && [ -d "${DIR_NVIM_SRC_DEF}" ]; then
27+
export DIR_NVIM_SRC="${DIR_NVIM_SRC_DEF}"
28+
echo "Assumed DIR_NVIM_SRC=${DIR_NVIM_SRC}"
29+
fi
30+
31+
if [ ! -d "${DIR_NVIM_SRC}" ]; then
1432
cat << EOM
1533
16-
\$NVIM_SRC not set
34+
\$DIR_NVIM_SRC=${DIR_NVIM_SRC} not set or missing.
1735
18-
Nvim source is required to run src/gen/gen_vimdoc.lua
36+
Nvim source is required to run ${0}
1937
2038
Please:
21-
mkdir -p src
22-
curl -L 'https://github.com/neovim/neovim/archive/refs/tags/stable.tar.gz' | tar zx --directory src
23-
export NVIM_SRC=src/neovim-stable
39+
mkdir -p ${DIR_NVIM_SRC_DEF}
40+
curl -L 'https://github.com/neovim/neovim/archive/refs/tags/stable.tar.gz' | tar zx --directory $(dirname "${DIR_NVIM_SRC_DEF}")
41+
export DIR_NVIM_SRC=/tmp/src/neovim-stable
2442
EOM
2543
exit 1
2644
fi
2745

28-
# unset to ensure no collisions with system installs etc.
29-
unset VIMRUNTIME
46+
# clean up previous
47+
rm -rfv "${DIR_WORK}"
3048

3149
# runtime/doc is hardcoded, copy the help in
32-
mkdir -pv runtime/doc
33-
cp -v "doc/nvim-tree-lua.txt" runtime/doc
50+
mkdir -pv "${DIR_WORK}/runtime/doc"
51+
cp -v "${DIR_NVT}/doc/nvim-tree-lua.txt" "${DIR_WORK}/runtime/doc"
3452

3553
# modify gen_vimdoc.lua to use our config
36-
cp -v "${NVIM_SRC}/src/gen/gen_vimdoc.lua" gen_vimdoc.lua
37-
sed -i -E 's/spairs\(config\)/spairs\(require("gen_vimdoc_config")\)/g' gen_vimdoc.lua
54+
cp -v "${DIR_NVIM_SRC}/src/gen/gen_vimdoc.lua" "${DIR_WORK}/gen_vimdoc.lua"
55+
sed -i -E 's/spairs\(config\)/spairs\(require("gen_vimdoc_config")\)/g' "${DIR_WORK}/gen_vimdoc.lua"
3856

3957
# use luacacts etc. from neovim src as well as our specific config
40-
export LUA_PATH="${NVIM_SRC}/src/?.lua;scripts/?.lua"
58+
export LUA_PATH="${DIR_NVIM_SRC}/src/?.lua;${DIR_NVT}/scripts/?.lua"
59+
60+
# gen_vimdoc.lua doesn't like dashes in lua module names
61+
# -> use nvim_tree instead of nvim-tree
62+
mkdir -pv "${DIR_WORK}/lua"
63+
ln -sv "${DIR_NVT}/lua/nvim-tree" "${DIR_WORK}/lua/nvim_tree"
4164

4265
# generate
66+
cd "${DIR_WORK}" && pwd
4367
./gen_vimdoc.lua
68+
cd -
4469

45-
# move the generated help out
46-
mv -v "runtime/doc/nvim-tree-lua.txt" doc
47-
48-
# clean up
49-
rmdir -v runtime/doc
50-
rmdir -v runtime
51-
rm -v gen_vimdoc.lua
52-
70+
# copy the generated help out
71+
cp -v "${DIR_WORK}/runtime/doc/nvim-tree-lua.txt" "${DIR_NVT}/doc"

scripts/gen_vimdoc_config.lua

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,28 @@
88
---Generated within help files in this order
99
---@type Module[]
1010
local modules = {
11-
{ helptag = "nvim-tree-config", title = "Class: Config", path = "lua/nvim-tree/_meta/config.lua", },
12-
{ helptag = "nvim-tree-config-sort", title = "Class: Config.Sort", path = "lua/nvim-tree/_meta/config/sort.lua", },
13-
{ helptag = "nvim-tree-config-view", title = "Class: Config.View", path = "lua/nvim-tree/_meta/config/view.lua", },
14-
{ helptag = "nvim-tree-config-renderer", title = "Class: Config.Renderer", path = "lua/nvim-tree/_meta/config/renderer.lua", },
15-
{ helptag = "nvim-tree-config-hijack-directories", title = "Class: Config.HijackDirectories", path = "lua/nvim-tree/_meta/config/hijack_directories.lua", },
16-
{ helptag = "nvim-tree-config-update-focused-file", title = "Class: Config.UpdateFocusedFile", path = "lua/nvim-tree/_meta/config/update_focused_file.lua", },
17-
{ helptag = "nvim-tree-config-system-open", title = "Class: Config.SystemOpen", path = "lua/nvim-tree/_meta/config/system_open.lua", },
18-
{ helptag = "nvim-tree-config-git", title = "Class: Config.Git", path = "lua/nvim-tree/_meta/config/git.lua", },
19-
{ helptag = "nvim-tree-config-diagnostics", title = "Class: Config.Diagnostics", path = "lua/nvim-tree/_meta/config/diagnostics.lua", },
20-
{ helptag = "nvim-tree-config-modified", title = "Class: Config.Modified", path = "lua/nvim-tree/_meta/config/modified.lua", },
21-
{ helptag = "nvim-tree-config-filters", title = "Class: Config.Filters", path = "lua/nvim-tree/_meta/config/filters.lua", },
22-
{ helptag = "nvim-tree-config-live-filter", title = "Class: Config.LiveFilter", path = "lua/nvim-tree/_meta/config/live_filter.lua", },
23-
{ helptag = "nvim-tree-config-filesystem-watchers", title = "Class: Config.FilesystemWatchers", path = "lua/nvim-tree/_meta/config/filesystem_watchers.lua", },
24-
{ helptag = "nvim-tree-config-actions", title = "Class: Config.Actions", path = "lua/nvim-tree/_meta/config/actions.lua", },
25-
{ helptag = "nvim-tree-config-trash", title = "Class: Config.Trash", path = "lua/nvim-tree/_meta/config/trash.lua", },
26-
{ helptag = "nvim-tree-config-tab", title = "Class: Config.Tab", path = "lua/nvim-tree/_meta/config/tab.lua", },
27-
{ helptag = "nvim-tree-config-notify", title = "Class: Config.Notify", path = "lua/nvim-tree/_meta/config/notify.lua", },
28-
{ helptag = "nvim-tree-config-bookmarks", title = "Class: Config.Bookmarks", path = "lua/nvim-tree/_meta/config/bookmarks.lua", },
29-
{ helptag = "nvim-tree-config-help", title = "Class: Config.Help", path = "lua/nvim-tree/_meta/config/help.lua", },
30-
{ helptag = "nvim-tree-config-ui", title = "Class: Config.UI", path = "lua/nvim-tree/_meta/config/ui.lua", name = "UI", },
31-
{ helptag = "nvim-tree-config-experimental", title = "Class: Config.Experimental", path = "lua/nvim-tree/_meta/config/experimental.lua", },
32-
{ helptag = "nvim-tree-config-log", title = "Class: Config.Log", path = "lua/nvim-tree/_meta/config/log.lua", },
33-
34-
-- { helptag = "nvim-tree-api", title = "Lua module: nvim_tree.api", path = "lua/nvim-tree/_meta/api.lua", },
35-
-- { helptag = "nvim-tree-api-decorator", title = "Lua module: nvim_tree.api.decorator", path = "lua/nvim-tree/_meta/api_decorator.lua", },
11+
{ helptag = "nvim-tree-config", title = "Class: Config", path = "./lua/nvim_tree/_meta/config.lua", },
12+
{ helptag = "nvim-tree-config-sort", title = "Class: Config.Sort", path = "./lua/nvim_tree/_meta/config/sort.lua", },
13+
{ helptag = "nvim-tree-config-view", title = "Class: Config.View", path = "./lua/nvim_tree/_meta/config/view.lua", },
14+
{ helptag = "nvim-tree-config-renderer", title = "Class: Config.Renderer", path = "./lua/nvim_tree/_meta/config/renderer.lua", },
15+
{ helptag = "nvim-tree-config-hijack-directories", title = "Class: Config.HijackDirectories", path = "./lua/nvim_tree/_meta/config/hijack_directories.lua", },
16+
{ helptag = "nvim-tree-config-update-focused-file", title = "Class: Config.UpdateFocusedFile", path = "./lua/nvim_tree/_meta/config/update_focused_file.lua", },
17+
{ helptag = "nvim-tree-config-system-open", title = "Class: Config.SystemOpen", path = "./lua/nvim_tree/_meta/config/system_open.lua", },
18+
{ helptag = "nvim-tree-config-git", title = "Class: Config.Git", path = "./lua/nvim_tree/_meta/config/git.lua", },
19+
{ helptag = "nvim-tree-config-diagnostics", title = "Class: Config.Diagnostics", path = "./lua/nvim_tree/_meta/config/diagnostics.lua", },
20+
{ helptag = "nvim-tree-config-modified", title = "Class: Config.Modified", path = "./lua/nvim_tree/_meta/config/modified.lua", },
21+
{ helptag = "nvim-tree-config-filters", title = "Class: Config.Filters", path = "./lua/nvim_tree/_meta/config/filters.lua", },
22+
{ helptag = "nvim-tree-config-live-filter", title = "Class: Config.LiveFilter", path = "./lua/nvim_tree/_meta/config/live_filter.lua", },
23+
{ helptag = "nvim-tree-config-filesystem-watchers", title = "Class: Config.FilesystemWatchers", path = "./lua/nvim_tree/_meta/config/filesystem_watchers.lua", },
24+
{ helptag = "nvim-tree-config-actions", title = "Class: Config.Actions", path = "./lua/nvim_tree/_meta/config/actions.lua", },
25+
{ helptag = "nvim-tree-config-trash", title = "Class: Config.Trash", path = "./lua/nvim_tree/_meta/config/trash.lua", },
26+
{ helptag = "nvim-tree-config-tab", title = "Class: Config.Tab", path = "./lua/nvim_tree/_meta/config/tab.lua", },
27+
{ helptag = "nvim-tree-config-notify", title = "Class: Config.Notify", path = "./lua/nvim_tree/_meta/config/notify.lua", },
28+
{ helptag = "nvim-tree-config-bookmarks", title = "Class: Config.Bookmarks", path = "./lua/nvim_tree/_meta/config/bookmarks.lua", },
29+
{ helptag = "nvim-tree-config-help", title = "Class: Config.Help", path = "./lua/nvim_tree/_meta/config/help.lua", },
30+
{ helptag = "nvim-tree-config-ui", title = "Class: Config.UI", path = "./lua/nvim_tree/_meta/config/ui.lua", name = "UI", },
31+
{ helptag = "nvim-tree-config-experimental", title = "Class: Config.Experimental", path = "./lua/nvim_tree/_meta/config/experimental.lua", },
32+
{ helptag = "nvim-tree-config-log", title = "Class: Config.Log", path = "./lua/nvim_tree/_meta/config/log.lua", },
3633
}
3734

3835
-- hydrate file names

scripts/lintdoc.sh

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,44 @@
1414

1515
set -e
1616

17-
if [ ! -d "${NVIM_SRC}" ]; then
17+
# unset to ensure no collisions with system installs etc.
18+
unset VIMRUNTIME
19+
20+
# Use a directory outside of nvim_tree source. Adding lua files inside will (rightly) upset luals.
21+
DIR_NVT="${PWD}"
22+
DIR_WORK="/tmp/nvim-tree-lintdoc"
23+
DIR_NVIM_SRC_DEF="/tmp/src/neovim-stable"
24+
25+
if [ ! -f "${DIR_NVT}/scripts/lintdoc.sh" ]; then
26+
echo "Must be run from nvim-tree root"
27+
exit 1
28+
fi
29+
30+
if [ -z "${DIR_NVIM_SRC}" ] && [ -d "${DIR_NVIM_SRC_DEF}" ]; then
31+
export DIR_NVIM_SRC="${DIR_NVIM_SRC_DEF}"
32+
echo "Assumed DIR_NVIM_SRC=${DIR_NVIM_SRC}"
33+
fi
34+
35+
if [ ! -d "${DIR_NVIM_SRC}" ]; then
1836
cat << EOM
1937
20-
\$NVIM_SRC not set
38+
\$DIR_NVIM_SRC=${DIR_NVIM_SRC} not set or missing.
2139
22-
Compiled Nvim source is required to run src/gen/gen_vimdoc.lua
40+
Nvim source is required to run ${0}
2341
2442
Please:
25-
mkdir -p src
26-
curl -L 'https://github.com/neovim/neovim/archive/refs/tags/stable.tar.gz' | tar zx --directory src
27-
export NVIM_SRC=src/neovim-stable
43+
mkdir -p ${DIR_NVIM_SRC_DEF}
44+
curl -L 'https://github.com/neovim/neovim/archive/refs/tags/stable.tar.gz' | tar zx --directory $(dirname "${DIR_NVIM_SRC_DEF}")
45+
export DIR_NVIM_SRC=/tmp/src/neovim-stable
2846
EOM
2947
exit 1
3048
fi
3149

32-
# unset to ensure no collisions with system installs etc.
33-
unset VIMRUNTIME
34-
3550
# runtime/doc in the Nvim source is practically hardcoded, copy our help in
36-
cp -v "doc/nvim-tree-lua.txt" "${NVIM_SRC}/runtime/doc"
51+
cp -v "${DIR_NVT}/doc/nvim-tree-lua.txt" "${DIR_NVIM_SRC}/runtime/doc"
3752

3853
# run from within Nvim source
39-
cd "${NVIM_SRC}"
54+
cd "${DIR_NVIM_SRC}"
4055

4156
# make nvim and execute the lint
42-
make lintdoc
57+
make

0 commit comments

Comments
 (0)