fix: various nvim/zsh plugin fixes

This commit is contained in:
2026-03-24 00:11:27 +02:00
parent 51659886a1
commit 59a0ff5b04
10 changed files with 32 additions and 175 deletions

View File

@@ -55,6 +55,9 @@ local map = {
M.get_current_keys = function()
local parser = vim.treesitter.get_parser()
if not parser then
return nil
end
local lang = parser:lang()
if map[lang] then
local ancestor_keys = map[lang]()

View File

@@ -39,6 +39,10 @@ return {
local client = vim.lsp.get_client_by_id(client_id)
local bufnr = args.buf
if client == nil then
return
end
-- Only attach to clients that support document formatting
if not client.server_capabilities.documentFormattingProvider then
return

View File

@@ -7,7 +7,7 @@ local lsp_status = require('casraf.lib.lsp_status')
local ts_keys = require('casraf.lib.ts_keys')
local function wrap_status()
return 'TW: ' .. (vim.wo.wrap and '' or '')
return (vim.wo.wrap and '' or '') .. ' TW'
end
return {

View File

@@ -758,9 +758,9 @@ install:
post_install: source "$DOTFILES/plugins/loader.zsh"
post_update: source "$DOTFILES/plugins/loader.zsh"
opts:
source: ~/.dotfiles/plugins
destination: ~/.local/share/zsh/
# flags: --delete
source: ~/.dotfiles/plugins/
destination: ~/.local/share/zsh/plugins/
flags: --delete
- name: mfaerevaag/wd
type: git

View File

@@ -1,119 +1,5 @@
#!/usr/bin/env zsh
platform_install() {
if [[ $# -eq 0 ]]; then
echo "Usage: platform_install [flags] [package]"
echo
echo "Install a package using the platform's package manager"
echo
echo "Flags:"
echo " --apt, -a <package> Install package using apt"
echo " --brew, -b <package> Install package using brew"
echo " --dpkg, -d <url> Install package using dpkg"
echo " --cmd, -c <cmd> Run a command to install package"
echo " --linux-strategy, -l <strategy> Use a specific strategy for linux"
echo " --mac-strategy, -m <strategy> Use a specific strategy for mac"
echo
echo "Strategies:"
echo " apt: Install package using apt"
echo " brew: Install package using brew"
echo " dpkg: Install package using dpkg"
echo " cmd: Run a command to install package"
return 1
fi
mac_strategy="brew"
linux_strategy="apt"
while [[ $# -gt 0 ]]; do
# echo "parsing: \"$1\", all: \"$@\""
case $1 in
--apt | -a)
apt_pkg="$2"
shift 2
;;
--brew | -b)
brew_pkg="$2"
shift 2
;;
--dpkg | -d)
dpkg_url="$2"
shift 2
;;
--cmd | -c)
install_cmd="$2"
shift 2
;;
--linux-strategy | -l)
linux_strategy="$2"
shift 2
;;
--mac-strategy | -m)
mac_strategy="$2"
shift 2
;;
*)
if [[ -z "$pkg" ]]; then
pkg="$1"
shift
else
echo_red "Unknown flag $1"
return 1
fi
;;
esac
done
# echo "mac_strategy=$mac_strategy"
# echo "linux_strategy=$linux_strategy"
# echo "brew_pkg=$brew_pkg"
# echo "apt_pkg=$apt_pkg"
# echo "dpkg_url=$dpkg_url"
# echo "install_cmd=$install_cmd"
# echo "is_mac=$(is_mac && echo true || echo false)"
# echo "is_linux=$(is_linux && echo true || echo false)"
if is_mac; then
strategy="$mac_strategy"
else
strategy="$linux_strategy"
fi
case "$strategy" in
apt) [[ -z "$apt_pkg" ]] || pkg="$apt_pkg" ;;
brew) [[ -z "$brew_pkg" ]] || pkg="$brew_pkg" ;;
dpkg) [[ -z "$dpkg_url" ]] || pkg="$dpkg_url" ;;
cmd) [[ -z "$install_cmd" ]] || pkg="$install_cmd" ;;
esac
if [[ -z "$pkg" ]]; then
echo_red "No package specified"
return 1
fi
echo "Installing $pkg using $strategy"
case "$strategy" in
apt) sudo apt install "$pkg" ;;
brew)
if [[ -z "$ARCH" ]]; then
ARCH=$(uname -m)
fi
arch -arch $ARCH brew install "$pkg"
;;
dpkg)
tmp="$(mktemp).deb"
curl -sL "$dpkg" -o "$tmp"
sudo dpkg -i "$tmp"
rm -rf "$tmp"
;;
cmd) eval $pkg ;;
*)
echo_red "Unknown strategy $strategy"
return 1
;;
esac
}
# sets pnpm version on closest package.json to current version
set-pnpm-pkg-version() {
fl=$(find-up package.json)
@@ -134,53 +20,3 @@ set-pnpm-pkg-version() {
mv $fl.tmp $fl
fi
}
# list all scripts in project directory, supports package.json and poe pyproject.toml
scriptls() {
if find-up package.json >/dev/null; then
jsscriptls
elif find-up pyproject.toml >/dev/null; then
pyscriptls
fi
return $?
}
# list all package.json scripts in project root
jsscriptls() {
if ! find-up package.json >/dev/null; then
return 1
fi
cat $(find-up package.json) | jq '.scripts'
}
# list all poe pyproject.toml tasks in project root
pyscriptls() {
if ! find-up pyproject.toml >/dev/null; then
return 1
fi
cat $(find-up pyproject.toml) | tomlq '.tool.poe.tasks'
}
# list all dependencies in package.json in project root
depls() {
if ! find-up package.json >/dev/null; then
return 1
fi
cat $(find-up package.json) | jq '.dependencies'
}
# list all dev dependencies in package.json in project root
devdepls() {
if ! find-up package.json >/dev/null; then
return 1
fi
cat $(find-up package.json) | jq '.devDependencies'
}
# list all peer dependencies in package.json in project root
peerdepls() {
if ! find-up package.json >/dev/null; then
return 1
fi
cat $(find-up package.json) | jq '.peerDependencies'
}

View File

@@ -22,11 +22,21 @@ function spinner() {
# (that way it works for any locale as long as the font supports the characters)
local LC_CTYPE=C
# Run the provided command in background
# Parse optional -<number> to select spinner style
local spin_index
if [[ "$1" =~ ^-([0-9]+)$ ]]; then
spin_index=${match[1]}
shift
else
spin_index=$(($RANDOM % 12))
fi
# Run the provided command in background (disable monitor to suppress job notifications)
setopt local_options no_monitor
"$@" &
local pid=$! # Process Id of the previous running command
case $(($RANDOM % 12)) in
case $spin_index in
0)
local spin='⠁⠂⠄⡀⢀⠠⠐⠈'
local charwidth=3
@@ -78,13 +88,15 @@ function spinner() {
esac
local i=0
local label="Running '$*'..."
tput civis # cursor invisible
while kill -0 "$pid" 2>/dev/null; do
local i=$(((i + $charwidth) % ${#spin}))
printf "%s" "${spin:$i:$charwidth}"
cursorBack 1
printf "%s %s" "${spin:$i:$charwidth}" "$label"
cursorBack $((1 + ${#label} + 1))
sleep .1
done
printf "\r%*s\r" $((${#label} + 2)) "" # clear the line
tput cnorm
wait "$pid" # capture exit code
return $?

View File

@@ -18,5 +18,9 @@ pubkey() {
# add pubkey to allowed signers
allow-signing() {
file=$(pubkey_file $1)
if [[ ! -f $file ]]; then
echo_red "Public key file not found: $file"
return 1
fi
echo "$(git config --get user.email) namespaces=\"git\" $(cat $file)" >>~/.ssh/allowed_signers
}

View File

@@ -80,9 +80,7 @@ posix_compliant() {
}
# decode a uri component
uridecode() {
posix_compliant "${*}"
}
alias uridecode=posix_compliant
center() {
if [[ $# -eq 0 ]]; then