From 196cfa0eb0fd592e60078cfa646bf3faf182d674 Mon Sep 17 00:00:00 2001 From: Vladimir Rudnyh Date: Tue, 3 Dec 2013 23:25:52 +0400 Subject: [PATCH 1/3] Remove spaces at the end of lines --- README.mkd | 2 +- autosuggestions.zsh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.mkd b/README.mkd index 51724b8..bca2b90 100644 --- a/README.mkd +++ b/README.mkd @@ -29,7 +29,7 @@ this: ```sh # Accept suggestions without leaving insert mode bindkey '^f' vi-forward-word -# or +# or bindkey '^f' vi-forward-blank-word ``` diff --git a/autosuggestions.zsh b/autosuggestions.zsh index f650486..6a187b8 100644 --- a/autosuggestions.zsh +++ b/autosuggestions.zsh @@ -1,5 +1,5 @@ # Fish-like autosuggestions for zsh. Some of the code was based on the code -# for 'predict-on' +# for 'predict-on' # # ```zsh # zle-line-init() { @@ -68,11 +68,11 @@ autosuggest-resume() { local widget # Replace prediction widgets by versions that will also highlight RBUFFER zle -A autosuggest-insert-or-space self-insert - zle -A autosuggest-insert-or-space magic-space - zle -A autosuggest-backward-delete-char backward-delete-char - zle -A autosuggest-accept-line accept-line + zle -A autosuggest-insert-or-space magic-space + zle -A autosuggest-backward-delete-char backward-delete-char + zle -A autosuggest-accept-line accept-line # Hook into some default widgets that should suspend autosuggestion - # automatically + # automatically for widget in $ZLE_AUTOSUGGEST_ACCEPT_WIDGETS; do [[ -z $widgets[$widget] ]] && continue eval "zle -A autosuggest-accept-suggestion $widget" From ea19b7bcf8d2eb5ee92fc62e3bbc0532930b8a51 Mon Sep 17 00:00:00 2001 From: Vladimir Rudnyh Date: Tue, 3 Dec 2013 23:45:56 +0400 Subject: [PATCH 2/3] Add highlight color config variables --- README.mkd | 7 +++++++ autosuggestions.zsh | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.mkd b/README.mkd index bca2b90..9ce8365 100644 --- a/README.mkd +++ b/README.mkd @@ -37,3 +37,10 @@ Emacs-mode users can simply use alt+f which is bound to forward-word The [zsh-history-substring-search](https://github.com/zsh-users/zsh-history-substring-search) plugin is also recommended. + +## Configuration + +You may override default global config variables after plugin load. + +- `AUTOSUGGESTION_HIGHLIGHT_COLOR`: suggestion highlight color, default is `'fg=8'`. +- `AUTOSUGGESTION_HIGHLIGHT_CURSOR`: highlight word after cursor or not. Must be integer value `1` or `0`, default is `1`. diff --git a/autosuggestions.zsh b/autosuggestions.zsh index 6a187b8..326a223 100644 --- a/autosuggestions.zsh +++ b/autosuggestions.zsh @@ -11,6 +11,10 @@ zmodload zsh/net/socket source "${0:a:h}/completion-client.zsh" +# configuration variables +AUTOSUGGESTION_HIGHLIGHT_COLOR='fg=8' +AUTOSUGGESTION_HIGHLIGHT_CURSOR=1 + function { if [[ -n $ZLE_DISABLE_AUTOSUGGEST ]]; then ZSH_HIGHLIGHT_HIGHLIGHTERS=() @@ -123,10 +127,7 @@ _zsh_highlight_autosuggest_highlighter_predicate() { } _zsh_highlight_autosuggest_highlighter() { - local color='fg=8' - [[ -n $AUTOSUGGESTION_HIGHLIGHT_COLOR ]] &&\ - color=$AUTOSUGGESTION_HIGHLIGHT_COLOR - region_highlight+=("$(( $CURSOR + 1 )) $(( $CURSOR + $#RBUFFER )) $color") + region_highlight+=("$(( $CURSOR + $AUTOSUGGESTION_HIGHLIGHT_CURSOR )) $(( $CURSOR + $#RBUFFER )) $AUTOSUGGESTION_HIGHLIGHT_COLOR") } autosuggest-insert-or-space() { From 48f03e2b0c4801f9d3ff330a6440dffa5d040a6e Mon Sep 17 00:00:00 2001 From: Vladimir Rudnyh Date: Wed, 4 Dec 2013 23:07:24 +0400 Subject: [PATCH 3/3] Suspend autosuggest on 'history-beginning-search-backward' and 'history-beginning-search-forward' commands --- autosuggestions.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/autosuggestions.zsh b/autosuggestions.zsh index 326a223..029dbf1 100644 --- a/autosuggestions.zsh +++ b/autosuggestions.zsh @@ -30,6 +30,7 @@ function { ZLE_AUTOSUGGEST_SUSPEND_WIDGETS=( vi-cmd-mode vi-backward-char backward-char backward-word beginning-of-line history-search-forward history-search-backward up-line-or-history +history-beginning-search-forward history-beginning-search-backward down-line-or-history )