From 85a231cc55e039a7e99a5a853a7d7ad8519fa596 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 4 Jul 2020 06:57:53 +0000 Subject: [PATCH] add git and golang for windows, fix some PATH stuff --- _webi/template.ps1 | 2 +- _webi/webi.ps1 | 2 +- git/install.ps1 | 56 +++++++++++++++++++++++++++++++++++ git/install.sh | 8 +++++ git/releases.js | 30 +++++++++++++++++++ golang/install.ps1 | 74 ++++++++++++++++++++++++++++++++++++++++++++++ golang/install.sh | 4 +++ node/install.ps1 | 2 +- vim-go/README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++ vim-go/install.ps1 | 4 +++ vim-go/install.sh | 9 ++++++ 11 files changed, 259 insertions(+), 3 deletions(-) create mode 100644 git/install.ps1 create mode 100644 git/install.sh create mode 100644 git/releases.js create mode 100644 golang/install.ps1 create mode 100644 vim-go/README.md create mode 100644 vim-go/install.ps1 create mode 100644 vim-go/install.sh diff --git a/_webi/template.ps1 b/_webi/template.ps1 index 6ebdcd8..491e3a5 100644 --- a/_webi/template.ps1 +++ b/_webi/template.ps1 @@ -35,7 +35,7 @@ if (!(Test-Path -Path .local\opt)) # Run pathman to set up the folder #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin" -& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\bin +& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\bin {{ installer }} diff --git a/_webi/webi.ps1 b/_webi/webi.ps1 index 7d8de29..d18996c 100644 --- a/_webi/webi.ps1 +++ b/_webi/webi.ps1 @@ -49,7 +49,7 @@ if (!(Test-Path -Path .local\bin\pathman.exe)) # Run pathman to set up the folder #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin" -& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\bin +& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\bin # {{ baseurl }} # {{ version }} diff --git a/git/install.ps1 b/git/install.ps1 new file mode 100644 index 0000000..d6d1e22 --- /dev/null +++ b/git/install.ps1 @@ -0,0 +1,56 @@ +#!/usr/bin/env pwsh + +$pkg_cmd_name = "git" +$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + +$pkg_src = "$Env:USERPROFILE\.local\opt\$pkg_cmd_name-v$Env:WEBI_VERSION" + +$pkg_dst = "$Env:USERPROFILE\.local\opt\$pkg_cmd_name" +$pkg_dst_cmd = "$pkg_dst\cmd\$pkg_cmd_name" +$pkg_dst_bin = "$pkg_dst\cmd" + +# Fetch archive +IF (!(Test-Path -Path "$pkg_download")) +{ + # TODO: arch detection + echo "Downloading $Env:PKG_NAME from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src")) +{ + echo "Installing $pkg_cmd_name" + # TODO: temp directory + + # Enter opt + ($none = pushd .local\tmp) | out-null + + # Remove any leftover tmp cruft + Remove-Item -Path "$pkg_cmd_name*" -Recurse -ErrorAction Ignore + + # Unpack archive + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + IF (!(Test-Path -Path "$pkg_cmd_name-v$Env:WEBI_VERSION")) { + New-Item -Path "$pkg_cmd_name-v$Env:WEBI_VERSION" -ItemType Directory + } + ($none = pushd "$pkg_cmd_name-v$Env:WEBI_VERSION") | out-null + & tar xf "$pkg_download" + ($none = popd) | out-null + + # Settle unpacked archive into place + echo "New Name: $pkg_cmd_name-v$Env:WEBI_VERSION" + echo "New Location: $pkg_src" + Move-Item -Path "$pkg_cmd_name-v$Env:WEBI_VERSION" -Destination "$Env:USERPROFILE\.local\opt" + + # Exit tmp + $none = popd +} + +echo "Copying into '$pkg_dst' from '$pkg_src'" +Remove-Item -Path "$pkg_dst" -Recurse -ErrorAction Ignore +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse + +# Add to path +& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\opt\git\cmd diff --git a/git/install.sh b/git/install.sh new file mode 100644 index 0000000..68e66d6 --- /dev/null +++ b/git/install.sh @@ -0,0 +1,8 @@ +#!/bin/bash +{ + set -e + set -u + + echo "This package doesn't work for Mac or Linux yet - only Windows 10" + exit 1 +} diff --git a/git/releases.js b/git/releases.js new file mode 100644 index 0000000..caeac2a --- /dev/null +++ b/git/releases.js @@ -0,0 +1,30 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'git-for-windows'; +var repo = 'git'; + +module.exports = function (request) { + // TODO support mac and linux tarballs + return github(request, owner, repo).then(function (all) { + // See https://github.com/git-for-windows/git/wiki/MinGit + // also consider https://github.com/git-for-windows/git/wiki/Silent-or-Unattended-Installation + all.releases = all.releases + .filter(function (rel) { + rel.os = 'windows'; + return ( + /MinGit/i.test(rel.name || rel.download) && + !/busybox/i.test(rel.name || rel.download) + ); + }) + .slice(0, 20); + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + console.info(JSON.stringify(all, null, 2)); + }); +} diff --git a/golang/install.ps1 b/golang/install.ps1 new file mode 100644 index 0000000..d7d1161 --- /dev/null +++ b/golang/install.ps1 @@ -0,0 +1,74 @@ +#!/usr/bin/env pwsh + +$pkg_cmd_name = "go" +$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + +$pkg_src = "$Env:USERPROFILE\.local\opt\$pkg_cmd_name-v$Env:WEBI_VERSION" + +$pkg_dst = "$Env:USERPROFILE\.local\opt\$pkg_cmd_name" +$pkg_dst_cmd = "$pkg_dst\bin\$pkg_cmd_name" +$pkg_dst_bin = "$pkg_dst\bin" + +# Fetch archive +IF (!(Test-Path -Path "$pkg_download")) +{ + # TODO: arch detection + echo "Downloading $Env:PKG_NAME from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src")) +{ + echo "Installing $pkg_cmd_name" + # TODO: temp directory + + # Enter opt + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path "$pkg_cmd_name*" -Recurse -ErrorAction Ignore + + # Unpack archive + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + echo "New Name: $pkg_cmd_name-v$Env:WEBI_VERSION" + Get-ChildItem "$pkg_cmd_name*" | Select -f 1 | Rename-Item -NewName "$pkg_cmd_name-v$Env:WEBI_VERSION" + echo "New Location: $pkg_src" + Move-Item -Path "$pkg_cmd_name-v$Env:WEBI_VERSION" -Destination "$Env:USERPROFILE\.local\opt" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst' from '$pkg_src'" +Remove-Item -Path "$pkg_dst" -Recurse -ErrorAction Ignore +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse + +# Special to go: re-run all go tooling builds +echo "Building go language tools..." +echo gopls +& "$pkg_dst_cmd" get golang.org/x/tools/gopls +echo golint +& "$pkg_dst_cmd" get golang.org/x/lint/golint +echo errcheck +& "$pkg_dst_cmd" get github.com/kisielk/errcheck +echo gotags +& "$pkg_dst_cmd" get github.com/jstemmer/gotags +echo goimports +& "$pkg_dst_cmd" get golang.org/x/tools/cmd/goimports +echo gorename +& "$pkg_dst_cmd" get golang.org/x/tools/cmd/gorename +echo gotype +& "$pkg_dst_cmd" get golang.org/x/tools/cmd/gotype +echo stringer +& "$pkg_dst_cmd" get golang.org/x/tools/cmd/stringer + +# Add to path +& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\opt\go\bin + +# Special to go: add default GOBIN to PATH +& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\go\bin diff --git a/golang/install.sh b/golang/install.sh index f35eecb..5f7af16 100644 --- a/golang/install.sh +++ b/golang/install.sh @@ -56,6 +56,10 @@ pkg_post_install() { echo "Building go language tools..." echo gopls "$pkg_dst_cmd" get golang.org/x/tools/gopls > /dev/null #2>/dev/null + echo golint + "$pkg_dst_cmd" get golang.org/x/lint/golint > /dev/null #2>/dev/null + echo errcheck + "$pkg_dst_cmd" get github.com/kisielk/errcheck > /dev/null #2>/dev/null echo gotags "$pkg_dst_cmd" get github.com/jstemmer/gotags > /dev/null #2>/dev/null echo goimports diff --git a/node/install.ps1 b/node/install.ps1 index c108acb..8c8789f 100644 --- a/node/install.ps1 +++ b/node/install.ps1 @@ -44,4 +44,4 @@ Copy-Item -Path "$Env:USERPROFILE\.local\opt\$Env:PKG_NAME-v$Env:WEBI_VERSION" - & .\.local\opt\node\npm.cmd --scripts-prepend-node-path=true config set scripts-prepend-node-path true # Add to path -& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\opt\node +& "$Env:USERPROFILE\.local\bin\pathman.exe" add '%USERPROFILE\.local\opt\node' diff --git a/vim-go/README.md b/vim-go/README.md new file mode 100644 index 0000000..ebabbd2 --- /dev/null +++ b/vim-go/README.md @@ -0,0 +1,71 @@ +--- +title: vim-go +homepage: https://github.com/fatih/vim-go +tagline: | + vim-go adds Go language support for Vim. +description: | + `vim-go` provides integration with various official and 3rd part go tooling for linting, vetting, etc. + + You'll also need `syntastic` or similar. +--- + +### How to install by hand + +```bash +git clone --depth=1 https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go +``` + +### How to configure your `.vimrc` + +```vimrc +" don't check syntax immediately on open or on quit +let g:syntastic_check_on_open = 1 +let g:syntastic_check_on_wq = 0 + +" we also want to get rid of accidental trailing whitespace on save +autocmd BufWritePre * :%s/\s\+$//e +``` + +```vimrc +""""""""""""""""""""""""""" +" Golang-specific options " +""""""""""""""""""""""""""" + +" tell syntastic that go, golint, and errcheck are installed +let g:syntastic_go_checkers = ['go', 'golint', 'errcheck'] + +" tell vim-go that goimports is installed +let g:go_fmt_command = "goimports" + +" tell vim-go to highlight +let g:go_highlight_functions = 1 +let g:go_highlight_methods = 1 +let g:go_highlight_structs = 1 +let g:go_highlight_operators = 1 +let g:go_highlight_build_constraints = 1 +``` + +### How to install go language tools + +```bash +# gopls +go get golang.org/x/tools/gopls + +# golint +go get golang.org/x/lint/golint + +# errcheck +go get github.com/kisielk/errcheck + +# gotags +go get github.com/jstemmer/gotags + +# goimports +go get golang.org/x/tools/cmd/goimports + +# gorename +go get golang.org/x/tools/cmd/gorename + +# gotype +go get golang.org/x/tools/cmd/gotype +``` diff --git a/vim-go/install.ps1 b/vim-go/install.ps1 new file mode 100644 index 0000000..5c72a7c --- /dev/null +++ b/vim-go/install.ps1 @@ -0,0 +1,4 @@ +#!/usr/bin/env pwsh + +Remove-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start\vim-go" -Recurse -ErrorAction Ignore +& git clone --depth=1 https://github.com/fatih/vim-go.git "$Env:USERPROFILE\.vim\pack\plugins\start\vim-go" diff --git a/vim-go/install.sh b/vim-go/install.sh new file mode 100644 index 0000000..da4401b --- /dev/null +++ b/vim-go/install.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +{ + set -e + set -u + + rm -rf "$HOME/.vim/pack/plugins/start/vim-go" + git clone --depth=1 https://github.com/fatih/vim-go.git "$HOME/.vim/pack/plugins/start/vim-go" +} -- 2.25.1