From 7f3c7b7e1c18e1298d3d152a3f45dc825fcaabc3 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 16 Jul 2024 23:00:36 +0300 Subject: [PATCH] feat: prettier-plugin-sh + tweaks and codefixes --- .browserslistrc | 2 +- .editorconfig | 6 ++++++ .prettierignore | 16 ++++++++++------ .prettierrc.js | 1 + base/zshenv | 4 +--- base/zshrc | 12 ++++++------ config/asdf/asdfrc | 2 -- config/exports | 8 ++++++-- config/exports-apps | 6 +++--- config/nvim/lazyvim.json | 2 +- config/omp/own.json | 8 ++------ local/bin/x-load-configs | 16 ++++++++-------- package.json | 3 ++- scripts/install-go-packages.sh | 2 +- yarn.lock | 25 +++++++++++++++++++++++++ 15 files changed, 73 insertions(+), 40 deletions(-) diff --git a/.browserslistrc b/.browserslistrc index 8f26fc3..0f712b2 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1 +1 @@ -extends @ivuorinen/browserslist-config \ No newline at end of file +extends @ivuorinen/browserslist-config diff --git a/.editorconfig b/.editorconfig index feedc5a..e46e4a4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -27,3 +27,9 @@ space_redirects = true keep_padding = false function_next_line = true # --func-next-line +# Ignore the entire "third_party" directory when calling shfmt on directories, +# such as "shfmt -l -w .". When formatting files directly, +# like "shfmt -w third_party/foo.sh" or "shfmt --filename=third_party/foo.sh", +# the ignore logic is applied only when the --apply-ignore flag is given. +[{tools/**,local/bin/asdf/**,config/cheat/cheatsheets/**}] +ignore = true diff --git a/.prettierignore b/.prettierignore index bc65981..676d435 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,8 +1,12 @@ .mypy_cache/* -tools/dotbot* -local/bin/antigen.zsh -config/cheat/cheatsheets/community -config/tmux/plugins/* -lazy-lock.json Brewfile.lock.json - +config/cheat/cheatsheets/community +config/cheat/cheatsheets/tldr +config/fzf/* +config/nvim-kickstart/* +config/tmux/plugins/* +config/zsh/* +lazy-lock.json +local/bin/antigen.zsh +local/bin/asdf +tools/dotbot* diff --git a/.prettierrc.js b/.prettierrc.js index c9aa2b4..25592d8 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,4 +1,5 @@ module.exports = { + plugins: ['prettier-plugin-sh'], ...require('@ivuorinen/prettier-config'), trailingComma: 'all', // Add custom options below: diff --git a/base/zshenv b/base/zshenv index 9582af8..8f0793d 100644 --- a/base/zshenv +++ b/base/zshenv @@ -16,6 +16,4 @@ export XDG_BIN_HOME="$HOME/.local/bin" export XDG_CACHE_HOME="$HOME/.cache" export XDG_RUNTIME_DIR="$HOME/.local/run" -source "$DOTFILES/config/exports" -source "$DOTFILES/config/alias" - +source "$DOTFILES/config/shared" diff --git a/base/zshrc b/base/zshrc index e27c1db..ce3fa03 100755 --- a/base/zshrc +++ b/base/zshrc @@ -78,12 +78,12 @@ x-have pyenv && { # Autoupdate tmux window name TMUX_WINDOW_NAME_PLUGIN="$DOTFILES/config/tmux/plugins/tmux-window-name/scripts/rename_session_windows.py" [ -f "$TMUX_WINDOW_NAME_PLUGIN" ] && { - tmux-window-name() + tmux_window_name() { ($TMUX_WINDOW_NAME_PLUGIN &) } - add-zsh-hook chpwd tmux-window-name - tmux-window-name + add-zsh-hook chpwd tmux_window_name + tmux_window_name } } @@ -95,8 +95,8 @@ source "$DOTFILES/config/alias" # Herd checks for a few environment variables to inject PHP binaries and configurations. # Herd injected PHP binary. -# export PATH="/Users/ivuorinen/Library/Application Support/Herd/bin/":$PATH +# export PATH="/Users/ivuorinen/Library/Application\ Support/Herd/bin/":$PATH # Herd injected PHP 8.3 configuration. -# export HERD_PHP_83_INI_SCAN_DIR="/Users/ivuorinen/Library/Application Support/Herd/config/php/83/" +# export HERD_PHP_83_INI_SCAN_DIR="/Users/ivuorinen/Library/Application\ Support/Herd/config/php/83/" # Herd injected PHP 7.4 configuration. -# export HERD_PHP_74_INI_SCAN_DIR="/Users/ivuorinen/Library/Application Support/Herd/config/php/74/" +# export HERD_PHP_74_INI_SCAN_DIR="/Users/ivuorinen/Library/Application\ Support/Herd/config/php/74/" diff --git a/config/asdf/asdfrc b/config/asdf/asdfrc index bfc3011..231755b 100644 --- a/config/asdf/asdfrc +++ b/config/asdf/asdfrc @@ -2,6 +2,4 @@ legacy_version_file=yes use_release_candidates=no -plugin_repository_last_check_duration=60 -disable_plugin_short_name_repository=no concurrency=auto diff --git a/config/exports b/config/exports index 11a65e0..15856c3 100755 --- a/config/exports +++ b/config/exports @@ -37,12 +37,16 @@ have() # function to run dark-notify and change alacritty theme # it uses flock to prevent running multiple instances # install flock with `brew install flock` on macOS -function darknotify-alacritty { +function darknotify-alacritty +{ have flock && [[ -f /tmp/dark-notify-alacritty.lock ]] && return have dark-notify && { # true is used to prevent the command show it was backgrounded - true & flock /tmp/dark-notify-alacritty.lock dark-notify -c "$HOME/.dotfiles/local/bin/x-change-alacritty-theme" & + true \ + && flock /tmp/dark-notify-alacritty.lock dark-notify -c "$HOME/.dotfiles/local/bin/x-change-alacritty-theme" & } + + return 0 } darknotify-alacritty diff --git a/config/exports-apps b/config/exports-apps index a482c96..f7e61ae 100755 --- a/config/exports-apps +++ b/config/exports-apps @@ -69,13 +69,13 @@ export GOBIN="$XDG_BIN_HOME" # Herd, herd.laravel.com # Herd injected PHP binary. -export PATH="$HOME/Library/Application Support/Herd/bin/":$PATH +export PATH="$HOME/Library/Application\ Support/Herd/bin/":$PATH x-have herd && { # Herd injected PHP 8.3 configuration. - export HERD_PHP_83_INI_SCAN_DIR="$HOME/Library/Application Support/Herd/config/php/83/" + export HERD_PHP_83_INI_SCAN_DIR="$HOME/Library/Application\ Support/Herd/config/php/83/" # Herd injected PHP 7.4 configuration. - export HERD_PHP_74_INI_SCAN_DIR="$HOME/Library/Application Support/Herd/config/php/74/" + export HERD_PHP_74_INI_SCAN_DIR="$HOME/Library/Application\ Support/Herd/config/php/74/" } # nb, https://xwmx.github.io/nb/ diff --git a/config/nvim/lazyvim.json b/config/nvim/lazyvim.json index 3b8a768..09ff175 100644 --- a/config/nvim/lazyvim.json +++ b/config/nvim/lazyvim.json @@ -32,4 +32,4 @@ "NEWS.md": "6077" }, "version": 6 -} \ No newline at end of file +} diff --git a/config/omp/own.json b/config/omp/own.json index e40b6a3..fe501d8 100644 --- a/config/omp/own.json +++ b/config/omp/own.json @@ -111,9 +111,7 @@ { "background": "transparent", "foreground": "lightGreen", - "foreground_templates": [ - "{{ if gt .Code 0 }}red{{ end }}" - ], + "foreground_templates": ["{{ if gt .Code 0 }}red{{ end }}"], "properties": { "always_enabled": true }, @@ -128,9 +126,7 @@ "transient_prompt": { "background": "transparent", "foreground": "lightGreen", - "foreground_templates": [ - "{{ if gt .Code 0 }}red{{ end }}" - ], + "foreground_templates": ["{{ if gt .Code 0 }}red{{ end }}"], "template": "\u279c " }, "version": 2 diff --git a/local/bin/x-load-configs b/local/bin/x-load-configs index 247a38f..9110820 100755 --- a/local/bin/x-load-configs +++ b/local/bin/x-load-configs @@ -2,12 +2,12 @@ # Load our configuration files # Copyright (c) 2023 Ismo Vuorinen. All Rights Reserved. -set -euo pipefail - -# Set verbosity with VERBOSE=1 x-load-configs +# Enable verbosity with VERBOSE=1 x-load-configs VERBOSE="${VERBOSE:=0}" +# Enable debugging with DEBUG=1 x-load-configs +DEBUG="${DEBUG:=0}" -[ "$VERBOSE" = "1" ] && { +[ "$DEBUG" = "1" ] && { set -x } @@ -37,7 +37,7 @@ loadConfigFiles() HOST_FILE=$CONFIG_FILE-$HOST SECRET_HOST=$HOST_FILE-secret - [ "$VERBOSE" = "1" ] && configMsg "?" "$CONFIG_FILE" + [ "$VERBOSE" = "1" ] && configMsg "Looking for" "$CONFIG_FILE" # global (exports|alias|functions) FILENAME for all hosts # shellcheck source=../config/exports @@ -47,19 +47,19 @@ loadConfigFiles() # global secret FILENAME, git ignored # shellcheck source=../config/exports-secret - [ "$VERBOSE" = "1" ] && configMsg "?" "$SECRET_FILE" + [ "$VERBOSE" = "1" ] && configMsg "Looking for" "$SECRET_FILE" [ -r "$SECRET_FILE" ] && { source "$SECRET_FILE" && [ "$VERBOSE" = "1" ] && configMsg "Found" "$SECRET_FILE" } # host specific (exports|alias|functions) FILENAME # shellcheck source=../config/exports - [ "$VERBOSE" = "1" ] && configMsg "?" "$HOST_FILE" + [ "$VERBOSE" = "1" ] && configMsg "Looking for" "$HOST_FILE" [ -r "$HOST_FILE" ] && { source "$HOST_FILE" && [ "$VERBOSE" = "1" ] && configMsg "Found" "$HOST_FILE" } # host specific (exports|alias|functions) FILENAME, git ignored # shellcheck source=../config/exports - [ "$VERBOSE" = "1" ] && configMsg "?" "$SECRET_HOST" + [ "$VERBOSE" = "1" ] && configMsg "Looking for" "$SECRET_HOST" [ -r "$SECRET_HOST" ] && { source "$SECRET_HOST" \ && [ "$VERBOSE" = "1" ] && configMsg "Found" "$SECRET_HOST" diff --git a/package.json b/package.json index 40901c4..b570458 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ }, "homepage": "https://github.com/ivuorinen/dotfiles#readme", "devDependencies": { - "@ivuorinen/base-configs": "^1.1.0" + "@ivuorinen/base-configs": "^1.1.0", + "prettier-plugin-sh": "^0.14.0" }, "packageManager": "yarn@1.22.22" } diff --git a/scripts/install-go-packages.sh b/scripts/install-go-packages.sh index 24dd6a2..ffcb05e 100755 --- a/scripts/install-go-packages.sh +++ b/scripts/install-go-packages.sh @@ -53,7 +53,7 @@ x-have git-profile && { x-have antidot && { antidot update \ - && msg_ok "Updated antidot database" + && msg_ok "Updated antidot database" } echo "" diff --git a/yarn.lock b/yarn.lock index 79774e0..3565fce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3418,6 +3418,11 @@ mute-stream@^1.0.0: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-1.0.0.tgz#e31bd9fe62f0aed23520aa4324ea6671531e013e" integrity sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA== +mvdan-sh@^0.10.1: + version "0.10.1" + resolved "https://registry.yarnpkg.com/mvdan-sh/-/mvdan-sh-0.10.1.tgz#5b3a4462a89cf20739b12d851589342c875f4d1f" + integrity sha512-kMbrH0EObaKmK3nVRKUIIya1dpASHIEusM13S4V1ViHFuxuNxCo+arxoa6j/dbV22YBGjl7UKJm9QQKJ2Crzhg== + mz@^2.4.0: version "2.7.0" resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" @@ -4008,6 +4013,14 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +prettier-plugin-sh@^0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/prettier-plugin-sh/-/prettier-plugin-sh-0.14.0.tgz#22b186adea79b36212ccd9faa8dd01f33ef34ff6" + integrity sha512-hfXulj5+zEl/ulrO5kMuuTPKmXvOg0bnLHY1hKFNN/N+/903iZbNp8NyZBTsgI8dtkSgFfAEIQq0IQTyP1ZVFQ== + dependencies: + mvdan-sh "^0.10.1" + sh-syntax "^0.4.1" + prettier@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.2.tgz#03ff86dc7c835f2d2559ee76876a3914cec4a90a" @@ -4353,6 +4366,13 @@ set-function-name@^2.0.1: functions-have-names "^1.2.3" has-property-descriptors "^1.0.2" +sh-syntax@^0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/sh-syntax/-/sh-syntax-0.4.2.tgz#3bad5c6134b510e7b4c53b16f409ce4fd2a65245" + integrity sha512-/l2UZ5fhGZLVZa16XQM9/Vq/hezGGbdHeVEA01uWjOL1+7Ek/gt6FquW0iKKws4a9AYPYvlz6RyVvjh3JxOteg== + dependencies: + tslib "^2.6.2" + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -4796,6 +4816,11 @@ tsconfig-paths@^3.15.0: minimist "^1.2.6" strip-bom "^3.0.0" +tslib@^2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" + integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== + tuf-js@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/tuf-js/-/tuf-js-2.2.1.tgz#fdd8794b644af1a75c7aaa2b197ddffeb2911b56"