From 11f9f923d0a4ca2afa27e0ca598e842201bac342 Mon Sep 17 00:00:00 2001 From: Hadeed Ahmad Date: Wed, 30 Aug 2023 07:00:57 +0500 Subject: [PATCH] fzf stuff --- docs/pacman_pkgs.txt | 2 ++ nvim/lua/plugins/completion.lua | 2 +- zsh/dot-zshrc | 22 +++++++++++----------- zsh/zsh-bindings | 8 ++++++++ zsh/zsh-completion | 7 +++++++ zsh/zsh-functions | 26 +++++++++++--------------- zsh/zsh-options | 2 ++ 7 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 zsh/zsh-bindings create mode 100644 zsh/zsh-completion diff --git a/docs/pacman_pkgs.txt b/docs/pacman_pkgs.txt index 9fbd27d..dfd02cd 100644 --- a/docs/pacman_pkgs.txt +++ b/docs/pacman_pkgs.txt @@ -1,4 +1,6 @@ bat +bear +ccls exa fd kitty diff --git a/nvim/lua/plugins/completion.lua b/nvim/lua/plugins/completion.lua index c01c19b..7483843 100644 --- a/nvim/lua/plugins/completion.lua +++ b/nvim/lua/plugins/completion.lua @@ -11,7 +11,7 @@ return { cmp.setup { mapping = cmp.mapping.preset.insert { - [""] = function(fallback) + [""] = function(fallback) if cmp.visible() then cmp.confirm { select=true } else diff --git a/zsh/dot-zshrc b/zsh/dot-zshrc index 79f2506..a1412bb 100644 --- a/zsh/dot-zshrc +++ b/zsh/dot-zshrc @@ -1,6 +1,15 @@ function create_dir() [ ! -d "$1" ] && mkdir -p "$1" function safe_source() [ -f "$1" ] && source "$1" function zsh_add_file() safe_source "$ZDOTDIR/$1" +function zsh_add_plugin() { + PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2) + + [ ! -d "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME" ] && + git clone "https://github.com/$1.git" "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME" + + safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh" + safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.zsh" +} zsh_add_file "zsh-aliases" zsh_add_file "zsh-functions" @@ -12,16 +21,7 @@ zsh_add_plugin "zdharma-continuum/fast-syntax-highlighting" zsh_add_plugin "zsh-users/zsh-autosuggestions" zsh_add_plugin "zsh-users/zsh-completions" -create_dir "$HOME/.cache/zsh" -autoload -Uz compinit && compinit -d "$HOME/.cache/zsh/zcompdump" -zmodload zsh/complist -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' - -autoload -z edit-command-line -zle -N edit-command-line - -bindkey -e -bindkey "^V" edit-command-line -bindkey '^K' autosuggest-execute +zsh_add_file "zsh-completions" +zsh_add_file "zsh-bindings" # vim: filetype=zsh diff --git a/zsh/zsh-bindings b/zsh/zsh-bindings new file mode 100644 index 0000000..b2108e9 --- /dev/null +++ b/zsh/zsh-bindings @@ -0,0 +1,8 @@ +autoload -z edit-command-line +zle -N edit-command-line +bindkey "^V" edit-command-line + +bindkey '^Y' autosuggest-execute +bindkey '^F' find-directory + +# vim: filetype=zsh diff --git a/zsh/zsh-completion b/zsh/zsh-completion new file mode 100644 index 0000000..4b1cf3f --- /dev/null +++ b/zsh/zsh-completion @@ -0,0 +1,7 @@ +create_dir "$HOME/.cache/zsh" +autoload -Uz compinit +compinit -d "$HOME/.cache/zsh/zcompdump" +zmodload zsh/complist +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' + +# vim: filetype=zsh diff --git a/zsh/zsh-functions b/zsh/zsh-functions index 805c216..fdf4d2a 100644 --- a/zsh/zsh-functions +++ b/zsh/zsh-functions @@ -1,21 +1,6 @@ -function zsh_add_plugin() { - PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2) - - [ ! -d "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME" ] && - git clone "https://github.com/$1.git" "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME" - - safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh" - safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.zsh" -} - function cc() python -c "from math import *; print($*)" function mkcd() mkdir -p -- $1 && cd -- $1 -function serve() { - gem list -i '^webrick$' > /dev/null || gem install webrick - ruby -run -e httpd . -p 3000 -} - function save-ssh-key() { mv "$1" "$HOME/.ssh/${1}_${2}" mv "$1.pub" "$HOME/.ssh/${1}_${2}.pub" @@ -25,4 +10,15 @@ function eik() { kitten edit-in-kitty "$1" } +function find-directory() { + FOLDER=$(fd -t d --hidden | fzf --height "50%" --reverse) + if [ -n "$FOLDER" ]; then + BUFFER="cd $FOLDER" + zle .accept-line + else + zle reset-prompt + fi +} +zle -N find-directory + # vim: filetype=zsh diff --git a/zsh/zsh-options b/zsh/zsh-options index 6c112ef..59ffc87 100644 --- a/zsh/zsh-options +++ b/zsh/zsh-options @@ -11,6 +11,8 @@ setopt INC_APPEND_HISTORY setopt RM_STAR_SILENT setopt NO_BEEP +bindkey -e + stty stop undef zle_highlight=("paste:none")