diff --git a/vim-commentary/install.ps1 b/vim-commentary/install.ps1 index 482491c01..9becf7ce6 100644 --- a/vim-commentary/install.ps1 +++ b/vim-commentary/install.ps1 @@ -8,12 +8,17 @@ IF ($null -eq $Env:WEBI_HOST -or "" -eq $Env:WEBI_HOST) { # Install vim-commentary # ########################## -# Every package should define these variables -$pkg_cmd_name = "vim-commentary" -$pkg_src = "$HOME\Downloads\webi\$Env:WEBI_PKG_PATHNAME" -$pkg_dst = "$HOME\.vim\pack\plugins\start\$Env:PKG_NAME" +# ~/.vim/plugins/.vim +$my_vim_confname = "commentary.vim" + +# ~/.vim/pack/plugins/start// +$my_vim_plugin = "vim-commentary" -$my_vim_filename = "commentary.vim" +# Non-executable packages should define these variables +$pkg_cmd_name = "${my_vim_plugin}" +$pkg_no_exec = $true +$pkg_src = "$HOME\Downloads\webi\$Env:WEBI_PKG_PATHNAME" +$pkg_dst = "$HOME\.vim\pack\plugins\start\$my_vim_plugin" function fn_vim_init { if (-Not (Test-Path "$HOME\.vimrc")) { @@ -26,10 +31,10 @@ function fn_vim_init { } function fn_git_shallow_clone { - # IF (Test-Path -Path "$pkg_src") { - # Write-Host "Found $pkg_src" - # Return - # } + IF (Test-Path -Path "$pkg_src") { + Write-Host "Found $pkg_src" + Return + } Write-Output "Checking for Git..." IF (-Not (Get-Command -Name "git" -ErrorAction Silent)) { @@ -62,18 +67,18 @@ function fn_install { } function fn_vim_config_download { - $my_vim_filepath = "$HOME\.vim\plugins\$my_vim_filename" - IF (Test-Path -Path "$my_vim_filepath") { - Write-Host "Found $my_vim_filepath" + $my_vim_confpath = "$HOME\.vim\plugins\$my_vim_confname" + IF (Test-Path -Path "$my_vim_confpath") { + Write-Host "Found $my_vim_confpath" Return } - & curl.exe -sS -o "$my_vim_filepath" ` - "$Env:WEBI_HOST/packages/${Env:PKG_NAME}/${my_vim_filename}" + & curl.exe -sS -o "$my_vim_confpath" ` + "$Env:WEBI_HOST/packages/${Env:PKG_NAME}/${my_vim_confname}" } function fn_vim_config_update { - $my_vim_filepath = "$HOME\.vim\plugin\$my_vim_filename" + $my_vim_confpath = "$HOME\.vim\plugin\$my_vim_confname" Write-Host '' @@ -82,7 +87,7 @@ function fn_vim_config_update { Write-Host '' Write-Host "Add the following to ~/.vimrc:" ` -ForegroundColor magenta -BackgroundColor white - Write-Host " source $my_vim_filepath" ` + Write-Host " source $my_vim_confpath" ` -ForegroundColor magenta -BackgroundColor white Write-Host '' diff --git a/vim-commentary/install.sh b/vim-commentary/install.sh index 13cd8e3a6..08168ef49 100644 --- a/vim-commentary/install.sh +++ b/vim-commentary/install.sh @@ -12,44 +12,45 @@ fn_vim_init() { ( ); } __install_vim_plugin() { + # ~/.vim/plugins/.vim + my_vim_confname="commentary.vim" + + # ~/.vim/pack/plugins/start// + my_vim_plugin="vim-commentary" + + # as opposed to PKG_NAME- / WEBI_PKG_PATHNAME: + # ~/Downloads/webi/-/ # Non-executable packages should define these variables - pkg_cmd_name="vim-commentary" + pkg_cmd_name="${my_vim_plugin}" pkg_no_exec=true - pkg_dst="${HOME}/.vim/pack/plugins/start/vim-commentary" - - my_name="commentary" - my_pkg_name="vim-commentary" - my_note="${my_pkg_name}: installed via webinstall.dev/${my_pkg_name}" + pkg_dst="${HOME}/.vim/pack/plugins/start/${my_vim_plugin}" pkg_install() { ( fn_vim_init - rm -rf ~/.vim/pack/plugins/start/"${my_pkg_name}"/ - mv ./vim-commentary-*/ ~/.vim/pack/plugins/start/"${my_pkg_name}" - ); } - - pkg_link() { ( - return 0 + rm -rf ~/.vim/pack/plugins/start/"${my_vim_plugin}"/ + mv ./"${WEBI_PKG_PATHNAME}"/ ~/.vim/pack/plugins/start/"${my_vim_plugin}" ); } pkg_post_install() { ( mkdir -p ~/.vim/plugins - if [ -f ~/.vim/plugins/"${my_name}.vim" ]; then - echo "Found ~/.vim/plugins/${my_name}.vim" + if [ -f ~/.vim/plugins/"${my_vim_confname}" ]; then + echo "Found ~/.vim/plugins/${my_vim_confname}" else webi_download \ - "${WEBI_HOST}/packages/${my_pkg_name}/${my_name}.vim" \ - ~/.vim/plugins/"${my_name}.vim" \ - "${my_name}.vim" + "${WEBI_HOST}/packages/${PKG_NAME}/${my_vim_confname}" \ + ~/.vim/plugins/"${my_vim_confname}" \ + "${my_vim_confname}" fi - if ! grep "source.*plugins.${my_name}.vim" -r ~/.vimrc > /dev/null 2> /dev/null; then + if ! grep "source.*plugins.${my_vim_confname}" -r ~/.vimrc > /dev/null 2> /dev/null; then + my_note="${my_vim_plugin}: installed via webinstall.dev/${PKG_NAME}" set +e printf '\n" %s\n' "${my_note}" >> ~/.vimrc - printf 'source ~/.vim/plugins/%s.vim\n' "${my_name}" >> ~/.vimrc + printf 'source ~/.vim/plugins/%s\n' "${my_vim_confname}" >> ~/.vimrc set -e - echo "Updated ~/.vimrc to 'source ~/.vim/plugins/${my_name}.vim'" + echo "Updated ~/.vimrc to 'source ~/.vim/plugins/${my_vim_confname}'" fi echo ""