From 5b575986c91ecaa6f1f79d74b5fc0bb57acdb684 Mon Sep 17 00:00:00 2001 From: bretello Date: Sat, 26 Nov 2022 00:52:01 +0100 Subject: [PATCH] misc improvements/cleanup - add fzf-tab-config - fix fzf plugin install - change shortcut for spell - set default shell to zsh --- brethil_dotfile.sh | 1 + extras/fzf-tab-config.zsh | 25 +++++++++++++++++++++++++ vim/plugs.vim | 2 +- vim/shortcuts.vim | 4 ++-- vim/vimrc | 4 +++- 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 extras/fzf-tab-config.zsh diff --git a/brethil_dotfile.sh b/brethil_dotfile.sh index 1274de4..1fd8379 100755 --- a/brethil_dotfile.sh +++ b/brethil_dotfile.sh @@ -14,6 +14,7 @@ antibody bundle < "$DOTFILES/antibody_plugins.txt" # Setup completion style source $DOTFILES/completion_style.zsh +source $DOTFILES/extras/fzf-tab-config.zsh if [[ "$(command -v systemctl)" ]]; then antibody bundle robbyrussell/oh-my-zsh path:plugins/systemd diff --git a/extras/fzf-tab-config.zsh b/extras/fzf-tab-config.zsh new file mode 100644 index 0000000..f82ed1d --- /dev/null +++ b/extras/fzf-tab-config.zsh @@ -0,0 +1,25 @@ +# disable sort when completing options of any command +zstyle ':completion:complete:*:options' sort false + +# use input as query string when completing zlua +zstyle ':fzf-tab:complete:_zlua:*' query-string input + +# (experimental, may change in the future) +# some boilerplate code to define the variable `extract` which will be used later +# please remember to copy them +local extract=" +# trim input(what you select) +local in=\${\${\"\$(<{f})\"%\$'\0'*}#*\$'\0'} +# get ctxt for current completion(some thing before or after the current word) +local -A ctxt=(\"\${(@ps:\2:)CTXT}\") +# real path +local realpath=\${ctxt[IPREFIX]}\${ctxt[hpre]}\$in +realpath=\${(Qe)~realpath} +" + +# give a preview of commandline arguments when completing `kill` +zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w" +zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap + +# give a preview of directory by exa when completing cd +zstyle ':fzf-tab:complete:cd:*' extra-opts --preview=$extract'exa -1 --color=always $realpath' diff --git a/vim/plugs.vim b/vim/plugs.vim index a0da1e0..fb34658 100644 --- a/vim/plugs.vim +++ b/vim/plugs.vim @@ -44,7 +44,7 @@ Plug 'https://github.com/nathanaelkane/vim-indent-guides' Plug 'https://github.com/igankevich/mesonic' " fzf -Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf' Plug 'junegunn/fzf.vim' " Open tags with fzf's :Tags Plug 'https://github.com/ludovicchabant/vim-gutentags.git' diff --git a/vim/shortcuts.vim b/vim/shortcuts.vim index 970450b..29f8c98 100644 --- a/vim/shortcuts.vim +++ b/vim/shortcuts.vim @@ -46,7 +46,7 @@ map cp :cp "disable highlighting for current word map :noh -map ss :setlocal spell! +map S :setlocal spell! nnoremap M :bel copensilent make redraw! nnoremap wz :call WinZoomToggle() @@ -56,7 +56,7 @@ nnoremap B :Bclose nnoremap k :Rg "" Fugitive -nnoremap / :Git +nnoremap / :vert Git nnoremap \ :0Git nnoremap d :Gvdiffsplit nnoremap b :Git blame diff --git a/vim/vimrc b/vim/vimrc index dc25032..87ace71 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -27,8 +27,10 @@ colorscheme gruvbox set nowrap set mouse=a set relativenumber number -set foldlevelstart=3 foldmethod=indent foldenable "without nofoldenable all folds are closed at startup" +set foldlevelstart=3 foldmethod=indent nofoldenable "without foldenable all folds are open at startup" set ttymouse=xterm2 " fix mouse when used in tmux/byobu https://unix.stackexchange.com/q/50733 +set shell=zsh +"set shellcmdflag=-ilc " make builtin shell interactive set nobackup nowb noswapfile " no need for backups of every file set history=10000