add and update vim plugins with sensible defaults
authorAJ ONeal <aj@therootcompany.com>
Wed, 16 Sep 2020 10:02:23 +0000 (10:02 +0000)
committerAJ ONeal <aj@therootcompany.com>
Fri, 18 Sep 2020 09:56:18 +0000 (09:56 +0000)
golang/install.sh
vim-go/README.md
vim-go/go.vim [new file with mode: 0644]
vim-go/install.ps1
vim-go/install.sh
vim-prettier/README.md [new file with mode: 0644]
vim-prettier/install.ps1 [new file with mode: 0644]
vim-prettier/install.sh [new file with mode: 0644]
vim-prettier/prettier.vim [new file with mode: 0644]

index 5f7af1642e5e893443d5cc3ab2a2b6af9232ff29..44fd5bee6e7db1bf103d6fa191c50f7319844268 100644 (file)
@@ -70,6 +70,8 @@ pkg_post_install() {
     "$pkg_dst_cmd" get golang.org/x/tools/cmd/gotype > /dev/null #2>/dev/null
     echo stringer
     "$pkg_dst_cmd" get golang.org/x/tools/cmd/stringer > /dev/null #2>/dev/null
+    echo goreturns
+    "$pkg_dst_cmd" get github.com/sqs/goreturns > /dev/null #2>/dev/null
 }
 
 pkg_done_message() {
index 46ec3fdd8b3b0954f9eb2eabcb44b89dfa3bfbc3..1e1f31a5846b974f0415511be9e301354a3115e7 100644 (file)
@@ -16,7 +16,8 @@ webi vim-go
 > `vim-go` provides integration with various official and 3rd part go tooling
 > for linting, vetting, etc.
 
-You'll also need `ALE`, `syntastic`, or similar.
+You'll also need `ALE`, [`syntastic`](https://webinstall.dev/vim-syntastic), or
+similar.
 
 ### How to install by hand
 
@@ -26,7 +27,7 @@ git clone --depth=1 https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/star
 
 ### How to configure your `.vimrc`
 
-```vimrc
+```vim
 " don't check syntax immediately on open or on quit
 let g:syntastic_check_on_open = 1
 let g:syntastic_check_on_wq = 0
@@ -35,7 +36,7 @@ let g:syntastic_check_on_wq = 0
 autocmd BufWritePre * :%s/\s\+$//e
 ```
 
-```vimrc
+```vim
 """""""""""""""""""""""""""
 " Golang-specific options "
 """""""""""""""""""""""""""
@@ -75,6 +76,9 @@ go get golang.org/x/tools/cmd/goimports
 # gorename
 go get golang.org/x/tools/cmd/gorename
 
+# goreturns
+go get github.com/sqs/goreturns
+
 # gotype
 go get golang.org/x/tools/cmd/gotype
 ```
diff --git a/vim-go/go.vim b/vim-go/go.vim
new file mode 100644 (file)
index 0000000..6d8f73b
--- /dev/null
@@ -0,0 +1,17 @@
+""""""""""""""""""""""""""""""
+"  Golang-specific defaults  "
+" from webinstall.dev/vim-go "
+""""""""""""""""""""""""""""""
+
+" 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 = "goreturns"
+
+" 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
index 3a5ee52aecc5e1294675af160e3ead9a5c1cb087..ff2f7d4a583ea3cdca31a643e2606d33e6f123b1 100644 (file)
@@ -1,7 +1,6 @@
 #!/usr/bin/env pwsh
 
-IF (!(Test-Path -Path "$Env:USERPROFILE\.vim\pack\plugins\start")) {
-    New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force
-}
+New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force
+
 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"
index 2041d6ee3ff15b37c43176f525a97f7ce6691b5c..acd91816db624c76b2ca8b343be34ef0bfc612cc 100644 (file)
@@ -7,4 +7,33 @@
     mkdir -p "$HOME/.vim/pack/plugins/start"
     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"
+
+    # Install go linting tools
+    echo "Building go language tools..."
+    echo gopls
+    go get golang.org/x/tools/gopls > /dev/null #2>/dev/null
+    echo golint
+    go get golang.org/x/lint/golint > /dev/null #2>/dev/null
+    echo errcheck
+    go get github.com/kisielk/errcheck > /dev/null #2>/dev/null
+    echo goimports
+    go get golang.org/x/tools/cmd/goimports > /dev/null #2>/dev/null
+    echo goreturns
+    go get github.com/sqs/goreturns > /dev/null #2>/dev/null
+
+    if [ -f "$HOME/.vimrc" ]; then
+        set +e
+        if ! grep 'source.*go.vim' -r ~/.vimrc; then
+            mkdir -p ~/.vim/plugin
+            printf '\n" Golang: reasonable defaults from webinstall.dev/vim-go\n' >> ~/.vimrc
+            printf 'source ~/.vim/plugin/go.vim\n' >> ~/.vimrc
+        fi
+        set -e
+    fi
+
+    if ! [ -f "$HOME/.vim/plugin/go.vim" ]; then
+        mkdir -p ~/.vim/plugin
+        WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
+        curl -fsS -o ~/.vim/plugin/go.vim "$WEBI_HOST/packages/vim-go/go.vim"
+    fi
 }
diff --git a/vim-prettier/README.md b/vim-prettier/README.md
new file mode 100644 (file)
index 0000000..8c7462a
--- /dev/null
@@ -0,0 +1,63 @@
+---
+title: vim-prettier
+homepage: https://github.com/prettier/vim-prettier
+tagline: |
+  vim-prettier adds Prettier support for Vim.
+---
+
+## Updating `vim-prettier`
+
+```bash
+webi vim-prettier
+```
+
+## Cheat Sheet
+
+> `vim-prettier` is a vim plugin wrapper for prettier, pre-configured with
+> custom default prettier settings.
+
+You'll also need `ALE`, [`syntastic`](https://webinstall.dev/vim-syntastic), or
+similar.
+
+### How to install by hand
+
+```bash
+git clone --depth=1 https://github.com/prettier/vim-prettier ~/.vim/pack/plugins/start/vim-prettier
+```
+
+### How to configure your `.vimrc`
+
+```vim
+" 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
+```
+
+```vim
+"""""""""""""""""""""""""""
+" Prettier-specific options "
+"""""""""""""""""""""""""""
+
+" format as-you-type is quite annoying, so we turn it off
+let g:prettier#autoformat = 0
+
+" list all of the extensions for which prettier should run
+autocmd BufWritePre .babelrc,.eslintrc,.jshintrc,*.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
+```
+
+### How to install Prettier
+
+With `webi`:
+
+```bash
+webi prettier
+```
+
+With `node`:
+
+```bash
+npm install -g prettier@2
+```
diff --git a/vim-prettier/install.ps1 b/vim-prettier/install.ps1
new file mode 100644 (file)
index 0000000..5488301
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env pwsh
+
+New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force
+
+Remove-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start\vim-prettier" -Recurse -ErrorAction Ignore
+& git clone --depth=1 https://github.com/prettier/vim-prettier.git "$Env:USERPROFILE\.vim\pack\plugins\start\vim-prettier"
diff --git a/vim-prettier/install.sh b/vim-prettier/install.sh
new file mode 100644 (file)
index 0000000..addf1d7
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    mkdir -p "$HOME/.vim/pack/plugins/start"
+    rm -rf "$HOME/.vim/pack/plugins/start/vim-prettier"
+    git clone --depth=1 https://github.com/prettier/vim-prettier.git "$HOME/.vim/pack/plugins/start/vim-prettier"
+
+    npm install -g prettier@2
+
+    if [ -f "$HOME/.vimrc" ]; then
+        set +e
+        if ! grep 'source.*prettier.vim' -r ~/.vimrc; then
+            mkdir -p ~/.vim/plugin
+            printf '\n" Prettier: reasonable defaults from webinstall.dev/vim-prettier\n' >> ~/.vimrc
+            printf 'source ~/.vim/plugin/prettier.vim\n' >> ~/.vimrc
+        fi
+        set -e
+    fi
+
+    if ! [ -f "$HOME/.vim/plugin/prettier.vim" ]; then
+        mkdir -p ~/.vim/plugin
+        WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
+        curl -fsS -o ~/.vim/plugin/prettier.vim "$WEBI_HOST/packages/vim-prettier/prettier.vim"
+    fi
+}
diff --git a/vim-prettier/prettier.vim b/vim-prettier/prettier.vim
new file mode 100644 (file)
index 0000000..233a6ad
--- /dev/null
@@ -0,0 +1,10 @@
+""""""""""""""""""""""""""""""""""""
+"    Prettier-specific defaults    "
+" from webinstall.dev/vim-prettier "
+""""""""""""""""""""""""""""""""""""
+
+" format as-you-type is quite annoying, so we turn it off
+let g:prettier#autoformat = 0
+
+" list all of the extensions for which prettier should run
+autocmd BufWritePre .babelrc,.eslintrc,.jshintrc,*.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync