From: AJ ONeal Date: Wed, 16 Sep 2020 10:02:23 +0000 (+0000) Subject: add and update vim plugins with sensible defaults X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=10b5d609d746a75227ab5c74902741dff234570d;p=webi-installers%2F.git add and update vim plugins with sensible defaults --- diff --git a/golang/install.sh b/golang/install.sh index 5f7af16..44fd5be 100644 --- a/golang/install.sh +++ b/golang/install.sh @@ -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() { diff --git a/vim-go/README.md b/vim-go/README.md index 46ec3fd..1e1f31a 100644 --- a/vim-go/README.md +++ b/vim-go/README.md @@ -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 index 0000000..6d8f73b --- /dev/null +++ b/vim-go/go.vim @@ -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 diff --git a/vim-go/install.ps1 b/vim-go/install.ps1 index 3a5ee52..ff2f7d4 100644 --- a/vim-go/install.ps1 +++ b/vim-go/install.ps1 @@ -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" diff --git a/vim-go/install.sh b/vim-go/install.sh index 2041d6e..acd9181 100644 --- a/vim-go/install.sh +++ b/vim-go/install.sh @@ -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 index 0000000..8c7462a --- /dev/null +++ b/vim-prettier/README.md @@ -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 index 0000000..5488301 --- /dev/null +++ b/vim-prettier/install.ps1 @@ -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 index 0000000..addf1d7 --- /dev/null +++ b/vim-prettier/install.sh @@ -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 index 0000000..233a6ad --- /dev/null +++ b/vim-prettier/prettier.vim @@ -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