diff options
author | Soispha <soispha@vhack.eu> | 2024-02-20 17:21:42 +0100 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2024-02-20 17:21:42 +0100 |
commit | f2bdeaed0bcf97a880fe36cfc8a050d1643120b8 (patch) | |
tree | ba4fe9c3ddf076529701c0e776ffef2104ac23d5 /hm/soispha/conf | |
parent | refactor(treewide): Add a `.sh` extension to shell scripts (diff) | |
download | nixos-config-f2bdeaed0bcf97a880fe36cfc8a050d1643120b8.zip |
refactor(treewide): Reformat all files with treefmt
This includes getting all shellscripts to pass shellcheck. To accomplish this, some old scripts were removed
Diffstat (limited to '')
66 files changed, 856 insertions, 990 deletions
diff --git a/hm/soispha/conf/alacritty/toml/hints.toml b/hm/soispha/conf/alacritty/toml/hints.toml index 33b21924..af01dc3e 100644 --- a/hm/soispha/conf/alacritty/toml/hints.toml +++ b/hm/soispha/conf/alacritty/toml/hints.toml @@ -2,12 +2,12 @@ alphabet = "jfkdls;ahgurieowpq" [[hints.enabled]] -command = "xdg-open" # On Linux/BSD -hyperlinks = true +command = "xdg-open" # On Linux/BSD +hyperlinks = true post_processing = true -persist = false -mouse.enabled = true -binding = { key = "U", mods = "Control|Shift" } +persist = false +mouse.enabled = true +binding = { key = "U", mods = "Control|Shift" } regex = "(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://)[^\u0000-\u001F\u007F-\u009F<>\"\\s{-}\\^⟨⟩`]+" diff --git a/hm/soispha/conf/firefox/scripts/extract_cookies.sh b/hm/soispha/conf/firefox/scripts/extract_cookies.sh index e4eec72c..e3d50d43 100755 --- a/hm/soispha/conf/firefox/scripts/extract_cookies.sh +++ b/hm/soispha/conf/firefox/scripts/extract_cookies.sh @@ -10,7 +10,6 @@ # which means cookies which are kept only in memory ("session cookies") # will not be extracted. You will need an extension to do that. - # USAGE: # # $ extract_cookies.sh > /tmp/cookies.txt @@ -31,20 +30,17 @@ # # B) If you've redirected stdin (with < or |) , then that will be used. - # HISTORY: I believe this is circa 2010 from: # http://slacy.com/blog/2010/02/using-cookies-sqlite-in-wget-or-curl/ # However, that site is down now. # Cleaned up by Hackerb9 (2017) to be more robust and require less typing. - cleanup() { rm -f "$TMPFILE" exit 0 } -trap cleanup EXIT INT QUIT TERM - +trap cleanup EXIT INT QUIT TERM if [ "$#" -ge 1 ]; then SQLFILE="$1" @@ -59,14 +55,13 @@ fi # We have to copy cookies.sqlite, because FireFox has a lock on it TMPFILE=$(mktemp /tmp/cookies.sqlite.XXXXXXXXXX) -cat "$SQLFILE" >> "$TMPFILE" - +cat "$SQLFILE" >>"$TMPFILE" # This is the format of the sqlite database: # CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER); echo "# Netscape HTTP Cookie File" -sqlite3 -separator $'\t' "$TMPFILE" << EOF +sqlite3 -separator $'\t' "$TMPFILE" <<EOF .mode tabs .header off select host, diff --git a/hm/soispha/conf/firefox/scripts/unzip_mozlz4.py b/hm/soispha/conf/firefox/scripts/unzip_mozlz4.py index 90dfdd29..44e00d53 100755 --- a/hm/soispha/conf/firefox/scripts/unzip_mozlz4.py +++ b/hm/soispha/conf/firefox/scripts/unzip_mozlz4.py @@ -18,26 +18,27 @@ def mozlz4_to_text(filepath): def main(args): - # Given command-line arguments of an input filepath for a ".mozlz4" file - # and optionally an output filepath, write the decompressed text to the - # output filepath. - # Default output filepath is the input filepath minus the last three characters - # (e.g. "foo.jsonlz4" becomes "foo.json") - filepath_in = args[0] - if len(args) < 2: - filepath_out = filepath_in[:-3] - else: - filepath_out = args[1] - text = mozlz4_to_text(filepath_in) - with open(filepath_out, "wb") as outfile: - outfile.write(text) - print("Wrote decompressed text to {}".format(filepath_out)) + # Given command-line arguments of an input filepath for a ".mozlz4" file + # and optionally an output filepath, write the decompressed text to the + # output filepath. + # Default output filepath is the input filepath minus the last three characters + # (e.g. "foo.jsonlz4" becomes "foo.json") + filepath_in = args[0] + if len(args) < 2: + filepath_out = filepath_in[:-3] + else: + filepath_out = args[1] + text = mozlz4_to_text(filepath_in) + with open(filepath_out, "wb") as outfile: + outfile.write(text) + print("Wrote decompressed text to {}".format(filepath_out)) if __name__ == "__main__": - import sys - args = sys.argv[1:] - if args and not args[0] in ("--help", "-h"): - main(args) - else: - print("Usage: mozlz4.py <mozlz4 file to read> <location to write>") + import sys + + args = sys.argv[1:] + if args and not args[0] in ("--help", "-h"): + main(args) + else: + print("Usage: mozlz4.py <mozlz4 file to read> <location to write>") diff --git a/hm/soispha/conf/firefox/scripts/update_extensions.sh b/hm/soispha/conf/firefox/scripts/update_extensions.sh index f8ed3a9a..83b0146d 100755 --- a/hm/soispha/conf/firefox/scripts/update_extensions.sh +++ b/hm/soispha/conf/firefox/scripts/update_extensions.sh @@ -1,8 +1,7 @@ #!/bin/sh - tmp=$(mktemp) -cat << EOF > "$tmp" +cat <<EOF >"$tmp" darkreader:navbar keepassxc-browser:navbar vhack-libredirect:navbar @@ -15,8 +14,6 @@ EOF # The bin is provided in the devshell; # The cat execution should be unquoted; # shellcheck disable=SC2046 -generate_extensions $(cat "$tmp") > "$(dirname "$0")"/../config/extensions/extensions.json - - +generate_extensions $(cat "$tmp") >"$(dirname "$0")"/../config/extensions/extensions.json -rm "$tmp"; +rm "$tmp" diff --git a/hm/soispha/conf/git/scripts/commit.sh b/hm/soispha/conf/git/scripts/commit.sh index 9baf93bb..c0d706e2 100755 --- a/hm/soispha/conf/git/scripts/commit.sh +++ b/hm/soispha/conf/git/scripts/commit.sh @@ -3,17 +3,16 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -ROOT="$(git rev-parse --show-toplevel)"; +ROOT="$(git rev-parse --show-toplevel)" # Take first line from previous commit if [ -f "$ROOT/.git/COMMIT_EDITMSG" ]; then - sed '1s/\(.*\)\((.*)\)\?\(:.*\)/\1\2: /;1p;d' "$ROOT/.git/COMMIT_EDITMSG" > "$ROOT/.git/COMMIT_TEMPLATE" + sed '1s/\(.*\)\((.*)\)\?\(:.*\)/\1\2: /;1p;d' "$ROOT/.git/COMMIT_EDITMSG" >"$ROOT/.git/COMMIT_TEMPLATE" else - printf "\n" > "$ROOT/.git/COMMIT_TEMPLATE" + printf "\n" >"$ROOT/.git/COMMIT_TEMPLATE" fi -sed '1d' "$(git config commit.template)" >> "$ROOT/.git/COMMIT_TEMPLATE" +sed '1d' "$(git config commit.template)" >>"$ROOT/.git/COMMIT_TEMPLATE" git commit --template "$ROOT/.git/COMMIT_TEMPLATE" --verbose "$@" - # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/default.nix b/hm/soispha/conf/lf/commands/default.nix index 1cb6996a..f5372a38 100644 --- a/hm/soispha/conf/lf/commands/default.nix +++ b/hm/soispha/conf/lf/commands/default.nix @@ -233,7 +233,7 @@ in { gnutar unzip # TODO: this is unfree! unrar - + p7zip ; }; diff --git a/hm/soispha/conf/lf/commands/scripts/archive.sh b/hm/soispha/conf/lf/commands/scripts/archive.sh index 5f4e3792..9ac07898 100755 --- a/hm/soispha/conf/lf/commands/scripts/archive.sh +++ b/hm/soispha/conf/lf/commands/scripts/archive.sh @@ -9,46 +9,52 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # times. set -f -archivers="$(tmp echo gzip xz 7z zip)"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" + +archivers="$(tmp echo gzip xz 7z zip)" prompt "Archive name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Archive already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Archive name: " +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "Archive already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Archive name: " + fi fi - fi done -root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/";fi)"; +root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/"; fi)" # fx contains all selected file name separated by a newline while read -r raw_file; do - file="$(echo "$raw_file" | sed "s|$root||")"; - set -- "$@" "$file"; -done < "$(tmp echo "$fx")"; + file="$(echo "$raw_file" | sed "s|$root||")" + set -- "$@" "$file" +done <"$(tmp echo "$fx")" case "$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" in - "gzip") - tar -czf "$name".tar.gz "$@" - ;; - "xz") - tar -cf "$name".tar "$@" - xz -z -9 -e -T0 "$name".tar - ;; - "7z") - 7z a "$name".7z "$@" - ;; - "zip") - zip --symlinks -r "$name".zip "$@" - ;; +"gzip") + tar -czf "$name".tar.gz "$@" + ;; +"xz") + tar -cf "$name".tar "$@" + xz -z -9 -e -T0 "$name".tar + ;; +"7z") + 7z a "$name".7z "$@" + ;; +"zip") + zip --symlinks -r "$name".zip "$@" + ;; esac # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/broot_jump.sh b/hm/soispha/conf/lf/commands/scripts/broot_jump.sh index 0feb5daf..4afb36ac 100755 --- a/hm/soispha/conf/lf/commands/scripts/broot_jump.sh +++ b/hm/soispha/conf/lf/commands/scripts/broot_jump.sh @@ -3,6 +3,15 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + tmp=$(mktmp) res="$(broot --outcmd "$tmp" && sed 's/cd //' "$tmp")" diff --git a/hm/soispha/conf/lf/commands/scripts/chmod.sh b/hm/soispha/conf/lf/commands/scripts/chmod.sh index f2cc0dc8..81373352 100755 --- a/hm/soispha/conf/lf/commands/scripts/chmod.sh +++ b/hm/soispha/conf/lf/commands/scripts/chmod.sh @@ -3,11 +3,22 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + readp "Mode bits: " bits +# shellcheck disable=SC2269 +bits="$bits" while read -r file; do chmod "$bits" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" lf -remote 'send reload' # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/cow_cp.sh b/hm/soispha/conf/lf/commands/scripts/cow_cp.sh index 85fd3431..c17b7668 100755 --- a/hm/soispha/conf/lf/commands/scripts/cow_cp.sh +++ b/hm/soispha/conf/lf/commands/scripts/cow_cp.sh @@ -1,8 +1,17 @@ -#!/usr/bin/env dash +#!/usr/bin/env bash # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # source: https://github.com/gokcehan/lf/wiki/Tips#use-copy-on-write-when-possible # # # FIXME: Add this. The hardest part is in checking, if a file can be reflinked, as fuse and bind mount are hard to @@ -31,13 +40,13 @@ if [ "$mode" = 'copy' ]; then src_targets="$(df --output=target -- "$@" | sed '1d' | sort -u)" if [ "$(df --output=target -- "$PWD" | tail -n 1)" = \ - "$(echo "$src_targets" | tail -n 1)" ] && \ - (( "$(echo "$src_targets" | wc -l)" == 1 )) && \ + "$(echo "$src_targets" | tail -n 1)" ] && + (("$(echo "$src_targets" | wc -l)" == 1)) && [[ "$(df --output=fstype -- "$PWD" | tail -n 1)" =~ ^(btrfs|xfs|zfs)$ ]]; then - echo 'selected copy and cp reflink paste' + echo 'selected copy and cp reflink paste' - start=$(date '+%s') + start=$(date '+%s') # Handle same names in dst # TODO parallelism, idk - but exit/return/break won't stop the loop from subshell... @@ -47,7 +56,7 @@ if [ "$mode" = 'copy' ]; then count=0 while [ -w "$PWD/$name" ]; do - count=$((count+1)) + count=$((count + 1)) name="$original.~$count~" done @@ -55,15 +64,15 @@ if [ "$mode" = 'copy' ]; then cp_out="$(cp -rn --reflink=always -- "$i" "$PWD/$name" 2>&1)" set -e - if [ ! -z "$cp_out" ]; then + if [ -n "$cp_out" ]; then lf -remote "send $id echoerr $cp_out" exit 0 fi done - finish=$(( $(date '+%s') - $start )) + finish=$(($(date '+%s') - start)) t='' - if (( $finish > 2 )); then + if ((finish > 2)); then t="${finish}s" fi @@ -80,14 +89,14 @@ if [ "$mode" = 'copy' ]; then echo 'selected copy and lf native paste' lf -remote "send $id paste" lf -remote "send clear" - fi - - elif [ $mode = 'move' ]; then - echo 'selected move and lf native paste' - lf -remote "send $id paste" - lf -remote "send clear" fi +elif [ "$mode" = 'move' ]; then + echo 'selected move and lf native paste' + lf -remote "send $id paste" + lf -remote "send clear" +fi + # # for debug # set +x diff --git a/hm/soispha/conf/lf/commands/scripts/dl_file.sh b/hm/soispha/conf/lf/commands/scripts/dl_file.sh index 5092174f..4f97f9b9 100755 --- a/hm/soispha/conf/lf/commands/scripts/dl_file.sh +++ b/hm/soispha/conf/lf/commands/scripts/dl_file.sh @@ -3,31 +3,41 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # Provides the ability to download a file by dropping it into a window url="$(dragon -t -x)" if [ -n "$url" ]; then - prompt "File Name: " - name="" - while [ -z "$name" ] || [ -e "$name" ] - do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans + prompt "File Name: " + name="" + while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans - if [ "$ans" = "y" ]; then - break - else - prompt "File Name: " - fi - fi - done + if [ "$ans" = "y" ]; then + break + else + prompt "File Name: " + fi + fi + done - # Download the file with curl - [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed" + # Download the file with curl + if [ -n "$name" ]; then + curl -o "$name" "$url" || die "curl failed" + fi else - die "URL is null!" + die "URL is null!" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon.sh b/hm/soispha/conf/lf/commands/scripts/dragon.sh index 59a50920..70633583 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" dragon -a -x "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh b/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh index 051537f9..500be67c 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" dragon "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh b/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh index 8f880848..273482ea 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do - set -- "$@" "$file"; -done < "$(tmp echo "$fx")" + set -- "$@" "$file" +done <"$(tmp echo "$fx")" dragon -a "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh b/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh index 172c44d3..6f8981f3 100755 --- a/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh +++ b/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh @@ -5,12 +5,20 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH res="$(fd . --maxdepth 3 | fzf --header='Jump to location')" +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + if [ -f "$res" ]; then cmd="select" elif [ -d "$res" ]; then cmd="cd" fi - lf -remote "send $id $cmd \"$res\"" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/go_project_root.sh b/hm/soispha/conf/lf/commands/scripts/go_project_root.sh index 9ed9f7ad..e1147fce 100755 --- a/hm/soispha/conf/lf/commands/scripts/go_project_root.sh +++ b/hm/soispha/conf/lf/commands/scripts/go_project_root.sh @@ -3,11 +3,20 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -flake_base_dir="$(search_flake_base_dir)"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +flake_base_dir="$(search_flake_base_dir)" if [ "$flake_base_dir" ]; then lf -remote "send $id cd $flake_base_dir" || die "Bug: No base dir ($flake_base_dir)" else - die "Unable to locate base dir"; + die "Unable to locate base dir" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_dir.sh b/hm/soispha/conf/lf/commands/scripts/mk_dir.sh index adf60d99..6079b85d 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_dir.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_dir.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + prompt "Directory Name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Directory already exists, overwrite [y|N]: " - read -r ans +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "Directory already exists, overwrite [y|N]: " + read -r ans - if [ "$ans" = "y" ]; then - break - else - prompt "Directory Name: " + if [ "$ans" = "y" ]; then + break + else + prompt "Directory Name: " + fi fi - fi done mkdir "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file.sh b/hm/soispha/conf/lf/commands/scripts/mk_file.sh index cdef38a0..9fb0a000 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_file.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_file.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + prompt "File name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " + if [ "$ans" = "y" ]; then + break + else + prompt "File name: " + fi fi - fi done touch "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh index 662b29ac..2007cc99 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + prompt "File name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " + if [ "$ans" = "y" ]; then + break + else + prompt "File name: " + fi fi - fi done touch "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_ln.sh b/hm/soispha/conf/lf/commands/scripts/mk_ln.sh index f5dcd395..e767c848 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_ln.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_ln.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -while IFS= read -r i;do +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +while IFS= read -r i; do set -- "$@" "$i" -done < "$HOME"/.local/share/lf/files +done <"$HOME"/.local/share/lf/files mode="$1" shift @@ -16,20 +25,20 @@ if [ "$#" -eq 0 ]; then fi case "$mode" in - copy) - while [ "$#" -gt 0 ]; do - file="$1" - ans="$(basename "$file")" - - while [ -e "$ans" ];do - prompt "$ans already exists, new name for link: " - read -r ans - done - - ln -s "$file" "$(pwd)/$ans" - shift +copy) + while [ "$#" -gt 0 ]; do + file="$1" + ans="$(basename "$file")" + + while [ -e "$ans" ]; do + prompt "$ans already exists, new name for link: " + read -r ans done - ;; + + ln -s "$file" "$(pwd)/$ans" + shift + done + ;; esac rm ~/.local/share/lf/files # lf -remote "send clear" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh index 6e69fc4f..915725cc 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh @@ -3,29 +3,35 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" prompt "Script name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Script already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Script Name: " +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "Script already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Script Name: " + fi fi - fi done script="$(pwd)"/"$name" -cat "%SHELL_LIBRARY_TEMPLATE" > "$script" +cat "%SHELL_LIBRARY_TEMPLATE" >"$script" chmod +x "$script" "$VISUAL" "$script" - # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh index 612ff19d..0f8394fa 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh @@ -3,30 +3,36 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" prompt "Script name: " name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Script already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Script Name: " +while [ -z "$name" ] || [ -e "$name" ]; do + read -r name + if [ -e "$name" ]; then + prompt "Script already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Script Name: " + fi fi - fi done script="$(pwd)"/"$name" -sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" > "$script" +sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" >"$script" sed -i 's|dash|sh|' "$script" chmod +x "$script" "$VISUAL" "$script" - # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open.sh b/hm/soispha/conf/lf/commands/scripts/open.sh index 3dd8f485..4df06dd8 100755 --- a/hm/soispha/conf/lf/commands/scripts/open.sh +++ b/hm/soispha/conf/lf/commands/scripts/open.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + case $(file --mime-type "$f" -bL) in - text/*|application/json|application/vnd.hp-HPGL) "$EDITOR" "$f";; - image/*) "$IVIEWER" "$f";; - *) xdg-open "$f";; +text/* | application/json | application/vnd.hp-HPGL) "$EDITOR" "$f" ;; +image/*) "$IVIEWER" "$f" ;; +*) xdg-open "$f" ;; esac # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open_config.sh b/hm/soispha/conf/lf/commands/scripts/open_config.sh index 4054abdd..455ca25a 100755 --- a/hm/soispha/conf/lf/commands/scripts/open_config.sh +++ b/hm/soispha/conf/lf/commands/scripts/open_config.sh @@ -3,5 +3,14 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + "$EDITOR" "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" # TODO: implement this # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/restore_trash.sh b/hm/soispha/conf/lf/commands/scripts/restore_trash.sh index 94d26a26..7aeed7bf 100755 --- a/hm/soispha/conf/lf/commands/scripts/restore_trash.sh +++ b/hm/soispha/conf/lf/commands/scripts/restore_trash.sh @@ -3,5 +3,14 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh b/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh index f7714880..828c0708 100755 --- a/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh +++ b/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh @@ -3,6 +3,15 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + die "No yet implemented" # TODO: do what the 'die' says #sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv #nohub swaybg -i "$f" diff --git a/hm/soispha/conf/lf/commands/scripts/stripspace.sh b/hm/soispha/conf/lf/commands/scripts/stripspace.sh index c8781a60..65eefbcd 100755 --- a/hm/soispha/conf/lf/commands/scripts/stripspace.sh +++ b/hm/soispha/conf/lf/commands/scripts/stripspace.sh @@ -3,11 +3,20 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -files=$(mktmp); -echo "$fx" > "$files"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" -awk_source=$(mktmp); -cat << OFT > "$awk_source" +files=$(mktmp) +echo "$fx" >"$files" + +awk_source=$(mktmp) +cat <<OFT >"$awk_source" BEGIN {FS=" "} {for (i=1; i != NF + 1; i++) if (i == NF) { @@ -21,11 +30,11 @@ OFT while read -r file; do dirty_name=$(mktmp) - basename "$file" > "$dirty_name"; - clean_name=$(awk -f "$awk_source" "$dirty_name"); + basename "$file" >"$dirty_name" + clean_name=$(awk -f "$awk_source" "$dirty_name") - [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!"; - mv "$(cat "$dirty_name")" "$clean_name" || die "Move failed"; + [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!" + mv "$(cat "$dirty_name")" "$clean_name" || die "Move failed" lf -remote 'send reload' -done < "$files"; +done <"$files" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/trash.sh b/hm/soispha/conf/lf/commands/scripts/trash.sh index 4da188e5..c605420e 100755 --- a/hm/soispha/conf/lf/commands/scripts/trash.sh +++ b/hm/soispha/conf/lf/commands/scripts/trash.sh @@ -3,26 +3,35 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -trash_output=$(mktmp); -expected_error_output=$(mktmp); +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +trash_output=$(mktmp) +expected_error_output=$(mktmp) while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" # TODO: why are we using trashy at all, when trash-cli can do everything? # # try trashy first, through nix because both trashy and trash-cli provide a trash command, which conflicts -nix run nixpkgs#trashy -- put "$@" 2> "$trash_output"; +nix run nixpkgs#trashy -- put "$@" 2>"$trash_output" # FIXME: Find a way, that does not depend on parsing an error message <2023-08-29> -cat << EOF > "$expected_error_output"; +cat <<EOF >"$expected_error_output" [1;31merror:[0m Error during a \`trash\` operation: Unknown { description: "Path: '\"/.Trash-1000\"'. Message: Permission denied (os error 13)" } EOF -if [ "$(cat "$expected_error_output")" = "$(cat "$trash_output")" ];then - warning "Deleting with trash-cli to the /.Trash folder"; +if [ "$(cat "$expected_error_output")" = "$(cat "$trash_output")" ]; then + warning "Deleting with trash-cli to the /.Trash folder" # this file could not be trashed because it is on the tempfs volume, trash-cli can do this this - trash-put "$@"; + trash-put "$@" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/unarchive.sh b/hm/soispha/conf/lf/commands/scripts/unarchive.sh index 1ecc702b..d52eee61 100755 --- a/hm/soispha/conf/lf/commands/scripts/unarchive.sh +++ b/hm/soispha/conf/lf/commands/scripts/unarchive.sh @@ -3,20 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # extract the current file with the right command # (xkcd link: https://xkcd.com/1168/) set -f # TODO: add support for multiple files at once case "$f" in - *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$f";; - *.tar.gz|*.tgz) tar xzvf "$f";; - *.tar.xz|*.txz) tar xJvf "$f";; - *.zip) unzip "$f";; - *.rar) - die "rar is a unfree format!" - #unrar x $f - ;; - *.7z) 7z x "$f";; - *) die "Unsupported format" ;; +*.tar.bz | *.tar.bz2 | *.tbz | *.tbz2) tar xjvf "$f" ;; +*.tar.gz | *.tgz) tar xzvf "$f" ;; +*.tar.xz | *.txz) tar xJvf "$f" ;; +*.zip) unzip "$f" ;; +*.rar) + die "rar is a unfree format!" + #unrar x $f + ;; +*.7z) 7z x "$f" ;; +*) die "Unsupported format" ;; esac # vim: ft=sh diff --git a/hm/soispha/conf/nvim/files/ftplugin/tex.lua b/hm/soispha/conf/nvim/files/ftplugin/tex.lua index 05a2c593..f3fffa86 100644 --- a/hm/soispha/conf/nvim/files/ftplugin/tex.lua +++ b/hm/soispha/conf/nvim/files/ftplugin/tex.lua @@ -19,40 +19,39 @@ -- -- - -- Set tex specific telescope extension require("telescope").setup({ extensions = { bibtex = { -- Depth for the *.bib file - depth = 1; + depth = 1, -- Path to global bibliographies (placed outside of the project) - global_files = {}; + global_files = {}, -- Define the search keys to use in the picker - search_keys = { "author"; "year"; "title"; }; + search_keys = { "author", "year", "title" }, -- Template for the formatted citation - citation_format = "{{author}} ({{year}}), {{title}}."; + citation_format = "{{author}} ({{year}}), {{title}}.", -- Only use initials for the authors first name - citation_trim_firstname = true; + citation_trim_firstname = true, -- Max number of authors to write in the formatted citation -- following authors will be replaced by "et al." - citation_max_auth = 2; + citation_max_auth = 2, -- Wrapping in the preview window is disabled by default - wrap = false; + wrap = false, -- Custom format for citation label custom_formats = { - { id = "tex_autocite"; cite_marker = "\\autocite{%s}"; }; - }; - format = "tex_autocite"; + { id = "tex_autocite", cite_marker = "\\autocite{%s}" }, + }, + format = "tex_autocite", -- Use context awareness - context = true; + context = true, -- Fallback to global/directory .bib files if context not found -- This setting has no effect if context = false - context_fallback = true; - }; - }; + context_fallback = true, + }, + }, }) require("telescope").load_extension("bibtex") vim.keymap.set("n", "<leader>ib", function() - require("telescope").extensions.bibtex.bibtex() - end, { noremap = true; silent = true; desc = "list bibtex entries in telescope"; }) + require("telescope").extensions.bibtex.bibtex() +end, { noremap = true, silent = true, desc = "list bibtex entries in telescope" }) diff --git a/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua b/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua index ee28151c..d02171b5 100644 --- a/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua +++ b/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua @@ -1,17 +1,16 @@ -local opts = { bg = "NONE"; bold = true; } - +local opts = { bg = "NONE", bold = true } ---@param hl_group string: The name of the hl group ---@param extra_opts table: Extra options to pass to nvim_set_hl local set_hl = function(hl_group, extra_opts) - local local_opts = vim.deepcopy(opts); + local local_opts = vim.deepcopy(opts) for k, v in ipairs(extra_opts) do - local_opts[k] = v; + local_opts[k] = v end vim.api.nvim_set_hl(0, hl_group, local_opts) end -set_hl("@text.danger", { fg = "red"; }) -set_hl("@text.note", { fg = "blue"; }) -set_hl("@text.todo", { fg = "green"; }) -set_hl("@text.warning", { fg = "yellow"; }) +set_hl("@text.danger", { fg = "red" }) +set_hl("@text.note", { fg = "blue" }) +set_hl("@text.todo", { fg = "green" }) +set_hl("@text.warning", { fg = "yellow" }) diff --git a/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua b/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua index 025eb133..4c502153 100644 --- a/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua +++ b/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua @@ -1,44 +1,44 @@ require("nightfox").setup({ options = { -- Compiled file's destination location - compile_path = vim.fn.stdpath("cache") .. "/nightfox"; - compile_file_suffix = "_compiled"; -- Compiled file suffix - transparent = true; -- Disable setting background - terminal_colors = true; -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal` - dim_inactive = true; -- Non focused panes set to alternative background - module_default = true; -- Default enable value for modules + compile_path = vim.fn.stdpath("cache") .. "/nightfox", + compile_file_suffix = "_compiled", -- Compiled file suffix + transparent = true, -- Disable setting background + terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal` + dim_inactive = true, -- Non focused panes set to alternative background + module_default = true, -- Default enable value for modules colorblind = { - enable = true; -- Enable colorblind support - simulate_only = false; -- Only show simulated colorblind colors and not diff shifted + enable = true, -- Enable colorblind support + simulate_only = false, -- Only show simulated colorblind colors and not diff shifted severity = { - protan = 0.3; -- Severity [0,1] for protan (red) - deutan = 0.9; -- Severity [0,1] for deutan (green) - tritan = 0; -- Severity [0,1] for tritan (blue) - }; - }; - styles = { -- Style to be applied to different syntax groups - comments = "italic"; -- Value is any valid attr-list value `:help attr-list` - conditionals = "NONE"; - constants = "NONE"; - functions = "bold"; - keywords = "bold"; - numbers = "NONE"; - operators = "NONE"; - strings = "NONE"; - types = "NONE"; - variables = "NONE"; - }; + protan = 0.3, -- Severity [0,1] for protan (red) + deutan = 0.9, -- Severity [0,1] for deutan (green) + tritan = 0, -- Severity [0,1] for tritan (blue) + }, + }, + styles = { -- Style to be applied to different syntax groups + comments = "italic", -- Value is any valid attr-list value `:help attr-list` + conditionals = "NONE", + constants = "NONE", + functions = "bold", + keywords = "bold", + numbers = "NONE", + operators = "NONE", + strings = "NONE", + types = "NONE", + variables = "NONE", + }, inverse = { -- Inverse highlight for different types - match_paren = false; - visual = false; - search = false; - }; + match_paren = false, + visual = false, + search = false, + }, modules = { -- List of various plugins and additional options - diagnostic = { enable = true; background = false; }; - native_lsp = { enable = true; background = false; }; - }; - }; - palettes = {}; - specs = {}; - groups = {}; + diagnostic = { enable = true, background = false }, + native_lsp = { enable = true, background = false }, + }, + }, + palettes = {}, + specs = {}, + groups = {}, }) diff --git a/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua b/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua index 2ea38df4..da7e1735 100644 --- a/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua +++ b/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua @@ -1,4 +1,3 @@ require("debugprint").setup({ - create_keymaps = false; + create_keymaps = false, }) - diff --git a/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua b/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua index 10064b5e..da3be8e1 100644 --- a/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua +++ b/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua @@ -1,4 +1,4 @@ -local clip_val = require('femaco.utils').clip_val +local clip_val = require("femaco.utils").clip_val require("femaco").setup({ -- should prepare a new buffer and return the winid -- by default opens a floating window @@ -7,7 +7,7 @@ require("femaco").setup({ prepare_buffer = function(opts) local buf = vim.api.nvim_create_buf(false, false) return vim.api.nvim_open_win(buf, true, opts) - end; + end, -- should return options passed to nvim_open_win -- @param code_block: data about the code-block with the keys -- * range @@ -15,30 +15,30 @@ require("femaco").setup({ -- * lang float_opts = function(code_block) return { - relative = "cursor"; - width = clip_val(5, 120, vim.api.nvim_win_get_width(0) - 10); -- TODO: how to offset sign column etc? - height = clip_val(5, #code_block.lines, vim.api.nvim_win_get_height(0) - 6); - anchor = "NW"; - row = 0; - col = 0; - style = "minimal"; - border = "rounded"; - zindex = 1; + relative = "cursor", + width = clip_val(5, 120, vim.api.nvim_win_get_width(0) - 10), -- TODO: how to offset sign column etc? + height = clip_val(5, #code_block.lines, vim.api.nvim_win_get_height(0) - 6), + anchor = "NW", + row = 0, + col = 0, + style = "minimal", + border = "rounded", + zindex = 1, } - end; + end, -- return filetype to use for a given lang -- lang can be nil ft_from_lang = function(lang) return lang - end; + end, -- what to do after opening the float post_open_float = function(winnr) vim.wo.signcolumn = "no" - end; + end, -- create the path to a temporary file create_tmp_filepath = function(filetype) return os.tmpname() - end; + end, -- if a newline should always be used, useful for multiline injections -- which separators needs to be on separate lines such as markdown, neorg etc -- @param base_filetype: The filetype which FeMaco is called from, not the @@ -46,5 +46,5 @@ require("femaco").setup({ -- get it from vim.bo.filetyp). ensure_newline = function(base_filetype) return false - end; + end, }) diff --git a/hm/soispha/conf/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua b/hm/soispha/conf/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua index 8db7d293..42ea1eb6 100644 --- a/hm/soispha/conf/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua +++ b/hm/soispha/conf/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua @@ -21,16 +21,16 @@ require("flatten").setup({ ---Called to determine if a nested session should wait for the host to close the file. ---param argv: a list of all the arguments in the nested session ---@type fun(argv: table): boolean - should_block = require("flatten").default_should_block; + should_block = require("flatten").default_should_block, ---If this returns true, the nested session will be opened. ---If false, default behavior is used, and ---config.nest_if_no_args is respected. ---@type fun(host: channel):boolean - should_nest = require("flatten").default_should_nest; + should_nest = require("flatten").default_should_nest, ---Called before a nested session is opened. - pre_open = function() end; + pre_open = function() end, ---Called after a nested session is opened. ---@param bufnr buffer @@ -42,27 +42,27 @@ require("flatten").setup({ -- If the file is a git commit, create one-shot autocmd to delete its buffer on write if filetype == "gitcommit" or filetype == "gitrebase" then vim.api.nvim_create_autocmd("BufWritePost", { - buffer = bufnr; - once = true; + buffer = bufnr, + once = true, callback = vim.schedule_wrap(function() vim.api.nvim_buf_delete(bufnr, {}) - end); + end), }) end - end; + end, ---Called when a nested session is done waiting for the host. ---@param filetype string - block_end = function(filetype) end; - }; + block_end = function(filetype) end, + }, -- <String, Bool> dictionary of filetypes that should be blocking block_for = { - gitcommit = true; - }; + gitcommit = true, + }, -- Command passthrough - allow_cmd_passthrough = true; + allow_cmd_passthrough = true, -- Allow a nested session to open if Neovim is opened without arguments - nest_if_no_args = false; + nest_if_no_args = false, -- Window options window = { -- Options: @@ -75,7 +75,7 @@ require("flatten").setup({ -- OpenHandler -> allows you to handle file opening yourself (see Types) -- -- TODO: Open gitcommit filetypes in the current buffer, everything else in a new tab <2023-08-29> - open = "split"; + open = "split", -- Options: -- vsplit -> opens files in diff vsplits @@ -83,24 +83,24 @@ require("flatten").setup({ -- tab_vsplit -> creates a new tabpage, and opens diff vsplits -- tab_split -> creates a new tabpage, and opens diff splits -- OpenHandler -> allows you to handle file opening yourself (see Types) - diff = "tab_vsplit"; + diff = "tab_vsplit", -- Affects which file gets focused when opening multiple at once -- Options: -- "first" -> open first file of new files (default) -- "last" -> open last file of new files - focus = "first"; - }; + focus = "first", + }, -- Override this function to use a different socket to connect to the host -- On the host side this can return nil or the socket address. -- On the guest side this should return the socket address -- or a non-zero channel id from `sockconnect` -- flatten.nvim will detect if the address refers to this instance of nvim, to determine if this is a host or a guest - pipe_path = require"flatten".default_pipe_path; + pipe_path = require("flatten").default_pipe_path, -- The `default_pipe_path` will treat the first nvim instance within a single kitty/wezterm session as the host -- You can configure this behaviour using the following: one_per = { - kitty = true; -- Flatten all instance in the current Kitty session - wezterm = true; -- Flatten all instance in the current Wezterm session - }; + kitty = true, -- Flatten all instance in the current Kitty session + wezterm = true, -- Flatten all instance in the current Wezterm session + }, }) diff --git a/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua b/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua index cde50d3e..9687a5a0 100644 --- a/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua +++ b/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua @@ -1,21 +1,21 @@ require("goto-preview").setup({ - width = 120; -- Width of the floating window - height = 15; -- Height of the floating window - border = { "↖"; "─"; "┐"; "│"; "┘"; "─"; "└"; "│"; }; -- Border characters of the floating window - default_mappings = false; -- Bind default mappings - debug = false; -- Print debug information - opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent. - resizing_mappings = false; -- Binds arrow keys to resizing the floating window. - post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. - post_close_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + width = 120, -- Width of the floating window + height = 15, -- Height of the floating window + border = { "↖", "─", "┐", "│", "┘", "─", "└", "│" }, -- Border characters of the floating window + default_mappings = false, -- Bind default mappings + debug = false, -- Print debug information + opacity = nil, -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false, -- Binds arrow keys to resizing the floating window. + post_open_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook. + post_close_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook. references = { -- Configure the telescope UI for slowing the references cycling window. - telescope = {}; -- require("telescope.themes").get_dropdown({ hide_preview = false }) - }; + telescope = {}, -- require("telescope.themes").get_dropdown({ hide_preview = false }) + }, -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. - focus_on_open = true; -- Focus the floating window when opening it. - dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. - force_close = true; -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close - bufhidden = "wipe"; -- the bufhidden option to set on the floating window. See :h bufhidden - stack_floating_preview_windows = true; -- Whether to nest floating windows - preview_window_title = { enable = true; position = "left"; }; -- Whether to set the preview window title as the filename + focus_on_open = true, -- Focus the floating window when opening it. + dismiss_on_move = false, -- Dismiss the floating window when moving the cursor. + force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden + stack_floating_preview_windows = true, -- Whether to nest floating windows + preview_window_title = { enable = true, position = "left" }, -- Whether to set the preview window title as the filename }) diff --git a/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua b/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua index 8a0cf817..1eadf375 100644 --- a/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua +++ b/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua @@ -2,42 +2,42 @@ local fn = vim.fn -- Defaults require("lf").setup({ - default_action = "drop"; -- default action when `Lf` opens a file + default_action = "drop", -- default action when `Lf` opens a file -- TODO: what do these mappings do? - default_actions = { -- default action keybindings - ["<C-t>"] = "tabedit"; - ["<C-x>"] = "split"; - ["<C-v>"] = "vsplit"; - ["<C-o>"] = "tab drop"; - }; + default_actions = { -- default action keybindings + ["<C-t>"] = "tabedit", + ["<C-x>"] = "split", + ["<C-v>"] = "vsplit", + ["<C-o>"] = "tab drop", + }, - winblend = 10; -- psuedotransparency level - dir = ""; -- directory where `lf` starts ('gwd' is git-working-directory, ""/nil is CWD) - direction = "float"; -- window type: float horizontal vertical - border = "rounded"; -- border kind: single double shadow curved - height = fn.float2nr(fn.round(0.75 * vim.o.lines)); -- height of the *floating* window - width = fn.float2nr(fn.round(0.75 * vim.o.columns)); -- width of the *floating* window - escape_quit = true; -- map escape to the quit command (so it doesn't go into a meta normal mode) - focus_on_open = true; -- focus the current file when opening Lf (experimental) - mappings = true; -- whether terminal buffer mapping is enabled - tmux = false; -- tmux statusline can be disabled on opening of Lf - default_file_manager = true; -- make lf default file manager - disable_netrw_warning = true; -- don't display a message when opening a directory with `default_file_manager` as true - highlights = { -- highlights passed to toggleterm - Normal = { link = "Normal"; }; - NormalFloat = { link = "Normal"; }; - FloatBorder = { guifg = "#cdcbe0"; guibg = "#191726"; }; - }; + winblend = 10, -- psuedotransparency level + dir = "", -- directory where `lf` starts ('gwd' is git-working-directory, ""/nil is CWD) + direction = "float", -- window type: float horizontal vertical + border = "rounded", -- border kind: single double shadow curved + height = fn.float2nr(fn.round(0.75 * vim.o.lines)), -- height of the *floating* window + width = fn.float2nr(fn.round(0.75 * vim.o.columns)), -- width of the *floating* window + escape_quit = true, -- map escape to the quit command (so it doesn't go into a meta normal mode) + focus_on_open = true, -- focus the current file when opening Lf (experimental) + mappings = true, -- whether terminal buffer mapping is enabled + tmux = false, -- tmux statusline can be disabled on opening of Lf + default_file_manager = true, -- make lf default file manager + disable_netrw_warning = true, -- don't display a message when opening a directory with `default_file_manager` as true + highlights = { -- highlights passed to toggleterm + Normal = { link = "Normal" }, + NormalFloat = { link = "Normal" }, + FloatBorder = { guifg = "#cdcbe0", guibg = "#191726" }, + }, -- Layout configurations - layout_mapping = "<M-u>"; -- resize window with this key - views = { -- window dimensions to rotate through - { width = 0.800; height = 0.800; }; - { width = 0.600; height = 0.600; }; - { width = 0.950; height = 0.950; }; - { width = 0.500; height = 0.500; col = 0; row = 0; }; - { width = 0.500; height = 0.500; col = 0; row = 0.5; }; - { width = 0.500; height = 0.500; col = 0.5; row = 0; }; - { width = 0.500; height = 0.500; col = 0.5; row = 0.5; }; - }; + layout_mapping = "<M-u>", -- resize window with this key + views = { -- window dimensions to rotate through + { width = 0.800, height = 0.800 }, + { width = 0.600, height = 0.600 }, + { width = 0.950, height = 0.950 }, + { width = 0.500, height = 0.500, col = 0, row = 0 }, + { width = 0.500, height = 0.500, col = 0, row = 0.5 }, + { width = 0.500, height = 0.500, col = 0.5, row = 0 }, + { width = 0.500, height = 0.500, col = 0.5, row = 0.5 }, + }, }) diff --git a/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua b/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua index 4273085c..efb15720 100644 --- a/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua +++ b/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua @@ -3,12 +3,12 @@ require("lsp-progress").setup({ -- Spinning icons. -- --- @type string[] - spinner = { "⣾"; "⣽"; "⣻"; "⢿"; "⡿"; "⣟"; "⣯"; "⣷"; }; + spinner = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }, -- Spinning update time in milliseconds. -- --- @type integer - spin_update_time = 200; + spin_update_time = 200, -- Last message cached decay time in milliseconds. -- @@ -17,12 +17,12 @@ require("lsp-progress").setup({ -- for a while for user view. -- --- @type integer - decay = 700; + decay = 700, -- User event name. -- --- @type string - event = "LspProgressStatusUpdated"; + event = "LspProgressStatusUpdated", -- Event update time limit in milliseconds. -- @@ -31,12 +31,12 @@ require("lsp-progress").setup({ -- event rate to reduce this cost. -- --- @type integer - event_update_time_limit = 100; + event_update_time_limit = 100, -- Max progress string length, by default -1 is unlimited. -- --- @type integer - max_size = -1; + max_size = -1, -- Regular internal update time. -- @@ -44,7 +44,7 @@ require("lsp-progress").setup({ -- message. -- --- @type integer - regular_internal_update_time = 500; + regular_internal_update_time = 500, -- Disable emitting events on specific mode/filetype. -- User events would interrupt insert mode, thus break which-key like plugins behaviour. @@ -53,7 +53,7 @@ require("lsp-progress").setup({ -- * https://neovim.io/doc/user/builtin.html#mode() -- --- @type table[] - disable_events_opts = { { mode = "i"; filetype = "TelescopePrompt"; }; }; + disable_events_opts = { { mode = "i", filetype = "TelescopePrompt" } }, -- Format series message. -- @@ -89,7 +89,7 @@ require("lsp-progress").setup({ table.insert(builder, "- done") end return table.concat(builder, " ") - end; + end, -- Format client message. -- @@ -107,9 +107,9 @@ require("lsp-progress").setup({ --- `client_messages` array, or ignored if return nil. client_format = function(client_name, spinner, series_messages) return #series_messages > 0 - and ("[" .. client_name .. "] " .. spinner .. " " .. table.concat(series_messages, ", ")) + and ("[" .. client_name .. "] " .. spinner .. " " .. table.concat(series_messages, ", ")) or nil - end; + end, -- Format (final) message. -- @@ -123,22 +123,22 @@ require("lsp-progress").setup({ format = function(client_messages) local sign = " LSP" -- nf-fa-gear \uf013 return #client_messages > 0 and (sign .. " " .. table.concat(client_messages, " ")) or sign - end; + end, -- Enable debug. -- --- @type boolean - debug = false; + debug = false, -- Print log to console(command line). -- --- @type boolean - console_log = false; + console_log = false, -- Print log to file. -- --- @type boolean - file_log = true; + file_log = true, -- Log file to write, work with `file_log=true`. -- @@ -146,5 +146,5 @@ require("lsp-progress").setup({ -- For *NIX: `~/.local/share/nvim/lsp-progress.log`. -- --- @type string - file_log_name = "lsp-progress.log"; + file_log_name = "lsp-progress.log", }) diff --git a/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua b/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua index 9bcfd33c..f55a9ba7 100644 --- a/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua +++ b/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua @@ -1,16 +1,16 @@ require("ltex_extra").setup({ -- table <string> : languages for witch dictionaries will be loaded, e.g. { "es-AR", "en-US" } -- https://valentjn.github.io/ltex/supported-languages.html#natural-languages - load_langs = {"en-CA", "de-DE"}; -- en-US as default + load_langs = { "en-CA", "de-DE" }, -- en-US as default -- boolean : whether to load dictionaries on startup - init_check = true; + init_check = true, -- string : relative or absolute path to store dictionaries -- e.g. subfolder in the project root or the current working directory: ".ltex" -- e.g. shared files for all projects: vim.fn.expand("~") .. "/.local/share/ltex" - path = vim.fn.expand("~") .. "/.local/state/nvim/ltex"; -- project root or current working directory + path = vim.fn.expand("~") .. "/.local/state/nvim/ltex", -- project root or current working directory -- string : "none", "trace", "debug", "info", "warn", "error", "fatal" - log_level = "warn"; + log_level = "warn", -- table : configurations of the ltex language server. -- Only if you are calling the server from ltex_extra - server_opts = nil; + server_opts = nil, }) diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua index 0a603692..a05fa57f 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua @@ -1,7 +1,7 @@ require("luasnip").config.set_config({ -- Enable auto triggered snippets - enable_autosnippets = true; + enable_autosnippets = true, -- Use Tab (or some other key if you prefer) to trigger visual selection - store_selection_keys = "<Tab>"; + store_selection_keys = "<Tab>", }) diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua index c98ee7d2..c3f75058 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua @@ -1,4 +1,4 @@ -local ls = require("luasnip"); +local ls = require("luasnip") -- auto_pairs {{{ local get_visual = function(args, parent) if #parent.snippet.env.SELECT_RAW > 0 then @@ -29,31 +29,31 @@ local function pair(pair_begin, pair_end, file_types, condition_function) -- file_types = file_types or {}; return s( - { trig = pair_begin; wordTrig = false; snippetType = "autosnippet"; }, - { t({ pair_begin; }); d(1, get_visual); t({ pair_end; }); }, + { trig = pair_begin, wordTrig = false, snippetType = "autosnippet" }, + { t({ pair_begin }), d(1, get_visual), t({ pair_end }) }, { condition = function() - local filetype_check = true; + local filetype_check = true if file_types ~= nil then - filetype_check = file_types[vim.bo.filetype] or false; - end; + filetype_check = file_types[vim.bo.filetype] or false + end return (not condition_function(pair_begin, pair_end)) and filetype_check - end; + end, } ) end local auto_pairs = { - pair("(", ")", nil, char_count_same); - pair("{", "}", nil, char_count_same); - pair("[", "]", nil, char_count_same); - pair("<", ">", { ["rust"] = true; ["tex"] = true; }, char_count_same); - pair("'", "'", nil, even_count); - pair('"', '"', nil, even_count); - pair("`", "`", nil, even_count); + pair("(", ")", nil, char_count_same), + pair("{", "}", nil, char_count_same), + pair("[", "]", nil, char_count_same), + pair("<", ">", { ["rust"] = true, ["tex"] = true }, char_count_same), + pair("'", "'", nil, even_count), + pair('"', '"', nil, even_count), + pair("`", "`", nil, even_count), } -ls.add_snippets("all", auto_pairs, { type = "snippets"; key = "auto_pairs"; }) +ls.add_snippets("all", auto_pairs, { type = "snippets", key = "auto_pairs" }) -- }}} -- todo_comments {{{ @@ -65,34 +65,33 @@ local utils = require("Comment.utils") ---@return table comment_strings {begcstring, endcstring} local get_cstring = function(ctype) -- use the `Comments.nvim` API to fetch the comment string for the region (eq. '--%s' or '--[[%s]]' for `lua`) - local cstring = calculate_comment_string{ ctype = ctype; range = utils.get_region(); } or vim.bo.commentstring + local cstring = calculate_comment_string({ ctype = ctype, range = utils.get_region() }) or vim.bo.commentstring -- as we want only the strings themselves and not strings ready for using `format` we want to split the left and right side local left, right = utils.unwrap_cstr(cstring) -- create a `{left, right}` table for it - return { left; right; } + return { left, right } end _G.luasnip = {} _G.luasnip.vars = { - username = "@soispha"; - email = "soispha@vhack.eu"; + username = "@soispha", + email = "soispha@vhack.eu", } - --- Options for marks to be used in a TODO comment ---@return table,table: The first table contains a node for the date, the second for the signature local marks = { signature = function() return t("(" .. _G.luasnip.vars.username .. ")"), t("") - end; + end, date_signature = function() - return t("<" .. os.date"%Y-%m-%d" .. ">"), t("(" .. _G.luasnip.vars.username .. ")") - end; + return t("<" .. os.date("%Y-%m-%d") .. ">"), t("(" .. _G.luasnip.vars.username .. ")") + end, date = function() - return t("<" .. os.date"%Y-%m-%d" .. ">"), t("") - end; + return t("<" .. os.date("%Y-%m-%d") .. ">"), t("") + end, empty = function() return t(""), t("") - end; + end, } ---@param alias string @@ -100,19 +99,19 @@ local marks = { ---@param mark_function function: This function should return two nodes ---@return table: Returns the comment node local todo_snippet_nodes = function(alias, opts, mark_function) - local date_node, signature_node = mark_function(); + local date_node, signature_node = mark_function() -- format them into the actual snippet local comment_node = fmta("<> <><>: <> <> <>", { f(function() return get_cstring(opts.ctype)[1] -- get <comment-string[1]> - end); - t(alias); -- [name-of-comment] - signature_node; - i(0); -- {comment-text} - date_node; + end), + t(alias), -- [name-of-comment] + signature_node, + i(0), -- {comment-text} + date_node, f(function() return get_cstring(opts.ctype)[2] -- get <comment-string[2]> - end); + end), }) return comment_node end @@ -128,17 +127,13 @@ local todo_snippet = function(context, alias, opts, mark_function) if not context.trig then return error("context doesn't include a `trig` key which is mandatory", 2) -- all we need from the context is the trigger end - opts.ctype = opts.ctype or - 1 -- comment type can be passed in the `opts` table, but if it is not, we have to ensure, it is defined - local alias_string = alias -- `choice_node` documentation - context.name = context.name or - (alias_string .. " comment") -- generate the `name` of the snippet if not defined - context.dscr = context.dscr or - (alias_string .. " comment with a signature-mark") -- generate the `dscr` if not defined - context.docstring = context.docstring or - (" {1:" .. alias_string .. "}: {3} <{2:mark}>{0} ") -- generate the `docstring` if not defined + opts.ctype = opts.ctype or 1 -- comment type can be passed in the `opts` table, but if it is not, we have to ensure, it is defined + local alias_string = alias -- `choice_node` documentation + context.name = context.name or (alias_string .. " comment") -- generate the `name` of the snippet if not defined + context.dscr = context.dscr or (alias_string .. " comment with a signature-mark") -- generate the `dscr` if not defined + context.docstring = context.docstring or (" {1:" .. alias_string .. "}: {3} <{2:mark}>{0} ") -- generate the `docstring` if not defined local comment_node = todo_snippet_nodes(alias, opts, mark_function) - return s(context, comment_node, opts) -- the final todo-snippet constructed from our parameters + return s(context, comment_node, opts) -- the final todo-snippet constructed from our parameters end ---@param context table: The luasnip context @@ -147,39 +142,41 @@ end ---@param marks table: Possible marks to account in snipped generation ---@return table: All possible snippets build from the marks local process_marks = function(context, aliases, opts, marks) - local output = {}; + local output = {} for mark_name, mark_function in pairs(marks) do - local contex_trig_local = context.trig; - context.trig = context.trig .. "-" .. mark_name; - output[#output + 1] = todo_snippet(context, aliases, opts, mark_function); - context.trig = contex_trig_local; + local contex_trig_local = context.trig + context.trig = context.trig .. "-" .. mark_name + output[#output + 1] = todo_snippet(context, aliases, opts, mark_function) + context.trig = contex_trig_local end - return output; + return output end local todo_snippet_specs = { - { { trig = "todo"; }; { "TODO"; }; { ctype = 1; }; }; - { { trig = "fix"; }; { "FIXME"; "ISSUE"; }; { ctype = 1; }; }; - { { trig = "hack"; }; { "HACK"; }; { ctype = 1; }; }; - { { trig = "warn"; }; { "WARNING"; }; { ctype = 1; }; }; - { { trig = "perf"; }; { "PERFORMANCE"; "OPTIMIZE"; }; { ctype = 1; }; }; - { { trig = "note"; }; { "NOTE"; "INFO"; }; { ctype = 1; }; }; + { { trig = "todo" }, { "TODO" }, { ctype = 1 } }, + { { trig = "fix" }, { "FIXME", "ISSUE" }, { ctype = 1 } }, + { { trig = "hack" }, { "HACK" }, { ctype = 1 } }, + { { trig = "warn" }, { "WARNING" }, { ctype = 1 } }, + { { trig = "perf" }, { "PERFORMANCE", "OPTIMIZE" }, { ctype = 1 } }, + { { trig = "note" }, { "NOTE", "INFO" }, { ctype = 1 } }, -- NOTE: Block commented todo-comments - { { trig = "todob"; }; { "TODO"; }; { ctype = 2; }; }; - { { trig = "fixb"; }; { "FIXME"; "ISSUE"; }; { ctype = 2; }; }; - { { trig = "hackb"; }; { "HACK"; }; { ctype = 2; }; }; - { { trig = "warnb"; }; { "WARNING"; }; { ctype = 2; }; }; - { { trig = "perfb"; }; { "PERF"; "PERFORMANCE"; "OPTIM"; "OPTIMIZE"; }; { ctype = 2; }; }; - { { trig = "noteb"; }; { "NOTE"; "INFO"; }; { ctype = 2; }; }; + { { trig = "todob" }, { "TODO" }, { ctype = 2 } }, + { { trig = "fixb" }, { "FIXME", "ISSUE" }, { ctype = 2 } }, + { { trig = "hackb" }, { "HACK" }, { ctype = 2 } }, + { { trig = "warnb" }, { "WARNING" }, { ctype = 2 } }, + { { trig = "perfb" }, { "PERF", "PERFORMANCE", "OPTIM", "OPTIMIZE" }, { ctype = 2 } }, + { { trig = "noteb" }, { "NOTE", "INFO" }, { ctype = 2 } }, } local todo_comment_snippets = {} for _, v in ipairs(todo_snippet_specs) do local snippets = process_marks(v[1], v[2][1], v[3], marks) - for _, value in pairs(snippets) do table.insert(todo_comment_snippets, value) end + for _, value in pairs(snippets) do + table.insert(todo_comment_snippets, value) + end end -ls.add_snippets("all", todo_comment_snippets, { type = "snippets"; key = "todo_comments"; }) +ls.add_snippets("all", todo_comment_snippets, { type = "snippets", key = "todo_comments" }) -- }}} diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua index c467dd68..17e1e7fb 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua @@ -12,10 +12,10 @@ return { -- HEADER s( { - trig = "h([123456])"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; + trig = "h([123456])", + regTrig = true, + wordTrig = false, + snippetType = "autosnippet", }, fmt( [[ @@ -24,50 +24,50 @@ return { { f(function(_, snip) return snip.captures[1] - end); - d(1, get_visual); + end), + d(1, get_visual), f(function(_, snip) return snip.captures[1] - end); + end), } ), - { condition = line_begin; } - ); -- PARAGRAPH + { condition = line_begin } + ), -- PARAGRAPH s( - { trig = "pp"; snippetType = "autosnippet"; }, + { trig = "pp", snippetType = "autosnippet" }, fmt( [[ <p>{}</p> ]], - { d(1, get_visual); } + { d(1, get_visual) } ), - { condition = line_begin; } - ); -- UNORDERED LIST + { condition = line_begin } + ), -- UNORDERED LIST s( - { trig = "itt"; snippetType = "autosnippet"; }, + { trig = "itt", snippetType = "autosnippet" }, fmt( [[ <ul> <li>{}</li>{} </ul> ]], - { i(1); i(0); } + { i(1), i(0) } ), - { condition = line_begin; } - ); -- LIST ITEM + { condition = line_begin } + ), -- LIST ITEM s( - { trig = "ii"; snippetType = "autosnippet"; }, + { trig = "ii", snippetType = "autosnippet" }, fmt( [[ <li>{}</li> ]], - { d(1, get_visual); } + { d(1, get_visual) } ), - { condition = line_begin; } - ); + { condition = line_begin } + ), -- DOCUMENT TEMPLATE s( - { trig = "base"; }, + { trig = "base" }, fmt( [[ <!doctype HTML> @@ -81,16 +81,16 @@ return { </body> </html> ]], - { i(1, "FooBar"); i(0); } + { i(1, "FooBar"), i(0) } ), - { condition = line_begin; } - ); -- ANCHOR TAG + { condition = line_begin } + ), -- ANCHOR TAG s( { - trig = "([^%l])aa"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; + trig = "([^%l])aa", + regTrig = true, + wordTrig = false, + snippetType = "autosnippet", }, fmt( [[ @@ -99,10 +99,10 @@ return { { f(function(_, snip) return snip.captures[1] - end); - i(1); - d(2, get_visual); + end), + i(1), + d(2, get_visual), } ) - ); + ), } diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua index e50898fc..22434aa3 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua @@ -6,29 +6,29 @@ local get_visual = function(args, parent) end end -local translation_table = { ["("] = ")"; ["{"] = "}"; ["["] = "]"; } +local translation_table = { ["("] = ")", ["{"] = "}", ["["] = "]" } -- Return snippet tables return { -- LEFT/RIGHT ALL BRACES s( { - trig = "([^%a])l([%(%[%{])"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; + trig = "([^%a])l([%(%[%{])", + regTrig = true, + wordTrig = false, + snippetType = "autosnippet", }, fmta("<>\\left<><>\\right<>", { f(function(_, snip) return snip.captures[1] - end); + end), f(function(_, snip) return snip.captures[2] - end); - d(1, get_visual); + end), + d(1, get_visual), f(function(_, snip) return translation_table[snip.captures[2]] - end); + end), }) - ); + ), } diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua index 19989093..ebf4f9d7 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua @@ -1,37 +1,37 @@ -- Return snippet tables return { - s({ trig = ";a"; snippetType = "autosnippet"; }, { t("\\alpha"); }); - s({ trig = ";b"; snippetType = "autosnippet"; }, { t("\\beta"); }); - s({ trig = ";g"; snippetType = "autosnippet"; }, { t("\\gamma"); }); - s({ trig = ";G"; snippetType = "autosnippet"; }, { t("\\Gamma"); }); - s({ trig = ";d"; snippetType = "autosnippet"; }, { t("\\delta"); }); - s({ trig = ";D"; snippetType = "autosnippet"; }, { t("\\Delta"); }); - s({ trig = ";e"; snippetType = "autosnippet"; }, { t("\\epsilon"); }); - s({ trig = ";ve"; snippetType = "autosnippet"; }, { t("\\varepsilon"); }); - s({ trig = ";z"; snippetType = "autosnippet"; }, { t("\\zeta"); }); - s({ trig = ";h"; snippetType = "autosnippet"; }, { t("\\eta"); }); - s({ trig = ";o"; snippetType = "autosnippet"; }, { t("\\theta"); }); - s({ trig = ";vo"; snippetType = "autosnippet"; }, { t("\\vartheta"); }); - s({ trig = ";O"; snippetType = "autosnippet"; }, { t("\\Theta"); }); - s({ trig = ";k"; snippetType = "autosnippet"; }, { t("\\kappa"); }); - s({ trig = ";l"; snippetType = "autosnippet"; }, { t("\\lambda"); }); - s({ trig = ";L"; snippetType = "autosnippet"; }, { t("\\Lambda"); }); - s({ trig = ";m"; snippetType = "autosnippet"; }, { t("\\mu"); }); - s({ trig = ";n"; snippetType = "autosnippet"; }, { t("\\nu"); }); - s({ trig = ";x"; snippetType = "autosnippet"; }, { t("\\xi"); }); - s({ trig = ";X"; snippetType = "autosnippet"; }, { t("\\Xi"); }); - s({ trig = ";i"; snippetType = "autosnippet"; }, { t("\\pi"); }); - s({ trig = ";I"; snippetType = "autosnippet"; }, { t("\\Pi"); }); - s({ trig = ";r"; snippetType = "autosnippet"; }, { t("\\rho"); }); - s({ trig = ";s"; snippetType = "autosnippet"; }, { t("\\sigma"); }); - s({ trig = ";S"; snippetType = "autosnippet"; }, { t("\\Sigma"); }); - s({ trig = ";t"; snippetType = "autosnippet"; }, { t("\\tau"); }); - s({ trig = ";f"; snippetType = "autosnippet"; }, { t("\\phi"); }); - s({ trig = ";vf"; snippetType = "autosnippet"; }, { t("\\varphi"); }); - s({ trig = ";F"; snippetType = "autosnippet"; }, { t("\\Phi"); }); - s({ trig = ";c"; snippetType = "autosnippet"; }, { t("\\chi"); }); - s({ trig = ";p"; snippetType = "autosnippet"; }, { t("\\psi"); }); - s({ trig = ";P"; snippetType = "autosnippet"; }, { t("\\Psi"); }); - s({ trig = ";w"; snippetType = "autosnippet"; }, { t("\\omega"); }); - s({ trig = ";W"; snippetType = "autosnippet"; }, { t("\\Omega"); }); + s({ trig = ";a", snippetType = "autosnippet" }, { t("\\alpha") }), + s({ trig = ";b", snippetType = "autosnippet" }, { t("\\beta") }), + s({ trig = ";g", snippetType = "autosnippet" }, { t("\\gamma") }), + s({ trig = ";G", snippetType = "autosnippet" }, { t("\\Gamma") }), + s({ trig = ";d", snippetType = "autosnippet" }, { t("\\delta") }), + s({ trig = ";D", snippetType = "autosnippet" }, { t("\\Delta") }), + s({ trig = ";e", snippetType = "autosnippet" }, { t("\\epsilon") }), + s({ trig = ";ve", snippetType = "autosnippet" }, { t("\\varepsilon") }), + s({ trig = ";z", snippetType = "autosnippet" }, { t("\\zeta") }), + s({ trig = ";h", snippetType = "autosnippet" }, { t("\\eta") }), + s({ trig = ";o", snippetType = "autosnippet" }, { t("\\theta") }), + s({ trig = ";vo", snippetType = "autosnippet" }, { t("\\vartheta") }), + s({ trig = ";O", snippetType = "autosnippet" }, { t("\\Theta") }), + s({ trig = ";k", snippetType = "autosnippet" }, { t("\\kappa") }), + s({ trig = ";l", snippetType = "autosnippet" }, { t("\\lambda") }), + s({ trig = ";L", snippetType = "autosnippet" }, { t("\\Lambda") }), + s({ trig = ";m", snippetType = "autosnippet" }, { t("\\mu") }), + s({ trig = ";n", snippetType = "autosnippet" }, { t("\\nu") }), + s({ trig = ";x", snippetType = "autosnippet" }, { t("\\xi") }), + s({ trig = ";X", snippetType = "autosnippet" }, { t("\\Xi") }), + s({ trig = ";i", snippetType = "autosnippet" }, { t("\\pi") }), + s({ trig = ";I", snippetType = "autosnippet" }, { t("\\Pi") }), + s({ trig = ";r", snippetType = "autosnippet" }, { t("\\rho") }), + s({ trig = ";s", snippetType = "autosnippet" }, { t("\\sigma") }), + s({ trig = ";S", snippetType = "autosnippet" }, { t("\\Sigma") }), + s({ trig = ";t", snippetType = "autosnippet" }, { t("\\tau") }), + s({ trig = ";f", snippetType = "autosnippet" }, { t("\\phi") }), + s({ trig = ";vf", snippetType = "autosnippet" }, { t("\\varphi") }), + s({ trig = ";F", snippetType = "autosnippet" }, { t("\\Phi") }), + s({ trig = ";c", snippetType = "autosnippet" }, { t("\\chi") }), + s({ trig = ";p", snippetType = "autosnippet" }, { t("\\psi") }), + s({ trig = ";P", snippetType = "autosnippet" }, { t("\\Psi") }), + s({ trig = ";w", snippetType = "autosnippet" }, { t("\\omega") }), + s({ trig = ";W", snippetType = "autosnippet" }, { t("\\Omega") }), } diff --git a/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua b/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua index c6cd1420..4ed49f7b 100644 --- a/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua +++ b/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua @@ -1,6 +1,6 @@ require("lint").linters_by_ft = { -- text - markdown = {}; + markdown = {}, -- tex = {'chktex'}, -- maybe add some text linters ? -- shell (already covered by the bash language sever) @@ -9,12 +9,12 @@ require("lint").linters_by_ft = { -- zsh = { "shellcheck"; }; -- dash = { "shellcheck"; }; - yaml = { "yamllint"; }; - nix = { "nix"; "statix"; }; + yaml = { "yamllint" }, + nix = { "nix", "statix" }, } -vim.api.nvim_create_autocmd({ "BufEnter"; "BufWritePost"; }, { +vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, { callback = function() require("lint").try_lint() - end; + end, }) diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua b/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua index eaf68ecf..7235c5a3 100644 --- a/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua @@ -11,7 +11,7 @@ if not has_plenary then return end -local log = plenary.log.new({ plugin = "telescope_rooter"; level = "info"; }) +local log = plenary.log.new({ plugin = "telescope_rooter", level = "info" }) -- TODO: expose this function local toggle = function(_) @@ -19,19 +19,19 @@ local toggle = function(_) print("Telescope#rooter#enabled=" .. vim.inspect(vim.g["Telescope#rooter#enabled"])) end -local config = { patterns = { ".git"; }; enable = true; debug = false; } +local config = { patterns = { ".git" }, enable = true, debug = false } -- default enabled vim.g["Telescope#rooter#enabled"] = vim.F.if_nil(config.enable, true) -- redefine log if debug enabled if vim.F.if_nil(config.debug, false) then - log = plenary.log.new({ plugin = "telescope_rooter"; level = "debug"; }) + log = plenary.log.new({ plugin = "telescope_rooter", level = "debug" }) end -local group = vim.api.nvim_create_augroup("TelescopeRooter", { clear = true; }) +local group = vim.api.nvim_create_augroup("TelescopeRooter", { clear = true }) -vim.api.nvim_create_autocmd({ "DirChangedPre"; }, { +vim.api.nvim_create_autocmd({ "DirChangedPre" }, { callback = function() if vim.g["Telescope#rooter#enabled"] ~= true then return @@ -41,11 +41,11 @@ vim.api.nvim_create_autocmd({ "DirChangedPre"; }, { vim.g["Telescope#rooter#oldpwd"] = vim.loop.cwd() log.debug("before " .. vim.inspect(vim.loop.cwd())) end - end; - group = group; + end, + group = group, }) -vim.api.nvim_create_autocmd({ "BufEnter"; "BufWinEnter"; }, { +vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { callback = function() if vim.g["Telescope#rooter#enabled"] ~= true then return @@ -53,18 +53,18 @@ vim.api.nvim_create_autocmd({ "BufEnter"; "BufWinEnter"; }, { vim.schedule(function() if vim.bo.filetype == "TelescopePrompt" then - local rootdir = vim.fs.dirname(vim.fs.find(config.patterns, { upward = true; })[1]) + local rootdir = vim.fs.dirname(vim.fs.find(config.patterns, { upward = true })[1]) if rootdir ~= nil then vim.api.nvim_set_current_dir(rootdir) log.debug("changing dir to " .. rootdir) end end end) - end; - group = group; + end, + group = group, }) -vim.api.nvim_create_autocmd({ "BufWinLeave"; }, { +vim.api.nvim_create_autocmd({ "BufWinLeave" }, { callback = function() if vim.g["Telescope#rooter#enabled"] ~= true then return @@ -79,6 +79,6 @@ vim.api.nvim_create_autocmd({ "BufWinLeave"; }, { end end end) - end; - group = group; + end, + group = group, }) diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh index 9ac1ab91..6f09a7e6 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh @@ -6,37 +6,36 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } enforce_project() { - project="$(jq '.project' "$(ptmp "$1")")"; + project="$(jq '.project' "$(ptmp "$1")")" [ "$project" = "null" ] && die "No project supplied!" if grep -q "^$(echo "$project" | sed 's|"\(.*\)"|\1|')\$" "$(ptmp "%PROJECTS_NEWLINE")"; then - dbg "project('$project') is a valid part of %PROJECTS_COMMA"; + dbg "project('$project') is a valid part of %PROJECTS_COMMA" else - die "The project '$(echo "$project" | sed 's|"||g')' is not registered with the nix config, registered projects: %PROJECTS_COMMA"; + die "The project '$(echo "$project" | sed 's|"||g')' is not registered with the nix config, registered projects: %PROJECTS_COMMA" fi } - -read -r new_task; +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -enforce_project "$new_task"; +enable_hook_dbg +enforce_project "$new_task" -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh index 8a776d3a..085115e7 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh @@ -6,38 +6,37 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } update_git_repo() { - task_data="$(task _get rc.data.location)"; + task_data="$(task _get rc.data.location)" [ "$task_data" ] || die "Taskwarrior should have a location set" cd "$task_data" || die "(BUG?): Your data.location path is not accessable" [ -d ./.git/ ] || git init - git add .; - git commit --message="chore: Update" --no-gpg-sign; + git add . + git commit --message="chore: Update" --no-gpg-sign } - -read -r new_task; +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -update_git_repo; +enable_hook_dbg +update_git_repo -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh index b043f141..996e105a 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh @@ -6,39 +6,38 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } update_git_repo() { - task_data="$(task _get rc.data.location)"; + task_data="$(task _get rc.data.location)" [ "$task_data" ] || die "Taskwarrior should have a location set" cd "$task_data" || die "(BUG?): Your data.location path is not accessable" [ -d ./.git/ ] || git init - git add .; - git commit --message="chore: Update" --no-gpg-sign; + git add . + git commit --message="chore: Update" --no-gpg-sign } - -read -r _old_task; -read -r new_task; +read -r _old_task +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -update_git_repo; +enable_hook_dbg +update_git_repo -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py index 03b4ce42..c8efb596 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py @@ -70,12 +70,17 @@ combined = " ".join(["'%s'" % tag for tag in tags]).encode("utf-8").strip() # Task has been started. if "start" in new and not "start" in old: # Prevent this task from starting if "task +ACTIVE count" is greater than "MAX_ACTIVE". - p = subprocess.Popen(["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], stdout=subprocess.PIPE) + p = subprocess.Popen( + ["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], + stdout=subprocess.PIPE, + ) out, err = p.communicate() count = int(out.rstrip()) if count >= MAX_ACTIVE: - print("Only %d task(s) can be active at a time. " - "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE) + print( + "Only %d task(s) can be active at a time. " + "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE + ) sys.exit(1) system("timew start " + combined.decode() + " :yes") diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py index 88234cbf..d5b380d0 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py @@ -102,12 +102,17 @@ def main(): # An active task has just been started. if "start" in modified and "start" not in original: # Prevent this task from starting if "task +ACTIVE count" is greater than "MAX_ACTIVE". - p = subprocess.Popen(["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], stdout=subprocess.PIPE) + p = subprocess.Popen( + ["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], + stdout=subprocess.PIPE, + ) out, err = p.communicate() count = int(out.rstrip()) if count >= MAX_ACTIVE: - print("Only %d task(s) can be active at a time. " - "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE) + print( + "Only %d task(s) can be active at a time. " + "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE + ) sys.exit(1) # An active task has just been stopped. @@ -119,10 +124,18 @@ def main(): if UDA_KEY not in modified: modified[UDA_KEY] = 0 - this_duration = (end - start) - total_duration = (this_duration + duration_str_to_time_delta(str(modified[UDA_KEY]))) - print("Total Time Tracked: %s (%s in this instance)" % (total_duration, this_duration)) - modified[UDA_KEY] = str(int(total_duration.days * (60 * 60 * 24) + total_duration.seconds)) + "seconds" + this_duration = end - start + total_duration = this_duration + duration_str_to_time_delta( + str(modified[UDA_KEY]) + ) + print( + "Total Time Tracked: %s (%s in this instance)" + % (total_duration, this_duration) + ) + modified[UDA_KEY] = ( + str(int(total_duration.days * (60 * 60 * 24) + total_duration.seconds)) + + "seconds" + ) return json.dumps(modified, separators=(",", ":")) diff --git a/hm/soispha/conf/xdg/url_handler.sh b/hm/soispha/conf/xdg/url_handler.sh index 9cca2fc0..53ae4986 100755 --- a/hm/soispha/conf/xdg/url_handler.sh +++ b/hm/soispha/conf/xdg/url_handler.sh @@ -3,18 +3,16 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -project="$(echo "%ALL_PROJECTS_PIPE|nvim|zathura|" | rofi -sep "|" -dmenu)"; +project="$(echo "%ALL_PROJECTS_PIPE|nvim|zathura|" | rofi -sep "|" -dmenu)" if [ "$project" = "nvim" ]; then "$TERMINAL" -e nvim "$1" elif [ "$project" = "zathura" ]; then zathura "$1" elif [ "$project" ]; then - firefox -P "$project" "$1"; + firefox -P "$project" "$1" else notify-send "(URL HANDLER) No project selected" && exit 1 fi - # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/disk.sh b/hm/soispha/conf/yambar/scripts/disk.sh index 003455ab..284661b9 100755 --- a/hm/soispha/conf/yambar/scripts/disk.sh +++ b/hm/soispha/conf/yambar/scripts/disk.sh @@ -5,18 +5,17 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # Main loop while true; do - # vars - used_space=$(btrfs filesystem usage /srv 2> /dev/null | awk '{if ( /Used:/ ) { print $2 } } ' | head -n1) - all_space=$(btrfs filesystem usage /srv 2> /dev/null | awk '{if ( /Device size:/ ) { print $3 } } ' | head -n1 | tr -d "GiB") + # vars + used_space=$(btrfs filesystem usage /srv 2>/dev/null | awk '{if ( /Used:/ ) { print $2 } } ' | head -n1) + all_space=$(btrfs filesystem usage /srv 2>/dev/null | awk '{if ( /Device size:/ ) { print $3 } } ' | head -n1 | tr -d "GiB") + # Check space available (4) and percentage used (5) + spaceperc=$(echo "$(echo "$used_space" | tr -d "GiB")" "$all_space" | awk '{div=$1/$2;div *= 100; printf"%2d%%\n",div }') - # Check space available (4) and percentage used (5) - spaceperc=$(echo "$(echo "$used_space" | tr -d "GiB" )" "$all_space" | awk '{div=$1/$2;div *= 100; printf"%2d%%\n",div }') - - echo "diskspace|string|$used_space" - echo "diskperc|string|$spaceperc" - echo "" - sleep 1 + echo "diskspace|string|$used_space" + echo "diskperc|string|$spaceperc" + echo "" + sleep 1 done # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/grades-average.sh b/hm/soispha/conf/yambar/scripts/grades-average.sh index 8c1900cf..b93869c5 100755 --- a/hm/soispha/conf/yambar/scripts/grades-average.sh +++ b/hm/soispha/conf/yambar/scripts/grades-average.sh @@ -4,12 +4,12 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH while true; do - grade="$(grades list average | awk '{print $2}')"; + grade="$(grades list average | awk '{print $2}')" - echo "grade|string|$grade"; - echo ""; + echo "grade|string|$grade" + echo "" - sleep 1; + sleep 1 done # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/mpd_song_name.sh b/hm/soispha/conf/yambar/scripts/mpd_song_name.sh index b778afbc..b251619b 100755 --- a/hm/soispha/conf/yambar/scripts/mpd_song_name.sh +++ b/hm/soispha/conf/yambar/scripts/mpd_song_name.sh @@ -3,12 +3,11 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - while true; do - state="$(mpc status '%state%')"; + state="$(mpc status '%state%')" if [ "$state" = "playing" ]; then - song="$(mpc --format '[[%artist% - ]%title%]|[%file%]' current)"; + song="$(mpc --format '[[%artist% - ]%title%]|[%file%]' current)" echo "playing|bool|true" echo "song|string|$song" else @@ -16,7 +15,7 @@ while true; do fi echo "" # commit - sleep 2; + sleep 2 done # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/network.sh b/hm/soispha/conf/yambar/scripts/network.sh index 717ea6be..b4396640 100755 --- a/hm/soispha/conf/yambar/scripts/network.sh +++ b/hm/soispha/conf/yambar/scripts/network.sh @@ -8,40 +8,40 @@ retest_if_con_fails=10 backend=nmcli case "$backend" in - "nmcli") # Test for connectivity with nmcli - while true; do - connection_status=$(nmcli networking connectivity) - if [ "$connection_status" = "full" ]; then - echo "internet|string|Connected" - echo "" - sleep $retest - else - echo "internet|string|Disconnected" - echo "" - sleep $retest_if_con_fails - fi - done - ;; - "ping") # Test for connectivity with ping - ip_address='8.8.8.8' - ping_number=3 +"nmcli") # Test for connectivity with nmcli + while true; do + connection_status=$(nmcli networking connectivity) + if [ "$connection_status" = "full" ]; then + echo "internet|string|Connected" + echo "" + sleep $retest + else + echo "internet|string|Disconnected" + echo "" + sleep $retest_if_con_fails + fi + done + ;; +"ping") # Test for connectivity with ping + ip_address='8.8.8.8' + ping_number=3 - while true; do + while true; do - ping_result=$(mktmp) - ping $ip_address -c $ping_number -q | awk 'BEGIN {FS="/"} END {print $5}' > "$ping_result" + ping_result=$(mktmp) + ping $ip_address -c $ping_number -q | awk 'BEGIN {FS="/"} END {print $5}' >"$ping_result" - if [ "$(cat "$ping_result" | wc -l)" -eq 0 ]; then - echo "med|string|No connection" - echo "" - sleep $retest_if_con_fails - else - echo "med|string|$(cat "$ping_result") ms" - echo "" - sleep $retest - fi - done - ;; + if [ "$(wc -l <"$ping_result")" -eq 0 ]; then + echo "med|string|No connection" + echo "" + sleep $retest_if_con_fails + else + echo "med|string|$(cat "$ping_result") ms" + echo "" + sleep $retest + fi + done + ;; esac # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh b/hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh deleted file mode 100755 index 9e75acfa..00000000 --- a/hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# An improved amixer script that actually detects volume beyond 100% - - -SLEEPTIME=1 - - -while true; do - - volume=$(pactl get-sink-volume 0 | awk 'BEGIN { FS="/"} {print $2 }' | tr -d "%" | tr -d ' ') - - if [ "$volume" -eq 0 ]; then - echo "muted|bool|true" - - else - # Read sink volume in percentages - echo "volume|string|$volume" - echo "muted|bool|false" - fi - - echo "" - sleep "$SLEEPTIME" - -done diff --git a/hm/soispha/conf/yambar/scripts/old/cpu.sh b/hm/soispha/conf/yambar/scripts/old/cpu.sh deleted file mode 100755 index bae820d0..00000000 --- a/hm/soispha/conf/yambar/scripts/old/cpu.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# I didn't write this script; this is almost directly copied from the dnkl/yambar github. - - -# cpu.sh - measures CPU usage at a configurable sample interval -# -# Usage: cpu.sh INTERVAL_IN_SECONDS -# -# This script will emit the following tags on stdout (N is the number -# of logical CPUs): -# -# Name Type -# -------------------- -# cpu range 0-100 -# cpu0 range 0-100 -# cpu1 range 0-100 -# ... -# cpuN-1 range 0-100 -# -# I.e. ‘cpu’ is the average (or aggregated) CPU usage, while cpuX is a -# specific CPU’s usage. -# -# Example configuration (update every second): -# -# - script: -# path: /path/to/cpu.sh -# args: [1] -# content: {string: {text: "{cpu}%"}} -# - -interval=2 - -case ${interval} in - ''|*[!0-9]*) - echo "interval must be an integer" - exit 1 - ;; - *) - ;; -esac - -# Get number of CPUs, by reading /proc/stat -# The output looks like: -# -# cpu A B C D ... -# cpu0 A B C D ... -# cpu1 A B C D ... -# cpuN A B C D ... -# -# The first line is a summary line, accounting *all* CPUs -IFS=$'\n' readarray -t all_cpu_stats < <(grep -e "^cpu" /proc/stat) -cpu_count=$((${#all_cpu_stats[@]} - 1)) - -# Arrays of ‘previous’ idle and total stats, needed to calculate the -# difference between each sample. -prev_idle=() -prev_total=() -for i in $(seq ${cpu_count}); do - prev_idle+=(0) - prev_total+=(0) -done - -prev_average_idle=0 -prev_average_total=0 - -while true; do - IFS=$'\n' readarray -t all_cpu_stats < <(grep -e "^cpu" /proc/stat) - - usage=() # CPU usage in percent, 0 <= x <= 100 - - average_idle=0 # All CPUs idle time since boot - average_total=0 # All CPUs total time since boot - - for i in $(seq 0 $((cpu_count - 1))); do - # Split this CPUs stats into an array - stats=($(echo "${all_cpu_stats[$((i + 1))]}")) - - # man procfs(5) - user=${stats[1]} - nice=${stats[2]} - system=${stats[3]} - idle=${stats[4]} - iowait=${stats[5]} - irq=${stats[6]} - softirq=${stats[7]} - steal=${stats[8]} - guest=${stats[9]} - guestnice=${stats[10]} - - # Guest time already accounted for in user - user=$((user - guest)) - nice=$((nice - guestnice)) - - idle=$((idle + iowait)) - - total=$((user + nice + system + irq + softirq + idle + steal + guest + guestnice)) - - average_idle=$((average_idle + idle)) - average_total=$((average_total + total)) - - # Diff since last sample - diff_idle=$((idle - prev_idle[i])) - diff_total=$((total - prev_total[i])) - - usage[i]=$((100 * (diff_total - diff_idle) / diff_total)) - - prev_idle[i]=${idle} - prev_total[i]=${total} - done - - diff_average_idle=$((average_idle - prev_average_idle)) - diff_average_total=$((average_total - prev_average_total)) - - average_usage=$((100 * (diff_average_total - diff_average_idle) / diff_average_total)) - - prev_average_idle=${average_idle} - prev_average_total=${average_total} - - echo "cpu|range:0-100|${average_usage}" - for i in $(seq 0 $((cpu_count - 1))); do - echo "cpu${i}|range:0-100|${usage[i]}" - done - - echo "" - sleep "${interval}" -done diff --git a/hm/soispha/conf/yambar/scripts/old/dfspace.sh b/hm/soispha/conf/yambar/scripts/old/dfspace.sh deleted file mode 100755 index 0b262481..00000000 --- a/hm/soispha/conf/yambar/scripts/old/dfspace.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# Sleep seconds -timer="60" - -# Main loop -while true; do - - # vars - used_space=$(btrfs filesystem usage / 2> /dev/null | awk '{if ( /Used:/ ) { print $2 } } ' | head -n1) - all_space=$(btrfs filesystem usage / 2> /dev/null | awk '{if ( /Device size:/ ) { print $3 } } ' | head -n1 | tr -d "GiB") - - - # Check space available (4) and percentage used (5) - spaceperc=$(echo "$(echo "$used_space" | tr -d "GiB" )" "$all_space" | awk '{div=$1/$2;div *= 100; printf"%2d%%\n",div }') - - echo "diskspace|string|$used_space" - echo "diskperc|string|$spaceperc" - echo "" - sleep $timer - -done - diff --git a/hm/soispha/conf/yambar/scripts/old/grades-average.sh b/hm/soispha/conf/yambar/scripts/old/grades-average.sh deleted file mode 100755 index a04b958c..00000000 --- a/hm/soispha/conf/yambar/scripts/old/grades-average.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. ~/.local/lib/shell/lib - -grade=$(grades list average | awk '{print $2}'); - -echo "grade|string|$grade"; -echo ""; - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/hm/soispha/conf/yambar/scripts/old/meminfo.sh b/hm/soispha/conf/yambar/scripts/old/meminfo.sh deleted file mode 100755 index 0156e94c..00000000 --- a/hm/soispha/conf/yambar/scripts/old/meminfo.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Checks memory usage - -# Number of seconds to retest -timer=5 - -# Main loop -while true; do - - mem_total=$(LANG=C free -b|awk '/^Mem:/{print $2}') - mem_used=$(LANG=C free -b|awk '/^Mem:/{print $3}') - swap_total=$(LANG=C free -b|awk '/^Swap:/{print $2}') - swap_used=$(LANG=C free -b|awk '/^Swap:/{print $3}') - - - memperc=$(echo "$mem_used" "$mem_total" | awk '{ div = 100 * ($1 / $2)} { printf "%.0f ", div }' | tr -d ' ' ) - swapperc=$(echo "$swap_used" "$swap_total" | awk '{ - if ( $1 == 0 || $2 == 0 ) { - print "%" - } else { - div = 100 * ($1 / $2); - printf "%.0f ", div -} -}' | tr -d ' ' ) - - -echo "memperc|string|$memperc" -if [ "$swapperc" = "%" ];then - echo "swapstate|bool|false" -else - echo "swapperc|string|$swapperc" - echo "swapstate|bool|true" -fi -echo "" -sleep "$timer" - -done diff --git a/hm/soispha/conf/yambar/scripts/old/nmclitest.sh b/hm/soispha/conf/yambar/scripts/old/nmclitest.sh deleted file mode 100755 index 3e8bc73a..00000000 --- a/hm/soispha/conf/yambar/scripts/old/nmclitest.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# Test for connectivity with nmcli - -Timer=${1:-120} # Number of seconds to retest -Timer2=${2:-10} # Number of seconds to retest if connection fails - -# Main loop -while true; do - - CONN=$(nmcli networking connectivity) - - if [[ "$CONN" == "full" ]]; then - echo "internet|string|Connected" - echo "" - sleep $Timer - else - echo "internet|string|Disconnected" - echo "" - sleep $Timer2 - fi - -done - diff --git a/hm/soispha/conf/yambar/scripts/old/pingtest.sh b/hm/soispha/conf/yambar/scripts/old/pingtest.sh deleted file mode 100755 index 2b5f9998..00000000 --- a/hm/soispha/conf/yambar/scripts/old/pingtest.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Test for connectivity with ping - -Timer=${1:-120} # Number of seconds to retest -Timer2=${2:-10} # Number of seconds to retest if connection fails -IP=${3:-'8.8.8.8'} # IP address to test, defaults to Google -PCount=${4:-3} # Number of pings to send - -# Main loop -while true; do - - # Pings the IP address for five times - PINGSTR=$(ping $IP -c $PCount -q) - # Use text formatting to get min/max ms delays - MED=$(echo $PINGSTR | sed 's/min\/avg\/max\/mdev = /\n/g' | tail -n 1 | sed 's/\//\t/g' | cut -f2) - - if [[ "$MED" == "" ]]; then - echo "med|string|No connection" - echo "" - sleep $Timer2 - else - echo "med|string|$MED ms" - echo "" - sleep $Timer - fi - -done - diff --git a/hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh b/hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh deleted file mode 100755 index 00544e70..00000000 --- a/hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. ~/.local/lib/shell/lib - - -CHARWIDTH=8 # i guess? - -tray_width_px() { - xwininfo -name panel | # trayer names its window "panel" - grep -i width: | - awk '{print $2}' -} - -px_to_spaces() { - spaces="$((1 + ${1:-0} / $CHARWIDTH))" - printf "% *s\n" $spaces -} - -sleep 0.2 # be sure trayer is already up - -output="$(px_to_spaces `tray_width_px`)" -echo "padding|string|$output" -echo "" - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/hm/soispha/conf/yambar/scripts/old/yambar-tray.sh b/hm/soispha/conf/yambar/scripts/old/yambar-tray.sh deleted file mode 100755 index 1704c6dd..00000000 --- a/hm/soispha/conf/yambar/scripts/old/yambar-tray.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - - -pkill stalonetray -pkill trayer - -# launch a tray. -echo - -sleep 0.1 # make sure yambar starts first so we can draw on tpo of it - -# trayer-srg fork! -trayer \ - --edge top \ - --tint 0x24242400 \ - --align right \ - --height 20 \ - --expand false \ - --transparent true \ - --alpha 0 \ - --width 20 \ - --monitor primary \ - --widthtype request - # &>/dev/null - - - diff --git a/hm/soispha/conf/yambar/scripts/sound-volume.sh b/hm/soispha/conf/yambar/scripts/sound-volume.sh index 721d51bf..f887b4de 100755 --- a/hm/soispha/conf/yambar/scripts/sound-volume.sh +++ b/hm/soispha/conf/yambar/scripts/sound-volume.sh @@ -14,7 +14,7 @@ while true; do fi echo "" - sleep 3; + sleep 3 done # vim: ft=sh |