From fbf825aef8a636fcb4579706cb98b5e2680268e6 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Sun, 15 Aug 2021 11:07:44 +0000 Subject: [PATCH 01/30] vimrc: fix coc.nvim goto bindings --- vimrc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/vimrc b/vimrc index bad40ec..756ecf4 100644 --- a/vimrc +++ b/vimrc @@ -289,10 +289,10 @@ if has_key(plugs, 'coc.nvim') && executable("node") xmap / (coc-codeaction-selected) " rename symbol - nnoremap rn (coc-rename) + nmap rn (coc-rename) " goto definition / references - nnoremap gd (coc-definition) - nnoremap gr (coc-references) + nmap gd (coc-definition) + nmap gr (coc-references) " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by @@ -367,11 +367,21 @@ if has_key(plugs, 'fzf.vim') \ fzf#vim#files(, fzf#vim#with_preview({'source': 'rg --files --hidden --glob "!**/.git/**" ' }), 0) endif - nnoremap :Rg + nnoremap :Rg + nnoremap :Rg! + nnoremap :Rg + nnoremap :Rg! endif - nnoremap :Files - nnoremap :Buffers + nnoremap :Files + nnoremap :Files! + nnoremap :Files + nnoremap :Files! + + nnoremap :Buffers + nnoremap :Buffers! + nnoremap :Buffers + nnoremap :Buffers! endif " Vim Tmux unified movement From d16b5c69ca7e2a5e58be1e3836945a8fd2a68cc4 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Sun, 29 Aug 2021 18:27:23 +0000 Subject: [PATCH 02/30] tmux/tmux: refactor to use source files - plugins -> $PSOXIZSH/tmux/plugins.conf - vim integration -> $PSOXIZSH/tmux/fragment/vim-movement.conf We also allow the user to include personal settings via ~/.config/tmux/{early,late}.conf which can include any of the fragments we collect! C --- tmux/tmux.conf | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/tmux/tmux.conf b/tmux/tmux.conf index ec83fc0..e88b9b9 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -1,32 +1,12 @@ # Plugins set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGINS" -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'tmux-plugins/tmux-prefix-highlight' -set -g @prefix_highlight_prefix_prompt 'Pre' -set -g @prefix_highlight_fg 'yellow' -set -g @prefix_highlight_bg 'default' -set -g @plugin 'tmux-plugins/tmux-copycat' -set -g @plugin 'tmux-plugins/tmux-yank' +if "test -f ~/.config/tmux/plugins.conf" { + source-file ~/.config/tmux/plugins.conf +} -# Integration with vim-tmux-navigator & fzf -is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ -| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" -is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \ -| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'" -bind -n C-h run "($is_vim && tmux send-keys C-h) \ - || tmux select-pane -L" -bind -n C-j run "($is_vim && tmux send-keys C-j) \ - || ($is_fzf && tmux send-keys C-j) \ - || tmux select-pane -D" -bind -n C-k run "($is_vim && tmux send-keys C-k) \ - || ($is_fzf && tmux send-keys C-k) \ - || tmux select-pane -U" -bind -n C-l run "($is_vim && tmux send-keys C-l) \ - || tmux select-pane -R" -bind-key -T copy-mode-vi 'C-h' select-pane -L -bind-key -T copy-mode-vi 'C-j' select-pane -D -bind-key -T copy-mode-vi 'C-k' select-pane -U -bind-key -T copy-mode-vi 'C-l' select-pane -R +if "test -f ~/.config/tmux/early.conf" { + source-file ~/.config/tmux/early.conf +} set-option -g prefix C-a set-option -g set-titles on @@ -69,5 +49,9 @@ bind - last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom # prefix + / to search bind-key / copy-mode \; send-key ? +if "test -f ~/.config/tmux/late.conf" { + source-file ~/.config/tmux/late.conf +} + # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run -b "$TMUX_PLUGINS/tpm/tpm" From a91b05a0f049df73f9dcfaa0c325f1b5d1da1eda Mon Sep 17 00:00:00 2001 From: Bazaah Date: Sun, 29 Aug 2021 18:32:17 +0000 Subject: [PATCH 03/30] tmux/fragment: add plugins, vim-movement --- tmux/fragment/plugins.conf | 70 +++++++++++++++++++++++++++++++++ tmux/fragment/vim-movement.conf | 34 ++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 tmux/fragment/plugins.conf create mode 100644 tmux/fragment/vim-movement.conf diff --git a/tmux/fragment/plugins.conf b/tmux/fragment/plugins.conf new file mode 100644 index 0000000..aa2077c --- /dev/null +++ b/tmux/fragment/plugins.conf @@ -0,0 +1,70 @@ +# Default plugins list. By default this file is symlinked into ~/.config/tmux/plugins.conf. +# +# If you wish to change your plugin list, remove the symlink and add your own plugins. +# You can copy this file in as a starting point via: +# +# cp -vf "$PSOXIZSH/tmux/fragment/plugins.conf" ~/.config/tmux/plugins.conf +# +# If you'd like to check out the available plugins the following git repo keeps a list +# +# github.com/tmux-plugins/list + +# ===== PLUGINS ===== + +# This must always come first in the plugin list +set -g @plugin 'tmux-plugins/tpm' + +# === Prefix highlight +# Flashes a small indicator when {prefix} is hit, or when in certain tmux modes + +set -g @plugin 'tmux-plugins/tmux-prefix-highlight' + +# Options +set -g @prefix_highlight_prefix_prompt 'Pre' # default is 'Wait' +set -g @prefix_highlight_fg 'yellow' # default is 'colour231' +set -g @prefix_highlight_bg 'default' # default is 'colour04' +# set -g @prefix_highlight_show_copy_mode 'on' # display prefix in copy mode +# set -g @prefix_highlight_copy_prompt 'Copy' # copy display text +# set -g @prefix_highlight_copy_mode_attr 'fg=default,bg=yellow' # copy colors +# set -g @prefix_highlight_show_sync_mode 'on' # display prefix in window sync mode +# set -g @prefix_highlight_sync_prompt 'Sync' # sync display text +# set -g @prefix_highlight_sync_mode_attr 'fg=default,bg=yellow' # sync colors +# set -g @prefix_highlight_output_prefix '< ' # static prefix to add to prompt +# set -g @prefix_highlight_output_suffix ' >' # static suffix to add to prompt +# set -g @prefix_highlight_empty_has_affixes 'off' # switch to 'on' to allow affixes on empty prompts +# set -g @prefix_highlight_empty_prompt 'Tmux' # placeholder text when prompt isn't in use +# set -g @prefix_highlight_empty_attr 'fg=default,bg=default' # empty colors +# === + +# === Copycat +# Provides quick and easy keyboard text search and copying to +# tmux buffers + +set -g @plugin 'tmux-plugins/tmux-copycat' + +# Options +# set -g @copycat_search '/' # basic +# set -g @copycat_git_special 'C-g' # git (SHA) +# set -g @copycat_file_search 'C-f' # file path +# set -g @copycat_url_search 'C-u' # URL +# set -g @copycat_digit_search 'C-d' # number +# set -g @copycat_hash_search 'C-h' # hash +# set -g @copycat_ip_search 'C-i' # IP +# === + +# === Yank +# Expands on Copycat adding keybinds for yanking into the system +# clipboard. Requires OS specific clipboard managers. + +set -g @plugin 'tmux-plugins/tmux-yank' + +# Options +# set -g @override_copy_command 'my-clipboard-copy --some-arg' # overide the default copy command, must accept input to stdin +# set -g @yank_selection 'clipboard' # or 'primary' or 'secondary' +# set -g @yank_selection_mouse 'clipboard' # or 'primary' or 'secondary' +# set -g @yank_action 'copy-pipe-and-cancel' # or 'copy-pipe' to remain in copy mode after yanking +# set -g @yank_with_mouse 'on' # or 'off' by default yank will copy mouse selected text +# === + +# vim: filetype=tmux + diff --git a/tmux/fragment/vim-movement.conf b/tmux/fragment/vim-movement.conf new file mode 100644 index 0000000..5f9b8ac --- /dev/null +++ b/tmux/fragment/vim-movement.conf @@ -0,0 +1,34 @@ +# This fragmenet is meant to be used with a Vim plugin and provides unified movement +# between Vim window/panes and tmux panes. It requires you install the following in +# Vim to function correctly: +# +# github.com/christoomey/vim-tmux-navigator +# +# Include it by adding the following snippet to your early (or late) tmux.conf: +# +# source-file "$PSOXIZSH/tmux/fragment/vim-movement.conf" + +# Checks for if we're inside a Vim/FZF window +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ +| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \ +| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'" + +# Binds Ctrl- to left,down,up,right movements +bind -n C-h run "($is_vim && tmux send-keys C-h) \ + || tmux select-pane -L" +bind -n C-j run "($is_vim && tmux send-keys C-j) \ + || ($is_fzf && tmux send-keys C-j) \ + || tmux select-pane -D" +bind -n C-k run "($is_vim && tmux send-keys C-k) \ + || ($is_fzf && tmux send-keys C-k) \ + || tmux select-pane -U" +bind -n C-l run "($is_vim && tmux send-keys C-l) \ + || tmux select-pane -R" +bind-key -T copy-mode-vi 'C-h' select-pane -L +bind-key -T copy-mode-vi 'C-j' select-pane -D +bind-key -T copy-mode-vi 'C-k' select-pane -U +bind-key -T copy-mode-vi 'C-l' select-pane -R + +# Rebinds pane clear which overwritten by the above to {prefix} Ctrl-l +bind C-l send-keys 'C-l' From fb196e31c535feed100926707dad8de6dba1500e Mon Sep 17 00:00:00 2001 From: Bazaah Date: Sun, 29 Aug 2021 18:38:54 +0000 Subject: [PATCH 04/30] zshrc: refactor tmux integrations We now require that a user's local tmux path is ~/.config/tmux. This is due to failings in how TPM parses tmux config files, namely that it doesn't expand variables and only looks one level deep for source-file declarations. By default we symlink $PSOXIZSH/tmux/tmux.conf to ~/.tmux.conf. Again, because both TPM and tmux itself have strong (unconfigurable) opinions about where config files live we'll just have to live with it. On the upside, this allows us to seperate out different tmux config 'fragments' into files which a user can then include. By default we symlink in fragment/plugins.conf, but all others are optional. --- zshrc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/zshrc b/zshrc index 39fd880..84a4bf0 100755 --- a/zshrc +++ b/zshrc @@ -195,21 +195,19 @@ source $PSOXIZSH/zsh-custom/zshnip/zshnip.zsh # Set zsh tmux config path if which tmux &>/dev/null; then - for tmux_config in {~/.config/tmux,~/.tmux,/etc/tmux}; do - if [ -d "$tmux_config" ]; then - TMUX_PATH="$tmux_config" - break - fi - done - [ -z "$TMUX_PATH" ] && TMUX_PATH=~/.config/tmux - export TMUX_PATH=$TMUX_PATH - [ -d "$TMUX_PATH" ] && [ -d "$TMUX_PATH/plugins" ] || { mkdir -vp $TMUX_PATH && cp -r $PSOXIZSH/tmux/. $TMUX_PATH } - # If a .conf is detected override the default zsh tmux path - [ -f "$TMUX_PATH/tmux.conf" ] && export ZSH_TMUX_CONFIG="$TMUX_PATH/tmux.conf" + # Bootstrap the user's plugin directory, if required + [ -d "$TMUX_PATH/plugins" ] || { mkdir -vp "$TMUX_PATH/plugins" && cp -r "$PSOXIZSH/tmux/plugins" "$TMUX_PATH/plugins" } - export TMUX_PLUGINS="$TMUX_PATH/plugins" + # Both tmux and TPM are very opininated about where configs must live, + # and TPM will only expand one layer of source-file directives, so we + # symlink the base config to the user local config file, if it doesn't + # exist. + [ ! -f ~/.tmux.conf ] && ln -s $PSOXIZSH/tmux/tmux.conf ~/.tmux.conf + [ ! -f "$TMUX_PATH/plugins.conf" ] && ln -s "$PSOXIZSH/tmux/fragment/plugins.conf" "$TMUX_PATH/plugins.conf" + + export TMUX_PATH=$TMUX_PATH TMUX_PLUGINS="$TMUX_PATH/plugins" TMUX_CONFIG=~/.tmux.conf fi if which fzf &>/dev/null; then From 1575eff1a43bc1c19ddc3ab85783080e823663bd Mon Sep 17 00:00:00 2001 From: psox Date: Thu, 4 Nov 2021 15:11:37 +0000 Subject: [PATCH 05/30] consolodate with psox/arch --- vimrc | 10 +++--- zshrc | 98 +++++++++++++++++++---------------------------------------- 2 files changed, 36 insertions(+), 72 deletions(-) diff --git a/vimrc b/vimrc index 756ecf4..4427084 100644 --- a/vimrc +++ b/vimrc @@ -367,19 +367,19 @@ if has_key(plugs, 'fzf.vim') \ fzf#vim#files(, fzf#vim#with_preview({'source': 'rg --files --hidden --glob "!**/.git/**" ' }), 0) endif - nnoremap :Rg - nnoremap :Rg! + nnoremap :Rg + nnoremap :Rg! nnoremap :Rg nnoremap :Rg! endif - nnoremap :Files - nnoremap :Files! + nnoremap :Files + nnoremap :Files! nnoremap :Files nnoremap :Files! nnoremap :Buffers - nnoremap :Buffers! + nnoremap :Buffers! nnoremap :Buffers nnoremap :Buffers! endif diff --git a/zshrc b/zshrc index 84a4bf0..fcc3dc7 100755 --- a/zshrc +++ b/zshrc @@ -54,67 +54,31 @@ fi path+=( $GOPATH/bin ${GOROOT+${GOROOT}/bin} ) +# check for starship +if which starship &>/dev/null && [[ ! -e ~/.no-starship ]] +then + export _STARSHIP_Y_="yes" +fi + # Path to your oh-my-zsh installation. export ZSH=$PSOXIZSH/oh-my-zsh export ZSH_CACHE_DIR=~/.cache/zsh [[ ! -d $ZSH_CACHE_DIR ]] && mkdir -p $ZSH_CACHE_DIR -# Set name of the theme to load. Optionally, if you set this to "random" -# it'll load a random theme each time that oh-my-zsh is loaded. -# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes -#ZSH_THEME="rkj-repos" -[[ -z $ZSH_THEME ]] && export ZSH_THEME="stemmet" - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. Case -# sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment the following line to disable bi-weekly auto-update checks. +[[ -z "$ZSH_THEME" ]] && [[ -z "$_STARSHIP_Y_" ]] && export ZSH_THEME="stemmet" DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to change how often to auto-update (in days). -export UPDATE_ZSH_DAYS=3 - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" HIST_STAMPS="yyyy-mm-dd" - -# Would you like to use another custom folder than $ZSH/custom? ZSH_CUSTOM=$(dirname $ZSH)/zsh-custom -# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) -# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=( - $pre_plugins - zsh_reload - gnu-utils - common-aliases - colored-man-pages +plugins=( + $pre_plugins + gnu-utils + common-aliases + colored-man-pages ) -( which git &>/dev/null ) && plugins+=( git git-extras git-flow-avh ) && [[ "$ZSH_THEME" == "stemmet" ]] && [ -z "$STARSHIP_SHELL" ] && plugins+=( git-prompt ) +( which git &>/dev/null ) && plugins+=( git git-extras git-flow-avh ) && [[ "$ZSH_THEME" == "stemmet" ]] && [ -z "$_STARSHIP_Y_" ] && plugins+=( git-prompt ) ( which perl &>/dev/null ) && plugins+=( perl ) ( which go &>/dev/null ) && plugins+=( golang ) ( which oc &>/dev/null ) && plugins+=( oc ) @@ -182,19 +146,14 @@ end source $PSOXIZSH/zsh-custom/zshnip/zshnip.zsh ( which lxc &>/dev/null ) && source $PSOXIZSH/zsh-custom/lxd-completion-zsh/_lxc -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - ( which vi &>/dev/null ) && export EDITOR='vi' ( which vim &>/dev/null ) && export EDITOR='vim' ( which nvim &>/dev/null ) && export EDITOR='nvim' # Set zsh tmux config path -if which tmux &>/dev/null; then +if which tmux &>/dev/null +then + [ -z "$TMUX_PATH" ] && TMUX_PATH=~/.config/tmux # Bootstrap the user's plugin directory, if required @@ -210,24 +169,20 @@ if which tmux &>/dev/null; then export TMUX_PATH=$TMUX_PATH TMUX_PLUGINS="$TMUX_PATH/plugins" TMUX_CONFIG=~/.tmux.conf fi -if which fzf &>/dev/null; then +if which fzf &>/dev/null +then # Press ? inside a C-r search to get a preview window, useful for long commands export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'" which tmux &> /dev/null && export FZF_TMUX=1 fi -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases alias zshconfig="vim $PSOXIZSH/zshrc" alias ohmyzsh="vim $PSOXIZSH/oh-my-zsh" alias curlj="curl -H 'Content-Type: application/json' " which nvim >/dev/null 2>&1 && alias vim="$(which nvim)" alias v=vim [[ -x /usr/bin/yay ]] && [[ "$(whoami)" != "pacman" ]] && alias yay='sudo -iupacman /usr/bin/yay' +[[ -x /usr/bin/paru ]] && [[ "$(whoami)" != "pacman" ]] && alias yay='sudo -iupacman /usr/bin/paru' typeset -A key @@ -252,7 +207,8 @@ setopt no_bang_hist cdable_vars auto_name_dirs # Finally, make sure the terminal is in application mode, when zle is # active. Only then are the values from $terminfo valid. -if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then +if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )) +then function zle-line-init () { echoti smkx } @@ -271,7 +227,7 @@ precmd() { export _DATE_=$(date -u +%Y%m%d) export _TIME_=$(date -u +%H%M%S) export _DTTS_="${_DATE_}T${_TIME_}Z" - if [[ ! -z $KUBECONFIG ]] + if [[ -n "$KUBECONFIG" && -z "$_STARSHIP_Y_" ]] then export KUBE_VARS=$(basename $KUBECONFIG)/$(kubectl config current-context) else @@ -279,8 +235,16 @@ precmd() { fi } -# Remove unwanted aliases +if [[ -n "$_STARSHIP_Y_" ]] +then + [[ ! -e ~/.config/starship.toml ]] && install -v -D $PSOXIZSH/starship.toml ~/.config/starship.toml + source <(starship init zsh --print-full-init) +fi +# alias reload +alias src='omz reload' + +# Remove unwanted aliases ( where fd | grep -qE '\/s?bin\/fd' ) && alias fd &>/dev/null && unalias fd # Clean up global aliases From 4af2ea3027f8fa20e6e87411fd77bdec556ce3d9 Mon Sep 17 00:00:00 2001 From: psox Date: Thu, 4 Nov 2021 15:12:41 +0000 Subject: [PATCH 06/30] consolodate with develop --- starship.toml | 81 ++++++++++++++++++++++++++++ tmux/fragment/ctrl-alt-movement.conf | 33 ++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 starship.toml create mode 100644 tmux/fragment/ctrl-alt-movement.conf diff --git a/starship.toml b/starship.toml new file mode 100644 index 0000000..3ab519d --- /dev/null +++ b/starship.toml @@ -0,0 +1,81 @@ + +format = """ +\\[$username@$hostname\\] $directory \ +$git_branch\ +$git_commit\ +$git_state\ +$git_status\ +$kubernetes\ +$docker_context\ +$aws\ +$terraform\ +$package\ +$cmake\ +$golang\ +$helm\ +$java\ +$nodejs\ +$perl\ +$php\ +$python\ +$rust\ +$nix_shell\ +$memory_usage\ +$env_var\ +$cmd_duration\ +$custom\ +$jobs\ +$status +$time $character\ +""" + +[cmd_duration] +min_time = 0 +show_milliseconds = true +format = " [ ⏱ $duration](bold blue)" + +[time] +disabled = false +time_format = "%FT%T" +format = "[$time]($style)" + +[git_status] +disabled = false + +[git_state] +disabled = false + +[directory] +truncation_length = 0 +truncate_to_repo = false +read_only = " 🔒" +format = "\\[[$path]($style)\\][$read_only](bold yellow)" + +[hostname] +disabled = false +ssh_only = false +format = "[$hostname]($style)" + +[username] +disabled = false +show_always = true +format = "[$user]($style)" + +[status] +format = '[ \[$symbol $status\]]($style) ' +map_symbol = true +disabled = false + +[docker_context] +only_with_files = false +disabled = false + +[aws] +disabled = false + +[kubernetes] +disabled = false + +[terraform] +disabled = false + diff --git a/tmux/fragment/ctrl-alt-movement.conf b/tmux/fragment/ctrl-alt-movement.conf new file mode 100644 index 0000000..9d10f26 --- /dev/null +++ b/tmux/fragment/ctrl-alt-movement.conf @@ -0,0 +1,33 @@ + +# This fragmenet is meant to be used with a Vim plugin and provides unified movement +# between Vim window/panes and tmux panes. It requires you install the following in +# Vim to function correctly: +# +# github.com/christoomey/vim-tmux-navigator +# +# Include it by adding the following snippet to your early (or late) tmux.conf: +# +# source-file "$PSOXIZSH/tmux/fragment/ctrl-alt-movement.conf" + +### --- This uses Ctrl-Alt- movement --- ### + +# Integration with vim-tmux-navigator & fzf +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ +| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \ +| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'" +bind -n C-M-Left run "($is_vim && tmux send-keys C-h) \ + || tmux select-pane -L" +bind -n C-M-Down run "($is_vim && tmux send-keys C-j) \ + || ($is_fzf && tmux send-keys C-j) \ + || tmux select-pane -D" +bind -n C-M-Up run "($is_vim && tmux send-keys C-k) \ + || ($is_fzf && tmux send-keys C-k) \ + || tmux select-pane -U" +bind -n C-M-Right run "($is_vim && tmux send-keys C-l) \ + || tmux select-pane -R" +bind-key -T copy-mode-vi 'C-M-Left' select-pane -L +bind-key -T copy-mode-vi 'C-M-Down' select-pane -D +bind-key -T copy-mode-vi 'C-M-Up' select-pane -U +bind-key -T copy-mode-vi 'C-M-Right' select-pane -R + From 2b6095933a7795a164745acf4336d945bf81794f Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 11 Nov 2021 19:34:26 +0000 Subject: [PATCH 07/30] ff submodules --- oh-my-zsh | 2 +- tmux/plugins/tpm | 2 +- zsh-custom/lxd-completion-zsh | 2 +- zsh-custom/plugins/zsh-autosuggestions | 2 +- zsh-custom/plugins/zsh-completions | 2 +- zsh-custom/plugins/zsh-history-substring-search | 2 +- zsh-custom/plugins/zsh-syntax-highlighting | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/oh-my-zsh b/oh-my-zsh index f6bc949..1903250 160000 --- a/oh-my-zsh +++ b/oh-my-zsh @@ -1 +1 @@ -Subproject commit f6bc949c05fd18ee557a89c92f82ff556200707d +Subproject commit 190325049ef93731ab28295dbedf36d44ab33d7a diff --git a/tmux/plugins/tpm b/tmux/plugins/tpm index 59f7885..693e5a2 160000 --- a/tmux/plugins/tpm +++ b/tmux/plugins/tpm @@ -1 +1 @@ -Subproject commit 59f78857f656afd462d7bc99b31cc8cc36c1872c +Subproject commit 693e5a2a0f6acfd2666882655d5dfd32e8c6c50b diff --git a/zsh-custom/lxd-completion-zsh b/zsh-custom/lxd-completion-zsh index 87d20cb..e82701c 160000 --- a/zsh-custom/lxd-completion-zsh +++ b/zsh-custom/lxd-completion-zsh @@ -1 +1 @@ -Subproject commit 87d20cb0c5d5261cdc469a2d16a679f577038204 +Subproject commit e82701cb2b8c42f63479bb1a34e4f78a7cb5b75c diff --git a/zsh-custom/plugins/zsh-autosuggestions b/zsh-custom/plugins/zsh-autosuggestions index ae315de..a411ef3 160000 --- a/zsh-custom/plugins/zsh-autosuggestions +++ b/zsh-custom/plugins/zsh-autosuggestions @@ -1 +1 @@ -Subproject commit ae315ded4dba10685dbbafbfa2ff3c1aefeb490d +Subproject commit a411ef3e0992d4839f0732ebeb9823024afaaaa8 diff --git a/zsh-custom/plugins/zsh-completions b/zsh-custom/plugins/zsh-completions index c6621bb..3273291 160000 --- a/zsh-custom/plugins/zsh-completions +++ b/zsh-custom/plugins/zsh-completions @@ -1 +1 @@ -Subproject commit c6621bb692928333b76e2a593c66b49020389ab1 +Subproject commit 32732916a0d0a25adcdb25c4906e0111681a81e2 diff --git a/zsh-custom/plugins/zsh-history-substring-search b/zsh-custom/plugins/zsh-history-substring-search index 0f80b8e..4abed97 160000 --- a/zsh-custom/plugins/zsh-history-substring-search +++ b/zsh-custom/plugins/zsh-history-substring-search @@ -1 +1 @@ -Subproject commit 0f80b8eb3368b46e5e573c1d91ae69eb095db3fb +Subproject commit 4abed97b6e67eb5590b39bcd59080aa23192f25d diff --git a/zsh-custom/plugins/zsh-syntax-highlighting b/zsh-custom/plugins/zsh-syntax-highlighting index 2d60a47..6e0e950 160000 --- a/zsh-custom/plugins/zsh-syntax-highlighting +++ b/zsh-custom/plugins/zsh-syntax-highlighting @@ -1 +1 @@ -Subproject commit 2d60a47cc407117815a1d7b331ef226aa400a344 +Subproject commit 6e0e950154a4c6983d9e077ed052298ad9126144 From b2a684c579a49154e5ede0f0c41a637751c62ac4 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 11 Nov 2021 19:50:07 +0000 Subject: [PATCH 08/30] ff all submodules --- oh-my-zsh | 2 +- zsh-custom/plugins/zsh-completions | 2 +- zsh-custom/plugins/zsh-syntax-highlighting | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oh-my-zsh b/oh-my-zsh index 1903250..1448d23 160000 --- a/oh-my-zsh +++ b/oh-my-zsh @@ -1 +1 @@ -Subproject commit 190325049ef93731ab28295dbedf36d44ab33d7a +Subproject commit 1448d234d6d9c25f64a48b16379b34db28a36898 diff --git a/zsh-custom/plugins/zsh-completions b/zsh-custom/plugins/zsh-completions index 3273291..bebaa61 160000 --- a/zsh-custom/plugins/zsh-completions +++ b/zsh-custom/plugins/zsh-completions @@ -1 +1 @@ -Subproject commit 32732916a0d0a25adcdb25c4906e0111681a81e2 +Subproject commit bebaa6126ede6bda698a6788c6cf3fa02ff1679c diff --git a/zsh-custom/plugins/zsh-syntax-highlighting b/zsh-custom/plugins/zsh-syntax-highlighting index 6e0e950..1a9264b 160000 --- a/zsh-custom/plugins/zsh-syntax-highlighting +++ b/zsh-custom/plugins/zsh-syntax-highlighting @@ -1 +1 @@ -Subproject commit 6e0e950154a4c6983d9e077ed052298ad9126144 +Subproject commit 1a9264bc661b3d52756916bf9ec3f41687d64db2 From f93cdf9fc693e31d119164fa9164e83e6e61a8ca Mon Sep 17 00:00:00 2001 From: Bazaah Date: Sun, 5 Dec 2021 11:45:38 +0000 Subject: [PATCH 09/30] README: remove TLS skip, tidy code blocks --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c9a69b1..0bbe207 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ finally made this repository so people can pull the latest. if you already have directory and make sure you have not make any changes. If you have stash them and then run the following commands. ```bash + ( git pull --recurse-submodules=yes git submodule foreach git fetch --all --prune @@ -25,7 +26,7 @@ src ```bash -git clone --recurse-submodules --recursive --config http.sslVerify=false https://github.com/psox/psoxizsh.git ~/.psoxizsh +git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git ~/.psoxizsh ~/.psoxizsh/fresh-system @@ -36,7 +37,7 @@ git clone --recurse-submodules --recursive --config http.sslVerify=false https:/ ```bash # Make sure you are root -git clone --recurse-submodules --recursive --config http.sslVerify=false https://github.com/psox/psoxizsh.git /etc/psoxizsh +git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git /etc/psoxizsh # for each user that wants to use this /etc/psoxizsh/fresh-system @@ -67,13 +68,11 @@ export VIMHOME=$HOME/.psoxizsh/vim Once these values are set in your environment you can start vim and type. -```viml +```vim :PlugInstall ``` -Exit vim and start again, if you get an error with the YouCompleteMe plugin, go to the -[You Complete Me](https://github.com/Valloric/YouCompleteMe#full-installation-guide) -page and see if you can fix it. Normally install a more complete version of vim will -solve the problem. +Exit vim and start again. Enjoy + From a5156ed43537e0df105f2b759ce11a8748b51427 Mon Sep 17 00:00:00 2001 From: pSox Date: Fri, 1 Apr 2022 14:49:16 +0100 Subject: [PATCH 10/30] Updated to lasted comments --- README.md | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 0bbe207..c4d30be 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,23 @@ ## About this Over the years I have collect various bits from various locations. I often share what I have done with work colleagues and -finally made this repository so people can pull the latest. if you already have an installation cd to the `~/.psoxizsh` +finally made this repository so people can pull the latest. if you already have an installation cd to the `~/.psoxizsh` or `/etc/psoxizsh` as root directory and make sure you have not make any changes. If you have stash them and then run the following commands. +This is optomized by default for dark terminals, and contains configurations for use with + +* zsh >= v5.8 +* neovim >= v0.6 +* tmux >= 3.2 + +All of these have standard setting but can be cusntomized by using optional include files. Please read the following configs + +* `vimrc` +* `zshrc` +* `tmux/tmux.conf` + +and look at the include files to check for overides + ```bash ( @@ -28,6 +42,7 @@ src git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git ~/.psoxizsh +# This should work on linux. It is not tested on MacOS or Windows ~/.psoxizsh/fresh-system ``` @@ -39,14 +54,17 @@ git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git # Make sure you are root git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git /etc/psoxizsh -# for each user that wants to use this +# This should work on linux. It is not tested on MacOS or Windows +# for each user that wants to use this as the user run this command /etc/psoxizsh/fresh-system ``` -## Configure Vim or NeoVim +## Configure NeoVim -Make sure you have vim 8 installed and after starting zsh check that the following variable are set by typing +Make sure you have neovim (tested on v0.6.1) installed and after starting zsh check that the following variable are set by typing + +You will need to install `neovim`, `nodejs` and `npm` to get the full use of vim ```bash echo $VIMINIT @@ -54,25 +72,5 @@ echo $MYVIMRC echo $VIMHOME ``` -Also check your `/etc/vimrc` or `/etc/vim/vimrc` to see if they do something funny. A good example of a -`vimrc` that can be appended to the end of the `vimrc` file off the `/etc` directory -can be found in `~/.psoxizsh/etc/`. - -If these are not set try adding the following to the beginning of your `~/.zshrc` file. - -```bash -export VIMINIT='source $MYVIMRC' -export MYVIMRC=$HOME/.psoxizsh/vimrc -export VIMHOME=$HOME/.psoxizsh/vim -``` - -Once these values are set in your environment you can start vim and type. - -```vim -:PlugInstall -``` - -Exit vim and start again. - Enjoy From 69149048231abed1f2787924a171a0e379a39096 Mon Sep 17 00:00:00 2001 From: psox Date: Fri, 1 Apr 2022 15:18:29 +0100 Subject: [PATCH 11/30] Update to reflect latest changes and add some more documentation --- .vim/coc-settings.json | 9 +++++++ README.md | 58 ++++++++++++++++++++++++++++++------------ fresh-system | 2 +- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json index 8353113..f95a651 100644 --- a/.vim/coc-settings.json +++ b/.vim/coc-settings.json @@ -1,7 +1,12 @@ { "cSpell.words": [ + "Alacritty", "Coms", + "Iosevka", + "MYVIMRC", "Psox", + "VIMHOME", + "VIMINIT", "Xuyuanp", "adelarsq", "ansible", @@ -10,7 +15,10 @@ "junegunn", "luochen", "neoclide", + "neovim", + "nvim", "pearofducks", + "psoxizsh", "rakr", "romainl", "roxma", @@ -18,6 +26,7 @@ "sheerun", "syntastic", "tpope", + "vimrc", "yarp" ] } \ No newline at end of file diff --git a/README.md b/README.md index c4d30be..b1b5e34 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,46 @@ ## About this -Over the years I have collect various bits from various locations. I often share what I have done with work colleagues and -finally made this repository so people can pull the latest. if you already have an installation cd to the `~/.psoxizsh` or `/etc/psoxizsh` as root -directory and make sure you have not make any changes. If you have stash them and then run the following commands. +Over the years I have collect various bits from various locations. I often share +what I have done with work colleagues and finally made this repository so people +can pull the latest. -This is optomized by default for dark terminals, and contains configurations for use with +This is optimized by default for dark terminals, and contains configurations for +use with -* zsh >= v5.8 -* neovim >= v0.6 -* tmux >= 3.2 +- zsh >= v5.8 +- neovim >= v0.6 +- tmux >= 3.2 -All of these have standard setting but can be cusntomized by using optional include files. Please read the following configs +All of these have standard setting but can be customized by using optional +include files. Please read the following configs -* `vimrc` -* `zshrc` -* `tmux/tmux.conf` +- `vimrc` +- `zshrc` +- `tmux/tmux.conf` -and look at the include files to check for overides +and look at the include files to check for overrides. + +## Looks + +For the best appearance I have tested the latest versions of + +- Konsole +- Microsoft Terminal +- WezTerm +- Kitty (the Linux version, not the on based of putty) +- Alacritty (Windows and Linux) + +I have previously used this on iTerm2 on MacOS but not recently. + +I also use the _Iosevka Term Curly_ font on both Linux and Windows with +ligatures enabled where possible. + +## Updates + +If you already have an installation cd to the `~/.psoxizsh` or `/etc/psoxizsh` +as root directory and make sure you have not make any changes. If you have stash +them and then run the following commands. ```bash @@ -42,7 +65,7 @@ src git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git ~/.psoxizsh -# This should work on linux. It is not tested on MacOS or Windows +# This should work on Linux. It is not tested on MacOS or Windows ~/.psoxizsh/fresh-system ``` @@ -54,7 +77,7 @@ git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git # Make sure you are root git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git /etc/psoxizsh -# This should work on linux. It is not tested on MacOS or Windows +# This should work on Linux. It is not tested on MacOS or Windows # for each user that wants to use this as the user run this command /etc/psoxizsh/fresh-system @@ -62,10 +85,14 @@ git clone --recurse-submodules --recursive https://github.com/psox/psoxizsh.git ## Configure NeoVim -Make sure you have neovim (tested on v0.6.1) installed and after starting zsh check that the following variable are set by typing +Make sure you have neovim (tested on v0.6.1) installed and after starting zsh +check that the following variable are set by typing You will need to install `neovim`, `nodejs` and `npm` to get the full use of vim +Just start neovim (`nvim`) and wait for it to finish. After that quit and it +should be ready to use. + ```bash echo $VIMINIT echo $MYVIMRC @@ -73,4 +100,3 @@ echo $VIMHOME ``` Enjoy - diff --git a/fresh-system b/fresh-system index 8054c50..9e61049 100755 --- a/fresh-system +++ b/fresh-system @@ -2,7 +2,7 @@ ( cd ~ [[ ! -e ~/.zshrc ]] && touch ~/.zshrc - install -v --mode=700 -d ~/.ssh + install -v -m 0700 -d ~/.ssh grep -E '^source (/etc/psoxizsh|~/.psoxizsh)/zshrc' ~/.zshrc 2>/dev/null >/dev/null if [[ $? -ne 0 ]] then From 9abd2923297162c5536b77cd446b46c5bc955f98 Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Fri, 1 Apr 2022 09:18:56 -0700 Subject: [PATCH 12/30] Updated plugin from osx to macos Fix for the warning ``` The `osx` plugin is deprecated and has been renamed to `macos`. Please update your .zshrc to use the `macos` plugin instead. ``` --- zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zshrc b/zshrc index fcc3dc7..c7dfc4c 100755 --- a/zshrc +++ b/zshrc @@ -102,7 +102,7 @@ plugins=( ( which kubectl &>/dev/null ) && plugins+=( kubectl ) ( [[ -e /etc/arch-release ]] ) && plugins+=( archlinux ) ( [[ -e /etc/suse-release ]] ) && plugins+=( suse ) -( [[ "$(uname)" == "Darwin" ]] ) && plugins+=( osx ) +( [[ "$(uname)" == "Darwin" ]] ) && plugins+=( macos ) #( which vim &>/dev/null ) && plugins+=( vim-interaction ) ( which ssh &>/dev/null ) && [[ -d ~/.ssh ]] && plugins+=( ssh-agent ) plugins+=( From 36fcf67bd6e659a17ece5c9b3b4b7f558152841d Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 05:56:32 +0000 Subject: [PATCH 13/30] zshrc: add experimental flag for testing lua based neovim config This commit adds an env var, PSOXIZSH_EXPERIMENTAL_NEOVIM_LUA, that can be set to opt into using an 'init.lua' based configuration. This setting only makes sense to use with neovim, and thus even if we do decide to switch to lua, we'll need to keep the old vimrc config around for a long time yet, to ensure backwards compatibility --- zshrc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/zshrc b/zshrc index c7dfc4c..4dbb67b 100755 --- a/zshrc +++ b/zshrc @@ -117,12 +117,20 @@ plugins+=( if [[ "$OSTYPE" =~ "linux*" || "$OSTYPE" =~ "darwin*" || "$OSTYPE" == "cygwin" ]] then export VIMINIT='source $MYVIMRC' - export MYVIMRC=$PSOXIZSH/vimrc export VIMHOME=~/.vim - cmp $PSOXIZSH/vim/autoload/plug.vim $VIMHOME/autoload/plug.vim 2>/dev/null || ( - mkdir -vp $VIMHOME/autoload/ - cp -av $PSOXIZSH/vim/autoload/plug.vim $VIMHOME/autoload/plug.vim - ) + + # Feature flag lua based Neovim config, until this is tested + # (and we figure out how to detect if we're running nvim or vim) + if [[ -n ${PSOXIZSH_EXPERIMENTAL_NEOVIM_LUA} ]] + then + export MYVIMRC=$PSOXIZSH/init.lua + else + export MYVIMRC=$PSOXIZSH/vimrc + cmp $PSOXIZSH/vim/autoload/plug.vim $VIMHOME/autoload/plug.vim 2>/dev/null || ( + mkdir -vp $VIMHOME/autoload/ + cp -av $PSOXIZSH/vim/autoload/plug.vim $VIMHOME/autoload/plug.vim + ) + fi fi if [[ -d ~/.ssh ]] From 94facbcce9ed834aa7446831986fa5f02b6c89bd Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 21 Jul 2022 07:43:14 +0000 Subject: [PATCH 14/30] nvim/util: add mreload/1, mconfig/2, try_* variants These functions are primarily designed for reloading lua modules, and specifically, lua modules returning some sort of local config object or function. --- nvim/lua/psoxizsh/util.lua | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 nvim/lua/psoxizsh/util.lua diff --git a/nvim/lua/psoxizsh/util.lua b/nvim/lua/psoxizsh/util.lua new file mode 100644 index 0000000..1b6d80c --- /dev/null +++ b/nvim/lua/psoxizsh/util.lua @@ -0,0 +1,68 @@ + +local Util = {} + +-- Reload a given module, returning the result of loading it. +function Util.mreload(module) + if package.loaded[module] then + package.loaded[module] = nil + end + + return require(module) +end + +-- Try reloading the given module, returning ok, module +function Util.try_mreload(module) + return pcall(Util.mreload, module) +end + +-- Try reloading the given config module, returning either +-- its table or an empty one, if the module couldn't be loaded +-- +-- The arguments can be: +-- 1. module string --> table +-- 2. module string --> fn() -> table +-- 3. table +-- 4. fn() --> table +-- +-- It the latter cases, *configuration will not be reloaded*, this is +-- primaraily meant for inline, static configuration +function Util.try_mconfig(module) + if type(module) ~= "string" then + module = type(module) == "function" and module() or module + module = type(module) == "table" and module or {} + + return module + end + + local ok, config = Util.try_mreload(module) + config = type(config) == "function" and config() or config + + return (ok and type(config) == "table") and config or {} +end + +-- Retrieve the config table stored in the provided module, +-- merged with default the config module, if one is provided +-- +-- The arguments can be: +-- 1. module string --> table +-- 2. module string --> fn() -> table +-- 3. table +-- 4. fn() --> table +-- +-- It the latter cases, *configuration will not be reloaded*, this is +-- primaraily meant for inline, static configuration +-- +-- Note: the config returned from the given module may optionally +-- set 'no_defaults = true' to opt out of the merging +function Util.mconfig(module, defaults) + module = Util.try_mconfig(module) + defaults = Util.try_mconfig(defaults) + + if module.no_defaults then + return module + else + return vim.tbl_deep_extend('keep', module, defaults) + end +end + +return Util From 0ff9ecdba38de5107c5cd2146f976ab844a53a5f Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 06:30:29 +0000 Subject: [PATCH 15/30] nvim/plugins/bootstrap: install package manager if fresh system This module bootstraps our plugin manager It can (and should) be called before any plugins are initialized, containing only a dependency on system git, for cloning the package manager locally. The 'install_path' variable was taken from packer.nvim's documentation and installs packer as an optional (opt) plugin. This is important for when we have packer manage itself, as we'll need to: 1. Ensure it's loaded during bootstrap via `packadd packer` 2. Install load hooks on it's various commands + module --- nvim/lua/psoxizsh/plugins/bootstrap.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/bootstrap.lua diff --git a/nvim/lua/psoxizsh/plugins/bootstrap.lua b/nvim/lua/psoxizsh/plugins/bootstrap.lua new file mode 100644 index 0000000..b826aff --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/bootstrap.lua @@ -0,0 +1,24 @@ +local fn = vim.fn +local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim' +local repo_url = 'https://github.com/wbthomason/packer.nvim' +local strapped = nil + +-- Bootstraps our package manager, ensuring it is present on the local system +local function bootstrap() + local should_install = fn.empty(fn.glob(install_path)) > 0 + + if should_install then + fn.system({'git', 'clone', '--depth', '1', repo_url, install_path}) + end + + return should_install +end + +if not strapped then + strapped = bootstrap() +end + +return function() + return strapped +end + From cb591260b87b1d07dc1c9686733b3a99d8968202 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 08:38:56 +0000 Subject: [PATCH 16/30] nvim/plugins: Plugins, a hookable wrapper around packer.nvim This commit adds a wrapper api around packer.nvim, allowing callers to provide hooks into packer's plugin initialization lifecycle. There are 4 recognized hooks: 'early', 'pre', 'post' and 'late'. 'early' and 'pre' run before any plugins are loaded, with 'early' running before *any* work has been done, while 'pre' runs just before calling into packer. 'post' and 'late' are more interesting, as they are guaranteed to run after all plugins (and their private configs) have fully loaded. Furthermore, both hooks are provided the active Plugins object as their first arg, allowing them access to the entire list of plugins and the api suite of Plugins itself. This behavior is very similar to vim-plug's plug#begin .. plug#end fences, but improves on the pattern by: - Properly handling bootstrap situations (our old setup would require a restart before everything loaded correctly) - Async, does not block user activity while loading leading to a smoother experience Special care has been taken to detect and handle bootstrap situations, where if found, we completely defer a lot of activity (and the hooks 'post', 'late') until packer indicates that the entire install workflow has completed. -- Usage The expected usage of this api set si via requiring the module, setting up your hooks and initializing the module: ```lua local htable = { early = early_hook, ... } local plugs = require('psoxizsh.plugins'):setup({ hooks = htable }):init() ``` As a convenience, you may directly call the module with your hooks, rather than writing out the above: ``` require 'psoxizsh.plugins' { hooks = ... } ``` Plugins also provides several other interesting methods: - :reload/0 | completely reload plugin configuration, including rerunning any hooks - :list/0 | get the list of raw plugin specs that were passed to packer - :do_hook/1 | request Plugins run @hook 'early' | 'pre' | 'post' | 'late' - :get/1 | get the spec object for the provided plugin id - :has/1 | check if the spec contains the provided plugin id --- nvim/lua/psoxizsh/plugins/init.lua | 217 +++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/init.lua diff --git a/nvim/lua/psoxizsh/plugins/init.lua b/nvim/lua/psoxizsh/plugins/init.lua new file mode 100644 index 0000000..095f93d --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/init.lua @@ -0,0 +1,217 @@ +local cmd, bootstrap, util = vim.cmd, require 'psoxizsh.plugins.bootstrap', require 'psoxizsh.util' +local cb_table = {} +local packer = nil + +-- Plugins provides a hook based wrapper around packer.nvim, allowing +-- callers to register hooks at specific lifecycle events such as pre +-- and post plugin load. +-- +-- A new, uninitialized one is provided upon requiring this module, +-- See :setup/1 and :init/0 for more on configuring and initializing +-- this object +local Plugins = { mt = {} } + +-- Creates a new, uninitialized Plugins +-- +-- You must call :init/0 (and likely :setup/1) before using this +-- object, though you can directly invoke the Plugins object as +-- you would :setup/1 as a convenience +function Plugins.new() + local m = { + _list = {}, + _hooks = {}, + } + setmetatable(m, Plugins.mt) + + return m +end + +-- Configures this Plugins, with the provided opts +-- +-- You can provide a tables of hooks by name or { name, callback } +-- tuples. +-- +-- In the former case, Plugins will create User autocmds +-- when the lifecycle stage is hit, which you can register arbitrary +-- code to be invoked on. +-- +-- In the latter, the provided callback fn will be invoked at the +-- lifecycle stage, with 'post' and 'late' hooks being provided the +-- current Plugins object as the first argument +-- +-- @opts = { +-- hooks = { +-- early = name | { name, callback/0 } +-- pre = name | { name, callback/0 } +-- post = name | { name, callback/1 } +-- late = name | { name, callback/1 } +-- } +-- } +function Plugins.setup(self, opts) + opts = opts or {} + local hooks = opts.hooks or {} + + self._hooks = vim.tbl_map(function(hk) + local t = type(hk) + if t == 'string' then return hk end + if t == 'table' then return hk[1] end + end, hooks) + + local callbacks = vim.tbl_map(function(hk) + local t = type(hk[2]) + if t == 'function' then return hk[2] end + end, hooks) + + self:list_regen() + self:register_callbacks(callbacks) + + return self +end + +-- Invokes the plugin manager, and hooks any provided hooks as they become ready +-- +-- Note, you shouldn't rerun this function, use :reload/0 instead if you want to +-- reload an existing Plugins +function Plugins.init(self) + self:do_hook 'early' + + if packer == nil then + cmd [[packadd packer.nvim]] + + packer = require 'packer' + packer.init { + max_jobs = 32 + } + end + + packer.reset() + + self:do_hook 'pre' + + for _, spec in ipairs(self:list()) do + packer.use(spec) + end + + self:do_hook 'post' + self:do_hook 'late' + + return self +end + +-- Regenerate the plugin spec list, reloading the config if it has changed. +-- +-- Note that this method *only* reloads the spec list, it does not reload +-- plugins, see :reload/0 for that +function Plugins.list_regen(self) + local plugs = util.mreload('psoxizsh.plugins.plug') + self._list = plugs(util.try_mconfig('plug')) + + return self:list() +end + +-- Return the current plugin list +function Plugins.list(self) + return self._list +end + +-- Get the plugin spec for the provided @id. +-- +-- The plugin id will be either the last component of the name, or if redefined by 'as', +-- whatever 'as' is. +-- +-- Returns the spec if it exists, nil otherwise +function Plugins.get(self, id) + local needle = function(p) + local plugid = p.as and p.as or p[1] and p[1]:match("^.+/(.+)$") + + return plugid == id + end + + return vim.tbl_filter(needle, self:list())[1] +end + +-- Check if the plugin @id exists in the current spec table +-- +-- Returns true if it does, nil otherwise +function Plugins.has(self, id) + return self:get(id) and true or nil +end + +-- Reload plugins, and rerun any registered hooks +function Plugins.reload(self) + self:list_regen() + self:init() + packer.compile() +end + +-- Request the active Plugins to run the provided lifecycle's hook +-- +-- Note that this may not run immediately, depending on current lifecycle +-- of underlying plugin manager +-- +-- @name { 'early' | 'pre' | 'post' | 'late' } +function Plugins.do_hook(self, name) + if name and name == 'post' or 'late' then + self:_post_hook(self._hooks[name]) + else + self:_pre_hook(self._hooks[name]) + end +end + +-- Manually (re)register callbacks for any configured lifecycle hooks +-- +-- Note that any hooks that were not registered in :setup/1 will be +-- silently ignored. +-- +-- You may consider re-initializing the active Plugins via :setup/1:init/0 +function Plugins.register_callbacks(self, callbacks) + _G._psoxizsh_plugins_cb = function(id) cb_table[id](self) end + cb_table = {} + + cmd [[augroup PsoxConfigCallbacks]] + cmd [[autocmd!]] + for n, fn in pairs(callbacks) do + local id = self._hooks[n] + cb_table[id] = fn + cmd(string.format('autocmd User %s call v:lua._psoxizsh_plugins_cb("%s")', id, id)) + end + cmd [[augroup END]] +end + +function Plugins._pre_hook(self, hook) + self:_dispatch_autocmd(hook) +end + +function Plugins._post_hook(self, hook) + if bootstrap() and hook then + cmd [[augroup PsoxConfigBootstrap]] + cmd [[autocmd!]] + cmd [[autocmd VimEnter * ++once PackerSync]] + cmd [[augroup END]] + + cmd ('augroup PsoxConfigDeferHook_' .. hook) + cmd ('autocmd!') + cmd ('autocmd User PackerCompileDone doautocmd User ' .. hook) + cmd ('augroup END') + else + self:_dispatch_autocmd(hook) + end +end + +function Plugins._dispatch_autocmd(_, hook) + if hook then cmd('doautocmd User ' .. hook) end +end + +-- Setup a convenience method for setting up + initializing a Plugins object +-- via directly calling the object with the opts that would normally be +-- provided to :setup/1 +function Plugins.mt.__call(self, opts) + self:setup(opts):init() +end + +-- Allow callers to access the underlying packer object +function Plugins.mt.__index(_, key) + return Plugins[key] or packer[key] +end + +return Plugins.new() From 1ce92532bdfc830b7c9bc0d3bd302749332a5086 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 06:59:14 +0000 Subject: [PATCH 17/30] nvim/plug: add empty default plugin set This commit adds an empty plugin set, along with functionality to extend it via a list of extra plugin specs. No attempt is made to deduplicate items in this list, though packer may handle this itself. --- nvim/lua/psoxizsh/plugins/plug.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/plug.lua diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua new file mode 100644 index 0000000..5a1495d --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -0,0 +1,18 @@ + +local plugins = { +} + +local function concatArray(a, b) + local result = {unpack(a)} + for i = 1,#b do + result[#a+i] = b[i] + end + + return result +end + +return function(extra) + extra = extra or {} + + return concatArray(plugins, extra) +end From 028f81f9500d90ccf3424e2e22eb5333fe66c131 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 07:03:04 +0000 Subject: [PATCH 18/30] nvim/plug: wbthomason/packer.nvim@master This commit adds packer to it's list of managed plugins, taking over from the bootstrap install. Notably, we ensure that it knows where to find itself (opt = true), and take care to ensure that it will be loaded on require or command. --- nvim/lua/psoxizsh/plugins/plug.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index 5a1495d..148e770 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -1,5 +1,11 @@ local plugins = { + -- Allow packer to manage itself + { 'wbthomason/packer.nvim', + opt = true, + cmd = 'Packer*', + module_pattern = { 'packer', 'packer%..*' } + }, } local function concatArray(a, b) From 5117eb57ff85c62dd43cf49eda954f83a6dc0589 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 08:43:35 +0000 Subject: [PATCH 19/30] nvim/autocmd: add lib for easy use of autocmds in lua I couldn't find any nice, easy to use library or package for interacting with autocmds from lua, and neovim has only in a very recent version (0.7) added support for them through the vim.api object. This commit adds a small module that provides an ergonomic api for interacting with them in lua. First import the module local au = 'psoxizsh.autocmd' Then you can create grouped autocmds in a variety of ways, several of which are shown below. ```lua -- Invoke the group, and add { events, patterns, command } triples au.Example1 { -- String commands are interpreted as vimscript to be executed { 'FileType', 'lua', 'echo "Hello from a lua file!"' } -- Or you can provide a lua function instead { 'FileType', { 'yaml', 'yml' }, function() print('hello from a yaml file!') end } } ``` ```lua -- Or pass a function that takes the group as an arg au.Example2(function(grp) -- And add the { patterns, command } tuple for each cmd grp.FileType { '*.md', 'MarkdownTidy' } grp.User { 'LSPError', 'messages' } end) ``` --- nvim/lua/psoxizsh/autocmd.lua | 126 +++++++++++++++++++++++++++++ nvim/lua/psoxizsh/plugins/plug.lua | 5 ++ 2 files changed, 131 insertions(+) create mode 100644 nvim/lua/psoxizsh/autocmd.lua diff --git a/nvim/lua/psoxizsh/autocmd.lua b/nvim/lua/psoxizsh/autocmd.lua new file mode 100644 index 0000000..597a565 --- /dev/null +++ b/nvim/lua/psoxizsh/autocmd.lua @@ -0,0 +1,126 @@ + +local M = { mt = {} } +local Groups = {} +local Group = { mt = {} } +local AutoCmd = { mt = {} } + +local __builtin_support = vim.fn.has('nvim-0.7') == 1 + +-- Use the recent builtin APIs provided by neovim itself +local function builtin(group, autos) + vim.api.nvim_create_augroup(group, {}) + + for _, auto in ipairs(autos) do + local opts = auto.opts or {} + opts.group = group + opts.pattern = auto.pattern + + if type(auto.command) == "string" then + opts.command = auto.command + elseif type(auto.command) == "function" then + opts.callback = auto.command + end + + vim.api.nvim_create_autocmd(auto.event, opts) + end +end + +-- Use an old library to make the autos +-- Note that relies on the local package manager to ensure this plugin is available +local function polyfill(group, autos) + local poly = require 'autocmd-lua' + local autocmds = {} + + for _, auto in ipairs(autos) do + local events = auto.event + + if type(auto.event) == "string" then + events = { auto.event } + end + + for _, e in ipairs(events) do + table.insert(autocmds, { event = e, pattern = auto.pattern, cmd = auto.command }) + end + end + + poly.augroup { + group = group, + autocmds = autocmds, + } +end + +local autocmd = __builtin_support and builtin or polyfill + +function M.new() + local m = {} + setmetatable(m, M.mt) + + return m +end + +function M.mt.__index(_, group) + if Groups[group] ~= nil then + return Groups[group] + else + -- Create a group object that uses the autocmd function on being called. + -- This object should take the list of objects provided to it, insert + -- them into it's local storage and then execute autocmd on them + return Group.new(group) + end +end + +-- Spawn a new Group with the given name +function Group.new(name) + local g = { __name = name, __autos = {} } + setmetatable(g, Group.mt) + Groups[name] = g + + return g +end + +-- Insert a new auto command object spec into the provided Group's list +function Group.insert(self, cmd) + if not cmd.disable then + table.insert(self.__autos, { + command = table.remove(cmd, 3), + pattern = table.remove(cmd, 2), + event = table.remove(cmd, 1), + opts = cmd + }) + end +end + +-- Spawn a new AutoCmd with the given event name, currying the parent group's name +function Group.mt.__index(self, event) + return AutoCmd.new(self, event) +end + +-- Allows module users to pass a Group a list of auto command parameters +function Group.mt.__call(self, command_like) + if type(command_like) == "function" then + command_like(self) + elseif type(command_like) == "table" then + for _, auto in ipairs(command_like) do + Group.insert(self, auto) + end + end + + autocmd(self.__name, self.__autos) +end + +-- Create a new dummy object that stores its group and event +-- Used to allow for currying of autocmd parameters +function AutoCmd.new(group, event) + local a = { __group = group, __event = event } + setmetatable(a, AutoCmd.mt) + + return a +end + +-- Add the given partial arg list passed to this AutoCmd to the correct group +function AutoCmd.mt.__call(self, args) + table.insert(args, 1, self.__event) + Group.insert(self.__group, args) +end + +return M.new() diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index 148e770..4d23486 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -6,6 +6,11 @@ local plugins = { cmd = 'Packer*', module_pattern = { 'packer', 'packer%..*' } }, + + -- Used for autocmds if we're not using a late enough version of neovim + { 'jakelinnzy/autocmd-lua', + disable = vim.fn.has('nvim-0.7') == 1 + }, } local function concatArray(a, b) From 892e3dea02c4dab4bb5aeb8b2f28627ca064dbea Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 21 Jul 2022 07:45:13 +0000 Subject: [PATCH 20/30] nvim/plug: svermeulen/vimpeccable@master as 'vimp' Nice utility for defining key mappings, as neovim doesn't have first class support for it yet --- nvim/lua/psoxizsh/plugins/plug.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index 4d23486..893b52a 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -7,6 +7,11 @@ local plugins = { module_pattern = { 'packer', 'packer%..*' } }, + -- Utils for wrapping vimscript in lua easier + { 'svermeulen/vimpeccable', + as = 'vimp' + }, + -- Used for autocmds if we're not using a late enough version of neovim { 'jakelinnzy/autocmd-lua', disable = vim.fn.has('nvim-0.7') == 1 From 330f5c03125be67b3c1679d1924bef8d1ddea4e6 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 07:58:41 +0000 Subject: [PATCH 21/30] nvim/plug: port plugins from vimrc Minus a lot of old of the old conditional code around vim/neovim differences. This commit also removes some of the default plugin list. Replacements will be added in the following commits. - scrooloose/vim-statline | 12 years old doesn't seem to have an effect - vim-airline/vim-airline-themes vim-airline/vim-airline | Throwing all sorts of errors when loaded by packer. Not sure what is wrong, but I think it's just incompatible. - airblade/vim-gitgutter | Nothing wrong with gitgutter, but it appears that a lot of the nvim world uses (and more importantly, integrates with) gitsigns. It's also a lot faster. - scrooloose/nerdtree Xuyuanp/nerdtree-git-plugin | Again, nothing really wrong with nerdtree, but there are better options in neovim land (neo-tree.nvim) --- nvim/lua/psoxizsh/plugins/config/fzf.lua | 35 +++++++++++ nvim/lua/psoxizsh/plugins/config/neomake.lua | 14 +++++ .../lua/psoxizsh/plugins/config/pear-tree.lua | 8 +++ nvim/lua/psoxizsh/plugins/config/vim-qf.lua | 11 ++++ nvim/lua/psoxizsh/plugins/plug.lua | 62 +++++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/config/fzf.lua create mode 100644 nvim/lua/psoxizsh/plugins/config/neomake.lua create mode 100644 nvim/lua/psoxizsh/plugins/config/pear-tree.lua create mode 100644 nvim/lua/psoxizsh/plugins/config/vim-qf.lua diff --git a/nvim/lua/psoxizsh/plugins/config/fzf.lua b/nvim/lua/psoxizsh/plugins/config/fzf.lua new file mode 100644 index 0000000..55fc2be --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/fzf.lua @@ -0,0 +1,35 @@ +return function() + local fn, o, api = vim.fn, vim.o, vim.api + + if fn.executable('rg') == 1 then + -- Override the default grep implementation in vim + o.grepprg = 'rg --vimgrep --smart-case --follow' + + if fn.has('nvim-0.7') == 1 then + -- Only search file contents, not file name + -- We can use the stock :Files for that + local rg_func = function(opts) + return fn['fzf#vim#grep']( + "rg --column --line-number --no-heading --color=always --smart-case " .. fn.shellescape(opts.args), + true, + fn['fzf#vim#with_preview']({options = '--delimiter : --nth 4..'}), + opts.bang + ) + end + api.nvim_create_user_command('Rg', rg_func, { nargs = '*', bang = true }) + + -- If the user hasn't set a default FZF command, and has ripgrep installed, + -- use it over find, otherwise defer to the user's preferred command + if fn.empty(os.getenv('FZF_DEFAULT_COMMAND')) == 1 then + local files_func = function(opts) + return fn['fzf#vim#files']( + opts.args, + fn['fzf#vim#with_preview']({source = 'rg --files --hidden --glob "!**/.git/**" '}), + opts.bang + ) + end + api.nvim_create_user_command('Files', files_func, { nargs = '?', bang = true, complete = 'dir' }) + end + end + end +end diff --git a/nvim/lua/psoxizsh/plugins/config/neomake.lua b/nvim/lua/psoxizsh/plugins/config/neomake.lua new file mode 100644 index 0000000..f3c79c9 --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/neomake.lua @@ -0,0 +1,14 @@ +return function() + local g, fn = vim.g, vim.fn + + -- Don't move cursor into qf/loc on open + g.neomake_open_list = 2 + -- Allow multiple makers to resolve + g.neomake_serialize = 1 + g.neomake_serialize_abort_on_error = 1 + + -- Let Neomake control window size + g.qf_auto_resize = 0 + + fn['neomake#configure#automake']('rw', 800) +end diff --git a/nvim/lua/psoxizsh/plugins/config/pear-tree.lua b/nvim/lua/psoxizsh/plugins/config/pear-tree.lua new file mode 100644 index 0000000..f7f3857 --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/pear-tree.lua @@ -0,0 +1,8 @@ +return function() + local g = vim.g + + -- Balance pairs when on open, close and delete + g.pear_tree_smart_openers = 1 + g.pear_tree_smart_closers = 1 + g.pear_tree_smart_backspace = 1 +end diff --git a/nvim/lua/psoxizsh/plugins/config/vim-qf.lua b/nvim/lua/psoxizsh/plugins/config/vim-qf.lua new file mode 100644 index 0000000..7ebfd47 --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/vim-qf.lua @@ -0,0 +1,11 @@ + +return function() + local g = vim.g + + -- Don't force qf/loc windows to bottom + g.qf_window_bottom = 0 + g.qf_loclist_window_bottom = 0 + + -- Let Neomake control window size + g.qf_auto_resize = 0 +end diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index 893b52a..59026b4 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -7,6 +7,9 @@ local plugins = { module_pattern = { 'packer', 'packer%..*' } }, + -- Community patch for Vim + { 'tpope/vim-sensible' }, + -- Utils for wrapping vimscript in lua easier { 'svermeulen/vimpeccable', as = 'vimp' @@ -16,6 +19,65 @@ local plugins = { { 'jakelinnzy/autocmd-lua', disable = vim.fn.has('nvim-0.7') == 1 }, + + -- Text alignment + { 'junegunn/vim-easy-align' }, + { 'tmsvg/pear-tree', + config = require 'psoxizsh.plugins.config.pear-tree' + }, + + -- Git integration + { 'tpope/vim-fugitive' }, + + -- Comment helpers + { 'scrooloose/nerdcommenter' }, + + -- Stat line integrations + + -- Buffer mangement + { 'qpkorr/vim-bufkill' }, + { 'romainl/vim-qf', + config = require 'psoxizsh.plugins.config.vim-qf' + }, + + -- IDE stuff + language highlighting + { 'neomake/neomake', + config = require 'psoxizsh.plugins.config.neomake' + }, + { 'vim-perl/vim-perl', + ft = 'perl', + run = 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' + }, + { 'rust-lang/rust.vim', + ft = 'rust' + }, + { 'pearofducks/ansible-vim', + ft = {'yaml', 'yml'} + }, + { 'kevinoid/vim-jsonc' }, + { 'luochen1990/rainbow' }, + { 'sheerun/vim-polyglot' }, + + -- Fuzzy search helpers + { 'junegunn/fzf', + cmd = 'FZF', + fn = { 'fzf#run', 'fzf#wrap' } + }, + { 'junegunn/fzf.vim', + config = require 'psoxizsh.plugins.config.fzf' + }, + { 'adelarsq/vim-matchit' }, + { 'mox-mox/vim-localsearch' }, + + -- Color themes + { 'rakr/vim-one', + config = function() vim.cmd(string.format('colorscheme %s', vim.g.my_color_scheme or 'one')) end + }, + { 'romainl/vim-cool' }, + + -- Other + { 'roxma/nvim-yarp' }, + { 'roxma/vim-hug-neovim-rpc' }, } local function concatArray(a, b) From cc4a95f70d903943408cde34da8f2d66cc026508 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Fri, 22 Jul 2022 09:30:35 +0000 Subject: [PATCH 22/30] nvim/plug: nvim-neo-tree/neo-tree.nvim@v2.x This plugin replaces the functionality of nerdtree, providing a much smoother experience. It also comes with a bunch new features: - Floating window support - Vastly more configurable - Icon support - Intelligent file grouping / hiding - Faster responses to filesystem events --- nvim/lua/psoxizsh/plugins/config/neotree.lua | 162 +++++++++++++++++++ nvim/lua/psoxizsh/plugins/plug.lua | 15 ++ 2 files changed, 177 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/config/neotree.lua diff --git a/nvim/lua/psoxizsh/plugins/config/neotree.lua b/nvim/lua/psoxizsh/plugins/config/neotree.lua new file mode 100644 index 0000000..ac234e3 --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/neotree.lua @@ -0,0 +1,162 @@ +return function() + local g, fn = vim.g, vim.fn + local neotree, util, vimp = require 'neo-tree', require 'psoxizsh.util', require 'vimp' + + local defaults = { + close_if_last_window = true, + enable_git_status = true, + default_component_configs = { + container = { + enable_character_fade = true + }, + indent = { + indent_size = 2, + padding = 1, -- extra padding on left hand side + -- indent guides + with_markers = true, + indent_marker = "│", + last_indent_marker = "└", + highlight = "NeoTreeIndentMarker", + -- expander config, needed for nesting files + with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders + expander_collapsed = "", + expander_expanded = "", + expander_highlight = "NeoTreeExpander", + }, + icon = { + folder_closed = "", + folder_open = "", + folder_empty = "ﰊ", + -- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there + -- then these will never be used. + default = "*", + highlight = "NeoTreeFileIcon" + }, + modified = { + symbol = "[+]", + highlight = "NeoTreeModified", + }, + name = { + trailing_slash = false, + use_git_status_colors = true, + highlight = "NeoTreeFileName", + }, + git_status = { + symbols = { + -- Change type + added = "✚", -- or "✚", but this is redundant info if you use git_status_colors on the name + modified = "~", -- or "", but this is redundant info if you use git_status_colors on the name + deleted = "✖",-- this can only be used in the git_status source + renamed = "",-- this can only be used in the git_status source + -- Status type + untracked = "", + ignored = "", + unstaged = "", + staged = "", + conflict = "", + }, + }, + }, + window = { + position = "left", + width = 40, + mapping_options = { + noremap = true, + nowait = true, + }, + mappings = { + ["?"] = "show_help", + ["q"] = "close_window", + ["R"] = "refresh", + [""] = { "toggle_node", nowait = false }, + [""] = "open", + ["S"] = "open_split", + ["s"] = "open_vsplit", + ["C"] = "close_node", + ["z"] = "close_all_nodes", + ["Z"] = "expand_all_nodes", + ["X"] = "delete", + ["r"] = "rename", + ["a"] = { "add", config = { show_path = "relative" } }, + ["A"] = { "add_directory", config = { show_path = "relative" } }, + ["c"] = { "copy", config = { show_path = "relative" } }, + ["m"] = { "move", config = { show_path = "relative" } }, + ["y"] = "copy_to_clipboard", + ["p"] = "paste_from_clipboard", + }, + }, + filesystem = { + filtered_items = { + visible = false, -- when true, they will just be displayed differently than normal items + hide_dotfiles = true, + hide_gitignored = true, + hide_hidden = true, -- only works on Windows for hidden files/directories + hide_by_name = { --[[ Example: 'node_modules' ]] }, + hide_by_pattern = { --[[ Example '*.meta' ]] }, + never_show = { --[[ remains hidden even if visible is toggled to true ]] }, + }, + follow_current_file = true, -- This will find and focus the file in the active buffer every + -- time the current file is changed while the tree is open. + group_empty_dirs = false, -- when true, empty folders will be grouped together + hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree + -- in whatever position is specified in window.position + -- "open_current", -- netrw disabled, opening a directory opens within the + -- window like netrw would, regardless of window.position + -- "disabled", -- netrw left alone, neo-tree does not handle opening dirs + use_libuv_file_watcher = true, -- This will use the OS level file watchers to detect changes + -- instead of relying on nvim autocmd events. + window = { + mappings = { + [""] = "navigate_up", + ["."] = "set_root", + ["H"] = "toggle_hidden", + ["/"] = "fuzzy_finder", + ["D"] = "fuzzy_finder_directory", + ["f"] = "filter_on_submit", + [""] = "clear_filter", + ["[g"] = "prev_git_modified", + ["]g"] = "next_git_modified", + }, + }, + }, + buffers = { + follow_current_file = true, -- This will find and focus the file in the active buffer every + -- time the current file is changed while the tree is open. + group_empty_dirs = true, -- when true, empty folders will be grouped together + show_unloaded = true, + window = { + mappings = { + ["X"] = "buffer_delete", + [""] = "navigate_up", + ["."] = "set_root", + }, + }, + }, + git_status = { + window = { + position = "float", + mappings = { + ["A"] = "git_add_all", + ["gu"] = "git_unstage_file", + ["ga"] = "git_add_file", + ["gr"] = "git_revert_file", + ["gc"] = "git_commit", + ["gp"] = "git_push", + ["gg"] = "git_commit_and_push", + }, + }, + }, + } + + g['neo_tree_remove_legacy_commands'] = 1 + fn.sign_define("DiagnosticSignError", {text = " ", texthl = "DiagnosticSignError"}) + fn.sign_define("DiagnosticSignWarn", {text = " ", texthl = "DiagnosticSignWarn"}) + fn.sign_define("DiagnosticSignInfo", {text = " ", texthl = "DiagnosticSignInfo"}) + fn.sign_define("DiagnosticSignHint", {text = "", texthl = "DiagnosticSignHint"}) + + vimp.nnoremap({'silent'}, '', ':Neotree toggle reveal position=left') + vimp.nnoremap({'silent'}, 'gs', ':Neotree float git_status') + vimp.nnoremap({'silent'}, '', ':Neotree toggle reveal float source=buffers') + + neotree.setup(util.mconfig('config.neotree', defaults)) +end diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index 59026b4..68cc876 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -29,6 +29,21 @@ local plugins = { -- Git integration { 'tpope/vim-fugitive' }, + -- File browser + { 'nvim-neo-tree/neo-tree.nvim', + as = 'neo-tree', + branch = 'v2.x', + requires = { + 'nvim-lua/plenary.nvim', + 'kyazdani42/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + }, + after = 'vimp', + cmd = { 'Neotree', 'NeoTree*' }, + keys = { '', 'gs', '' }, + config = require 'psoxizsh.plugins.config.neotree' + }, + -- Comment helpers { 'scrooloose/nerdcommenter' }, From 4ffaae034cfe1f7ccf4394d4af0bfb3e7c9dfaf5 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 21 Jul 2022 19:05:33 +0000 Subject: [PATCH 23/30] nvim/plug: lewis6991/gitsigns.nvim@release Replacing gitgutter, gitsigns appears to be the standard neovim git integration plugin. It is _significantly_ faster in responding to file deltas, and plays really nicely with a lot of other tooling in the neovim ecosystem. It also appears very customizable. --- nvim/lua/psoxizsh/plugins/config/gitsigns.lua | 12 ++++++++++++ nvim/lua/psoxizsh/plugins/plug.lua | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/config/gitsigns.lua diff --git a/nvim/lua/psoxizsh/plugins/config/gitsigns.lua b/nvim/lua/psoxizsh/plugins/config/gitsigns.lua new file mode 100644 index 0000000..7fd0116 --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/gitsigns.lua @@ -0,0 +1,12 @@ +return function() + local gitsigns, util = require 'gitsigns', require 'psoxizsh.util' + + local defaults = { + sign_priority = 100, + current_line_blame_formatter_opts = { + relative_time = false + }, + } + + gitsigns.setup(util.mconfig('config.gitsigns', defaults)) +end diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index 68cc876..a0827b6 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -48,6 +48,11 @@ local plugins = { { 'scrooloose/nerdcommenter' }, -- Stat line integrations + { 'lewis6991/gitsigns.nvim', + tag = 'release', + requires = { 'nvim-lua/plenary.nvim' }, + config = require 'psoxizsh.plugins.config.gitsigns' + }, -- Buffer mangement { 'qpkorr/vim-bufkill' }, From 4fe3d09d6560cd530108a390d9e6e21f1a8e4d23 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 21 Jul 2022 18:41:00 +0000 Subject: [PATCH 24/30] nvim/plug: akinsho/bufferline.nvim@v1.* This commit adds replacement to airline's bufferline. It provides a fast, flexible bufferline with a couple big improvements over airline: 1. Fast 2. Sidebar aware (e.x for NERDTree) 3. Buffer management, including grouping (via directory), movement and go-to-buffer 4. A lot of options to customize 5. Optional icon integration It loses the powerline look, but I'm pretty sure I can get it back if desired in the future. --- .../psoxizsh/plugins/config/bufferline.lua | 23 +++++++++++++++++++ nvim/lua/psoxizsh/plugins/plug.lua | 7 ++++++ 2 files changed, 30 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/config/bufferline.lua diff --git a/nvim/lua/psoxizsh/plugins/config/bufferline.lua b/nvim/lua/psoxizsh/plugins/config/bufferline.lua new file mode 100644 index 0000000..c9ceceb --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/bufferline.lua @@ -0,0 +1,23 @@ +return function() + local bl, vimp, util = require 'bufferline', require 'vimp', require 'psoxizsh.util' + + local defaults = { + always_show_bufferline = true, + numbers = "none", + diagnostics = 'coc', + offsets = {{ + filetype = 'neo-tree', + text = 'File Explorer', + text_align = 'center' + }}, + show_buffer_close_icons = false, + separator_style = { '\u{E0B0}', '\u{E0B1}' }, + sort_by = 'relative_directory', + } + + bl.setup { options = util.mconfig('config.bufferline', defaults) } + + vimp.nnoremap({'silent'}, '', ':BufferLineCycleNext') + vimp.nnoremap({'silent'}, '', ':BufferLineCyclePrev') + vimp.nnoremap({'silent'}, '', ':BufferLinePick') +end diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index a0827b6..0900bf1 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -48,6 +48,13 @@ local plugins = { { 'scrooloose/nerdcommenter' }, -- Stat line integrations + { 'akinsho/bufferline.nvim', + as = "bufferline", + tag = "v1.*", + requires = { 'kyazdani42/nvim-web-devicons' }, + after = 'vimp', + config = require 'psoxizsh.plugins.config.bufferline' + }, { 'lewis6991/gitsigns.nvim', tag = 'release', requires = { 'nvim-lua/plenary.nvim' }, From 8d0bc13e7e45e5cef1bbbf626e47f7747d4992e2 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 21 Jul 2022 18:40:17 +0000 Subject: [PATCH 25/30] nvim/plug: nvim-lualine/lualine.nvim@master Replacing airline, lualine seems to be a super customizable statusline plugin. I yoinked the base config file from the net and modified it to suit my needs. --- nvim/lua/psoxizsh/plugins/config/lualine.lua | 65 ++++++++++++++++++++ nvim/lua/psoxizsh/plugins/plug.lua | 7 +++ 2 files changed, 72 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/config/lualine.lua diff --git a/nvim/lua/psoxizsh/plugins/config/lualine.lua b/nvim/lua/psoxizsh/plugins/config/lualine.lua new file mode 100644 index 0000000..880fc27 --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/lualine.lua @@ -0,0 +1,65 @@ +return function() + local ll, util, nwd = require 'lualine', require 'psoxizsh.util', require("nvim-web-devicons") + + local file_color = function() + local _, color = nwd.get_icon_colors_by_filetype(vim.bo.filetype) + + return { fg = color } + end + local diff_source = function() + -- May be nil if gitsigns hasn't populated yet + local gs = vim.b.gitsigns_status_dict or {} + + return { + added = gs.added, + modified = gs.changed, + removed = gs.removed, + } + end + + local filename = { + 'filename', + icon = 'ƒ', + symbols = { modified = '|', readonly = '|', unnamed = '〜' }, + color = file_color, + } + local branch = { 'branch', icon = '', color = { gui = 'bold,italic' } } + local diagnostics = { 'diagnostics', sources = { 'coc' }, update_in_insert = true } + local diff = { 'diff', source = diff_source } + + local defaults = { + options = { + theme = 'auto', + icons_enabled = true, + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = {}, + always_divide_middle = true, + globalstatus = true, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { branch, diff, diagnostics }, + lualine_c = { filename }, + lualine_x = {'filetype', 'encoding', 'fileformat'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { filename }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + extensions = { 'fugitive', 'quickfix', 'man', 'fzf', 'neo-tree' } + } + + ll.setup(util.mconfig('config.lualine', defaults)) +end diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index 0900bf1..b0b51a6 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -48,6 +48,13 @@ local plugins = { { 'scrooloose/nerdcommenter' }, -- Stat line integrations + { 'nvim-lualine/lualine.nvim', + requires = { + 'kyazdani42/nvim-web-devicons', + 'lewis6991/gitsigns.nvim' + }, + config = require 'psoxizsh.plugins.config.lualine' + }, { 'akinsho/bufferline.nvim', as = "bufferline", tag = "v1.*", From 61d3ef5b6c0415b557ad8565970e837d638b712c Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 21 Jul 2022 19:46:37 +0000 Subject: [PATCH 26/30] nvim/plug: port vim-tmux-navigator + config --- .../psoxizsh/plugins/config/vim-tmux-navigator.lua | 11 +++++++++++ nvim/lua/psoxizsh/plugins/plug.lua | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/config/vim-tmux-navigator.lua diff --git a/nvim/lua/psoxizsh/plugins/config/vim-tmux-navigator.lua b/nvim/lua/psoxizsh/plugins/config/vim-tmux-navigator.lua new file mode 100644 index 0000000..6dfbe99 --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/vim-tmux-navigator.lua @@ -0,0 +1,11 @@ +return function() + local g, vimp = vim.g, require 'vimp' + + g['tmux_navigator_no_mappings'] = 1 + g['tmux_navigator_disable_when_zoomed'] = 1 + + vimp.nnoremap({'override', 'silent'}, '', ':TmuxNavigateLeft') + vimp.nnoremap({'override', 'silent'}, '', ':TmuxNavigateDown') + vimp.nnoremap({'override', 'silent'}, '', ':TmuxNavigateUp') + vimp.nnoremap({'override', 'silent'}, '', ':TmuxNavigateRight') +end diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index b0b51a6..e469241 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -109,6 +109,13 @@ local plugins = { }, { 'romainl/vim-cool' }, + -- Tmux integration for pane movement + { 'christoomey/vim-tmux-navigator', + keys = { '', '', '', '' }, + cmd = { 'TmuxNavigateLeft', 'TmuxNavigateDown', 'TmuxNavigateUp', 'TmuxNavigateRight', 'TmuxNavigatePrevious' }, + config = require 'psoxizsh.plugins.config.vim-tmux-navigator' + }, + -- Other { 'roxma/nvim-yarp' }, { 'roxma/vim-hug-neovim-rpc' }, From 2a309d6e4f29e7e1ec710274a0fccddc72cd104f Mon Sep 17 00:00:00 2001 From: Bazaah Date: Thu, 21 Jul 2022 19:41:42 +0000 Subject: [PATCH 27/30] nvim/plug: port coc.nvim + config --- nvim/lua/psoxizsh/plugins/config/coc.lua | 103 +++++++++++++++++++++++ nvim/lua/psoxizsh/plugins/plug.lua | 5 ++ 2 files changed, 108 insertions(+) create mode 100644 nvim/lua/psoxizsh/plugins/config/coc.lua diff --git a/nvim/lua/psoxizsh/plugins/config/coc.lua b/nvim/lua/psoxizsh/plugins/config/coc.lua new file mode 100644 index 0000000..c9a23ac --- /dev/null +++ b/nvim/lua/psoxizsh/plugins/config/coc.lua @@ -0,0 +1,103 @@ +return function() + local fn, o, g = vim.fn, vim.opt, vim.g + local vimp, au = require 'vimp', require 'psoxizsh.autocmd' + + if fn.executable('node') == 0 then return end + + local t = function(s) + return vim.api.nvim_replace_termcodes(s, true, true, true) + end + local pumvisible = function() + return fn.pumvisible() == 1 + end + + g['coc_global_extensions'] = { + 'coc-yank', + 'coc-spell-checker', + 'coc-vimlsp', + 'coc-rust-analyzer', + 'coc-json', + 'coc-markdownlint', + 'coc-yaml' + } + + -- Do action on current word + vimp.nmap({'silent'}, '.', '(coc-codeaction-selected)w') + + -- Do action on a selection + vimp.nmap({'silent'}, '/', '(coc-codeaction-selected)') + vimp.xmap({'silent'}, '/', '(coc-codeaction-selected)') + + -- Rename symbol + vimp.nmap({'silent'}, 'rn', '(coc-rename)') + -- Goto definition / references + vimp.nmap({'silent'}, 'gd', '(coc-definition)') + vimp.nmap({'silent'}, 'gr', '(coc-references)') + + -- Basically, we're checking to see if the column behind the current + -- either doesn't exist or is whitespace + local ck_backspace = function() + local col = fn.col('.') - 1 + + return + col == 0 + and true + or fn.getline('.'):sub(col, col):match('%s') + and true + or false + end + + vimp.inoremap({'silent', 'expr'}, '', function() + return + pumvisible() + and t'' + or ck_backspace() + and t'' + or fn['coc#refresh']() + end) + vimp.inoremap({'expr'}, '', function() + return pumvisible() and t'' or t'' + end) + + -- Use to confirm completion, `u` means break undo chain at current + -- position. Coc only does snippet and additional edit on confirm. + -- could be remapped by other vim plugin, try `:verbose imap `. + vimp.inoremap({'expr'}, '', function() + local info = + fn.exists('*complete_info') == 1 + and fn.complete_info().selected ~= -1 + or pumvisible() + + return info and t'' or t'u' + end) + + -- Use `[g` and `]g` to navigate diagnostics + vimp.nmap({'silent'}, '[g', '(coc-diagnostic-prev)') + vimp.nmap({'silent'}, ']g', '(coc-diagnostic-next)') + + if fn.has('nvim-0.4') then + -- Remap PageUp and PageDown for scroll float windows/popups. + vimp.nnoremap({'silent', 'nowait', 'expr'}, '', [[coc#float#has_scroll() ? coc#float#scroll(1) : "\"]]) + vimp.nnoremap({'silent', 'nowait', 'expr'}, '', [[coc#float#has_scroll() ? coc#float#scroll(0) : "\"]]) + end + + -- Use K to show documentation in preview window. + local show_documentation = function() + if vim.tbl_contains({'vim', 'help'}, o.filetype:get()) then + vim.cmd('help ' .. fn.expand(t'')) + elseif vim.fn['coc#rpc#ready']() == 1 then + vim.fn.CocActionAsync('doHover') + else + vim.cmd('!' .. o.keywordprg:get() .. ' ' .. fn.expand(t'')) + end + end + vimp.nnoremap({'silent'}, 'K', show_documentation) + + -- Open yank list + vimp.nnoremap({'silent'}, '', t':CocList -A --normal yank') + + au.PsoxCocAutos { + { 'CursorHold', '*', function() fn.CocActionAsync('highlight') end }, + { 'User', 'CocJumpPlaceholder', function() fn.CocActionAsync('showSignatureHelp') end }, + } +end diff --git a/nvim/lua/psoxizsh/plugins/plug.lua b/nvim/lua/psoxizsh/plugins/plug.lua index e469241..80983d1 100644 --- a/nvim/lua/psoxizsh/plugins/plug.lua +++ b/nvim/lua/psoxizsh/plugins/plug.lua @@ -75,6 +75,11 @@ local plugins = { }, -- IDE stuff + language highlighting + { 'neoclide/coc.nvim', + branch = 'release', + after = 'vimp', + config = require 'psoxizsh.plugins.config.coc' + }, { 'neomake/neomake', config = require 'psoxizsh.plugins.config.neomake' }, From e00c378ac34e16a9556fd0cf02dee14e7e5a7e13 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 09:01:24 +0000 Subject: [PATCH 28/30] psoxizsh/init: port static configuration from vimrc Using the hooks provided by psoxizsh.plugins, we recreate our vimrc configuration, minus a lot of the vim<->nvim compat logic. A lot of the remaining configuration has also been split out into plugin specific modules that are managed directly by packer (and thus loaded on demand without conditionals on our part) --- nvim/lua/psoxizsh/init.lua | 193 +++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 nvim/lua/psoxizsh/init.lua diff --git a/nvim/lua/psoxizsh/init.lua b/nvim/lua/psoxizsh/init.lua new file mode 100644 index 0000000..76aff51 --- /dev/null +++ b/nvim/lua/psoxizsh/init.lua @@ -0,0 +1,193 @@ +local o, g, fn, cmd = vim.opt, vim.g, vim.fn, vim.cmd +local au, util = require 'psoxizsh.autocmd', require 'psoxizsh.util' + +local function psoxizsh_early_config() + -- Local early configuration + util.try_mreload('early') + + -- Set global color scheme var + if not g.my_color_scheme then + g.my_color_scheme = 'one' + end + + -- Hide buffers don't close them + o.hidden = true + + -- Sane pane opening + o.splitbelow = true + o.splitright = true + + -- File indent opts + o.encoding = "utf-8" + + o.shiftwidth = 2 + o.tabstop = 8 + o.softtabstop = 2 + o.expandtab = true + + o.list = true + o.listchars:append { + trail = '\u{02FD}', + extends = '\u{22B3}', + precedes = '\u{22B2}', + nbsp = '\u{02EC}', + conceal = '\u{2219}', + tab = '\u{2559}\u{254C}\u{2556}', + } + + o.ignorecase = true + o.infercase = true + + cmd 'filetype plugin indent on' + + -- Set completion messages off + o.shortmess:append { c = true } + + -- Preview window + menu for autocompletions + o.completeopt:append { + 'preview', + 'menuone', + 'longest', + } + + -- Lower update time (Default 4000) + o.updatetime = 300 + + -- Numbered lines + o.number = true + o.relativenumber = true + + o.signcolumn = 'yes:1' + + -- Disable '--INSERT--' and friends + o.showmode = false + + -- Use existing buffers + o.switchbuf = { "useopen", "usetab" } + + -- Local pre plugin configuration + util.try_mreload('pre') +end + +-- Load plugins + +local function psoxizsh_post_config(plugs) + local vimp = require 'vimp' + -- Local post plugin configuration + util.try_mreload('post') + + -- Setup file backups + cmd ':silent !mkdir -p ~/.vimbackup' + o.backupdir = fn.expand('~') .. '/.vimbackup' + o.directory = fn.expand('~') .. '/.vimbackup' + + o.hlsearch = true + + -- ripgrep settings + g.rg_highlight = 'true' + g.rg_derive_root = 'true' + + -- Other + g.rainbow_active = 1 + + au.PsoxFileAutos { + { 'FileType', 'yaml', 'setlocal indentkeys-=<:> ts=8 sts=2 sw=2 expandtab' }, + { 'FileType', 'go', 'setlocal ts=8 sts=4 sw=4 noexpandtab' }, + { 'FileType', 'quickfix,netrw', 'setlocal nobuflisted' }, + { 'FileType', 'netrw', function() require('vimp').nmap({'buffer', 'silent'}, '', ':call CloseNetrw()') end }, + } + + cmd([[ + function! CloseNetrw() abort + for bufn in range(1, bufnr('$')) + if bufexists(bufn) && getbufvar(bufn, '&filetype') ==# 'netrw' + silent! execute 'bwipeout ' . bufn + if getline(2) =~# '^" Netrw ' + silent! bwipeout + endif + return + endif + endfor + endfunction + ]]) + + if plugs:has('fzf') then + if fn.executable('rg') == 1 then + vimp.nnoremap('', ':Rg ') + vimp.nnoremap('', ':Rg! ') + vimp.nnoremap({'silent'}, '', ':Rg') + vimp.nnoremap({'silent'}, '', ':Rg!') + end + + vimp.nnoremap('', ':Files ') + vimp.nnoremap('', ':Files! ') + vimp.nnoremap({'silent'}, '', ':Files') + vimp.nnoremap({'silent'}, '', ':Files!') + + vimp.nnoremap('', ':Buffers ') + vimp.nnoremap('', ':Buffers! ') + vimp.nnoremap({'silent'}, '', ':Buffers') + vimp.nnoremap({'silent'}, '', ':Buffers!') + end + + -- Workaround for writing readonly files + vimp.cnoremap({'silent'}, 'w!!', 'w !sudo tee % >/dev/null') + + -- Open any known user configuration paths for editing + vimp.nnoremap({'silent'}, 've', function() + local rtp = vim.fn.join(o.runtimepath:get(), ',') + local files = { + early = vim.fn.globpath(rtp, '/lua/early.lua', 0, 1)[1] or nil, + pre = vim.fn.globpath(rtp, '/lua/pre.lua', 0, 1)[1] or nil, + post = vim.fn.globpath(rtp, '/lua/post.lua', 0, 1)[1] or nil, + late = vim.fn.globpath(rtp, '/lua/late.lua', 0, 1)[1] or nil, + my = os.getenv("MYVIMRC") or nil, + } + + for _, file in pairs(files) do + if vim.fn.filereadable(file) == 1 then + cmd('edit ' .. file) + end + end + end) + + -- Toggles all gutter items + vimp.nnoremap({'silent'}, 'N', function() + if o.number:get() then + o.number = false + o.relativenumber = false + o.signcolumn = 'no' + else + o.number = true + o.relativenumber = true + o.signcolumn = 'yes:1' + end + end) + + -- Reload configuration + vimp.nnoremap('vs', function() vimp.unmap_all() plugs:reload() end) + + o.background = 'dark' + o.termguicolors = true + g.one_allow_italics = 1 + cmd('highlight Comment term=italic cterm=italic gui=italic') +end + +local function psoxizsh_late_config(_) + -- Local late configuration + util.try_mreload('late') + + -- Rest of config below is specifically not user override-able + o.exrc = true + o.secure = true + o.modeline = true + o.modelines = 7 +end + +local hooks = { + early = { 'PsoxConfigEarly', psoxizsh_early_config }, + post = { 'PsoxConfigPost', psoxizsh_post_config }, + late = { 'PsoxConfigLate', psoxizsh_late_config }, +} + +return require('psoxizsh.plugins') { hooks = hooks } From 574f7641cc502f658a95635d113f234e85473ea0 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Fri, 22 Jul 2022 15:00:26 +0000 Subject: [PATCH 29/30] psoxizsh/init: use global statusline where possible This is relatively recent feature, only available in neovim 0.7 or higher --- nvim/lua/psoxizsh/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nvim/lua/psoxizsh/init.lua b/nvim/lua/psoxizsh/init.lua index 76aff51..3ab26c6 100644 --- a/nvim/lua/psoxizsh/init.lua +++ b/nvim/lua/psoxizsh/init.lua @@ -65,6 +65,9 @@ local function psoxizsh_early_config() -- Use existing buffers o.switchbuf = { "useopen", "usetab" } + -- Set global statusline (0.7+ only) + if fn.has('nvim-0.7') == 1 then o.laststatus = 3 end + -- Local pre plugin configuration util.try_mreload('pre') end From 2c8ed58cfee7980005a70de35c0b80d9c280ae79 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Tue, 19 Jul 2022 09:02:56 +0000 Subject: [PATCH 30/30] init.lua: entry point for neovim lua config Adds psoxizsh/nvim to the runtimepath, and runs the main init script --- init.lua | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 init.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..78c95d9 --- /dev/null +++ b/init.lua @@ -0,0 +1,3 @@ +vim.opt.rtp:append( os.getenv('PSOXIZSH') .. '/nvim' ) + +require 'psoxizsh'