feat(zsh): completion for nvim with modified files

This commit is contained in:
TheK4n 2023-01-25 00:02:15 +03:00
parent 5390b9a761
commit af126bb2c8
3 changed files with 19 additions and 1 deletions

View File

@ -21,6 +21,7 @@ zsh:
test -d ~/.subzsh || \
ln -s $(PWD)/sub/zsh ~/.subzsh
ln -s ~/.subzsh/zshrc ~/.zshrc
ln -s ~/.subzsh/zfunc ~/.zfunc
mkdir ~/.subzsh/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.subzsh/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.subzsh/plugins/zsh-syntax-highlighting

View File

@ -1,8 +1,9 @@
# enable completion features
fpath+=~/.zfunc
fpath=(~/.zfunc $fpath)
autoload -Uz compinit
compinit -d ~/.cache/zcompdump
compdef _nvim nvim
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate

16
sub/zsh/zfunc/_nvim Normal file
View File

@ -0,0 +1,16 @@
#compdef nvim
#autoload
_nvim() {
subcmds=($(git diff --name-only 2>/dev/null))
if [[ -z "$subcmds" ]]; then
_files
else
_values -C 'modified files' $subcmds
_files
fi
}
_nvim