Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dot_Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ brew "bat"
brew "berkeley-db"
brew "betterleaks"
brew "bottom"
brew "carapace"
brew "chezmoi"
brew "clang-format"
brew "cloc"
Expand Down
65 changes: 2 additions & 63 deletions dot_zsh/custom.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -61,69 +61,8 @@ setopt transient_rprompt #
# compinit は dot_zshrc で sheldon 読み込み前に実行済み
zstyle ':completion:*:default' menu select=1

# npm completion

###-begin-npm-completion-###
# shellcheck disable=SC2207,SC2046,SC2034,SC2162,SC2219
#
# npm command completion script
#
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc)
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
#

if type complete &>/dev/null; then
_npm_completion() {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -n : -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
fi

local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
if type __ltrim_colon_completions &>/dev/null; then
__ltrim_colon_completions "${words[cword]}"
fi
}
complete -o default -F _npm_completion npm
elif type compdef &>/dev/null; then
_npm_completion() {
local si=$IFS
compadd -- $(COMP_CWORD=$((CURRENT - 1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
npm completion -- "${words[@]}" \
2>/dev/null)
IFS=$si
}
compdef _npm_completion npm
elif type compctl &>/dev/null; then
_npm_completion() {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
compctl -K _npm_completion npm
fi
###-end-npm-completion-###
# npm / yarn / pnpm の補完は carapace が担当する
# (sheldon の plugins.carapace で読み込み。旧 `npm completion` 生成コードは削除済み)

# AWS CLI
# shellcheck disable=SC1091
Expand Down
2 changes: 1 addition & 1 deletion dot_zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ promptinit
typeset -U fpath

# compinit を sheldon 読み込み前に走らせる
# (zsh-better-npm-completion 等が source 中に compdef を呼ぶため)
# (carapace / gibo-completion 等が source 中に compdef を呼ぶため)
# .zcompdump が24時間以内に更新されていればセキュリティ監査(compaudit)をスキップして高速化
autoload -Uz compinit
zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
Expand Down
14 changes: 11 additions & 3 deletions private_dot_config/sheldon/plugins.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ github = "zsh-users/zsh-autosuggestions"
[plugins.zsh-history-substring-search]
github = "zsh-users/zsh-history-substring-search"

[plugins.zsh-better-npm-completion]
github = "lukechilds/zsh-better-npm-completion"

[plugins.zsh-ssh]
github = "zpm-zsh/ssh"

[plugins.git-open]
github = "paulirish/git-open"

# carapace はマルチシェル対応の補完エンジン(約1000コマンドの spec を内蔵)
# 他の補完プラグインより後に読み込み、compdef を上書きさせる
# 特定コマンドを zsh 標準の補完に戻したい場合は CARAPACE_EXCLUDES='git,npm' のように指定する
[plugins.carapace]
inline = '''
if command -v carapace &>/dev/null; then
zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m'
source <(carapace _carapace)
fi
'''

# zsh-syntax-highlighting は最後に読み込む
# (他プラグインで定義された関数・コマンドもハイライト対象にするため)
[plugins.zsh-syntax-highlighting]
Expand Down
Loading