updated to use new shed module schema

This commit is contained in:
2026-03-04 00:02:30 -05:00
parent 05fd14d48f
commit 7113140cd7
18 changed files with 622 additions and 284 deletions

View File

@@ -142,6 +142,10 @@ in {
"move 100%-470 15, match:title ^(Firefox )$"
] ++ smartGapsWindowrules;
cursor = {
no_hardware_cursors = true;
};
input = {
kb_layout = "us";
follow_mouse = 1;

View File

@@ -0,0 +1,15 @@
{ lib, config, ... }:
{
programs.shed = {
extraCompletion = {
cargo = {
wordList = [
"build"
"test"
"run"
"clippy"
];
};
};
};
}

View File

@@ -3,8 +3,10 @@
{
imports = [
./env.nix
./complete.nix
./aliases.nix
./extraconfig.nix
./options.nix
./keymaps.nix
];
}

View File

@@ -15,6 +15,9 @@
FZF_DEFAULT_OPTS = "--height 40% --layout=reverse --border";
LESS = "-R"; # pager uses alt buffer
PS1 = "\!prompt ";
PSR = "\e[36;1m$\!shed_ver\e[0m";
};
};
}

View File

@@ -6,221 +6,7 @@ let
in
{
programs.shed = {
settings.extraPreConfig = ''
prompt_topline() {
local user_and_host="\e[0m\e[1m$USER\e[1;36m@\e[1;31m$HOST\e[0m"
echo -n "\e[1;34m $user_and_host\n"
}
prompt_stat_line() {
local last_exit_code="$?"
local last_cmd_status
local last_cmd_runtime
if [ "$last_exit_code" -eq "0" ]; then
last_cmd_status="\e[1;32m\e[0m"
else
last_cmd_status="\e[1;31m\e[0m"
fi
local last_runtime_raw="$(echo -p "\t")"
if [ -z "$last_runtime_raw" ]; then
return 0
else
last_cmd_runtime="\e[1;38;2;249;226;175m󰔛 $(echo -p "\T")\e[0m"
fi
echo -n "\e[1;34m $last_cmd_runtime ($last_cmd_status)\n"
}
prompt_git_line() {
git rev-parse --is-inside-work-tree > /dev/null 2>&1 || return
local gitsigns
local status="$(git status --porcelain 2>/dev/null)"
[ -n "$status" ] && echo "$status" | command grep -q '^ [MADR]' && gitsigns="$gitsigns!"
[ -n "$status" ] && echo "$status" | command grep -q '^??' && gitsigns="$gitsigns?"
[ -n "$status" ] && echo "$status" | command grep -q '^[MADR]' && gitsigns="$gitsigns+"
local ahead="$(git rev-list --count @{upstream}..HEAD 2>/dev/null)"
local behind="$(git rev-list --count HEAD..@{upstream} 2>/dev/null)"
[ $ahead -gt 0 ] && gitsigns="$gitsigns"
[ $behind -gt 0 ] && gitsigns="$gitsigns"
local branch="$(git branch --show-current 2>/dev/null)"
if [ -n "$gitsigns" ] || [ -n "$branch" ]; then
if [ -n "$gitsigns" ]; then
gitsigns="\e[1;31m[$gitsigns]"
fi
echo -n "\e[1;34m \e[1;35m ''${branch}$gitsigns\e[0m\n"
fi
}
prompt_jobs_line() {
local job_count="$(echo -p '\j')"
if [ "$job_count" -gt 0 ]; then
echo -n "\e[1;34m \e[1;33m󰒓 $job_count job(s) running\e[0m\n"
fi
}
prompt_pwd_line() {
echo -p "\e[1;34m \e[1;36m\W\e[1;32m/"
}
prompt_dollar_line() {
local dollar="$(echo -p "\$ ")"
local dollar="$(echo -e "\e[1;32m$dollar\e[0m")"
echo -n "\e[1;34m $dollar "
}
prompt() {
local statline="$(prompt_stat_line)"
local topline="$(prompt_topline)"
local gitline="$(prompt_git_line)"
local jobsline="$(prompt_jobs_line)"
local pwdline="$(prompt_pwd_line)"
local dollarline="$(prompt_dollar_line)"
local prompt="$topline$statline$gitline$jobsline$pwdline\n$dollarline"
echo -en "$prompt"
}
shed_ver() {
shed --version
}
export PS1="\!prompt "
export PSR='\e[36;1m$\!shed_ver\e[0m'
'';
settings.extraPostConfig = ''
encrypt() {
if [ -z "$1" ]; then
echo "Usage: encrypt <text> [recipient]"
return 1
fi
if [ -z "$2" ]; then
gpg --encrypt --armor -r "$1"
else
echo "$1" | gpg --encrypt --armor -r "$2"
fi
}
decrypt() {
if [ -z "$1" ]; then
gpg --decrypt --quiet 2>/dev/null
else
echo "$1" | gpg --decrypt --quiet
fi
}
viflake() {
filename="$(upfind flake.nix)"
if [ -n "$filename" ]; then
nvim "$filename"
else
echo "No flake.nix found in this directory or any parent directories."
return 1
fi
}
upfind() {
until [ "$#" -eq 0 ]; do
filename="$1"
(
until [ -f "./$filename" ]; do
builtin cd ..
if [ "$PWD" = "/" ]; then
echo "upsearch: failed to find file '$filename' in this directory or any parent directories." 1>&2
break
fi
done
if [ -f "./$filename" ]; then
realpath "./$filename"
fi
)
shift 1
done
}
nvim() {
${shellsound} ${sndpath}/nvim.wav
command nvim "$@"
}
neovide() {
${shellsound} ${sndpath}/nvim.wav
command neovide "$@"
}
grimblast() {
if command grimblast "$@"; then
${shellsound} ${sndpath}/screenshot.wav
fi
}
gitcheckout_sfx() {
if git checkout "$@"; then
${shellsound} ${sndpath}/gitcheckout.wav
else
${shellsound} ${sndpath}/error.wav
fi
}
gitrebase_sfx() {
if git rebase "$@"; then
${shellsound} ${sndpath}/gitrebase.wav
else
${shellsound} ${sndpath}/error.wav
fi
}
gitcommit_sfx() {
local output="$(git commit "$@")"
if [ "$?" -eq "0" ]; then
${shellsound} ${sndpath}/gitcommit.wav
echo "$output" | ${color-commit}
return 0
else
${shellsound} ${sndpath}/error.wav
echo "$output"
return 1
fi
}
gitpush_sfx() {
if git push "$@"; then
${shellsound} ${sndpath}/gitpush.wav
else
${shellsound} ${sndpath}/error.wav
fi
}
gitpull_sfx() {
if git pull "$@"; then
${shellsound} ${sndpath}/gitpull.wav
else
${shellsound} ${sndpath}/error.wav
fi
}
ls() {
eza -1 --group-directories-first --icons "$@"
${shellsound} ${sndpath}/ls.wav
}
mkcd() {
command mkdir -p "$1" && builtin cd "$1"
}
cd() {
eza -1 --group-directories-first --icons "$@" 2> /dev/null
builtin cd "$@"
${shellsound} ${sndpath}/cd.wav
}
hyprsock() {
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock
}
vipe() {
local tmp=$(mktemp)
$EDITOR "$tmp" >/dev/tty </dev/tty
cat "$tmp"
rm "$tmp"
}
settings.extraPostConfig = /* bash */ ''
if [ "$0" = "-shed" ]; then
${shellsound} $FLAKEPATH/assets/sound/login.wav
fi

View File

@@ -0,0 +1,251 @@
{ ... }:
{
programs.shed = {
functions = {
prompt_topline = /* bash */ ''
local user_and_host="\e[0m\e[1m$USER\e[1;36m@\e[1;31m$HOST\e[0m"
echo -n "\e[1;34m $user_and_host\n"
'';
prompt_statline = /* bash */ ''
local last_exit_code="$?"
local last_cmd_status
local last_cmd_runtime
if [ "$last_exit_code" -eq "0" ]; then
last_cmd_status="\e[1;32m\e[0m"
else
last_cmd_status="\e[1;31m\e[0m"
fi
local last_runtime_raw="$(echo -p "\t")"
if [ -z "$last_runtime_raw" ]; then
return 0
else
last_cmd_runtime="\e[1;38;2;249;226;175m󰔛 $(echo -p "\T")\e[0m"
fi
echo -n "\e[1;34m $last_cmd_runtime ($last_cmd_status)\n"
'';
prompt_gitline = /* bash */ ''
git rev-parse --is-inside-work-tree > /dev/null 2>&1 || return
local gitsigns
local status="$(git status --porcelain 2>/dev/null)"
local branch="$(git branch --show-current 2>/dev/null)"
[ -n "$status" ] && echo "$status" | command grep -q '^ [MADR]' && gitsigns="$gitsigns!"
[ -n "$status" ] && echo "$status" | command grep -q '^??' && gitsigns="$gitsigns?"
[ -n "$status" ] && echo "$status" | command grep -q '^[MADR]' && gitsigns="$gitsigns+"
local ahead="$(git rev-list --count @{upstream}..HEAD 2>/dev/null)"
local behind="$(git rev-list --count HEAD..@{upstream} 2>/dev/null)"
[ $ahead -gt 0 ] && gitsigns="$gitsigns"
[ $behind -gt 0 ] && gitsigns="$gitsigns"
local diff="$(git diff --shortstat)"
local add=""
local del=""
local changed=""
i=0
while read -d "," part; do
if [ $i -ge 3 ]; then break; fi
case $i in
0)
changed="$(echo $part | cut -d' ' -f1)"
;;
1)
add="$(echo $part | cut -d' ' -f1)"
;;
2)
del="$(echo $part | cut -d' ' -f1)"
;;
esac
i=$(($i + 1))
done < <(echo "$diff,")
if [ -n "$gitsigns" ] || [ -n "$branch" ]; then
if [ -n "$gitsigns" ]; then
gitsigns="\e[1;31m[$gitsigns]"
fi
if [ -n "$changed" ] && [ "$changed" -gt 0 ]; then
changed="\e[1;34m~$changed \e[0m"
fi
if [ -n "$add" ] && [ "$add" -gt 0 ]; then
add="\e[1;32m+$add \e[0m"
fi
if [ -n "$del" ] && [ "$del" -gt 0 ]; then
del="\e[1;31m-$del\e[0m"
fi
echo -n "\e[1;34m \e[1;35m $branch$gitsigns\e[0m $changed$add$del\n"
fi
'';
prompt_jobsline = /* bash */ ''
local job_count="$(echo -p '\j')"
if [ "$job_count" -gt 0 ]; then
echo -n "\e[1;34m \e[1;33m󰒓 $job_count job(s) running\e[0m\n"
fi
'';
prompt_sshline = /* bash */ ''
local ssh_server="$(echo $SSH_CONNECTION | cut -f3 -d' ')"
[ -n "$ssh_server" ] && echo -n "\e[1;34m \e[1;39m🌐 $ssh_server\e[0m\n"
'';
prompt_pwdline = /* bash */ ''
echo -p "\e[1;34m \e[1;36m\W\e[1;32m/"
'';
prompt_dollarline = /* bash */ ''
local dollar="$(echo -p "\$ ")"
local dollar="$(echo -e "\e[1;32m$dollar\e[0m")"
echo -n "\e[1;34m $dollar "
'';
prompt = /* bash */ ''
local statline="$(prompt_stat_line)"
local topline="$(prompt_topline)"
local gitline="$(prompt_git_line)"
local jobsline="$(prompt_jobs_line)"
local sshline="$(prompt_ssh_line)"
local pwdline="$(prompt_pwd_line)"
local dollarline="$(prompt_dollar_line)"
local prompt="$topline$statline$gitline$jobsline$sshline$pwdline\n$dollarline"
echo -en "$prompt"
'';
shed_ver = ''
shed --version
'';
encrypt = /* bash */ ''
if [ -z "$1" ]; then
echo "Usage: encrypt <text> [recipient]"
return 1
fi
if [ -z "$2" ]; then
gpg --encrypt --armor -r "$1"
else
echo "$1" | gpg --encrypt --armor -r "$2"
fi
'';
decrypt = /* bash */ ''
if [ -z "$1" ]; then
gpg --decrypt --quiet 2>/dev/null
else
echo "$1" | gpg --decrypt --quiet
fi
'';
viflake = /* bash */ ''
filename="$(upfind flake.nix)"
if [ -n "$filename" ]; then
nvim "$filename"
else
echo "No flake.nix found in this directory or any parent directories."
return 1
fi
'';
upfind = /* bash */ ''
until [ "$#" -eq 0 ]; do
filename="$1"
(
until [ -f "./$filename" ]; do
builtin cd ..
if [ "$PWD" = "/" ]; then
echo "upsearch: failed to find file '$filename' in this directory or any parent directories." 1>&2
break
fi
done
if [ -f "./$filename" ]; then
realpath "./$filename"
fi
)
shift 1
done
'';
nvim = /* bash */ ''
${shellsound} ${sndpath}/nvim.wav
command nvim "$@"
'';
neovide = /* bash */ ''
${shellsound} ${sndpath}/nvim.wav
command neovide "$@"
'';
grimblast = /* bash */ ''
if command grimblast "$@"; then
${shellsound} ${sndpath}/screenshot.wav
fi
'';
gitcheckout_sfx = /* bash */ ''
if git checkout "$@"; then
${shellsound} ${sndpath}/gitcheckout.wav
else
${shellsound} ${sndpath}/error.wav
fi
'';
gitrebase_sfx = /* bash */ ''
if git rebase "$@"; then
${shellsound} ${sndpath}/gitrebase.wav
else
${shellsound} ${sndpath}/error.wav
fi
'';
gitcommit_sfx = /* bash */ ''
local output="$(git commit "$@")"
if [ "$?" -eq "0" ]; then
${shellsound} ${sndpath}/gitcommit.wav
echo "$output" | ${color-commit}
return 0
else
${shellsound} ${sndpath}/error.wav
echo "$output"
return 1
fi
'';
gitpush_sfx = /* bash */ ''
if git push "$@"; then
${shellsound} ${sndpath}/gitpush.wav
else
${shellsound} ${sndpath}/error.wav
fi
'';
gitpull_sfx = /* bash */ ''
if git pull "$@"; then
${shellsound} ${sndpath}/gitpull.wav
else
${shellsound} ${sndpath}/error.wav
fi
'';
ls = /* bash */ ''
eza -1 --group-directories-first --icons "$@"
${shellsound} ${sndpath}/ls.wav
'';
mkcd = /* bash */ ''
command mkdir -p "$1" && builtin cd "$1"
'';
cd = /* bash */ ''
eza -1 --group-directories-first --icons "$@" 2> /dev/null
builtin cd "$@"
${shellsound} ${sndpath}/cd.wav
'';
hyprsock = /* bash */ ''
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock
'';
vipe = /* bash */ ''
local tmp=$(mktemp)
$EDITOR "$tmp" -R - >/dev/tty </dev/tty
cat "$tmp"
rm "$tmp"
'';
};
};
}

View File

@@ -0,0 +1,205 @@
{ ... }:
{
programs.shed = {
functions = {
_read_obj= /* bash */ ''
_obj=""
while read_key -v key; do
if [[ "''${#_obj}" -ge 3 ]]; then return 1; fi
case "$key" in
i|a)
if [ -n "$_obj" ]; then return 1; fi
_obj="$key"
;;
b|e)
if [ -n "$_obj" ]; then return 1; fi
_obj="$key"
break
;;
w|W)
_obj="$_obj$key"
break
;;
f|F)
read_key -v char
_obj="$key$char"
break
;;
\(|\)|\[|\]|\{|\}|\"|\')
if [ -z "$_obj" ]; then return 1; fi
_obj="$_obj$key"
break
;;
esac
done
'';
_surround_1 = /* bash */ ''
local _obj
_read_obj
_get_surround_target
_KEYS="v$_obj"
'';
_surround_2 = /* bash */ ''
local start
local end
if [ -z "$_ANCHOR" ]; then
echo "No anchor" 1>&2
fi
if [ -z "$_CURSOR" ]; then
echo "No cursor"
fi
if [ "$_ANCHOR" -lt "$_CURSOR" ]; then
start=$_ANCHOR
end=$_CURSOR
else
start=$_CURSOR
end=$_ANCHOR
fi
end=$((end + 1))
delta=$((end - start))
left="''${_BUFFER:0:$start}"
mid="''${_BUFFER:$start:$delta}"
right="''${_BUFFER:$end}"
echo "sl = $_sl sr = $_sr start = $start end = $end delta = $delta left = $left mid = $mid right = $right" 1>&2
_BUFFER="$left$_sl$mid$_sr$right"
_CURSOR=$start
'';
_get_surround_target = /* bash */ ''
read_key -v _s_ch
case "$_s_ch" in
\(|\)) _sl='('; _sr=')' ;;
\[|\]) _sl='['; _sr=']' ;;
\{|\}) _sl='{'; _sr='}' ;;
\<|\>) _sl='<'; _sr='>' ;;
*) _sl="$_s_ch"; _sr="$_s_ch" ;;
esac
'';
_surround_del = /* bash */ ''
_get_surround_target
local left_buf="''${_BUFFER:0:$_CURSOR}"
local right_buf="''${_BUFFER:$left}"
local left=""
local right=""
_scan_left $_sl "$left_buf"
if [ "$?" -ne 0 ]; then
_scan_right $_sl "$right_buf"
[ "$?" -ne 0 ] && echo "No match found in left or right scan for char '$_sl' on $left_buf" 1>&2 && return 1
left=$right
fi
mid_start=$((left + 1))
right=""
left_buf="''${_BUFFER:0:$left}"
right_buf="''${_BUFFER:$mid_start}"
_scan_right $_sr "$right_buf"
[ "$?" -ne 0 ] && echo "No match found in right scan for char '$_sr'" 1>&2 && return 1
mid_end=$((mid_start + right))
right_start=$((mid_end + 1))
new_left_buf="''${_BUFFER:0:$left}"
new_mid_buf="''${_BUFFER:$mid_start:$right}"
new_right_buf="''${_BUFFER:$right_start}"
_BUFFER="$new_left_buf$new_mid_buf$new_right_buf"
'';
_scan_left = /* bash */ ''
local needle="$1"
local haystack="$2"
local i=$((''${#haystack} - 1))
while [ "$i" -ge 0 ]; do
ch="''${haystack:$i:1}"
if [ "$ch" = "$needle" ]; then
left=$i
return 0
fi
i=$((i - 1))
done
return 1
'';
_scan_right = /* bash */ ''
local needle="$1"
local haystack="$2"
local i=0
while [ "$i" -lt "''${#haystack}" ]; do
ch="''${haystack:$i:1}"
if [ "$ch" = "$needle" ]; then
right="$i"
return 0
fi
i=$((i + 1))
done
return 1
'';
_enum_chars = /* bash */ ''
local i=0
[ -z "$1" ] && return 1
[ "''${#1}" -eq 1 ] && echo "0 $1" && return 0
while [ "$i" -lt ''${#1} ]; do
echo -n "$i ''${1:$i:1} "
i=$((i + 1))
[ $i -ge "''${#1}" ] && break
echo -n " "
done
echo
'';
_enum_chars_rev = /* bash */ ''
local i=$((''${#1} - 1))
[ -z "$1" ] && return 1
[ "''${#1}" -eq 1 ] && echo "0 $1" && return 0
while [ "$i" -ge 0 ]; do
echo -n "$i ''${1:$i:1} "
i=$((i - 1))
[ $i -lt 0 ] && break
echo -n " "
done
echo
'';
_edit_line = /* bash */ ''
tmp="$(mktemp)"
echo -n "$_BUFFER" > "$tmp"
$EDITOR "$tmp"
_BUFFER="$(cat "$tmp")"
rm "$tmp"
'';
};
keymaps = [
{
modes = [ "n" ];
keys = "<leader>e";
command = ":!_edit_line<CR>";
}
{
modes = [ "n" ];
keys = "ys";
command = ":!_surround_1<CR>:!_surround_2<CR>";
}
{
modes = [ "n" ];
keys = "ds";
command = ":!_surround_del<CR>";
}
];
};
}

View File

@@ -33,6 +33,13 @@ in {
};
config = lib.mkIf config.movOpts.envConfig.userPkgs.enable {
home.packages = with pkgs; [
cargo
rustc
clippy
rust-analyzer
nerd-fonts.envy-code-r
clippy
rust-analyzer
nemo
feh
gtk3
@@ -45,7 +52,7 @@ in {
zsh-syntax-highlighting
zsh-history-substring-search
zsh-autosuggestions
libreoffice
#libreoffice
gtrash
ripgrep
wf-recorder
@@ -61,7 +68,6 @@ in {
gparted
dust
porsmo
rustup
w3m
neovide
claude-code

View File

@@ -14,6 +14,11 @@
alias = {
draft = "!if git rev-parse > /dev/null 2>&1; then echo \"$1\" >> $(git rev-parse --git-dir)/DRAFT_MSG; else exit 1; fi #";
};
safe = {
directory = [
"/home/pagedmov/mnt/net"
];
};
core.pager = "delta";
interactive.diffFilter = "delta --color-only";
delta.navigate = "true";

View File

@@ -21,6 +21,31 @@
pattern = [ "*" ];
desc = "Start the floaterm window";
}
{
pattern = [ "qf" ];
event = [ "FileType" ];
callback = {
__raw = /* lua */ ''
function()
vim.keymap.set("n", "<CR>", "<CR>", { buffer = true })
end'';
};
}
{
pattern = [ "nix" ];
event = [ "FileType" ];
callback = {
__raw = /* lua */ ''
function()
require("otter").activate(
{ "bash", "lua", "python" },
true, -- completions
true, -- diagnostics
nil
)
end'';
};
}
];
};
}

View File

@@ -1,14 +1,6 @@
{ env, config, pkgs, host, self, ... }: {
programs.nixvim = {
nixpkgs.useGlobalPackages = true;
extraPackages = [
pkgs.cargo
pkgs.rustc
pkgs.clippy
pkgs.rustup
pkgs.rust-analyzer
pkgs.nerd-fonts.envy-code-r
];
};
imports = [ ./plugins ./options.nix ./keymaps.nix ./autocmd.nix ];
}

View File

@@ -36,6 +36,11 @@
key = "<S-Tab>";
mode = "n";
}
{
action = "zA";
key = "<CR>";
mode = "n";
}
{
action = "<C-w>w";
key = "<Tab>";

View File

@@ -30,7 +30,7 @@ in {
virtual_text = true;
signs = false;
};
extraConfigLua = ''
extraConfigLua = /* lua */ ''
if vim.g.started_by_firenvim == true then
vim.o.laststatus = 0
end
@@ -59,6 +59,7 @@ in {
vim.opt.termguicolors = true
vim.opt.ruler = true
vim.opt.scrolloff = 6
vim.opt.foldlevelstart = 99
vim.opt.undofile = true
vim.opt.foldmethod = "manual"
vim.opt.wrap = true
@@ -67,8 +68,17 @@ in {
vim.opt.breakat = " \t!@*-+;:,./?"
vim.opt.guifont = "EnvyCodeR Nerd Font Mono:h18"
vim.g.mapleader = "!"
vim.g.mapleader = " "
vim.g.rust_recommended_style = 0
vim.treesitter.query.set("nix", "injections", [[
;; extends
((comment) @injection.language
.
(indented_string_expression
(string_fragment) @injection.content)
(#gsub! @injection.language "^%s*/%*%s*(%S+)%s*%*/.*$" "%1"))
]])
'';
};
}

View File

@@ -2,6 +2,8 @@
{
imports = [
./otter.nix
./treesitter.nix
./alpha.nix
./haskell.nix
./vim-matchup.nix

View File

@@ -0,0 +1,10 @@
{
programs.nixvim = {
plugins.otter = {
enable = true;
settings = {
handle_leading_whitespace = true;
};
};
};
}

View File

@@ -0,0 +1,16 @@
{
programs.nixvim = {
plugins.treesitter = {
enable = true;
folding = {
enable = true;
};
indent = {
enable = true;
};
highlight = {
enable = true;
};
};
};
}