view dot_zshrc @ 319:b93f12d23fbd

Rename init.lua to config.lua init.lua is now automatically sourced, and runs before init.vim causing issues like lspconfig that cannot be found. Renaming to something that will not be sourced automatically and manually load it from init.vim when all plugins are loaded
author Zeger Van de Vannet <zegervdv@me.com>
date Thu, 17 Dec 2020 17:49:14 +0100
parents c49fb04cf6da
children 14492409db21
line wrap: on
line source

# vim:ft=zsh

source ~/.zsh/zsh-history-substring-search.zsh
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=green,fg=black'

export TERM=xterm-256color

export LC_ALL=$LANG

PROMPT='%F{cyan}%T%f %F{red}%m%f %F{blue}%~%b%f
%j -> '


vim_ins_mode="%F{black}%K{yellow} INS %k%f"
vim_cmd_mode="%F{white}%K{red} NRM %k%f"
vim_mode=$vim_ins_mode

# Cursor mapping from nyquase/vi-mode
function select_cursor() {
  case $KEYMAP in
    # Block cursor in normal and visual mode
    vicmd) echo -ne "\e[2 q";;
    # Line cursor in insert mode
    main|viins) echo -ne "\e[5 q";;
    # Else Block cursor
    *) echo -ne "\e[2 q";;
  esac
}

function zle-keymap-select {
  vim_mode="${${KEYMAP/vicmd/${vim_cmd_mode}}/(main|viins)/${vim_ins_mode}}"
  zle reset-prompt
  zle -R
  select_cursor
}
zle -N zle-keymap-select

function zle-line-init() {
  echoti smkx
  zle reset-prompt
  select_cursor
}
zle -N zle-line-init

function zle-line-finish {
  vim_mode=$vim_ins_mode
  echoti rmkx
  echo -ne "\e[2 q"
}
zle -N zle-line-finish

function TRAPINT() {
  vim_mode=$vim_ins_mode
  return $(( 128 + $1 ))
}

RPROMPT='${vim_mode}'

zmodload -i zsh/complist

bindkey -v

bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey '^p' history-substring-search-up
bindkey '^n' history-substring-search-down

export LESS_TERMCAP_mb=$(printf "\e[1;31m")
export LESS_TERMCAP_md=$(printf "\e[1;31m")
export LESS_TERMCAP_me=$(printf "\e[0m")
export LESS_TERMCAP_se=$(printf "\e[0m")
export LESS_TERMCAP_so=$(printf "\e[1;44;33m")
export LESS_TERMCAP_ue=$(printf "\e[0m")
export LESS_TERMCAP_us=$(printf "\e[1;32m")

export CLICOLOR=1
export LS_COLORS='no=00;37:fi=00:di=00;33:ln=04;36:pi=40;33:so=01;35:bd=40;33;01:'

# Options
setopt monitor
setopt auto_cd
setopt cdablevars
setopt pushd_ignore_dups
setopt interactive_comments
setopt append_history
setopt inc_append_history
setopt hist_ignore_dups
setopt hist_find_no_dups
setopt hist_reduce_blanks
setopt extended_history
setopt hist_expire_dups_first
setopt hist_verify
setopt share_history
setopt transient_rprompt
setopt prompt_subst
setopt multios
setopt correct_all
setopt autopushd
setopt pushdminus
setopt pushdsilent
setopt nobeep
setopt notify
REPORTTIME=5

HISTSIZE=3000
SAVEHIST=3000
HISTFILE=~/.zsh_history

# Completion
setopt complete_in_word
setopt always_to_end
setopt auto_menu

# activate color-completion
zstyle ':completion:*:default'         list-colors ${(s.:.)LS_COLORS}

# format on completion
zstyle ':completion:*:descriptions'    format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'

# insert all expansions for expand completer
zstyle ':completion:*:expand:*'        tag-order all-expansions
zstyle ':completion:*:history-words'   list false

# activate menu
zstyle ':completion:*:history-words'   menu yes

# ignore duplicate entries
zstyle ':completion:*:history-words'   remove-all-dups yes
zstyle ':completion:*:history-words'   stop yes

zstyle ':completion:*:matches'         group 'yes'
zstyle ':completion:*'                 group-name ''
if [[ "$NOMENU" -eq 0 ]] ; then
  # if there are more than 5 options allow selecting from a menu
  zstyle ':completion:*'               menu select=5
else
  # don't use any menus at all
  setopt no_auto_menu
fi

zstyle ':completion:*:messages'        format '%d'
zstyle ':completion:*:options'         auto-description '%d'

# describe options in full
zstyle ':completion:*:options'         description 'yes'

# complete manual by their section
zstyle ':completion:*:manuals'    separate-sections true
zstyle ':completion:*:manuals.*'  insert-sections   true
zstyle ':completion:*:man:*'      menu yes select

# Search path for sudo completion
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
                                           /usr/local/bin  \
                                           /usr/sbin       \
                                           /usr/bin        \
                                           /sbin           \
                                           /bin            \
                                           /usr/X11R6/bin

# provide .. as a completion
zstyle ':completion:*' specal-dirs ..

# case insensitive path-completion
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'

# nvim completion
zstyle ':completion::*:nvim:*' ignored-patterns '*.(o|hex|elf|pyc|pdf|dup)'

autoload -U compinit && compinit

# fg when pressing Ctrl+Z
function fancy-ctrl-z () {
  if [[ $#BUFFER -eq 0 ]]; then
    if [[ $(jobs | wc -l) -gt 0 ]]; then
      BUFFER='fg'
      zle accept-line
    fi
  else
    zle push-input
    zle clear-screen
  fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z

# Ctags based completion for rg
_rg() {
  if (( CURRENT == 2 )); then
    compadd $(cut -f 1 tags tmp/tags 2>/dev/null | grep -v '!_TAG')
  fi
}

compdef _rg rg

# Aliases
alias l="ls -haltr --color"
alias ll="ls -haltr --color"
alias ls="ls --color"
alias xclip='xclip -selection clipboard'
alias view='nvim -R'

# Exports
export XDG_CONFIG_HOME=$HOME/.config
export PATH=$HOME/bin:$PATH

export EDITOR=nvim
export HGEDITOR=nvim

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='ag -g ""'
[ -f ~/.zshrc.local ] && source ~/.zshrc.local