Skip to content

Commit

Permalink
Update vimsrc feature
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinAskestad committed Oct 3, 2024
1 parent 6f9b85f commit 9c74266
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 12 deletions.
51 changes: 48 additions & 3 deletions src/vimsrc/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,57 @@
"name": "VIM",
"id": "vim",
"version": "0.0.1",
"description": "VIM, from source",
"description": "VIM, from source.",
"options": {
"version": {
"type": "string",
"default": "latest",
"description": "The version of VIM to build"
"default": "9.1.0327",
"description": "The version of VIM to build."
},
"enable_gui": {
"type": "boolean",
"default": false,
"description": "Enable GUI Version of VIM."
},
"enable_sound": {
"type": "boolean",
"default": false,
"description": "Enable sound."
},
"enable_perl": {
"type": "boolean",
"default": false,
"description": "Enable Perl interpreter."
},
"enable_python": {
"type": "boolean",
"default": false,
"description": "Enable Python interpreter."
},
"enable_python3": {
"type": "boolean",
"default": false,
"description": "Enable Python 3 interpreter."
},
"enable_ruby": {
"type": "boolean",
"default": false,
"description": "Enable Ruby interpreter."
},
"enable_lua": {
"type": "boolean",
"default": false,
"description": "Enable Lua interpreter."
},
"enable_tcl": {
"type": "boolean",
"default": false,
"description": "Enable Tcl interpreter."
},
"enable_mzscheme": {
"type": "boolean",
"default": false,
"description": "Enable MZ Scheme interpreter."
}
}
}
42 changes: 33 additions & 9 deletions src/vimsrc/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@ RACKET_VERSION="8.5"

set -e

unset_false_variables() {
if [ "${VIM_ENABLE_GUI}" = "false" ]; then
unset VIM_ENABLE_GUI
fi
if [ "${VIM_ENABLE_SOUND}" = "false" ]; then
unset VIM_ENABLE_SOUND
fi
if [ "${VIM_ENABLE_PERL}" = "false" ]; then
unset VIM_ENABLE_PERL
fi
if [ "${VIM_ENABLE_PYTHON}" = "false" ]; then
unset VIM_ENABLE_PYTHON
fi
if [ "${VIM_ENABLE_PYTHON3}" = "false" ]; then
unset VIM_ENABLE_PYTHON3
fi
if [ "${VIM_ENABLE_RUBY}" = "false" ]; then
unset VIM_ENABLE_RUBY
fi
if [ "${VIM_ENABLE_LUA}" = "false" ]; then
unset VIM_ENABLE_LUA
fi
if [ "${VIM_ENABLE_TCL}" = "false" ]; then
unset VIM_ENABLE_TCL
fi
if [ "${VIM_ENABLE_MZSCHEME}" = "false" ]; then
unset VIM_ENABLE_MZSCHEME
fi
}

unset_false_variables

echo "Download, build and install VIM"

if [ "$(id -u)" -ne 0 ]; then
Expand All @@ -30,7 +62,7 @@ export DEBIAN_FRONTEND=noninteractive
apt_get_update() {
case "${ID}" in
debian|ubuntu)
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
if [ ! -d "/var/lib/apt/lists" ] || [ -z "$(ls -A /var/lib/apt/lists/)" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
Expand Down Expand Up @@ -144,14 +176,6 @@ requested_version="${VIM_VERSION}"
version_list="$(curl -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/vim/vim/tags" | grep -o '"name": "v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"' | sed 's/"name": "v//;s/"//g' | sort -rV)"
if [ "${requested_version}" = "latest" ]; then
VIM_VERSION="$(echo "${version_list}" | head -n 1)"
else
set +e
VIM_VERSION="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
set -e
fi
if [ -z "${VIM_VERSION}" ] || ! echo "${version_list}" | grep "^$(echo "${VIM_VERSION}" | sed 's/\./\\./g')$" > /dev/null 2>&1; then
echo "Invalid VIM version: ${requested_version}" >&2
exit 1
fi

echo "Downloading source for ${VIM_VERSION}..."
Expand Down
13 changes: 13 additions & 0 deletions test/vimsrc/eight.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Test a plain install of VIM, version 8.2

set -e

source dev-container-features-test-lib

check "vim version" vim --version

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
13 changes: 13 additions & 0 deletions test/vimsrc/lua.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Test an installation of VIM with LUA.

set -e

source dev-container-features-test-lib

check "vim version" vim --version

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
13 changes: 13 additions & 0 deletions test/vimsrc/plain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Test a plain install of VIM, no added options.

set -e

source dev-container-features-test-lib

check "vim version" vim --version

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
13 changes: 13 additions & 0 deletions test/vimsrc/python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Test an installation of VIM with Python.

set -e

source dev-container-features-test-lib

check "vim version" vim --version

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
36 changes: 36 additions & 0 deletions test/vimsrc/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"plain": {
"image": "ubuntu",
"features": {
"vimsrc": {
"version": "9.1.0327"
}
}
},
"lua": {
"image": "ubuntu",
"features": {
"vimsrc": {
"version": "9.1.0327",
"enable_lua": true
}
}
},
"python": {
"image": "ubuntu",
"features": {
"vimsrc": {
"version": "9.1.0327",
"enable_python3": true
}
}
},
"eight": {
"image": "ubuntu",
"features": {
"vimsrc": {
"version": "8.2.5172"
}
}
}
}

0 comments on commit 9c74266

Please sign in to comment.