# Github cli completion
# if command -v gh > /dev/null; and not test -f $HOME/.config/fish/completions/gh.fish
#     gh completion -s fish > $HOME/.config/fish/completions/gh.fish
# end

# kitten from kitty
if command -v kitty > /dev/null
  kitty + complete setup fish | source
end

# Starship prompt
if command -v starship > /dev/null
  starship init fish --print-full-init | source
end

# direnv
if command -v direnv > /dev/null
  direnv hook fish | source
  # set -g direnv_fish_mode eval_after_arrow
end

# poetry
# if not test -d "$POETRY_HOME"
#   curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
# end
# if not test -f "$HOME/.config/fish/completions/poetry.fish"
#   poetry completions fish > $HOME/.config/fish/completions/poetry.fish
# end

# pyenv
# if not test -d "$PYENV_ROOT"
#   git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT
#   git clone https://github.com/pyenv/pyenv-update.git $PYENV_ROOT/plugins/pyenv-update
#   git clone https://github.com/pyenv/pyenv-virtualenv.git $PYENV_ROOT/plugins/pyenv-virtualenv
# end
# pyenv init - | source
# pyenv virtualenv-init - | source

# nodenv
# if not test -d "$NODENV_ROOT"
#   git clone https://github.com/nodenv/nodenv.git $NODENV_ROOT
#   mkdir -p $NODENV_ROOT/plugins
#   git clone https://github.com/nodenv/node-build.git $NODENV_ROOT/plugins/node-build
#   git clone https://github.com/nodenv/nodenv-env.git $NODENV_ROOT/plugins/nodenv-env
#   git clone https://github.com/nodenv/nodenv-man.git $NODENV_ROOT/plugins/nodenv-man
#   git clone https://github.com/nodenv/nodenv-aliases.git $NODENV_ROOT/plugins/nodenv-aliases
#   git clone https://github.com/nodenv/nodenv-each.git $NODENV_ROOT/plugins/nodenv-each
#   git clone https://github.com/nodenv/nodenv-update.git $NODENV_ROOT/plugins/nodenv-update
#   git clone https://github.com/nodenv/nodenv-vars.git $NODENV_ROOT/plugins/nodenv-vars
# end
# nodenv init - | source

# vi key bindings
fish_vi_key_bindings

# fzf
if not test -f "$HOME/.config/fish/functions/fzf_key_bindings.fish"
  curl -fLo $HOME/.config/fish/functions/fzf_key_bindings.fish https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.fish
end
fzf_key_bindings

# z.lua
# if not test -f "$HOME/.config/fish/z.lua"
#   curl -fLo $HOME/.config/fish/z.lua https://raw.githubusercontent.com/skywind3000/z.lua/master/z.lua
#   mkdir -p $HOME/.local/share/zlua
# end
# lua $HOME/.config/fish/z.lua --init fish | source
# if command -v ranger >/dev/null
#   if not test -f "$HOME/.config/ranger/plugins/ranger_zlua.py"
#     curl -fLo $HOME/.config/ranger/plugins/ranger_zlua.py https://github.com/skywind3000/z.lua/raw/master/ranger_zlua.py
#   end
# end
# alias zc='z -c'      # restrict matches to subdirs of $PWD
# alias zz='z -i'      # cd with interactive selection
# alias zf='z -I'      # use fzf to select in multiple matches
# alias zb='z -b'      # quickly cd to the parent directory
# alias zbi='z -b -i'  # interactive jump backward
# alias zbf='z -b -I'  # interactive jump backward with fzf

# zoxide
if command -v zoxide >/dev/null
  zoxide init fish | source
  if command -v ranger >/dev/null
    if not test -f "$HOME/.config/ranger/plugins/ranger_zoxide.py"
      curl -fLo $HOME/.config/ranger/plugins/ranger_zoxide.py https://github.com/ajeetdsouza/zoxide/raw/main/contrib/ranger.py
    end
  end
end
