This commit is contained in:
anon 2023-10-25 19:00:04 +02:00
parent e4efa9b02e
commit a0546e929c
109 changed files with 16186 additions and 0 deletions

0
anchor
View File

7
bash/.bash_profile Normal file
View File

@ -0,0 +1,7 @@
# /etc/skel/.bash_profile
# This file is sourced by bash for login shells. The following line
# runs your .bashrc and is recommended by the bash info pages.
if [[ -f ~/.bashrc ]] ; then
. ~/.bashrc
fi

51
bash/.bashrc Normal file
View File

@ -0,0 +1,51 @@
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
BTS_L=192.168.0.206
SRCF=~/.bashrc.d/
MACHINE_NAME="$(cat ${SRCF}/MACHINE_NAME.val)"
export PATH="$PATH:."
# Personal
source ${SRCF}/Personal/.${USER}_personal.rc
source ${SRCF}/.def_apps.rc
source ${SRCF}/.paths.rc
# Bash behaviour setting
source ${SRCF}/.builtin.rc
source ${SRCF}/.glob.rc
source ${SRCF}/.winsize.rc
source ${SRCF}/.ignoreeof.rc
# Program looks
source ${SRCF}/.program_looks.rc
# Core behavour settings
source ${SRCF}/.core.rc
# Core behavour overriding
source ${SRCF}/.history.rc
source ${SRCF}/.cd.rc
# Periphery behaviour setting
source ${SRCF}/.gpg.rc
source ${SRCF}/.sudo.rc
# Short cutting
source ${SRCF}/.alias.rc
source ${SRCF}/.vimification.rc
source ${SRCF}/.signin.rc
# Tab completion
source ${SRCF}/.completion.rc
# Widgets
source ${SRCF}/.neofetch.rc
source ${SRCF}/.w.rc # watch (clock)
source ${SRCF}/.bash_fzfind.rc
source ${SRCF}/.nnn.rc
# Misc
source ${SRCF}/.python.rc
source ${SRCF}/.binds.rc
source ${SRCF}/.xterm.rc
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

315
bash/.bashrc.d/.Trash/.bashrc Executable file
View File

@ -0,0 +1,315 @@
# Fancy prompts
function synctime(){
[ "$UID" != "0" ] && echo "You must be root to perform this operation." && return
EDATE="$(edate)"
EDATE=${EDATE//./-}
EDATE=${EDATE//- / }
date --set "${EDATE}"
hwclock --systohc
date
}
function PushdAlias() {
if [ -d "$1" ]; then
\pushd "$1" > /dev/null
SWP=$(\dirs -p | awk '!x[$0]++' | tail -n +2 | tac)
dirs -c
for i in $SWP; do
eval \pushd -n $i > /dev/null
done
dirs
else
\pushd "$@"
fi
}
alias sudo="sudoAlias"
function sudoAlias(){
if [ "$1" == "su" ]; then
\sudo su
return
fi
USRLINE=$(grep "^$1:" /etc/passwd)
if [ -n "$USRLINE" ]; then # Does user exists?
_UID=$(echo "$USRLINE" | cut -d ':' -f 3)
if (( $_UID >= 1000 )) && (( $_UID <= 60000 )); then # Is user loginable?
\sudo $1
else
echo no
fi
else
echo not implemented
fi
}
alias bc="bc -q"
#neofetch
case $- in # If not running interactively, don't do anything
*i*) ;;
*) return;;
esac
#cd ~
#####################
### VARIABLES ###
#####################
## DEFAULT APPLICATIONS ##
export EDITOR="vim"
export VISUAL="vim"
export BROWSER="firefox"
export PAGER="less"
export IMG_VIEWER="nomacs"
## Favourites ##
export FAVCOL="green"
export FAVCHAR="♞"
## Paths ##
MM="/home/anon/Main"
export CDPATH="${MM}"
export PATH="${PATH}:${MM}/bin"
## PROGRAMS ##
# gcc #
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# gpg #
GPG_TTY=$(tty)
export GPG_TTY
export PINENTRY_USER_DATA="USE_CURSES=1"
# mysql #
export MYSQL_PS1=$(env echo -e "\033[1;32m#\033[34m\\U\033[0;1m:\033[32m[\033[0m\\d\033[1;32m]>\033[0m\\_")
MYCLI_PS1=${MYSQL_PS1//\\U/\\u}
# mktemplate #
export MKTEMPLATE_HOME="${MM}/Templates/mktemplate_home/"
# fzf #
## MISC ##
export auto_resume=1
IGNOREEOF=3
#########################
####################
### BUILTINS ###
####################
enable -n echo
## ## ## ## ## ##
####################
### SETTINGS ###
####################
## GLOBS ##
shopt -s dotglob # With this set, the glob matches hidden files (".*") by default,
# but not the . or .. links.
shopt -s globstar # If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s extglob # Enable additional globs. Resulting in what is effectively a Regex
# language builtin to Bash.
## PROMPT ##
# Set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi
# Enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
fi
## HISTORY ##
HISTCONTROL=erasedups # remove duplicates
shopt -s histappend # append to the history file, don't overwrite it
shopt -s lithist # save multiline commands with embeded newlines
HISTSIZE=1000
HISTFILESIZE=2000
HISTTIMEFORMAT='%y/%m/%d %T: '
HISTFILE="${MM}/Bash/History/.bash_history"
shopt -s checkwinsize # check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s cdspell # If set, minor errors in the spelling of a directory component in a cd
# command will be corrected. The errors checked for are transposed characters,
# a missing character, and a character too many.
## ## ## ## ## ##
###################
### ALIASES ###
###################
# Output controll:
alias cbash='bash --norc --noprofile --init-file <(echo "unset HISTFILE")'
alias s='sudo'
# Core
alias ls='ls -a --color=auto'
alias ll='ls -l -F'
alias l='ls -CF'
alias cp='cp -v'
alias mv='mv -v'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias echo='echo -e'
alias diff='diff -s -y -t --color=auto' # report identical; side-by-side; expand tabs; color
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias lsblk='lsblk -o NAME,SIZE,RM,RO,TYPE,FSTYPE,MOUNTPOINTS'
alias df='df --print-type'
alias ip='ip --color=auto'
# GNU
alias cal='cal --monday'
alias tar='tar -v'
alias gzip='gzip -v'
alias gdb='gdb -q'
alias less='less --use-color'
alias history='history | tail -n 10'
# Misc.
alias hexedit='hexedit --color'
alias bat='bat --paging=never --italic-text always'
alias xclip='xclip -selection clipboard'
alias tt="tt_with_high_score.sh"
alias wget='wget --restrict-file-names=windows,ascii'
alias tshark='tshark --color'
alias mycli="mycli --prompt \"${MYCLI_PS1}\""
# Ease of use
alias cls="clear"
alias mkdir="mkdir -p"
alias hgrep="\\history | grep"
alias close="exit"
alias quit="exit"
alias figlet="figlet -w 120 -d ~/mm/Fonts/figlet-fonts/"
alias heavyDuty=". ${MM}/Bash/Bashrc/.heavyDutyrc"
alias locatei="locate -i"
alias mysql="mysql --user=${USER} -p"
alias tmux="export LINES=${LINES}; export COLUMNS=${COLUMNS}; tmux attach || tmux"
# Manuvering
alias cd="PushdAlias"
alias cdh="cd ~"
alias cdu="cdUp"
alias pop="popd"
alias popd="PopdAlias"
alias dirs="DirsAlias"
# Safety
alias rm='rm -I'
alias gpg='gpg -i --no-symkey-cache'
#alias youtube-dl='youtube-dl --restrict-filenames --no-overwrites'
alias yt-dlp='yt-dlp --restrict-filenames --no-overwrites'
#alias tar='tar --verify'
# Vimification
alias :e="${EDITOR}"
alias :q="exit"
alias :qa="xdotool getactivewindow windowkill"
# Shortcuts
# Files with editor
alias bashrc="${EDITOR} ${HOME}/.bashrc"
alias vimrc="${EDITOR} ${HOME}/.vimrc"
alias pufka="${EDITOR} ${MM}/C++/pufka.cdd"
alias random="${EDITOR} ${MM}/Personal/RANDOM.outpost.txt"
alias msgbuffer="${EDITOR} ${MM}/Personal/Msg/msg.buf"
# Programs
# Scripts
alias txt="txt.txt.sh"
#########################
#####################
### FUNCTIONS ###
#####################
function mkdircd() { mkdir -p "$@" && eval cd "\"\$$#\""; }
function cdUp() {
if [[ $# -eq 0 ]]; then
cd ..
return
fi
for ((i=0 ; i <= $# ; i++)); do
cd ..
done
}
function PopdAlias() {
\popd "$@" > /dev/null && dirs
}
function DirsAlias() {
if [ $# == 0 ]; then
\dirs -p | awk -v ln=0 'BEGIN { FS="\n" } { for(i=1; i<=NF; i++) print " \033[1;36m" ln++ ":\033[0m " $i }'
else
\dirs "$@"
fi
}
#########################
## enable programmable completion features (you don't need to enable
## this, if it's already enabled in /etc/bash.bashrc and /etc/profile
## sources /etc/bash.bashrc).
##if ! shopt -oq posix; then
# if [ -f /usr/share/bash-completion/bash_completion ]; then
# . /usr/share/bash-completion/bash_completion
# elif [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
#fi

View File

@ -0,0 +1,307 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
##########################################################################
####################
### BUILTINS ###
####################
enable -n echo
## ## ## ## ## ##
####################
### SETTINGS ###
####################
## GLOBS ##
# With this set, the glob matches hidden files (".*") by default,
# but not the . or .. links.
shopt -s dotglob
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# Enable additional globs. Resulting in what is effectively a Regex
# language builtin to Bash.
shopt -s extglob
## ## ## ## ## ##
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Set variable identifying the chroot you work in (used in the prompt below)
#if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
# debian_chroot=$(cat /etc/debian_chroot)
#fi
## PROMPT ##
# Set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# Uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
# Deffault Kali shit. ?!
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
# Fancy prompts
if [ "$color_prompt" = yes ]; then
prompt_color='\[\033[;32m\]'
info_color='\[\033[1;34m\]'
# 🩓
prompt_symbol=♞
if [ "$EUID" -eq 0 ]; then # Change prompt colors for root user
prompt_color='\[\033[;94m\]'
info_color='\[\033[1;31m\]'
prompt_symbol=♛
fi
PS1=$prompt_color'┌──${debian_chroot:+($debian_chroot)──}('$info_color'\u${prompt_symbol}\h'$prompt_color')-[\[\033[0;1m\]\w'$prompt_color']\n'$prompt_color'└─'$info_color'\$\[\033[0m\] '
PS2=$prompt_color'>\[\033[0m\]'
# BackTrack red prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
## ## ## ## ## ##
### MISC LOOKS ###
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# Enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
fi
# Colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
## ## ## ## ## ##
# Turn on vi mode
set -o vi
### HISTORY ###
HISTCONTROL=erasedups # remove duplicates
shopt -s histappend # append to the history file, don't overwrite it
HISTSIZE=1000
HISTFILESIZE=2000
HISTTIMEFORMAT='%y/%m/%d %T: '
## ## ## ## ## ##
### MISC ###
# Do not imidietly exit on "<Ctrl> + d"
IGNOREEOF=3
## ## ## ## ## ##
#########################
#####################
### VARIABLES ###
#####################
FOO="bar"
export EDITOR="vim"
export VISUAL="vim"
BROWSER="firefox"
export auto_resume=1
export PATH="${PATH}:~/mm/bin"
CDPATH="${HOME}/mm"
export PYTHONPATH="${PYTHONPATH}~/mm/lib"
export FFF_HIDDEN=1 # show hidden (how counterintuitive...)
export FFF_LS_COLORS=1
#export FFF_OPENER="openie"
export FFF_FILE_FORMAT=" %f"
export FFF_FAV1="${HOME}/mm/"
export FFF_FAV2="${HOME}"
#export FFF_FAV1="~/Deskop/minecraft\ mod/"
export NNN_PRUG="p:preview-tabbed;o:organize"
GPG_TTY=$(tty)
export GPG_TTY
export PINENTRY_USER_DATA="USE_CURSES=1"
#########################
###################
### ALIASES ###
###################
# Output controll:
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff -s -y -t --color=auto' # report identical; side-by-side; expand tabs; color
alias hexedit='hexedit --color'
alias ip='ip --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias ls='ls -a --color=auto'
alias ll='ls -l -F'
alias l='ls -CF'
alias echo='echo -e'
alias df='df --print-type'
alias pacman='pacman --color=auto'
alias yay='yay --color=auto'
alias gdb='gdb -q'
alias tshark='tshark --color'
alias cp='cp -v'
alias mv='mv -v'
alias tar='tar -v'
alias gzip='gzip -v'
alias nnn='nnn -d -H -x'
alias bat='bat --paging=never --italic-text always'
alias wget='wget --restrict-file-names=windows,ascii'
alias xclip='xclip -selection clipboard'
# Ease of use
alias sudo='sudo '
alias cls="clear"
alias mkdir="mkdir -p"
alias cdb="cd \"${OLDPWD}\""
alias close="exit"
alias quit="exit"
alias figlet="figlet -w 120 -d ~/mm/Fonts/figlet-fonts/"
alias heavyDuty=". ~/heavyDuty.sh"
alias locatei="locate -i"
# Safety
alias rm='rm -I'
alias gpg='gpg -i'
#alias youtube-dl='youtube-dl --restrict-filenames --no-overwrites'
alias yt-dlp='yt-dlp --restrict-filenames --no-overwrites'
#alias tar='tar --verify'
# Vimification
alias :e="${EDITOR}"
alias :q="exit"
alias :qa="xdotool getactivewindow windowkill"
# Shortcuts
alias bashrc="${EDITOR} ${HOME}/.bashrc"
alias vimrc="${EDITOR} ${HOME}/.vimrc"
alias pufka="${EDITOR} ${HOME}/mm/C++/pufka.cdd"
alias owned-tech="${EDITOR} ${HOME}/mm/Personal/owned.db/tech.list"
alias msgbuffer="${EDITOR} ${HOME}/mm/Personal/Msg/msg.buf"
alias stibuffer="${EDITOR} ${HOME}/mm/Personal/Notes/short-term_ideas.buf"
alias todo="cd ${HOME}/mm/God && ./todo; cd \"${OLDPWD}\""
alias toget="cd ${HOME}/mm/God && ./toget; cd \"${OLDPWD}\""
alias devl="cd ${HOME}/mm/God && ./devl; cd \"${OLDPWD}\""
alias list="cd ${HOME}/mm/God && ./Lists; cd \"${OLDPWD}\""
alias ach="cd ${HOME}/mm/God && ./Ach; cd \"${OLDPWD}\""
alias god="cd ${HOME}/mm/God && ./God; cd \"${OLDPWD}\""
alias diy="cd ${HOME}/mm/diy/.Idea_list && ./diy; cd \"${OLDPWD}\""
alias cddpp="cdd_postprocessor.py"
alias music="ls ${HOME}/Music | shuf -n 1 --random-source=/dev/urandom"
alias mm="xdg-open ${HOME}/mm/."
alias downloadstories-folder="xdg-open ${HOME}/mm/Python/bots/downloaders/instagram/."
alias god-e="${EDITOR} ${HOME}/mm/C++/God/main.cpp"
alias xmrig="sudo ${HOME}/mm/biz/monero/xmrig-6.9.0/xmrig"
alias curlency="curl -X GET https://openexchangerates.org/api/latest.json?app_id=1b356f1e65e24ddb8d56a73c1da2d900"
alias books="xdg-open ${HOME}/mm/Archive/text/books/"
alias ekke="xdg-open ${HOME}/mm/házidolgozatok/EKKE"
alias órarend="ristretto ~/mm/házidolgozatok/EKKE/órarend"
alias xonotic="cd Xonotic; cd ./Xonotic; ./xonotic-linux64-sdl"
# Aliassed Scripts
alias mkdirs="${HOME}/mm/Linux/Bash/Aliased_scripts/mkdirs.sh"
alias txt="${HOME}/mm/Linux/Bash/Aliased_scripts/txt.txt.sh"
alias downloadstories="python3 ${HOME}/mm/Python/bots/downloaders/instagram/story_dowloader.py"
#########################
#####################
### FUNCTIONS ###
#####################
function mkdircd() { mkdir -p "$@" && eval cd "\"\$$#\""; }
function cdu() {
if [[ $# -eq 0 ]]; then
cd ..
return
fi
for ((i=0 ; i <= $# ; i++)); do
cd ..
done
}
function f() {
fff "$@"
cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")"
}
#########################
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
#neofetch

View File

@ -0,0 +1,317 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
##########################################################################
####################
### BUILTINS ###
####################
enable -n echo
## ## ## ## ## ##
####################
### SETTINGS ###
####################
## GLOBS ##
# With this set, the glob matches hidden files (".*") by default,
# but not the . or .. links.
shopt -s dotglob
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# Enable additional globs. Resulting in what is effectively a Regex
# language builtin to Bash.
shopt -s extglob
## ## ## ## ## ##
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, minor errors in the spelling of a directory component in a cd
# command will be corrected. The errors checked for are transposed characters,
# a missing character, and a character too many.
shopt -s cdspell
# Make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Set variable identifying the chroot you work in (used in the prompt below)
#if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
# debian_chroot=$(cat /etc/debian_chroot)
#fi
## PROMPT ##
# Set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# Uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
# Deffault Kali shit. ?!
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
# Fancy prompts
if [ "$color_prompt" = yes ]; then
prompt_color='\[\033[;32m\]'
info_color='\[\033[1;34m\]'
# 🩓
prompt_symbol=♞
if [ "$EUID" -eq 0 ]; then # Change prompt colors for root user
prompt_color='\[\033[;94m\]'
info_color='\[\033[1;31m\]'
prompt_symbol=♛
fi
PS1=$prompt_color'┌──${debian_chroot:+($debian_chroot)──}('$info_color'\u${prompt_symbol}\h'$prompt_color')-[\[\033[0;1m\]\w'$prompt_color']\n'$prompt_color'└─'$info_color'\$\[\033[0m\] '
PS2=$prompt_color'>\[\033[0m\]'
# BackTrack red prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
## ## ## ## ## ##
### MISC LOOKS ###
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# Enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
fi
# Colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
## ## ## ## ## ##
# Turn on vi mode
set -o vi
### HISTORY ###
HISTCONTROL=erasedups # remove duplicates
shopt -s histappend # append to the history file, don't overwrite it
shopt -s lithist # save multiline commands with embeded newlines
HISTSIZE=1000
HISTFILESIZE=2000
HISTTIMEFORMAT='%y/%m/%d %T: '
## ## ## ## ## ##
### MISC ###
# Do not imidietly exit on "<Ctrl> + d"
IGNOREEOF=3
## ## ## ## ## ##
#########################
#####################
### VARIABLES ###
#####################
FOO="bar"
export EDITOR="vim"
export VISUAL="vim"
BROWSER="firefox"
export auto_resume=1
export PATH="${PATH}:~/mm/bin"
CDPATH="${HOME}/mm"
export PYTHONPATH="${PYTHONPATH}~/mm/lib"
export FFF_HIDDEN=1 # show hidden (how counterintuitive...)
export FFF_LS_COLORS=1
#export FFF_OPENER="openie"
export FFF_FILE_FORMAT=" %f"
export FFF_FAV1="${HOME}/mm/"
export FFF_FAV2="${HOME}"
#export FFF_FAV1="~/Deskop/minecraft\ mod/"
export NNN_PRUG="p:preview-tabbed;o:organize"
GPG_TTY=$(tty)
export GPG_TTY
export PINENTRY_USER_DATA="USE_CURSES=1"
#########################
###################
### ALIASES ###
###################
# Output controll:
# Core
alias ls='ls -a --color=auto'
alias ll='ls -l -F'
alias l='ls -CF'
alias cp='cp -v'
alias mv='mv -v'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias echo='echo -e'
alias diff='diff -s -y -t --color=auto' # report identical; side-by-side; expand tabs; color
alias hexedit='hexedit --color'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias df='df --print-type'
alias ip='ip --color=auto'
# GNU
alias tar='tar -v'
alias gzip='gzip -v'
alias gdb='gdb -q'
# PKG managment
alias pacman='pacman --color=auto'
alias yay='yay --color=auto'
# Misc.
alias bat='bat --paging=never --italic-text always'
#alias nnn='nnn -d -H -x'
alias xclip='xclip -selection clipboard'
alias tt="tt -t 60 -bold -n 120 -g 120 -nobackspace -noskip -oneshot -csv -blockcursor -theme slate"
alias wget='wget --restrict-file-names=windows,ascii'
alias tshark='tshark --color'
# Ease of use
alias sudo='sudo '
alias cls="clear"
alias mkdir="mkdir -p"
alias cdb="cd \"${OLDPWD}\""
alias close="exit"
alias quit="exit"
alias figlet="figlet -w 120 -d ~/mm/Fonts/figlet-fonts/"
alias heavyDuty=". ~/.heavyDutyrc"
alias locatei="locate -i"
# Safety
alias rm='rm -I'
alias gpg='gpg -i --no-symkey-cache'
#alias youtube-dl='youtube-dl --restrict-filenames --no-overwrites'
alias yt-dlp='yt-dlp --restrict-filenames --no-overwrites'
#alias tar='tar --verify'
# Vimification
alias :e="${EDITOR}"
alias :q="exit"
alias :qa="xdotool getactivewindow windowkill"
# Shortcuts
alias bashrc="${EDITOR} ${HOME}/.bashrc"
alias vimrc="${EDITOR} ${HOME}/.vimrc"
alias pufka="${EDITOR} ${HOME}/mm/C++/pufka.cdd"
alias owned-tech="${EDITOR} ${HOME}/mm/Personal/owned.db/tech.list"
alias msgbuffer="${EDITOR} ${HOME}/mm/Personal/Msg/msg.buf"
alias stibuffer="${EDITOR} ${HOME}/mm/Personal/Notes/short-term_ideas.buf"
alias todo="cd ${HOME}/mm/God && ./todo; cd \"${OLDPWD}\""
alias toget="cd ${HOME}/mm/God && ./toget; cd \"${OLDPWD}\""
alias devl="cd ${HOME}/mm/God && ./devl; cd \"${OLDPWD}\""
alias list="cd ${HOME}/mm/God && ./Lists; cd \"${OLDPWD}\""
alias ach="cd ${HOME}/mm/God && ./Ach; cd \"${OLDPWD}\""
alias god="cd ${HOME}/mm/God && ./God; cd \"${OLDPWD}\""
alias diy="cd ${HOME}/mm/diy/.Idea_list && ./diy; cd \"${OLDPWD}\""
alias cddpp="cdd_postprocessor.py"
alias music="ls ${HOME}/Music | shuf -n 1 --random-source=/dev/urandom"
alias mm="xdg-open ${HOME}/mm/."
alias downloadstories-folder="xdg-open ${HOME}/mm/Python/bots/downloaders/instagram/."
alias god-e="${EDITOR} ${HOME}/mm/C++/God/main.cpp"
alias xmrig="sudo ${HOME}/mm/biz/monero/xmrig-6.9.0/xmrig"
alias curlency="curl -X GET https://openexchangerates.org/api/latest.json?app_id=1b356f1e65e24ddb8d56a73c1da2d900"
alias books="xdg-open ${HOME}/mm/Archive/text/books/"
alias ekke="xdg-open ${HOME}/mm/házidolgozatok/EKKE"
alias órarend="ristretto ~/mm/házidolgozatok/EKKE/órarend"
alias xonotic="cd Xonotic; cd ./Xonotic; ./xonotic-linux64-sdl"
# Aliassed Scripts
alias mkdirs="${HOME}/mm/Linux/Bash/Aliased_scripts/mkdirs.sh"
alias txt="${HOME}/mm/Linux/Bash/Aliased_scripts/txt.txt.sh"
alias downloadstories="python3 ${HOME}/mm/Python/bots/downloaders/instagram/story_dowloader.py"
#########################
#####################
### FUNCTIONS ###
#####################
function mkdircd() { mkdir -p "$@" && eval cd "\"\$$#\""; }
function cdu() {
if [[ $# -eq 0 ]]; then
cd ..
return
fi
for ((i=0 ; i <= $# ; i++)); do
cd ..
done
}
function f() {
fff "$@"
cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")"
}
#########################
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
#neofetch

299
bash/.bashrc.d/.Trash/.bashrc_... Executable file
View File

@ -0,0 +1,299 @@
#neofetch
case $- in # If not running interactively, don't do anything
*i*) ;;
*) return;;
esac
####################
### BUILTINS ###
####################
enable -n echo
## ## ## ## ## ##
####################
### SETTINGS ###
####################
## GLOBS ##
shopt -s dotglob # With this set, the glob matches hidden files (".*") by default,
# but not the . or .. links.
shopt -s globstar # If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s extglob # Enable additional globs. Resulting in what is effectively a Regex
# language builtin to Bash.
## PROMPT ##
# Set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# Uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
# Deffault Kali shit. ?!
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
# Fancy prompts
if [ "$color_prompt" = yes ]; then
prompt_color='\[\033[;32m\]'
info_color='\[\033[1;34m\]'
prompt_symbol=♞ # 🩓
if [ "$EUID" -eq 0 ]; then # Change prompt colors for root user
prompt_color='\[\033[;94m\]'
info_color='\[\033[1;31m\]'
prompt_symbol=♛
fi
PS1=$prompt_color'┌──${debian_chroot:+($debian_chroot)──}('$info_color'\u${prompt_symbol}\h'$prompt_color')-[\[\033[0;1m\]\w'$prompt_color']\n'$prompt_color'└─'$info_color'\$\[\033[0m\] '
PS2=$prompt_color'>\[\033[0m\]'
# BackTrack red prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# Enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
fi
## HISTORY ##
HISTCONTROL=erasedups # remove duplicates
shopt -s histappend # append to the history file, don't overwrite it
shopt -s lithist # save multiline commands with embeded newlines
HISTSIZE=1000
HISTFILESIZE=2000
HISTTIMEFORMAT='%y/%m/%d %T: '
shopt -s checkwinsize # check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s cdspell # If set, minor errors in the spelling of a directory component in a cd
# command will be corrected. The errors checked for are transposed characters,
# a missing character, and a character too many.
set -o vi # Turn on vi mode
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" # Make less more friendly for non-text input files, see lesspipe(1)
#if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then # Set variable identifying the chroot you work in (used in the prompt below)
# debian_chroot=$(cat /etc/debian_chroot)
#fi
## ## ## ## ## ##
#####################
### VARIABLES ###
#####################
#FOO="bar"
## DEFAULT APPLICATIONS ##
export EDITOR="vim"
export VISUAL="vim"
BROWSER="firefox"
IMG_VIEWER="nomacs"
## PATHS ##
MM="${HOME}/mm"
CDPATH="${MM}"
export PATH="${PATH}:~/mm/bin"
export PYTHONPATH="${PYTHONPATH}~/mm/lib"
## PROGRAMS ##
# gcc #
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# gpg #
GPG_TTY=$(tty)
export GPG_TTY
export PINENTRY_USER_DATA="USE_CURSES=1"
# fff #
#export FFF_HIDDEN=1 # show hidden (how counterintuitive...)
#export FFF_LS_COLORS=1
##export FFF_OPENER="openie"
#export FFF_FILE_FORMAT=" %f"
#export FFF_FAV1="${MM}/"
#export FFF_FAV2="${HOME}"
##export FFF_FAV1="~/Deskop/minecraft\ mod/"
#export NNN_PRUG="p:preview-tabbed;o:organize"
## MISC ##
export auto_resume=1
IGNOREEOF=3
#########################
###################
### ALIASES ###
###################
# Output controll:
# Core
alias ls='ls -a --color=auto'
alias ll='ls -l -F'
alias l='ls -CF'
alias cp='cp -v'
alias mv='mv -v'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias echo='echo -e'
alias diff='diff -s -y -t --color=auto' # report identical; side-by-side; expand tabs; color
alias hexedit='hexedit --color'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias df='df --print-type'
alias ip='ip --color=auto'
# GNU
alias tar='tar -v'
alias gzip='gzip -v'
alias gdb='gdb -q'
# PKG managment
alias pacman='pacman --color=auto'
alias yay='yay --color=auto'
# Misc.
alias bat='bat --paging=never --italic-text always'
#alias nnn='nnn -d -H -x'
alias xclip='xclip -selection clipboard'
alias tt="tt -t 60 -bold -n 120 -g 120 -nobackspace -noskip -oneshot -csv -blockcursor -theme slate"
alias wget='wget --restrict-file-names=windows,ascii'
alias tshark='tshark --color'
# Ease of use
alias sudo='sudo '
alias cls="clear"
alias mkdir="mkdir -p"
alias cdb="cd \"${OLDPWD}\""
alias close="exit"
alias quit="exit"
alias figlet="figlet -w 120 -d ~/mm/Fonts/figlet-fonts/"
alias heavyDuty=". ${MM}/Bash/Bashrc/.heavyDutyrc"
alias locatei="locate -i"
# Safety
alias rm='rm -I'
alias gpg='gpg -i --no-symkey-cache'
#alias youtube-dl='youtube-dl --restrict-filenames --no-overwrites'
alias yt-dlp='yt-dlp --restrict-filenames --no-overwrites'
#alias tar='tar --verify'
# Vimification
alias :e="${EDITOR}"
alias :q="exit"
alias :qa="xdotool getactivewindow windowkill"
# Shortcuts
alias music="ls ${HOME}/Music | shuf -n 1 --random-source=/dev/urandom"
alias downloadstories-folder="xdg-open ${MM}/Python/bots/downloaders/instagram/."
alias god-e="${EDITOR} ${MM}/C++/God/main.cpp"
alias xmrig="sudo ${MM}/biz/monero/xmrig-6.9.0/xmrig"
alias curlency="curl -X GET https://openexchangerates.org/api/latest.json?app_id=1b356f1e65e24ddb8d56a73c1da2d900"
alias órarend="${IMG_VIEWER} ~/mm/házidolgozatok/EKKE/órarend"
# Folders
alias books="xdg-open ${MM}/Archive/text/books/"
alias ekke="xdg-open ${MM}/házidolgozatok/EKKE"
alias mm="xdg-open ${MM}/."
# Files with editor
alias bashrc="${EDITOR} ${HOME}/.bashrc"
alias vimrc="${EDITOR} ${HOME}/.vimrc"
alias pufka="${EDITOR} ${MM}/C++/pufka.cdd"
alias owned-tech="${EDITOR} ${MM}/Personal/owned.db/tech.list"
alias msgbuffer="${EDITOR} ${MM}/Personal/Msg/msg.buf"
alias stibuffer="${EDITOR} ${MM}/Personal/Notes/short-term_ideas.buf"
# Programs
# Games
alias xonotic="cd Xonotic; cd ./Xonotic; ./xonotic-linux64-sdl"
# Lists
alias todo="cd ${MM}/God && ./todo; cd \"${OLDPWD}\""
alias toget="cd ${MM}/God && ./toget; cd \"${OLDPWD}\""
alias devl="cd ${MM}/God && ./devl; cd \"${OLDPWD}\""
alias list="cd ${MM}/God && ./Lists; cd \"${OLDPWD}\""
alias ach="cd ${MM}/God && ./Ach; cd \"${OLDPWD}\""
alias god="cd ${MM}/God && ./God; cd \"${OLDPWD}\""
alias diy="cd ${MM}/diy/.Idea_list && ./diy; cd \"${OLDPWD}\""
# Scripts
alias txt="txt.txt.sh"
alias cddpp="cdd_postprocessor.py"
alias mkdirs="${MM}/Linux/Bash/Aliased_scripts/mkdirs.sh"
alias downloadstories="python3 ${MM}/Python/bots/downloaders/instagram/story_dowloader.py"
#########################
#####################
### FUNCTIONS ###
#####################
function mkdircd() { mkdir -p "$@" && eval cd "\"\$$#\""; }
function cdu() {
if [[ $# -eq 0 ]]; then
cd ..
return
fi
for ((i=0 ; i <= $# ; i++)); do
cd ..
done
}
function f() {
fff "$@"
cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")"
}
#########################
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi

View File

@ -0,0 +1,13 @@
# Sourced by alias "heavyDuty"
clear
date
neofetch
prompt_color='\033[;33m'
info_color='\033[1;37m'
prompt_symbol=♜
export PS1=$prompt_color'┌──${debian_chroot:+($debian_chroot)──}('$info_color'\u${prompt_symbol}\h'$prompt_color')-[\[\033[0;1m\]\w'$prompt_color']\n'$prompt_color'└─'$info_color'#\[\033[0m\] '
PS2=$prompt_color'>\[\033[0m\]'
GRC_ALIASES=true
[[ -s "/etc/profile.d/grc.sh" ]] && source /etc/profile.d/grc.sh

View File

@ -0,0 +1,20 @@
alias ls='ls -a --color=always'
alias ll='ls -l'
alias l='ls -CF'
alias cls="clear"
alias close="exit"
alias quit="exit"
alias galamb-e="mousepad /home/jacob/Desktop/minecraft\ mod/kutatás/people/Galambok/Galambok.html"
alias galamb-f="firefox /home/jacob/Desktop/minecraft\ mod/kutatás/people/Galambok/Galambok.html"
alias galamb-cd="cd /home/jacob/Desktop/minecraft\ mod/kutatás/people/Galambok/"
alias galamb="xdg-open /home/jacob/Desktop/minecraft\ mod/kutatás/people/Galambok/."
alias galamb-pic="xdg-open /home/jacob/Desktop/minecraft\ mod/kutatás/people/Galambok/.scouce/képek/Vera/61220426_2313354255572080_6214017971581353984_o.jpg"
alias alias-e="mousepad /home/jacob/.bashrc"
alias downloadstories="python3 /home/jacob/Desktop/minecraft\ mod/Python/bots/dowloaders/instagram/story_dowloader.py"
alias downloadstories-folder="xdg-open /home/jacob/Desktop/minecraft\ mod/Python/bots/dowloaders/instagram/."
alias music="cd ~/Music/ && ls | shuf -n 1"
alias mm="xdg-open /home/jacob/Desktop/minecraft\ mod/."
alias txt="mousepad /home/jacob/Desktop/minecraft\ mod/C++/pufka.txt /home/jacob/Desktop/minecraft\ mod/Archive/text/a_self-made/RANDOM.txt /home/jacob/Desktop/minecraft\ mod/Archive/text/a_self-made/quotes.txt /home/jacob/Desktop/minecraft\ mod/Archive/text/a_self-made/regény/Repesz/REPESZ.txt"
alias exif.sh="bash /home/jacob/Desktop/minecraft\ mod/Linux/exif.sh"
alias god="cd ~/Desktop/minecraft\ mod/C++/God/ && ./God"
alias toupper="~/Desktop/minecraft\ mod/C++/toupper/toupper.out"

View File

@ -0,0 +1,24 @@
MACHINE_NAME=""
# Head
source ~/Main/Bash/Bashrc/.bashrc_-_head
# Bash behaviour setting
source ~/Main/Bash/Bashrc/.bashrc_-_personal_vars
source ~/Main/Bash/Bashrc/.bashrc_-_paths
source ~/Main/Bash/Bashrc/.bashrc_-_builtin
source ~/Main/Bash/Bashrc/.bashrc_-_glob
source ~/Main/Bash/Bashrc/.bashrc_-_winsize
source ~/Main/Bash/Bashrc/.bashrc_-_ignoreeof
# Bash looks
source ~/Main/Bash/Bashrc/.bashrc_-_${MACHINE_NAME}_prompt
source ~/Main/Bash/Bashrc/.bashrc_-_program_looks
# Short cutting
source ~/Main/Bash/Bashrc/.bashrc_-_alias
source ~/Main/Bash/Bashrc/.bashrc_-_vimification
# Core behavour overriding
source ~/Main/Bash/Bashrc/.bashrc_-_history
source ~/Main/Bash/Bashrc/.bashrc_-_cd
source ~/Main/Bash/Bashrc/.bashrc_-_auto_completion
# Periphery behaviour setting
source ~/Main/Bash/Bashrc/.bashrc_-_gpg
source ~/Main/Bash/Bashrc/.bashrc_-_fzf

View File

@ -0,0 +1,19 @@
# Set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi
# Fancy prompts
if [ "$color_prompt" = yes ]; then
prompt_color='\[\033[1;32m\]'
fi
PS1=$prompt_color' ─▶\[\033[0m\] '
PS2=$prompt_color' >\[\033[0m\] '
unset color_prompt force_color_prompt

View File

@ -0,0 +1,3 @@
prompt_color='\[\033[1;32m\]'
PS1=$prompt_color' ─▶\[\033[0m\] '
PS2=$prompt_color' >\[\033[0m\] '

View File

@ -0,0 +1,31 @@
alias xclip='xclip -selection clipboard'
# Ease of use
alias s='sudo'
alias cbash='bash --norc --noprofile --init-file <(echo "unset HISTFILE")'
alias history='history | tail -n 10'
alias cls="clear"
alias mkdir="mkdir -p"
alias hgrep="\\history | grep"
alias close="exit"
alias quit="exit"
alias figlet="figlet -w 120 -d ~/mm/Fonts/figlet-fonts/"
alias heavyDuty=". ${MM}/Bash/Bashrc/.heavyDutyrc"
alias locatei="locate -i"
alias resource="source /home/anon/.bashrc"
alias mysql="mysql --user=${USER} -p"
alias tmux="export LINES=${LINES}; export COLUMNS=${COLUMNS}; tmux attach || tmux"
# Safety
alias wget='wget --restrict-file-names=windows,ascii'
alias rm='rm -I'
alias gpg='gpg -i --no-symkey-cache'
alias yt-dlp='yt-dlp --restrict-filenames --no-overwrites'
# Quick access
alias tt="tt_with_high_score.sh"
alias txt="txt.txt.sh"
# Files with editor
alias bashrc="${EDITOR} ${HOME}/.bashrc"
alias vimrc="${EDITOR} ${HOME}/.vimrc"
alias tmuxrc="${EDITOR} .tmux.conf"
alias pufka="${EDITOR} ${MM}/C++/pufka.cdd"
alias random="${EDITOR} ${MM}/Personal/RANDOM.outpost.txt"
alias msgbuffer="${EDITOR} ${MM}/Personal/Msg/msg.buf"

View File

@ -0,0 +1,74 @@
CTRLFMODE="path"
CTRLCACHE="/home/anon/Desktop/"
function ctrl_f_mode(){
read -n 1 M
case $M in
p) CTRLFMODE="path";;
u) CTRLFMODE="user";;
o) CTRLFMODE="opt";;
c) CTRLFMODE="cmd" ;;
v) CTRLFMODE="var" ;;
*) CTRLFMODE="path";;
esac
env echo -e "\033[1mctrl-f mode: \"\033[0m${CTRLFMODE}\""
}
function echo_readline_line(){
PS1_CLEANED=${PS1//\\\[/}
PS1_CLEANED=${PS1_CLEANED//\\\]/}
env echo -e "${PS1_CLEANED}${1:0:${2}}\033[45m \033[0m${1:${2}}"
#env echo -e "${PS1}${1:0:${2}}\033[45m \033[0m${1:${2}}"
}
function ctrl_f(){
# Show command and substitution position
echo_readline_line "${READLINE_LINE}" "${READLINE_POINT}"
# Get narrowing substring
PX=""
if [ "${READLINE_LINE:$(expr $READLINE_POINT - 1):1}" != " " ]; then
PX=$(/home/anon/Main/C++/Holy/bash_auto_completion/out/last_word "${READLINE_LINE:0:${READLINE_POINT}}")
fi
#echo "'$PX'"
# Decide possible completions and use fzf for selection
case $CTRLFMODE in
"path")
if [ "$PX" != "" ]; then
STR=$(find "$PX" 2> /dev/null | fzf --multi=1)
else
STR=$(find 2> /dev/null | fzf --multi=1)
fi
;;
"opt")
#get command
#check catche
#parse
;;
"user")
if [ "$PX" != "" ]; then
STR="$(compgen -u ${PX} | fzf --multi=1)"
else
STR="$(compgen -u | fzf --multi=1)"
fi
;;
"cmd")
if [ "$PX" != "" ]; then
STR="$(compgen -c ${PX} | uniq | fzf --multi=1)"
else
STR="$(compgen -c | uniq | fzf --multi=1)"
fi
;;
"var")
if [ "$PX" != "" ]; then
STR="$(compgen -v ${PX} | fzf --multi=1)"
else
STR="$(compgen -v | fzf --multi=1)"
fi
;;
esac
# Remove ${PX}
STR="${STR:${#PX}}"
# Write $READLINE_LINE
READLINE_LINE="${READLINE_LINE:0:$(expr ${READLINE_POINT} - ${#PX})}\"${PX}${STR}\"${READLINE_LINE:${READLINE_POINT}}" # start_til_px + '"' + px + str '"' + rest
READLINE_POINT=$(expr ${READLINE_POINT} + ${#STR} + 2) # +2 for the '"'s
}
bind -x '"\C-e": ctrl_f_mode'
bind -x '"\C-f": ctrl_f'

View File

@ -0,0 +1 @@
enable -n echo

View File

@ -0,0 +1,38 @@
function mkdircd() {
mkdir -p "$@" && eval cd "\"\$$#\"";
}
function cdUp() {
if [[ $# -eq 0 ]]; then
cd ..
return
fi
for ((i=0 ; i <= $# ; i++)); do
cd ..
done
}
function PushdAlias() {
\pushd "$@" > /dev/null && dirs
}
function PopdAlias() {
\popd "$@" > /dev/null && dirs
}
function DirsAlias() {
if [ $# == 0 ]; then
\dirs | awk -v ln=0 '{ for(i=1; i<=NF; i++) print " \033[1;36m" ln++ ":\033[0m " $i }'
else
\dirs "$@"
fi
}
shopt -s cdspell # If set, minor errors in the spelling of a directory component in a cd
# command will be corrected. The errors checked for are transposed characters,
# a missing character, and a character too many.
alias cd="PushdAlias"
alias cdh="cd ~"
alias cdu="cdUp"
alias pop="popd"
alias popd="PopdAlias"
alias dirs="DirsAlias"

View File

@ -0,0 +1 @@
export FZF_DEFAULT_OPTS="--no-mouse --height=10 --layout=reverse -1"

View File

@ -0,0 +1,6 @@
shopt -s dotglob # With this set, the glob matches hidden files (".*") by default,
# but not the . or .. links.
shopt -s globstar # If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s extglob # Enable additional globs. Resulting in what is effectively a Regex
# language builtin to Bash.

View File

@ -0,0 +1,3 @@
GPG_TTY=$(tty)
export GPG_TTY
export PINENTRY_USER_DATA="USE_CURSES=1"

View File

@ -0,0 +1,9 @@
#neofetch
case $- in # If not running interactively, don't do anything
*i*) ;;
*) return;;
esac
#cd ~

View File

@ -0,0 +1,8 @@
HISTCONTROL=erasedups # remove duplicates
shopt -s histappend # append to the history file, don't overwrite it
shopt -s lithist # save multiline commands with embeded newlines
HISTSIZE=1000
HISTFILESIZE=2000
HISTTIMEFORMAT='%y/%m/%d %T: '
HISTFILE="${MM}/Bash/History/.bash_history"
PROMPT_COMMAND="\history -a;$PROMPT_COMMAND"

View File

@ -0,0 +1 @@
IGNOREEOF=3

View File

@ -0,0 +1,4 @@
MM="/home/anon/Main"
export CDPATH="${MM}"
export PATH="${PATH}:${MM}/bin"
export MKTEMPLATE_HOME="${MM}/Templates/mktemplate_home/"

View File

@ -0,0 +1,10 @@
## DEFAULT APPLICATIONS ##
export EDITOR="vim"
export VISUAL="vim"
export BROWSER="firefox"
export PAGER="less"
export IMG_VIEWER="nomacs"
## Favourites ##
export FAVCOL="green"
export FAVCHAR="♞"

View File

@ -0,0 +1,49 @@
# Enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
fi
### ALIAS BASED ###
# Core
alias ls='ls -a --color=auto'
alias ll='ls -l -F'
alias l='ls -CF'
alias cp='cp -v'
alias mv='mv -v'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias echo='echo -e'
alias diff='diff -s -y -t --color=auto' # report identical; side-by-side; expand tabs; color
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias lsblk='lsblk -o NAME,SIZE,RM,RO,TYPE,FSTYPE,MOUNTPOINTS'
alias df='df --print-type'
alias ip='ip --color=auto'
# GNU
alias cal='cal --monday'
alias tar='tar -v'
alias gzip='gzip -v'
alias gdb='gdb -q --tui'
alias less='less --use-color'
# Misc.
alias hexedit='hexedit --color'
alias bat='bat --paging=never --italic-text always'
alias tshark='tshark --color'
alias mycli="mycli --prompt \"${MYCLI_PS1}\""
### VARIABLE BASED ###
# mysql #
export MYSQL_PS1=$(env echo -e "\033[1;32m#\033[34m\\U\033[0;1m:\033[32m[\033[0m\\d\033[1;32m]>\033[0m\\_")
MYCLI_PS1=${MYSQL_PS1//\\U/\\u}
# gcc #
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# fzf #
export FZF_DEFAULT_OPTS="--multi --no-mouse --height=10 --layout=reverse"

View File

@ -0,0 +1,5 @@
set -o vi # Turn on vi mode
alias :e="${EDITOR}"
alias :q="exit"
alias :qa="xdotool getactivewindow windowkill"

View File

@ -0,0 +1,2 @@
shopt -s checkwinsize # check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.

51
bash/.bashrc.d/.alias.rc Executable file
View File

@ -0,0 +1,51 @@
#!/bin/bash
alias xclip='xclip -selection clipboard'
# Ease of use
# single char
alias c="cd"
alias g="egrep -i"
alias s='sudo'
alias l='ls'
alias v="${EDITOR}"
alias w="personal_watch" # defined else where too
# Two char
alias wi="whereis"
# # #
alias cbash='bash --norc --noprofile --init-file <(echo "unset HISTFILE")'
alias history='history | tail -n 10'
alias cls="clear; env echo -e \"${FAVCOLESC}###\033[0m\"; dirs"
alias mkdir="mkdir -p"
alias hgrep="\\history | grep"
alias close="exit"
alias quit="exit"
alias figlet="figlet -w 120 -d ${MM}/Fonts/figlet-fonts/"
alias heavyDuty=". ${MM}/Bash/Bashrc/.heavyDutyrc"
alias locatei="locate -i"
alias resource="source /home/anon/.bashrc"
alias mysql="mysql --user=${USER} -p"
alias tmux="export LINES=${LINES}; export COLUMNS=${COLUMNS}; tmux new-session -t '0' || tmux"
# Safety
alias wget='wget --restrict-file-names=windows,ascii'
alias rm='rm -I'
alias gpg='gpg -i --no-symkey-cache'
alias yt-dlp='yt-dlp --restrict-filenames --no-overwrites'
# Unsafety
alias curl='curl --insecure'
# Quick access
alias tt="tt_with_high_score.sh"
alias txt="vim \"${MM}/C++/pufka.cdd\" \"${MM}/Personal/RANDOM.txt\" \"${MM}/Archive/text/a_self-made/quotes.txt\" \"${MM}/Peak/peak.cdd\" \"${MM}/s/процесс.log\""
# Files with editor
alias bashrc="${EDITOR} ${HOME}/.bashrc"
alias vimrc="${EDITOR} ${HOME}/.vimrc"
alias tmuxrc="${EDITOR} ${HOME}/.tmux.conf"
alias pufka="${EDITOR} ${MM}/pufka/pufka.cdd"
if [ "${MACHINE_NAME}" != "BATTLESTATION" ]; then
alias random="${EDITOR} ${MM}/Personal/RANDOM.outpost.txt"
else
alias random="${EDITOR} ${MM}/Personal/RANDOM.txt"
fi
alias msgbuffer="${EDITOR} ${MM}/Personal/Msg/msg.buf"
# Listas
for i in $(lista -l 2> /dev/null); do
alias $i="lista -s '$i'"
done

87
bash/.bashrc.d/.bash_fzfind.rc Executable file
View File

@ -0,0 +1,87 @@
#!/bin/bash
[ -z "$CTRLFMODE" ] && CTRLFMODE="path"
[ -z "$CTRLFMETHOD" ] && CTRLFMETHOD="find"
#CTRLCACHE="/home/anon/Desktop/"
function ctrl_f_mode(){
read -n 1 M
case $M in
p) CTRLFMODE="path";;
u) CTRLFMODE="user";;
o) CTRLFMODE="opt";;
c) CTRLFMODE="cmd" ;;
v) CTRLFMODE="var" ;;
*) CTRLFMODE="path";;
esac
env echo -e "\033[1mctrl-f mode: \"\033[0m${CTRLFMODE}\""
}
function echo_readline_line(){
PS1_CLEANED="${PS1//\\\[/}"
PS1_CLEANED="${PS1_CLEANED//\\\]/}"
env echo -e "${PS1_CLEANED}${1:0:${2}}\033[45m \033[0m${1:${2}}"
#env echo -e "${PS1}${1:0:${2}}\033[45m \033[0m${1:${2}}"
}
function ctrl_f(){
# Show command and substitution position
echo_readline_line "${READLINE_LINE}" "${READLINE_POINT}"
# Get narrowing substring
OPX=""
if [ "${READLINE_LINE:$(expr $READLINE_POINT - 1):1}" != " " ]; then
OPX=$(lastWord "${READLINE_LINE:0:${READLINE_POINT}}")
fi
#echo "'$PX'"
# Decide possible completions and use fzf for selection
case $CTRLFMODE in
"path")
if [ $CTRLFMETHOD == "find" ]; then
PX="$OPX"
STR=$(eval find ./"$PX/" 2> /dev/null | fzf --multi=1)
elif [ $CTRLFMETHOD == "locate" ]; then
PX="$(realpath $PWD/$OPX)"
STR=$(eval locate --existing --regex $PX/'.*' 2> /dev/null | fzf --multi=1)
else
echo -e "\033[31;1mNonsensical \033[34;1m\${CTRLFMETHOD} \033[31;1mvalue.\033[0m"
fi
;;
"opt")
#get command
#check catche
#parse
;;
"user")
if [ "$PX" != "" ]; then
STR="$(compgen -u ${PX} | fzf --multi=1)"
else
STR="$(compgen -u | fzf --multi=1)"
fi
;;
"cmd")
if [ "$PX" != "" ]; then
STR="$(compgen -c ${PX} | uniq | fzf --multi=1)"
else
STR="$(compgen -c | uniq | fzf --multi=1)"
fi
;;
"var")
if [ "$PX" != "" ]; then
STR="$(compgen -v ${PX} | fzf --multi=1)"
else
STR="$(compgen -v | fzf --multi=1)"
fi
;;
esac
# Remove ${PX}
STR="${STR/${PX}/}"
# Write $READLINE_LINE
[ -z "$STR" ] && return
if [ "$CTRLFMODE" == "path" ]; then # quote paths
READLINE_LINE="${READLINE_LINE:0:$(expr ${READLINE_POINT} - ${#OPX})}\"${OPX}${STR}\"${READLINE_LINE:${READLINE_POINT}}" # start_til_px + '"' + px + str '"' + rest
READLINE_POINT=$(expr ${READLINE_POINT} + ${#OPX} + ${#STR} + 2) # +2 for the '"'s
else
READLINE_LINE="${READLINE_LINE:0:$(expr ${READLINE_POINT} - ${#OPX})}${OPX}${STR}${READLINE_LINE:${READLINE_POINT}}" # start_til_px + px + str + rest
READLINE_POINT=$(expr ${READLINE_POINT} + ${#OPX} + ${#STR})
fi
}
bind -x '"\C-e": ctrl_f_mode'
bind -x '"\C-f": ctrl_f'

30
bash/.bashrc.d/.bashrc Executable file
View File

@ -0,0 +1,30 @@
SRCF=~anon/Master/Bash/Bashrc/
MACHINE_NAME="$(cat ${SRCF}/MACHINE_NAME.val)"
# Personal
source ${SRCF}/Personal/.${USER}_personal.rc # ~/Master/Bash/Bashrc/Personal/.anon_personal.rc
source ${SRCF}/.def_apps.rc
source ${SRCF}/.paths.rc
# Bash behaviour setting
source ${SRCF}/.builtin.rc
source ${SRCF}/.glob.rc
source ${SRCF}/.winsize.rc
source ${SRCF}/.ignoreeof.rc
# Program looks
source ${SRCF}/.program_looks.rc
# Core behavour settings
source ${SRCF}/.core.rc
# Core behavour overriding
source ${SRCF}/.history.rc
source ${SRCF}/.cd.rc
# Periphery behaviour setting
source ${SRCF}/.gpg.rc
source ${SRCF}/.sudo.rc
# Short cutting
source ${SRCF}/.alias.rc
source ${SRCF}/.vimification.rc
source ${SRCF}/.signin.rc
# Widgets
source ${SRCF}/.neofetch.rc
source ${SRCF}/.w.rc # watch (clock)
source ~/Master/Bash/Bashrc/.bash_fzfind.rc

1
bash/.bashrc.d/.bc.rc Normal file
View File

@ -0,0 +1 @@
alias bc="bc -l"

4
bash/.bashrc.d/.binds.rc Normal file
View File

@ -0,0 +1,4 @@
bind -x '"\C-p": $(qckcmd -i ~/.qckcmd)'
#bind -x '"\C-p": eval $(qckcmd -i ~/.qckcmd)'
#bind -x '"\C-~": cd ~'
#bind -x '"\C-h": history'

2
bash/.bashrc.d/.builtin.rc Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
enable -n echo

61
bash/.bashrc.d/.cd.rc Executable file
View File

@ -0,0 +1,61 @@
#!/bin/bash
alias cd="PushdAlias"
alias cdh="cd ~"
alias cdu="cdUp"
alias pop="popd"
alias popd="PopdAlias"
alias dirs="DirsAlias"
function mkdircd() {
mkdir -p "$@" && eval cd "\"\$$#\"";
}
function cdUp() {
if [[ $# -eq 0 ]]; then
cd ..
return
fi
for ((i=0 ; i <= $# ; i++)); do
cd ..
done
}
function PushdAlias() {
if [ -d "$1" ]; then
\pushd "$1" > /dev/null
dirs
else
SPWD=$PWD
\pushd "$@" > /dev/null
[ $SPWD != $PWD ] && dirs
fi
}
function PopdAlias() {
if [[ $1 =~ ^[0-9]+$ ]]; then
for ((i=0 ; i < $1 ; i++)); do
\popd > /dev/null
done
dirs
return
fi
\popd "$@" > /dev/null && dirs
}
function DirsAlias() {
if [ $# == 0 ]; then
\dirs -p | awk -v ln=0 \
'{
if (system("test -d \"$(echo " $0 ")\""))
{ color="31"; }
else
{ color="36"; }
printf("\033[1;%sm%2d: \033[m%s\n", color, ln++, $0);
}'
else
\dirs "$@"
fi
}
shopt -s cdspell # If set, minor errors in the spelling of a directory component in a cd
# command will be corrected. The errors checked for are transposed characters,
# a missing character, and a character too many.

View File

@ -0,0 +1 @@
#source ~/.sdkman/candidates/springboot/current/shell-completion/bash/spring

2
bash/.bashrc.d/.core.rc Normal file
View File

@ -0,0 +1,2 @@
alias bc="bc -l"
stty -ixon # disable flow control and make ^S and ^Q available

7
bash/.bashrc.d/.def_apps.rc Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
## DEFAULT APPLICATIONS ##
export EDITOR="vim"
export VISUAL="vim"
export BROWSER="librewolf"
export PAGER="less"
export IMAGEVIEWER="nomacs"

7
bash/.bashrc.d/.glob.rc Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
shopt -s dotglob # With this set, the glob matches hidden files (".*") by default,
# but not the . or .. links.
shopt -s globstar # If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s extglob # Enable additional globs. Resulting in what is effectively a Regex
# language builtin to Bash.

4
bash/.bashrc.d/.gpg.rc Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
GPG_TTY=$(tty)
export GPG_TTY
export PINENTRY_USER_DATA="USE_CURSES=1"

9
bash/.bashrc.d/.history.rc Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
HISTCONTROL=erasedups # remove duplicates
shopt -s histappend # append to the history file, don't overwrite it
shopt -s lithist # save multiline commands with embeded newlines
HISTSIZE=10000
HISTFILESIZE=20000
HISTTIMEFORMAT='%y/%m/%d %T: '
HISTFILE="${MM}/Bash/History/.bash_history"
PROMPT_COMMAND="\history -a;$PROMPT_COMMAND"

2
bash/.bashrc.d/.ignoreeof.rc Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
IGNOREEOF=3

24
bash/.bashrc.d/.neofetch.rc Executable file
View File

@ -0,0 +1,24 @@
[ "$USER" == "anon" ] && return
if [ "$USER" == "root" ]; then
printf "${FAVCOLESC}
()
.-:--:-.
\____/
{====}
)__(
/____\
| |
| |
| |
| |
/____\
(======)
}======{
(________)
\033[0m"
return
fi
neofetch

10
bash/.bashrc.d/.nnn.rc Normal file
View File

@ -0,0 +1,10 @@
nnn_cd()
{
if ! [ -z "$NNN_PIPE" ]; then
printf "%s\0" "0c${PWD}" > "${NNN_PIPE}" !&
fi
}
trap nnn_cd EXIT
alias n="nnn"

29
bash/.bashrc.d/.paths.rc Normal file
View File

@ -0,0 +1,29 @@
#!/bin/bash
export MM="/home/anon/Master"
export CDPATH="${MM}"
export PATH="${PATH}:~/go/bin/:~/.cargo/bin/:${MM}/bin"
export MKTEMPLATE_HOME="${MM}/Templates/mktemplate_home/"
export QCKSWP_SAVES="${MM}/Qckswp/.qckswp.csv"
export LISTAHOME="${MM}/Lista/.lista/data/"
# array of essential files
export ESSENTIALS=(
"${MM}/pufka/pufka.cdd"
"${MM}/Personal/quotes.txt"
"${MM}/Personal/Notes/jelszo"
"${MM}/Peak/peak.cdd"
"${MM}/s/процесс.log"
)
# array of personal config files/directories
export RCCONFIG=(
"${MM}/Bash/Bashrc/"
"${MM}/Vim/Vimrc/"
"${MM}/Tmux/Tmuxrc/.tmux.conf"
"${MM}/ImageBoards/Storage/"
"${MM}/Personal/Wallpaper/"
"$MKTEMPLATE_HOME"
"$QCKSWP_SAVES"
"$LISTAHOME"
"${MM}/Fonts/figlet-fonts/"
)
# start page for lynx and possibly other browsers
export WWW_HOME="${HOME}/lynx_bookmarks.html"

View File

@ -0,0 +1,58 @@
#!/bin/bash
# Enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
fi
### VARIABLE BASED ###
# mysql #
export MYSQL_PS1=$(env echo -e "\033[1;32m#\033[34m\\U\033[0;1m:\033[32m[\033[0m\\d\033[1;32m]>\033[0m\\_")
MYCLI_PS1=${MYSQL_PS1//\\U/\\u}
# gcc #
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# fzf #
export FZF_DEFAULT_OPTS="--multi --no-mouse --height=10 --layout=reverse"
### ALIAS BASED ###
# Core
alias ls="\ls -aF --color=auto"
alias ll='l -l'
alias cp='cp -v'
alias mv='mv -v'
alias rm='rm -v'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias echo='echo -e'
alias whereis='whereisAlias'
alias diff='diff -s -y -t --color=auto' # report identical; side-by-side; expand tabs; color
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias lsblk='lsblk -o LABEL,NAME,SIZE,FSUSE%,RM,RO,TYPE,FSTYPE,MOUNTPOINTS'
alias df='df --print-type'
alias ip='ip --color=auto'
# GNU
alias less='less --use-color'
alias cal='cal --monday'
alias tar='tar -v'
alias gzip='gzip -v'
alias gdb='gdb -q --tui'
alias bc="bc -q"
# Misc.
alias hexedit='hexedit --color'
alias bat='bat --paging=never --italic-text always'
alias tshark='tshark --color'
alias mycli="mycli --prompt \"${MYCLI_PS1}\""
alias neofetch="neofetch --ascii ${MM}/Neofetch/${USER}.ascii --ascii_colors 15 ${FAVCOLNUM} ${SECCOLNUM}"
### OVERRIDE FUNCTIONS ###
function whereisAlias(){
\whereis $@ | awk -F ': ' -v OFS="" '{$1=""; print}'
}

View File

@ -0,0 +1,2 @@
alias ipython="ipython -i ${MM}/Python/Pythonrc/init.py"
alias vsource="source ./venv/bin/activate"

4
bash/.bashrc.d/.signin.rc Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
function signin(){
\sudo -u $1 bash
}

View File

@ -0,0 +1,36 @@
#function spinner_bye(){
# printf "${CON}"; [ -e /proc/$pid ] && kill -9 $pid
#}
#function spinner(){
# #Set timer
# T=$(date +%s)
#
# #Animation sprites
# sprite=(
# "\033[33m(\033[32m* \033[33m) ( \033[32m*\033[33m)"
# "\033[33m (\033[32m* \033[33m)( \033[32m*\033[33m) "
# "\033[33m ( \033[32m*\033[33m||\033[32m*\033[33m ) "
# "\033[33m (\033[32m*\033[33m||\033[32m*\033[33m) "
# "\033[33m( \033[32m*\033[33m) (\033[32m* \033[33m)"
# "\033[33m(\033[32m* \033[33m) ( \033[32m*\033[33m)")
#
# #Print empty line and hide cursor
# printf "\n${COF}"
#
# trap "spinner_bye; exit" INT
#
# #Run our command and get its pid
# "$@" & pid=$!
#
# #Waiting animation
# i=0; while [ -e /proc/$pid ]; do sleep 0.3
# printf "\r${GRN}Please wait... ${sprite[$i]}$DEF"
# ((i++)); [[ $i = ${#sprite[@]} ]] && i=0
# done
#
# #Print time and exit
# T=$(($(date +%s)-$T))
# printf "\n\nTime taken: $(date -u -d @${T} +'%T')\n"
#
# spinner_bye
#}

6
bash/.bashrc.d/.sudo.rc Normal file
View File

@ -0,0 +1,6 @@
#alias sudo="sudo --preserve-env"
function SudoAlias(){
\sudo -n true 2> /dev/null || ( pinentry-curses --ttyname $(tty) < <(echo GETPIN) | sed -n 2p | cut -d ' ' -f 2- | \sudo -S true 2> /dev/null ) && \sudo $@
}
alias sudo=SudoAlias

13
bash/.bashrc.d/.vimification.rc Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -o vi # Turn on vi mode
alias :e="${EDITOR}"
alias :q="exit"
alias :qa="xdotool getactivewindow windowkill"
function cdvim(){
cd $(dirname $1)
vim $(basename $1)
}
alias vimcd="cdvim"

14
bash/.bashrc.d/.w.rc Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
function personal_watch(){
FORMATED_DATE="date '+%H : %M : %S' | figlet -w ${COLUMNS} -f /home/anon/Main/Fonts/figlet-fonts/Small"
declare -a CMD
CMD+=("paste <(cal --color=always --monday;) <(${FORMATED_DATE} | sed 's/^/\o033[1;33m/;s/$/\o033[0m/');")
CMD+=("echo -e '\033[0m';")
CMD+=("alias_of_the_day.sh;")
CMD+=("echo '';")
CMD+=("nevnapok.sh;")
echo ${CMD[@]}
watch --no-title --color --precise -n 1 "${CMD[@]}"
}
alias w="personal_watch"

3
bash/.bashrc.d/.winsize.rc Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
shopt -s checkwinsize # check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.

1
bash/.bashrc.d/.xterm.rc Normal file
View File

@ -0,0 +1 @@
# [ -n "$XTERM_VERSION" ] && transset -a 0.75 &> /dev/null

View File

@ -0,0 +1 @@
SCOUT

View File

@ -0,0 +1,41 @@
#!/bin/bash
## Favourites ##
export FAVCOL="green"
export SECCOL="blue"
export FAVCOLESC="\033[32m"
export SECCOLESC="\033[34m"
export FAVCOLNUM="2"
export SECCOLNUM="4"
export FAVCHAR="♞"
get_git_branch() {
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ -n "$branch" ]; then
echo "$branch"
else
echo "none"
fi
}
case $MACHINE_NAME in
BATTLESTATION)
prompt_color="\[${FAVCOLESC}\]"
info_color="\[${SECCOLESC}\]"
BOLD="\[\033[1m\]"
NORMAL="\[\033[0m\]"
export PS1="$prompt_color┌──${BOLD}(${info_color}---${prompt_color}){${info_color}\u${FAVCHAR}\h${prompt_color}${BOLD}}${NORMAL}${prompt_color}@${BOLD}[${info_color}\w${prompt_color}]${NORMAL}\n"
export PS1+="${prompt_color}└<${info_color}${BOLD}\$${NORMAL} "
export PS2="${prompt_color} >\[\033[0m\]"
unset color_prompt info_color BOLD NORMAL
;;
SCOUT)
prompt_color="\[\033[31;1m\]"
PS1="$prompt_color[\$?] ("'$(get_git_branch)'") #:\[\033[0m\] "
PS2="$prompt_color >\[\033[0m\] "
PROMPT_COMMAND="PS1="'$PS1'
#prompt_color="\[\033[1m${FAVCOLESC}\]"
#PS1="$prompt_color ─▶\[\033[0m\] "
#PS2="$prompt_color >\[\033[0m\] "
unset color_prompt
;;
esac

View File

@ -0,0 +1,21 @@
#!/bin/bash
## Favourites ##
export FAVCOL="yellow"
export SECCOL="blue"
export FAVCOLESC="\033[33m"
export SECCOLESC="\033[38;5;245m"
export FAVCOLNUM="3"
export SECCOLNUM="245"
export FAVCHAR="♝"
function getGit(){
! [ -d "${PWD}/.git" ] && return
G=$(git status)
[ "$?" != "0" ] && return
B=$(echo "$G" | head -1 | cut -d ' ' -f 3)
D=$(echo "$G" | grep "deleted:" | wc -l)
M=$(echo "$G" | grep "modified:" | wc -l)
printf "Branch: %s Del: %s Mod: %s" $B $D $M
}
export PS1="\[${FAVCOLESC}\]...$(getGit)\[\033[0m\] "

View File

@ -0,0 +1,12 @@
#!/bin/bash
## Favourites ##
export FAVCOL="blue"
export SECCOL="green"
export FAVCOLESC="\033[34m"
export SECCOLESC="\033[32m"
export FAVCOLNUM="4"
export SECCOLNUM="2"
export FAVCHAR="⛂"
export PS1="\[\033[1m${FAVCOLESC}\]C:${PWD//\//\\\\}>\033[0m"
export PS2="$FAVCOLESC ${FAVCHAR}\[\033[0m\] "

View File

@ -0,0 +1,13 @@
#!/bin/bash
## Favourites ##
export FAVCOL="gray"
export SECCOL="red"
export FAVCOLESC="\033[38;5;240m"
export SECCOLESC="\033[31m"
export FAVCOLNUM="240"
export SECCOLNUM="9"
export FAVCHAR="✎"
export PS1="\[${SECCOLESC}\]#\[${FAVCOLESC}\]${USER}\[\033[0;1m\]:${SECCOLESC}[\[\033[0m\]${PWD}${SECCOLESC}\[\033[1m\]]\[${FAVCOLESC}\]${FAVCHAR}\[${SECCOLESC}\]>\[\033[0m\] "
export PS2="\[${FAVCOLESC}\] -\[\033[0m\] "

View File

@ -0,0 +1,12 @@
#!/bin/bash
## Favourites ##
export FAVCOL="white"
export SECCOL="grey"
export FAVCOLESC="\033[1m"
export SECCOLESC="\033[38;5;245m"
export FAVCOLNUM="15"
export SECCOLNUM="245"
export FAVCHAR="♟"
export PS1="\[\033[1m\]$\[\033[0m\] "
export PS2="\[${SECCOLESC}\]> \[\033[0m\]"

View File

@ -0,0 +1,11 @@
## Favourites ##
export FAVCOL="red"
export SECCOL="blue"
export FAVCOLESC="\033[31m"
export SECCOLESC="\033[34m"
export FAVCOLNUM="2"
export SECCOLNUM="9"
export FAVCHAR="♛"
export PS1="\[\033[1m${FAVCOLESC}\]\h\[\033[1m${SECCOLESC}\] \w #\[\033[0m\] "
export PS2=" \[${FAVCOLESC}\]>\[\033[0m\] "

View File

@ -0,0 +1,5 @@
[Settings]
source = cppreference.com
updatemanpath = false
pager = vim

319
gdb/.gdbinit Normal file
View File

@ -0,0 +1,319 @@
set startup-quietly on
set history save on
set auto-load safe-path /
set extended-prompt \[\e[32;1m\](\[\e[0;33m\f\[\e[32;1m\)\[\e[0m\[\e[31m\]$\[\e[0m
tui enable
focus next
#set pagination off
# Copyright (C) 2016 Pedro Alves
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This script defines the "info signal-dispositions" command, a
# command to list signal dispositions.
#
# To "install", copy the file somewhere, and add this to your .gdbinit
# file:
#
# source /path/to/signals.gdb
#
# Should probably be rewritten in gdb/Python, but ...
# Example output (gdb debugging itself):
#
# (gdb) info signal-dispositions
# Number Name Description Disposition
# 1 SIGHUP Hangup handle_sighup(int) in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 2 SIGINT Interrupt rl_signal_handler in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 3 SIGQUIT Quit rl_signal_handler in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 4 SIGILL Illegal instruction SIG_DFL
# 5 SIGTRAP Trace/breakpoint trap SIG_DFL
# 6 SIGABRT Aborted SIG_DFL
# 7 SIGBUS Bus error SIG_DFL
# 8 SIGFPE Floating point exception handle_sigfpe(int) in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 9 SIGKILL Killed SIG_DFL
# 10 SIGUSR1 User defined signal 1 SIG_DFL
# 11 SIGSEGV Segmentation fault SIG_DFL
# 12 SIGUSR2 User defined signal 2 SIG_DFL
# 13 SIGPIPE Broken pipe SIG_IGN
# 14 SIGALRM Alarm clock rl_signal_handler in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 15 SIGTERM Terminated rl_signal_handler in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 16 SIGSTKFLT Stack fault SIG_DFL
# 17 SIGCHLD Child exited sigchld_handler(int) in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 18 SIGCONT Continued tui_cont_sig(int) in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 19 SIGSTOP Stopped (signal) SIG_DFL
# 20 SIGTSTP Stopped rl_signal_handler in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 21 SIGTTIN Stopped (tty input) rl_signal_handler in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 22 SIGTTOU Stopped (tty output) rl_signal_handler in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 23 SIGURG Urgent I/O condition SIG_DFL
# 24 SIGXCPU CPU time limit exceeded GC_restart_handler in section .text of /lib64/libgc.so.1
# 25 SIGXFSZ File size limit exceeded SIG_IGN
# 26 SIGVTALRM Virtual timer expired SIG_DFL
# 27 SIGPROF Profiling timer expired SIG_DFL
# 28 SIGWINCH Window changed tui_sigwinch_handler(int) in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 29 SIGIO I/O possible SIG_DFL
# 30 SIGPWR Power failure GC_suspend_handler in section .text of /lib64/libgc.so.1
# 31 SIGSYS Bad system call SIG_DFL
# 34 SIG34 Real-time signal 0 SIG_DFL
# 35 SIG35 Real-time signal 1 SIG_DFL
# [...]
#
# (gdb) info signal-dispositions 2 5
# Number Name Description Disposition
# 2 SIGINT Interrupt rl_signal_handler in section .text of /home/pedro/brno/pedro/gdb/mygit/build/gdb/gdb
# 5 SIGTRAP Trace/breakpoint trap SIG_DFL
#
# Print the disposition of all signals, or optionally of the given
# signals (up to 10 arguments).
#
# Usage:
# (gdb) info signal-dispositions [SIGNUM1 SIGNUM12 ...]
#
define info signal-dispositions
__isd_print_tbl_hdr
if $argc == 0
__isd_info_all_signal_dispositions
else
# Looping over args 0..$argc and using eval to extract the current
# arg doesn't work, because "eval" command misses replacing $argN.
# See <https://sourceware.org/bugzilla/show_bug.cgi?id=20559>. We
# get to unroll the loop manually.
if $argc >= 1
__isd_info_signal_disposition $arg0
end
if $argc >= 2
__isd_info_signal_disposition $arg1
end
if $argc >= 3
__isd_info_signal_disposition $arg2
end
if $argc >= 4
__isd_info_signal_disposition $arg3
end
if $argc >= 5
__isd_info_signal_disposition $arg4
end
if $argc >= 6
__isd_info_signal_disposition $arg5
end
if $argc >= 7
__isd_info_signal_disposition $arg6
end
if $argc >= 8
__isd_info_signal_disposition $arg7
end
if $argc >= 9
__isd_info_signal_disposition $arg8
end
if $argc >= 10
__isd_info_signal_disposition $arg9
end
end
end
# Helpers go below.
# Print the disposition of a single signal, given by $arg0.
define __isd_info_signal_disposition
set $_isd_size = sizeof (struct sigaction)
__isd_mmap $_isd_size
if $_isd_mmap_res != (void *) -1
set $_isd_p = (struct sigaction *) $_isd_mmap_res
__isd_print_disposition $arg0 $_isd_p
__isd_munmap $_isd_p $_isd_size
end
end
# Prints the disposition of all signals.
define __isd_info_all_signal_dispositions
set $_isd_size = sizeof (struct sigaction)
__isd_mmap $_isd_size
if $_isd_mmap_res != (void *) -1
set $_isd_p = (struct sigaction *) $_isd_mmap_res
set $_isd_i = 1
set $_isd_nsig = 64
while $_isd_i < $_isd_nsig
__isd_print_disposition $_isd_i $_isd_p
set $_isd_i = $_isd_i + 1
end
__isd_munmap $_isd_p $_isd_size
end
end
# Call mmap in the inferior. $arg0 is the requested size. Returns in $_isd_mmap_res
define __isd_mmap
set $_isd_size = $arg0
# PROT_READ(1) | PROT_WRITE(2)
set $_isd_prot = 0x1 | 0x2
# MAP_PRIVATE(2) | MAP_ANONYMOUS(0x20)
set $_isd_flags = 0x2 | 0x20
set $_isd_mmap = (void *(*) (void *, size_t, int, int, int, off_t)) mmap
set $_isd_mmap_res = $_isd_mmap (0, $_isd_size, $_isd_prot, $_isd_flags, -1, 0)
end
# Call munmap in the inferior. $arg0 is address, and $arg1 is the size.
define __isd_munmap
set $_isd_munmap = (int (*) (void *, size_t)) munmap
call (void) $_isd_munmap ($arg0, $arg1)
end
# Print the table header.
define __isd_print_tbl_hdr
printf "%s\t%-9s\t%-24s\t%s\n", "Number", "Name", "Description", "Disposition"
end
# Helper that prints the disposition of a single signal. First arg is
# signal number, second is sigaction pointer.
define __isd_print_disposition
set $_isd_sig = $arg0
set $_isd_p = $arg1
set $_isd_res = __sigaction ($arg0, 0, $_isd_p)
if $_isd_res == 0
printf "%d\t", $_isd_sig
if $_isd_sig < 32
__isd_signame $_isd_sig
else
printf "SIG%d ", $_isd_sig
end
printf "\t"
if _new_sys_siglist[$arg0] != 0
printf "%-24s", _new_sys_siglist[$arg0]
else
if $arg0 >= 34
printf "Real-time signal %d", $arg0 - 34
printf "%10s", ""
else
printf "Unknown signal %d", $arg0
printf "%10s", ""
end
end
printf "\t"
# Avoid "__sigaction_handler.sa_handler" because of
# #define sa_handler __sigaction_handler.sa_handler
if (long) $_isd_p->__sigaction_handler == 0
printf "SIG_DFL\n"
else
if (long) $_isd_p->__sigaction_handler == 1
printf "SIG_IGN\n"
else
info symbol (long) $_isd_p->__sigaction_handler
end
end
end
end
# Mapping of signal numbers to names.
define __isd_signame
if $arg0 == 1
printf "%-9s", "SIGHUP"
end
if $arg0 == 2
printf "%-9s", "SIGINT"
end
if $arg0 == 3
printf "%-9s", "SIGQUIT"
end
if $arg0 == 4
printf "%-9s", "SIGILL"
end
if $arg0 == 5
printf "%-9s", "SIGTRAP"
end
if $arg0 == 6
printf "%-9s", "SIGABRT"
end
if $arg0 == 7
printf "%-9s", "SIGBUS"
end
if $arg0 == 8
printf "%-9s", "SIGFPE"
end
if $arg0 == 9
printf "%-9s", "SIGKILL"
end
if $arg0 == 10
printf "%-9s", "SIGUSR1"
end
if $arg0 == 11
printf "%-9s", "SIGSEGV"
end
if $arg0 == 12
printf "%-9s", "SIGUSR2"
end
if $arg0 == 13
printf "%-9s", "SIGPIPE"
end
if $arg0 == 14
printf "%-9s", "SIGALRM"
end
if $arg0 == 15
printf "%-9s", "SIGTERM"
end
if $arg0 == 16
printf "%-9s", "SIGSTKFLT"
end
if $arg0 == 17
printf "%-9s", "SIGCHLD"
end
if $arg0 == 18
printf "%-9s", "SIGCONT"
end
if $arg0 == 19
printf "%-9s", "SIGSTOP"
end
if $arg0 == 20
printf "%-9s", "SIGTSTP"
end
if $arg0 == 21
printf "%-9s", "SIGTTIN"
end
if $arg0 == 22
printf "%-9s", "SIGTTOU"
end
if $arg0 == 23
printf "%-9s", "SIGURG"
end
if $arg0 == 24
printf "%-9s", "SIGXCPU"
end
if $arg0 == 25
printf "%-9s", "SIGXFSZ"
end
if $arg0 == 26
printf "%-9s", "SIGVTALRM"
end
if $arg0 == 27
printf "%-9s", "SIGPROF"
end
if $arg0 == 28
printf "%-9s", "SIGWINCH"
end
if $arg0 == 29
printf "%-9s", "SIGIO"
end
if $arg0 == 30
printf "%-9s", "SIGPWR"
end
if $arg0 == 31
printf "%-9s", "SIGSYS"
end
end

13
git/.gitconfig Normal file
View File

@ -0,0 +1,13 @@
[user]
email = anon@anon.anon
name = anon
[init]
defaultBranch = master
[merge]
tool = vimdiff
[pull]
rebase = false
[http "http://*.onion"]
sslVerify = false
proxy = "socks5h://127.0.0.1:9050"

1
haskell/.ghci Normal file
View File

@ -0,0 +1 @@
:set prompt "\ESC[38;5;86m\STX \x03BB > \ESC[0m\STX"

4
init/startuprc.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
xset r rate 180 40
setxkbmap -option caps:swapescape

9
qckcmd/.qckcmd Normal file
View File

@ -0,0 +1,9 @@
V: python -m venv venv
v: vsource
m: make
t: make test
T: sudo rc-service tor restart
n: nnn
N: sudo rc-service NetworkManager restart
p: git push
4: ssh root@192.168.0.144

158
sql/.myclirc Normal file
View File

@ -0,0 +1,158 @@
# vi: ft=dosini
[main]
enable_pager = False
# Enables context sensitive auto-completion. If this is disabled the all
# possible completions will be listed.
smart_completion = True
# Multi-line mode allows breaking up the sql statements into multiple lines. If
# this is set to True, then the end of the statements must have a semi-colon.
# If this is set to False then sql statements can't be split into multiple
# lines. End of line (return) is considered as the end of the statement.
multi_line = False
# Destructive warning mode will alert you before executing a sql statement
# that may cause harm to the database such as "drop table", "drop database"
# or "shutdown".
destructive_warning = True
# log_file location.
log_file = ~/.mycli.log
# Default log level. Possible values: "CRITICAL", "ERROR", "WARNING", "INFO"
# and "DEBUG". "NONE" disables logging.
log_level = INFO
# Log every query and its results to a file. Enable this by uncommenting the
# line below.
# audit_log = ~/.mycli-audit.log
# Timing of sql statments and table rendering.
timing = True
# Beep after long-running queries are completed; 0 to disable.
beep_after_seconds = 0
# Table format. Possible values: ascii, double, github,
# psql, plain, simple, grid, fancy_grid, pipe, orgtbl, rst, mediawiki, html,
# latex, latex_booktabs, textile, moinmoin, jira, vertical, tsv, csv.
# Recommended: ascii
table_format = ascii
# Syntax coloring style. Possible values (many support the "-dark" suffix):
# manni, igor, xcode, vim, autumn, vs, rrt, native, perldoc, borland, tango, emacs,
# friendly, monokai, paraiso, colorful, murphy, bw, pastie, paraiso, trac, default,
# fruity.
# Screenshots at http://mycli.net/syntax
# Can be further modified in [colors]
syntax_style = default
# Keybindings: Possible values: emacs, vi.
# Emacs mode: Ctrl-A is home, Ctrl-E is end. All emacs keybindings are available in the REPL.
# When Vi mode is enabled you can use modal editing features offered by Vi in the REPL.
key_bindings = emacs
# Enabling this option will show the suggestions in a wider menu. Thus more items are suggested.
wider_completion_menu = False
# MySQL prompt
# \D - The full current date
# \d - Database name
# \h - Hostname of the server
# \m - Minutes of the current time
# \n - Newline
# \P - AM/PM
# \p - Port
# \R - The current time, in 24-hour military time (0-23)
# \r - The current time, standard 12-hour time (1-12)
# \s - Seconds of the current time
# \t - Product type (Percona, MySQL, MariaDB)
# \A - DSN alias name (from the [alias_dsn] section)
# \u - Username
# \x1b[...m - insert ANSI escape sequence
prompt = '\t \u@\h:\d> '
prompt_continuation = '->'
# Skip intro info on startup and outro info on exit
less_chatty = False
# Use alias from --login-path instead of host name in prompt
login_path_as_host = False
# Cause result sets to be displayed vertically if they are too wide for the current window,
# and using normal tabular format otherwise. (This applies to statements terminated by ; or \G.)
auto_vertical_output = False
# keyword casing preference. Possible values "lower", "upper", "auto"
keyword_casing = auto
# disabled pager on startup
enable_pager = True
# Custom colors for the completion menu, toolbar, etc.
[colors]
completion-menu.completion.current = 'bg:#ffffff #000000'
completion-menu.completion = 'bg:#008888 #ffffff'
completion-menu.meta.completion.current = 'bg:#44aaaa #000000'
completion-menu.meta.completion = 'bg:#448888 #ffffff'
completion-menu.multi-column-meta = 'bg:#aaffff #000000'
scrollbar.arrow = 'bg:#003333'
scrollbar = 'bg:#00aaaa'
selected = '#ffffff bg:#6666aa'
search = '#ffffff bg:#4444aa'
search.current = '#ffffff bg:#44aa44'
bottom-toolbar = 'bg:#222222 #aaaaaa'
bottom-toolbar.off = 'bg:#222222 #888888'
bottom-toolbar.on = 'bg:#222222 #ffffff'
search-toolbar = 'noinherit bold'
search-toolbar.text = 'nobold'
system-toolbar = 'noinherit bold'
arg-toolbar = 'noinherit bold'
arg-toolbar.text = 'nobold'
bottom-toolbar.transaction.valid = 'bg:#222222 #00ff5f bold'
bottom-toolbar.transaction.failed = 'bg:#222222 #ff005f bold'
# style classes for colored table output
output.header = "#00ff5f bold"
output.odd-row = ""
output.even-row = ""
output.null = "#808080"
# SQL syntax highlighting overrides
# sql.comment = 'italic #408080'
# sql.comment.multi-line = ''
# sql.comment.single-line = ''
# sql.comment.optimizer-hint = ''
# sql.escape = 'border:#FF0000'
# sql.keyword = 'bold #008000'
# sql.datatype = 'nobold #B00040'
# sql.literal = ''
# sql.literal.date = ''
# sql.symbol = ''
# sql.quoted-schema-object = ''
# sql.quoted-schema-object.escape = ''
# sql.constant = '#880000'
# sql.function = '#0000FF'
# sql.variable = '#19177C'
# sql.number = '#666666'
# sql.number.binary = ''
# sql.number.float = ''
# sql.number.hex = ''
# sql.number.integer = ''
# sql.operator = '#666666'
# sql.punctuation = ''
# sql.string = '#BA2121'
# sql.string.double-quouted = ''
# sql.string.escape = 'bold #BB6622'
# sql.string.single-quoted = ''
# sql.whitespace = ''
# Favorite queries.
[favorite_queries]
# Use the -d option to reference a DSN.
# Special characters in passwords and other strings can be escaped with URL encoding.
[alias_dsn]
# example_dsn = mysql://[user[:password]@][host][:port][/dbname]

80
tmux/.tmux.conf Normal file
View File

@ -0,0 +1,80 @@
# History
set -g history-limit 10000
# Vi support
set-window-option -g mode-keys vi
set -g status-keys vi
set -g escape-time 0
# Mouse support
set -g mouse on
# Rebinds
# Meta
unbind-key C-b
set -g prefix C-a
# Panes
unbind-key -n M-v
unbind-key -n M-s
bind-key -n M-v split-window -h
bind-key -n M-s split-window
unbind-key -n M-h
unbind-key -n M-j
unbind-key -n M-k
unbind-key -n M-l
bind-key -n M-h select-pane -L
bind-key -n M-j select-pane -D
bind-key -n M-k select-pane -U
bind-key -n M-l select-pane -R
# Windows
unbind-key -n M-T
unbind-key -n M-t
unbind-key -n M-H
unbind-key -n M-J
unbind-key -n M-L
bind-key -n M-T new-window
bind-key -n M-t new-window -c "#{pane_current_path}"
bind-key -n M-H previous-window
bind-key -n M-J choose-tree
bind-key -n M-L next-window
unbind-key -n M-Q
bind-key -n M-Q killw
# Copy mode
unbind-key -n C-Space
bind-key -n C-Space copy-mode
unbind-key -T copy-mode-vi v
bind-key -T copy-mode-vi v send-keys -X begin-selection
unbind-key -T copy-mode-vi y
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel \; run -b "tmux save-buffer - | \xclip -i -sel clipboard"
unbind-key p
bind-key p paste-buffer -p
# Environment
set -ga update-environment ' FAVCHAR'
set -ga update-environment ' LINES'
set -ga update-environment ' COLUMNS'
# Looks
set -g status on
set -g status-position top
set -g status-interval 1
set -g renumber-windows on
set -g base-index 1
#
set -g status-style "bg=color25 fg=white bold"
set -g pane-border-style "fg=white"
set -g pane-active-border-style "fg=white"
set -g message-style "fg=green"
#
#set -g window-style "fg=colour240"
#set -g window-active-style "fg=white bg=default"
#
set -g status-left-length 60
#set -g status-left "#[fg=color24]|#[fg=default] {#{user}#{?#{FAVCHAR},#{FAVCHAR},@}#h} #[fg=color24]|#[fg=default] <#{?#{LINES},#{LINES},?}x#{?#{COLUMNS},#{COLUMNS},?}> #[fg=color24]|#[fg=default] (#I/#{session_windows}) "
set -g status-left "#[fg=color16]|#[fg=default] {#{user}#{?#{FAVCHAR},#{FAVCHAR},@}#h} #[fg=color16]|#[fg=default] (#I/#{session_windows}) #[fg=color16]|#[fg=default] "
set -g status-right-length 95
set -g status-right "#[fg=color16]|#[fg=default] \"#{pane_title}\" #[fg=color16]|#[fg=default]"
#
set -g window-status-format "[ #{=/9/…:window_name} ]"
set -g window-status-current-format "[ #{=/9/…:window_name}*]"
set -g window-status-current-style "bg=white fg=color24"

12
vim/.vim/.netrwhist Normal file
View File

@ -0,0 +1,12 @@
let g:netrw_dirhistmax =10
let g:netrw_dirhistcnt =3
let g:netrw_dirhist_3='/home/anon/Swap/c4/documentation'
let g:netrw_dirhist_2='/home/anon/Swap/java/gateway/src/main/resources'
let g:netrw_dirhist_1='/home/anon/test'
let g:netrw_dirhist_0='/etc/portage/env/cross-aarch64-unknown-linux-gnu'
let g:netrw_dirhist_9='/etc/portage/env'
let g:netrw_dirhist_8='/home/anon/Swap/school/webprog/wp3/nap0918-app/resources/views/employees'
let g:netrw_dirhist_7='/home/anon/Swap/ctags_to_vim_hi/build'
let g:netrw_dirhist_6='/home/anon/Swap/java/annotations'
let g:netrw_dirhist_5='/home/anon/Swap/java/packages/myprivate'
let g:netrw_dirhist_4='/home/anon/Swap/jeger/documentation'

3059
vim/.vim/autoload/DrawIt.vim Normal file

File diff suppressed because it is too large Load Diff

431
vim/.vim/autoload/acp.vim Normal file
View File

@ -0,0 +1,431 @@
"=============================================================================
" Copyright (c) 2007-2009 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
if exists('g:loaded_autoload_acp') || v:version < 702
finish
endif
let g:loaded_autoload_acp = 1
" }}}1
"=============================================================================
" GLOBAL FUNCTIONS: {{{1
"
function acp#enable()
call acp#disable()
augroup AcpGlobalAutoCommand
autocmd!
autocmd InsertEnter * unlet! s:posLast s:lastUncompletable
autocmd InsertLeave * call s:finishPopup(1)
augroup END
if g:acp_mappingDriven
call s:mapForMappingDriven()
else
autocmd AcpGlobalAutoCommand CursorMovedI * call s:feedPopup()
endif
nnoremap <silent> i i<C-r>=<SID>feedPopup()<CR>
nnoremap <silent> a a<C-r>=<SID>feedPopup()<CR>
nnoremap <silent> R R<C-r>=<SID>feedPopup()<CR>
endfunction
"
function acp#disable()
call s:unmapForMappingDriven()
augroup AcpGlobalAutoCommand
autocmd!
augroup END
nnoremap i <Nop> | nunmap i
nnoremap a <Nop> | nunmap a
nnoremap R <Nop> | nunmap R
endfunction
"
function acp#lock()
let s:lockCount += 1
endfunction
"
function acp#unlock()
let s:lockCount -= 1
if s:lockCount < 0
let s:lockCount = 0
throw "AutoComplPop: not locked"
endif
endfunction
"
function acp#meetsForSnipmate(context)
if g:acp_behaviorSnipmateLength < 0
return 0
endif
let matches = matchlist(a:context, '\(^\|\s\|\<\)\(\u\{' .
\ g:acp_behaviorSnipmateLength . ',}\)$')
return !empty(matches) && !empty(s:getMatchingSnipItems(matches[2]))
endfunction
"
function acp#meetsForKeyword(context)
if g:acp_behaviorKeywordLength < 0
return 0
endif
let matches = matchlist(a:context, '\(\k\{' . g:acp_behaviorKeywordLength . ',}\)$')
if empty(matches)
return 0
endif
for ignore in g:acp_behaviorKeywordIgnores
if stridx(ignore, matches[1]) == 0
return 0
endif
endfor
return 1
endfunction
"
function acp#meetsForFile(context)
if g:acp_behaviorFileLength < 0
return 0
endif
if has('win32') || has('win64')
let separator = '[/\\]'
else
let separator = '\/'
endif
if a:context !~ '\f' . separator . '\f\{' . g:acp_behaviorFileLength . ',}$'
return 0
endif
return a:context !~ '[*/\\][/\\]\f*$\|[^[:print:]]\f*$'
endfunction
"
function acp#meetsForRubyOmni(context)
if !has('ruby')
return 0
endif
if g:acp_behaviorRubyOmniMethodLength >= 0 &&
\ a:context =~ '[^. \t]\(\.\|::\)\k\{' .
\ g:acp_behaviorRubyOmniMethodLength . ',}$'
return 1
endif
if g:acp_behaviorRubyOmniSymbolLength >= 0 &&
\ a:context =~ '\(^\|[^:]\):\k\{' .
\ g:acp_behaviorRubyOmniSymbolLength . ',}$'
return 1
endif
return 0
endfunction
"
function acp#meetsForPythonOmni(context)
return has('python') && g:acp_behaviorPythonOmniLength >= 0 &&
\ a:context =~ '\k\.\k\{' . g:acp_behaviorPythonOmniLength . ',}$'
endfunction
"
function acp#meetsForPerlOmni(context)
return g:acp_behaviorPerlOmniLength >= 0 &&
\ a:context =~ '\w->\k\{' . g:acp_behaviorPerlOmniLength . ',}$'
endfunction
"
function acp#meetsForXmlOmni(context)
return g:acp_behaviorXmlOmniLength >= 0 &&
\ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' .
\ g:acp_behaviorXmlOmniLength . ',}$'
endfunction
"
function acp#meetsForHtmlOmni(context)
return g:acp_behaviorHtmlOmniLength >= 0 &&
\ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' .
\ g:acp_behaviorHtmlOmniLength . ',}$'
endfunction
"
function acp#meetsForCssOmni(context)
if g:acp_behaviorCssOmniPropertyLength >= 0 &&
\ a:context =~ '\(^\s\|[;{]\)\s*\k\{' .
\ g:acp_behaviorCssOmniPropertyLength . ',}$'
return 1
endif
if g:acp_behaviorCssOmniValueLength >= 0 &&
\ a:context =~ '[:@!]\s*\k\{' .
\ g:acp_behaviorCssOmniValueLength . ',}$'
return 1
endif
return 0
endfunction
"
function acp#completeSnipmate(findstart, base)
if a:findstart
let s:posSnipmateCompletion = len(matchstr(s:getCurrentText(), '.*\U'))
return s:posSnipmateCompletion
endif
let lenBase = len(a:base)
let items = filter(GetSnipsInCurrentScope(),
\ 'strpart(v:key, 0, lenBase) ==? a:base')
return map(sort(items(items)), 's:makeSnipmateItem(v:val[0], v:val[1])')
endfunction
"
function acp#onPopupCloseSnipmate()
let word = s:getCurrentText()[s:posSnipmateCompletion :]
for trigger in keys(GetSnipsInCurrentScope())
if word ==# trigger
call feedkeys("\<C-r>=TriggerSnippet()\<CR>", "n")
return 0
endif
endfor
return 1
endfunction
"
function acp#onPopupPost()
" to clear <C-r>= expression on command-line
echo ''
if pumvisible()
inoremap <silent> <expr> <C-h> acp#onBs()
inoremap <silent> <expr> <BS> acp#onBs()
" a command to restore to original text and select the first match
return (s:behavsCurrent[s:iBehavs].command =~# "\<C-p>" ? "\<C-n>\<Up>"
\ : "\<C-p>\<Down>")
endif
let s:iBehavs += 1
if len(s:behavsCurrent) > s:iBehavs
call s:setCompletefunc()
return printf("\<C-e>%s\<C-r>=acp#onPopupPost()\<CR>",
\ s:behavsCurrent[s:iBehavs].command)
else
let s:lastUncompletable = {
\ 'word': s:getCurrentWord(),
\ 'commands': map(copy(s:behavsCurrent), 'v:val.command')[1:],
\ }
call s:finishPopup(0)
return "\<C-e>"
endif
endfunction
"
function acp#onBs()
" using "matchstr" and not "strpart" in order to handle multi-byte
" characters
if call(s:behavsCurrent[s:iBehavs].meets,
\ [matchstr(s:getCurrentText(), '.*\ze.')])
return "\<BS>"
endif
return "\<C-e>\<BS>"
endfunction
" }}}1
"=============================================================================
" LOCAL FUNCTIONS: {{{1
"
function s:mapForMappingDriven()
call s:unmapForMappingDriven()
let s:keysMappingDriven = [
\ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
\ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
\ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
\ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
\ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
\ '-', '_', '~', '^', '.', ',', ':', '!', '#', '=', '%', '$', '@', '<', '>', '/', '\',
\ '<Space>', '<C-h>', '<BS>', ]
for key in s:keysMappingDriven
execute printf('inoremap <silent> %s %s<C-r>=<SID>feedPopup()<CR>',
\ key, key)
endfor
endfunction
"
function s:unmapForMappingDriven()
if !exists('s:keysMappingDriven')
return
endif
for key in s:keysMappingDriven
execute 'iunmap ' . key
endfor
let s:keysMappingDriven = []
endfunction
"
function s:setTempOption(group, name, value)
call extend(s:tempOptionSet[a:group], { a:name : eval('&' . a:name) }, 'keep')
execute printf('let &%s = a:value', a:name)
endfunction
"
function s:restoreTempOptions(group)
for [name, value] in items(s:tempOptionSet[a:group])
execute printf('let &%s = value', name)
endfor
let s:tempOptionSet[a:group] = {}
endfunction
"
function s:getCurrentWord()
return matchstr(s:getCurrentText(), '\k*$')
endfunction
"
function s:getCurrentText()
return strpart(getline('.'), 0, col('.') - 1)
endfunction
"
function s:getPostText()
return strpart(getline('.'), col('.') - 1)
endfunction
"
function s:isModifiedSinceLastCall()
if exists('s:posLast')
let posPrev = s:posLast
let nLinesPrev = s:nLinesLast
let textPrev = s:textLast
endif
let s:posLast = getpos('.')
let s:nLinesLast = line('$')
let s:textLast = getline('.')
if !exists('posPrev')
return 1
elseif posPrev[1] != s:posLast[1] || nLinesPrev != s:nLinesLast
return (posPrev[1] - s:posLast[1] == nLinesPrev - s:nLinesLast)
elseif textPrev ==# s:textLast
return 0
elseif posPrev[2] > s:posLast[2]
return 1
elseif has('gui_running') && has('multi_byte')
" NOTE: auto-popup causes a strange behavior when IME/XIM is working
return posPrev[2] + 1 == s:posLast[2]
endif
return posPrev[2] != s:posLast[2]
endfunction
"
function s:makeCurrentBehaviorSet()
let modified = s:isModifiedSinceLastCall()
if exists('s:behavsCurrent[s:iBehavs].repeat') && s:behavsCurrent[s:iBehavs].repeat
let behavs = [ s:behavsCurrent[s:iBehavs] ]
elseif exists('s:behavsCurrent[s:iBehavs]')
return []
elseif modified
let behavs = copy(exists('g:acp_behavior[&filetype]')
\ ? g:acp_behavior[&filetype]
\ : g:acp_behavior['*'])
else
return []
endif
let text = s:getCurrentText()
call filter(behavs, 'call(v:val.meets, [text])')
let s:iBehavs = 0
if exists('s:lastUncompletable') &&
\ stridx(s:getCurrentWord(), s:lastUncompletable.word) == 0 &&
\ map(copy(behavs), 'v:val.command') ==# s:lastUncompletable.commands
let behavs = []
else
unlet! s:lastUncompletable
endif
return behavs
endfunction
"
function s:feedPopup()
" NOTE: CursorMovedI is not triggered while the popup menu is visible. And
" it will be triggered when popup menu is disappeared.
if s:lockCount > 0 || pumvisible() || &paste
return ''
endif
if exists('s:behavsCurrent[s:iBehavs].onPopupClose')
if !call(s:behavsCurrent[s:iBehavs].onPopupClose, [])
call s:finishPopup(1)
return ''
endif
endif
let s:behavsCurrent = s:makeCurrentBehaviorSet()
if empty(s:behavsCurrent)
call s:finishPopup(1)
return ''
endif
" In case of dividing words by symbols (e.g. "for(int", "ab==cd") while a
" popup menu is visible, another popup is not available unless input <C-e>
" or try popup once. So first completion is duplicated.
call insert(s:behavsCurrent, s:behavsCurrent[s:iBehavs])
call s:setTempOption(s:GROUP0, 'spell', 0)
call s:setTempOption(s:GROUP0, 'completeopt', 'menuone' . (g:acp_completeoptPreview ? ',preview' : ''))
call s:setTempOption(s:GROUP0, 'complete', g:acp_completeOption)
call s:setTempOption(s:GROUP0, 'ignorecase', g:acp_ignorecaseOption)
" NOTE: With CursorMovedI driven, Set 'lazyredraw' to avoid flickering.
" With Mapping driven, set 'nolazyredraw' to make a popup menu visible.
call s:setTempOption(s:GROUP0, 'lazyredraw', !g:acp_mappingDriven)
" NOTE: 'textwidth' must be restored after <C-e>.
call s:setTempOption(s:GROUP1, 'textwidth', 0)
call s:setCompletefunc()
call feedkeys(s:behavsCurrent[s:iBehavs].command . "\<C-r>=acp#onPopupPost()\<CR>", 'n')
return '' " this function is called by <C-r>=
endfunction
"
function s:finishPopup(fGroup1)
inoremap <C-h> <Nop> | iunmap <C-h>
inoremap <BS> <Nop> | iunmap <BS>
let s:behavsCurrent = []
call s:restoreTempOptions(s:GROUP0)
if a:fGroup1
call s:restoreTempOptions(s:GROUP1)
endif
endfunction
"
function s:setCompletefunc()
if exists('s:behavsCurrent[s:iBehavs].completefunc')
call s:setTempOption(0, 'completefunc', s:behavsCurrent[s:iBehavs].completefunc)
endif
endfunction
"
function s:makeSnipmateItem(key, snip)
if type(a:snip) == type([])
let descriptions = map(copy(a:snip), 'v:val[0]')
let snipFormatted = '[MULTI] ' . join(descriptions, ', ')
else
let snipFormatted = substitute(a:snip, '\(\n\|\s\)\+', ' ', 'g')
endif
return {
\ 'word': a:key,
\ 'menu': strpart(snipFormatted, 0, 80),
\ }
endfunction
"
function s:getMatchingSnipItems(base)
let key = a:base . "\n"
if !exists('s:snipItems[key]')
let s:snipItems[key] = items(GetSnipsInCurrentScope())
call filter(s:snipItems[key], 'strpart(v:val[0], 0, len(a:base)) ==? a:base')
call map(s:snipItems[key], 's:makeSnipmateItem(v:val[0], v:val[1])')
endif
return s:snipItems[key]
endfunction
" }}}1
"=============================================================================
" INITIALIZATION {{{1
let s:GROUP0 = 0
let s:GROUP1 = 1
let s:lockCount = 0
let s:behavsCurrent = []
let s:iBehavs = 0
let s:tempOptionSet = [{}, {}]
let s:snipItems = {}
" }}}1
"=============================================================================
" vim: set fdm=marker:

905
vim/.vim/autoload/markx.vim Normal file
View File

@ -0,0 +1,905 @@
" autoload/markx.vim
"
" MarkX - Richard Bentley-Green, 22/03/2023
"
" Auto-placement of signs in the left margin, in response to creation and
" deletion of marks, plus some extra mark-placement functions
"
if exists('g:Markx_loaded_autoload')
finish
endif
const g:Markx_loaded_autoload = 1
" ------------------------------------------------------------------------------
" Note:
" - Signs are named 'MarkX<N>' where '<N>' is the ASCII number of the mark character
" - Placed signs have Ids in the range ASCII(") to ASCII(}) - ie, 35 to 125
" - Local marks include 'a' to 'z', " ' ( ) . < > [ ] ^ ` { }
" - Global marks include 'A' to 'Z', '0' to '9'
const s:allLocalMarks = "abcdefghijklmnopqrstuvwxyz'<>[]`\"().^{}"
const s:allGlobalMarks = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
" A lookup table to determine the type of a mark
const s:mkTypes = 'x----pxx----x-nnnnnnnnnn--p-p--uuuuuuuuuuuuuuuuuuuuuuuuuup-px-pllllllllllllllllllllllllllx-x'
" The marks that the user wants displaying
let s:userLMarks = ''
let s:userPMarks = ''
let s:userXMarks = ''
let s:userUMarks = ''
let s:userNMarks = ''
" The local and global marks that the user wants displaying
let s:userLocalMarks = ''
let s:userGlobMarks = ''
" The marks that the user wants to consider for auto-selection placement.
" These are (must be) be a subset of s:userLMarks and s:userUMarks respectively
let s:autoLMarks = ''
let s:autoUMarks = ''
" The index into s:autoUMarks indicating the next mark to auto-place
" (the index into s:autoLMarks is defined per-buffer)
let s:autoA = 0
" Colour definitions for the signs
highlight default MarkXL ctermfg=214 ctermbg=0 cterm=bold guifg=#ffaf00 guibg=#000000 gui=bold
highlight default MarkXP ctermfg=108 ctermbg=0 cterm=bold guifg=#87af87 guibg=#000000 gui=bold
highlight default MarkXU ctermfg=109 ctermbg=0 cterm=bold guifg=#87afaf guibg=#000000 gui=bold
highlight default MarkXN ctermfg=175 ctermbg=0 cterm=bold guifg=#d787af guibg=#000000 gui=bold
" Sign priorities. The higher the value, the higher the priority (vim default is 10)
const s:sPriorL = get(g:, 'MarkxPriorL', 10)
const s:sPriorP = get(g:, 'MarkxPriorP', 10)
const s:sPriorU = get(g:, 'MarkxPriorU', 10)
const s:sPriorN = get(g:, 'MarkxPriorN', 10)
" The ASCII code for the first possible mark, and the span of all marks (NOT the
" same as the total number of marks)
const s:firstMarkNr = char2nr('"')
const s:spanMarkNrs = (char2nr('}') - char2nr('"')) + 1
" An optional character to place after the sign name. This may be an empty
" string or a single character. If defined, a character such as '>' or ':'
" is often used
const s:mktrail = get(g:, 'MarkxSignTrail', '')
" ----------------------------------
" Print a 'status' message to the command line
function s:PrintStatusMsg(msg)
echohl StatusMsg | echo a:msg | echohl None
endfunction
" Print a 'warning' message to the command line
function s:PrintWarningMsg(msg)
echohl WarningMsg | echo a:msg | echohl None
endfunction
" ----------------------------------
" Determine the type of mark
"
" mk - The mark name to assess
"
" Returns the type of mark;-
" '-' - Not a valid mark name
" 'l' - The mark is in the range 'a' to 'z'
" 'u' - The mark is in the range 'A' to 'Z'
" 'n' - The mark is in the range '0' to '9' (these marks cannot be explicitly set)
" 'p' - The mark is one of ' ` < > [ ]
" 'x' - The mark is one of " ( ) . ^ { } (these marks cannot be explicitly set)
"
function s:mkType(mk)
let l:type = '-'
let l:mkn = char2nr(a:mk) - s:firstMarkNr
if (l:mkn >= 0) && (l:mkn < s:spanMarkNrs)
let l:type = s:mkTypes[l:mkn]
endif
return l:type
endfunction
" Return a list of currently active marks (whether local or global) for
" the current buffer
"
" NOTE: If a mark is defined beyond the last line of the buffer then
" it is considered 'invalid'. However, vim still maintains the
" mark's position so if the file is extended to/beyond the
" line the mark is defined at, the mark shall become valid.
" The point is, vim does not automatically delete the 'invalid'
" mark, so it's not the place of this script to delete it either.
" Note also that if the mark is set beyond the end of an existing
" line, it is NOT considered 'invalid' which is a bit inconsistent.
" The upshot is that 'invalid' marks are treated by this function
" as if they were valid and are returned
"
" mk - A string specifying a list of marks to consider and return status'
" for
"
" Returns a list of active marks. Each list elements is itself a
" 3 element list; [0] = a single character (the mark's name),
" [1] = the line number the mark is attached to, and [2] = the
" buffer number that the mark is assigned to (this only applies
" if the mark is a global one; zero shall be returned for local
" marks)
"
function s:getMarks(mk)
" Index into 'mk' string
let l:mkx = 0
" Number of lines in buffer. Invalid marks will have line number in excess of this
let l:nlines = line('$')
" Table of mark names that are set
let l:currMarks = []
let l:currIdx = 0
while l:mkx < len(a:mk)
let l:pos = getpos("'".a:mk[l:mkx])
if l:pos[1]
" Mark is set (though may be invalid) - record it
call add(l:currMarks, [a:mk[l:mkx], l:pos[1], l:pos[0]])
let l:currIdx += 1
endif
let l:mkx += 1
endwhile
return l:currMarks
endfunction
" Define a sign - if the sign already exists then it is just updated
"
" mk - The mark name to create the sign for
" type - The type of mark (as returned by mkType(). The type is assumed
" to be valid
"
function s:makeSign(mk, type)
" Select the colour for the sign
let l:colour = 'MarkXP'
if a:type ==# 'l'
let l:colour = 'MarkXL'
elseif a:type ==# 'u'
let l:colour = 'MarkXU'
elseif a:type ==# 'n'
let l:colour = 'MarkXN'
endif
call sign_define('MarkX'.char2nr(a:mk), {'text' : a:mk.s:mktrail, 'texthl' : l:colour})
endfunction
" Refresh all signs in the current buffer
"
" globMarks - Optional. If specified, then this is the list of global marks
" to consider
" localMarks - Optional. If specified then this is the list of local marks
" to consider
"
function s:refreshSigns(globMarks = s:getMarks(s:userGlobMarks), localMarks = s:getMarks(s:userLocalMarks))
" The buffer number associated with the current window
let l:bufn = bufnr()
" Get list of placed signs in the specified buffer
let l:splacedtot = sign_getplaced(l:bufn, {'group' : 'MarkX'})
let l:splaced = repeat([0], s:spanMarkNrs)
let l:splacedCount = 0
" Extract Id and line number for each defined sign
if len(l:splacedtot)
" Buffer exists - extract list of signs that we might be interested in
let l:splacedlist = l:splacedtot[0]['signs']
let l:idx = 0
while l:idx < len(l:splacedlist)
let l:id = l:splacedlist[l:idx]['id'] - s:firstMarkNr
if (l:id >= 0) && (l:id < s:spanMarkNrs)
" This is a sign we may be interested in - record its line number
let l:splaced[l:id] = l:splacedlist[l:idx]['lnum']
let l:splacedCount += 1
endif
let l:idx += 1
endwhile
endif
" Refresh all the signs. This is done in two passes; the first pass handles
" the marks local to the buffer ('a' to 'z' and . ' ` ^ < > [ ] { } ( ) "), and
" the second pass handles the global marks ('A' to 'Z', '0' to '9')
" Get list of active local marks for current buffer
let l:mk = a:localMarks
let l:pass = 0
while l:pass < 2
" Check each mark in turn
let l:mkx = 0
while l:mkx < len(l:mk)
" The mark name, and the ASCII code equiv
let l:mkName = l:mk[l:mkx][0]
let l:mkCode = char2nr(l:mkName)
" The priority of the associated sign
let l:sPrior = 10
if l:pass
let l:sPrior = ((l:mkCode >= 65) && (l:mkCode <= 90)) ? s:sPriorU : s:sPriorN
else
let l:sPrior = ((l:mkCode >= 97) && (l:mkCode <= 122)) ? s:sPriorL : s:sPriorP
endif
" Index into l:placed[] array for this mark
let l:idx = l:mkCode - s:firstMarkNr
if l:splaced[l:idx]
" Sign is placed for this mark
if l:splaced[l:idx] != l:mk[l:mkx][1]
" Sign line number doesn't match mark's line number - move the sign
call sign_unplace('MarkX', {'buffer' : l:bufn, 'id' : l:mkCode})
call sign_place(l:mkCode, 'MarkX', 'MarkX'.(l:mkCode), l:bufn, {'lnum' : l:mk[l:mkx][1], 'priority' : l:sPrior})
endif
" Mark sign as 'processed'
let l:splaced[l:idx] = 0
let l:splacedCount -= 1
elseif !l:pass || (l:mk[l:mkx][2] == l:bufn)
" On second pass, the buffer number of the 'global' mark must match the
" specified buffer in order to be considered
" Sign is not placed for this mark - place it
call s:makeSign(l:mkName, s:mkType(l:mkName))
call sign_place(l:mkCode, 'MarkX', 'MarkX'.(l:mkCode), l:bufn, {'lnum' : l:mk[l:mkx][1], 'priority' : l:sPrior})
endif
let l:mkx += 1
endwhile
if !l:pass
" Prepare for second pass - get list of active global marks
let l:mk = a:globMarks
endif
let l:pass += 1
endwhile
" Remove any signs that do not have associated marks
let l:idx = 0
while l:splacedCount && (l:idx < s:spanMarkNrs)
if l:splaced[l:idx]
" Sign is placed - remove it
call sign_unplace('MarkX', {'buffer' : l:bufn, 'id' : l:idx + s:firstMarkNr})
" Mark sign as 'processed'
let l:splacedCount -= 1
endif
let l:idx += 1
endwhile
endfunction
" Place a mark. The mark is always placed in the current buffer. The mark
" may already exist in which case it it moved. If the mark is a global type,
" it may be attached to some other buffer, in which case it is moved to the
" current buffer
"
" Only marks 'a' to 'z', 'A' to 'Z' and ' ` [ ] < > may be specified
"
" mk - The mark name to create, place, and add the sign for
" ln - The line number to set the mark at. If 0 is specified then the mark
" is placed at the cursor position. If ln > 0 then the mark is placed
" at line ln, column 0
" signed - If non-zero then this indicates that a sign should always be placed
" for the mark 'mk'. If this is zero then the function will determine
" for itself whether or not to display a sign
"
" Failure status. non-zero = failed (mark not set/moved). zero = success
"
function s:placeMark(mk, ln, signed)
" Returned failure status
let l:fail = 1
" Type of mark
let l:type = s:mkType(a:mk)
if (l:type ==# 'n') || (l:type ==# 'x')
call s:PrintWarningMsg('MarkX: Cannot place mark "'.a:mk.'" - not a mark that can be user-controlled')
elseif l:type !=# '-'
" Mark is valid - determine where to place it
let l:ln = (a:ln) ? a:ln : line('.')
let l:col = (a:ln) ? 0 : col('.')
" Current buffer number
let l:bufn = bufnr()
" Determine if a sign should be placed for this mark or not
let l:signed = a:signed || (stridx((l:type ==# 'l') ? s:userLMarks : ((l:type ==# 'u') ? s:userUMarks : s:userPMarks), a:mk) >= 0)
" Mark is valid - get mark's current status
let l:pos = getpos("'".a:mk)
if (l:pos[1] != l:ln) || (l:pos[2] != l:col) || ((l:type ==# 'u') && (l:pos[0] != l:bufn))
" Mark is local and its position (if set at all) needs changing, or it's
" global and its position or associated buffer have changed, or the mark
" is not set at all
" The mark name converted to its ASCII code equiv
let l:mkCode = char2nr(a:mk)
if l:signed && (l:type ==# 'u') && l:pos[1] && (l:pos[0] != l:bufn)
" Mark is global and is set in a buffer other than the specified one - Remove
" associated sign (if any) from buffer to which the mark is currently associated
call sign_unplace('MarkX', {'buffer' : l:pos[0], 'id' : l:mkCode})
endif
" Place or move the marker
if a:ln
" Place at specified line, column 0
exe l:ln.'mark '.a:mk
else
" Place at cursor position
exe 'normal! m'.a:mk
endif
if l:signed
" The priority of the associated sign
let l:sPrior = s:sPriorP
if (l:type ==# 'l')
let l:sPrior = s:sPriorL
elseif l:type ==# 'u'
let l:sPrior = s:sPriorU
endif
" Adjust the associated sign
let l:totSign = sign_getplaced(l:bufn, {'group' : 'MarkX', 'id' : l:mkCode})
let l:sign = l:totSign[0]['signs']
if len(l:sign)
" Sign is placed for this mark
if l:sign[0]['lnum'] != l:ln
" Sign line number doesn't match mark's line number - move the sign
call sign_unplace('MarkX', {'buffer' : l:bufn, 'id' : l:mkCode})
call sign_place(l:mkCode, 'MarkX', 'MarkX'.(l:mkCode), l:bufn, {'lnum' : l:ln, 'priority' : l:sPrior})
endif
else
" Sign is not placed for this mark - place it
call s:makeSign(a:mk, l:type)
call sign_place(l:mkCode, 'MarkX', 'MarkX'.(l:mkCode), l:bufn, {'lnum' : l:ln, 'priority' : l:sPrior})
endif
endif
let l:fail = 0
endif
else
call s:PrintWarningMsg('MarkX: Cannot place mark "'.a:mk.'" - invalid mark')
endif
return l:fail
endfunction
" Unplace/remove a mark. If the mark is a global type then it may be defined
" in (and removed from) some buffer other than the current one
"
" Only marks 'a' to 'z', 'A' to 'Z' and ' ` < > [ ] may be specified
"
" mk - The mark name to remove
" Aglob - Only used for marks 'A' to 'Z'. If zero then a global mark
" will only be deleted if it is associated with the local buffer.
" Otherwise it shall always be deleted (regardless of the buffer it is
" associated with)
" quiet - If non-zero then SOME error/warning messages shall be suppressed
"
function s:unplaceMark(mk, Aglob, quiet)
" Type of mark
let l:type = s:mkType(a:mk)
if (l:type ==# 'n') || (l:type ==# 'x')
if !a:quiet
call s:PrintWarningMsg('MarkX: Cannot delete mark "'.a:mk.'" - not a mark that can be user-controlled')
endif
elseif l:type !=# '-'
" Mark is valid - get mark's current status
let l:pos = getpos("'".a:mk)
if (l:type !=# 'u') || a:Aglob || !l:pos[0] || (l:pos[0] == bufnr())
" Mark is associated with current buffer or caller has indicated that it should
" be deleted regardless
if l:pos[1]
" Mark is set - unset it
exe 'delmarks '.a:mk
endif
" The mark name converted to its ASCII code equiv
let l:mkCode = char2nr(a:mk)
" Unplace the sign for the mark (if it's placed). The sign may be in the
" current buffer or (if the associated mark is global) in some other buffer
if l:type ==# 'u'
" Global mark - may have a buffer number that doesn't actually exist;
" may be attached to a file that is not currently loaded or some such
if bufexists(l:pos[0])
call sign_unplace('MarkX', {'buffer' : l:pos[0], 'id' : l:mkCode})
endif
else
call sign_unplace('MarkX', {'buffer' : bufnr(), 'id' : l:mkCode})
endif
endif
else
call s:PrintWarningMsg('MarkX: Cannot delete mark "'.a:mk.'" - invalid mark')
endif
endfunction
" Unplace/remove multiple marks
"
" mk - A string indicating the marks to remove
" Only marks 'a' to 'z', 'A' to 'Z' and ' ` < > [ ] may be specified
" Aglob - Only used for marks 'A' to 'Z'. If zero then a global mark
" will only be deleted if it is associated with the local buffer.
" Otherwise it shall always be deleted (regardless of the buffer it is
" associated with)
"
function s:unplaceMany(mk, Aglob)
let l:idx = 0
while l:idx < len(a:mk)
call s:unplaceMark(a:mk[l:idx], a:Aglob, 1)
let l:idx += 1
endwhile
endfunction
" Determine the next mark in the range 'a' to 'z' or 'A' to 'Z' to use for
" auto-selection and set it
"
" A - If zero then the selected mark will be in the range 'a' to 'z'. If
" non-zero, the selected mark will be in the range 'A' to 'Z'
" ln - The line number to set the mark at. If 0 is specified then the mark
" is placed at the cursor position. If ln > 0 then the mark is placed
" at line ln, column 0
" force - If zero and no free marks are available then fail. If non-zero and no
" free marks are available then re-allocate an existing/placed mark
"
" Returns mark name. '' is returned if 'forced' is false and no free marks are
" available
"
function s:placeNext(A, ln, force)
let l:mkSet = ''
let l:allMarks = (a:A) ? s:autoUMarks : s:autoLMarks
if !len(l:allMarks)
call s:PrintWarningMsg('MarkX: Cannot auto-place mark - no '.((a:A) ? "'A' to 'Z'" : "'a' to 'z'").' marks specified in config')
else
let l:idxStart = (a:A) ? s:autoA : get(b:, 'MarkxAutoa', 0)
let l:idx = l:idxStart
let l:forced = 0
" Current buffer number
let l:bufn = bufnr()
" Number of lines in buffer. Invalid marks will have line number in excess of this
let l:nlines = line('$')
" Search for next free (unplaced) mark and place it
let l:stop = 0
while !l:stop
let l:pos = getpos("'".l:allMarks[l:idx])
" To be eligible for being used, the mark must be either not placed, or be
" invalid. Plus, if it's a global mark, it must be set in the current
" buffer (if it's set at all)
let l:eligible = (!l:pos[1] || (l:pos[1] > l:nlines)) && (!a:A || (l:pos[0] == l:bufn))
if !l:eligible
" Mark is defined/placed and not invalid - try next one
let l:idx += 1
if l:idx >= len(l:allMarks)
let l:idx = 0
endif
if l:idx == l:idxStart
" Have exhausted the search
if a:force
" Place the currently selected mark
let l:mkSet = l:allMarks[l:idx]
let l:forced = 1
else
call s:PrintWarningMsg('MarkX: Cannot auto-place mark - no free '.((a:A) ? "'A' to 'Z'" : "'a' to 'z'").' marks left')
endif
let l:stop = 1
endif
else
" Found a spare mark - place it
let l:mkSet = l:allMarks[l:idx]
let l:stop = 1
endif
endwhile
if l:mkSet !=# ''
" Set mark
call s:placeMark(l:allMarks[l:idx], a:ln, 1)
call s:PrintStatusMsg('MarkX: '.((l:forced) ? 'Moved' : 'Placed').' mark "'.(l:allMarks[l:idx]).'"')
" Record next mark to set for next time this is called
let l:idx += 1
if l:idx >= len(l:allMarks)
let l:idx = 0
endif
if a:A
let s:autoA = l:idx
else
let b:MarkxAutoa = l:idx
endif
endif
endif
return l:mkSet
endfunction
" Reset the auto-placement mark to just after the one specified for
" the current buffer
"
" mk - The mark to search for. This must be 'a' to 'z', or 'A' to 'Z'
"
" Returns the mark immediately after 'mk'. If 'mk' cannot be found
" then '' is returned
"
function s:resetPlaceNext(mk)
" Type of mark
let l:type = s:mkType(a:mk)
if (l:type ==# 'l') || (l:type ==# 'u')
let l:allMarks = (l:type ==# 'l') ? s:autoUMarks : s:autoLMarks
let l:idx = 0
" Search for specified mark
let l:stop = 0
while !l:stop && (l:idx < len(l:allMarks))
if a:mk == l:allMarks[l:idx]
" Have located mark - reset auto mark to just after this
let l:idx += 1
if l:idx >= len(l:allMarks)
let l:idx = 0
endif
if l:type ==# 'l'
let b:MarkxAutoa = l:idx
else
let s:autoA = l:idx
endif
let l:stop = 1
endif
let l:idx += 1
endwhile
endif
endfunction
" Return visual mode ordinates
"
" rat - If '1' then the returned list elements are ordered so that line1 <=
" line2 and col1 <= col2 (rationalised).
" If '0' then the returned list elements are ordered so that the
" line1/col1 represents the cursor position at the start of the selection
" and line2/col2 represents the current cursor position at the end of the
" selection (ie, the current cursor position)
"
" Returns
" A list in the order [line1, col1, line2, col2]. An empty list is returned on
" an error
"
function s:getVOrdinates(rat)
" Get start and end line numbers of the visual selection
let [l:l1, l:c1a, l:c1b] = getpos("'<")[1:3]
let [l:l2, l:c2a, l:c2b] = getpos("'>")[1:3]
let l:posn = []
" The act of handling the key mapping will have caused visual mode to drop-out. Return to it
exe 'normal! gv'
" Get the logical column numbers of the start and end of the visual selection
let l:c1 = col("'<")
let l:c2 = col("'>")
if a:rat == 1
" Rationalise the returned list
let l:posn = [l:l1, (l:c1 >= l:c2) ? l:c2 : l:c1, l:l2, (l:c1 >= l:c2) ? l:c1 : l:c2]
else
" Return list in an order showing the actual selection start and end points.
" l1 will always be <= l2, so we need to check the current cursor position
" to work out the order to return the list (to set cursor position at the end)
let l:cursor = getpos('.')
if ((l:cursor[1] == l:l1) && (l:cursor[2] == (l:c1a + l:c1b)))
" Cursor is on line l1 (actually, position '<)
let l:posn = [l:l2, l:c2, l:l1, l:c1]
else
" Cursor is on line l2 (actually position '>)
let l:posn = [l:l1, l:c1, l:l2, l:c2]
endif
endif
" Drop out of visual selection mode again
exe "normal! \<esc>"
return l:posn
endfunction
" Set a specific mark
function markx#Add(mk, ln)
if a:mk !=# ""
let l:fail = s:placeMark(a:mk, a:ln, 0)
if (!l:fail && get(g:, 'MarkxSteponAuto', 0))
call s:resetPlaceNext(a:mk)
endif
endif
endfunction
" Auto-select and place mark in the range 'a' to 'z'
function markx#Adda()
call s:placeNext(0, 0, get(g:, 'MarkxAutoLForce', 0))
endfunction
" Auto-select and place mark in the range 'A' to 'Z'
function markx#AddA()
call s:placeNext(1, 0, get(g:, 'MarkxAutoUForce', 0))
endfunction
" Set a mark while in visual selection mode
"
" type - '' = Place the mark 'mk'
" 'l' = auto-select and place mark in the range 'a' to 'z'
" 'u' = auto-select and place mark in the range 'A' to 'Z'
" mk - The mark to set if type is ''
"
function markx#Addv(type, mk)
" Get visual selection details and cursor position
let l:vsel = s:getVOrdinates(0)
let l:curs = getcurpos()
" Reposition cursor to where it is displayed in the window (this is often
" wrong when the visual selection is active)
call setpos('.', [0, l:vsel[2], l:vsel[3], l:curs[3]])
" Place mark
if a:type ==# ''
call markx#Add(a:mk, 0)
elseif a:type ==# 'l'
call markx#Adda()
else
call markx#AddA()
endif
" Restore cursor so that visual selection can continue correctly, and re-enter
" visual selection mode
call setpos('.', l:curs)
exe 'normal! gv'
endfunction
" Delete a mark
function markx#Del(mk)
if a:mk !=# ""
call s:unplaceMark(a:mk, 1, 0)
endif
endfunction
" Delete all marks of a particular type. Only marks that are specified to
" have signs displayed for them are deleted
"
" type - Type of marks to delete -
" 'l' = All marks 'a' to 'z'
" 'u' = All marks 'A' to 'Z'
" 'p' = All marks ' ` < > [ ]
" auto - Optional. If non-zero then only the auto-placement marks of the
" specific type are delete. This may only be used with types 'l'
" and 'u'. If zero then all marks of 'type' are deleted
"
function markx#DelAll(type, auto = 0)
let l:mk = ''
if a:type ==# 'l'
let l:mk = (a:auto) ? s:autoLMarks : s:userLMarks
elseif a:type ==# 'u'
let l:mk = (a:auto) ? s:autoUMarks : s:userUMarks
elseif a:type ==# 'p'
let l:mk = s:userPMarks
endif
if l:mk !=# ''
" Get confirmation if configured
if get(g:, 'MarkxConfirmDelAll', 0)
" Get confirmation
call inputsave()
echohl Question
let l:ans = input("MarkX: Delete all marks '".l:mk."' ? : ")
echohl None
call inputrestore()
echo "\<cr>"
if ((l:ans !=# 'y') && (l:ans !=# 'Y'))
let l:mk = ''
endif
endif
if l:mk !=# ''
" Delete
let l:Aglob = get(g:, 'MarkxDelAllUGlobal', 0)
call s:unplaceMany(l:mk, l:Aglob)
call s:PrintStatusMsg("MarkX: Deleted all marks '".l:mk."'".((a:type ==# 'u') ? ((l:Aglob) ? ' (globally)' : ' (from local buffer only)') : ''))
endif
endif
endfunction
" Refresh all marks/signs for current buffer
function markx#Refresh()
let l:da = get(b:, 'MarkxDispAll', 0)
if l:da
call s:refreshSigns(s:getMarks(s:allGlobalMarks), s:getMarks(s:allLocalMarks))
else
call s:refreshSigns()
endif
endfunction
" Refresh all marks/signs for all buffers displayed in current tab
function markx#RefreshAll()
" It is not possible to break out of the 'command line' buffer if open, so
" suppress the refresh if it is (avoids an error being output)
if !((getbufvar(winbufnr(0), '&buftype') == 'nofile') && (bufname() == '[Command Line]'))
" Save view before iterating through the windows
let l:focuswin = winnr()
let l:winview = winsaveview()
" Pre-fetch this so that s:refreshSigns() does not have to do each time it is called below
let l:globMarks = s:getMarks(s:userGlobMarks)
" List of ALL global marks set (only needed if b:MarkxDispAll is set)
let l:globMarksAll = []
let l:globMarksAllSet = 0
" A note of which buffers we have processed
let l:done = {}
" If 'secure' is set then the 'noautocmd' option when executing 'wincmd w'
" will cause an error (I don't really understand this)
const l:winCmdOpt = 'keepjumps '.((&secure) ? '' : 'noautocmd ')
for l:winx in range(1, winnr('$'))
exe l:winCmdOpt .l:winx.'wincmd w'
let l:bufn = bufnr()
if !has_key(l:done, l:bufn)
" Refresh marks in buffer
if get(b:, 'MarkxDispAll', 0)
" Display all marks for this buffer
if !l:globMarksAllSet
let l:globMarksAll = s:getMarks(s:allGlobalMarks)
let l:globMarksAllSet = 1
endif
call s:refreshSigns(l:globMarksAll, s:getMarks(s:allLocalMarks))
else
" Display only the marks specified in the config
call s:refreshSigns(l:globMarks)
endif
let l:done[l:bufn] = 1
endif
endfor
" Restore view
exe l:winCmdOpt.l:focuswin.'wincmd w'
call winrestview(l:winview)
endif
endfunction
" Toggle 'display all signs for all marks'
function markx#ToggleShowAll()
let l:da = get(b:, 'MarkxDispAll', 0)
let b:MarkxDispAll = 1 - l:da
call markx#Refresh()
call s:PrintStatusMsg("MarkX: 'Display ALL marks for buffer' ".((b:MarkxDispAll) ? 'on' : 'off'))
endfunction
" Initialise auto-placement mark list(s)
"
" type - The type of list to initialise - 'l' or 'u'
" desc - The range of the list (for error output only)
" autoMarks - The list of auto marks (string)
" rec - The list of recorded marks from the main user marks list
"
" Return error status - 1 = error
"
function s:initAutoList(type, desc, autoMarks, rec)
let l:err = 0
" Duplicate mark name detection
let l:autoDup = repeat([0], s:spanMarkNrs)
" Check that auto marks are valid
let l:idx = 0
while !l:err && (l:idx < len(a:autoMarks))
let l:mk = a:autoMarks[l:idx]
let l:type = s:mkType(l:mk)
if l:type == a:type
let l:mkIdx = char2nr(l:mk) - s:firstMarkNr
if l:autoDup[l:mkIdx]
call s:PrintWarningMsg("MarkX: List of ".a:desc." auto marks includes a duplictate mark name; '".l:mk."'")
call getchar()
let l:err = 1
elseif !a:rec[l:mkIdx]
" Auto mark is not defined in user marks - error
call s:PrintWarningMsg("MarkX: Auto ".a:desc." mark is outside of the managed range; '".l:mk."'")
call getchar()
let l:err = 1
endif
let l:autoDup[l:mkIdx] = 1
else
call s:PrintWarningMsg("MarkX: Auto ".a:desc." mark includes an invalid mark name; '".l:mk."'")
call getchar()
let l:err = 1
endif
let l:idx += 1
endwhile
return l:err
endfunction
" Initialisation
function markx#Init()
let l:err = 0
" Use user-selected marks to display, if specified. The default of
" 'all marks' is used if the list if empty
let l:allMarks = get(g:,'MarkxDisplayMarks', s:allLocalMarks.s:allGlobalMarks)
if !len(l:allMarks)
let l:allMarks = s:allLocalMarks.s:allGlobalMarks
endif
" Duplicate mark name and validity detection
let l:rec = repeat([0], s:spanMarkNrs)
" Split the list of all marks into their different types
let l:idx = 0
while !l:err && (l:idx < len(l:allMarks))
let l:mk = l:allMarks[l:idx]
let l:type = s:mkType(l:mk)
if l:type !=# '-'
" Check for duplicate
let l:mkIdx = char2nr(l:mk) - s:firstMarkNr
if l:rec[l:mkIdx]
call s:PrintWarningMsg("MarkX: List of marks includes a duplictate mark name; '".l:mk."'")
call getchar()
let l:err = 1
endif
let l:rec[l:mkIdx] = 1
endif
if l:type ==# 'l'
let s:userLMarks = s:userLMarks.l:mk
elseif l:type ==# 'u'
let s:userUMarks = s:userUMarks.l:mk
elseif l:type ==# 'n'
let s:userNMarks = s:userNMarks.l:mk
elseif l:type ==# 'p'
let s:userPMarks = s:userPMarks.l:mk
elseif l:type ==# 'x'
let s:userXMarks = s:userXMarks.l:mk
else
call s:PrintWarningMsg("MarkX: List of marks includes an invalid mark name; '".l:mk."'")
call getchar()
let l:err = 1
endif
let l:idx += 1
endwhile
" Lists of ALL local and ALL global marks the user is interested in
let s:userLocalMarks = s:userLMarks.s:userPMarks.s:userXMarks
let s:userGlobMarks = s:userUMarks.s:userNMarks
if !l:err
" Set up the lists of auto-selected marks
let s:autoLMarks = get(g:, 'MarkxAutoLMarks', s:userLMarks)
let s:autoUMarks = get(g:, 'MarkxAutoUMarks', s:userUMarks)
let l:err = s:initAutoList('l', "'a' to 'z'", s:autoLMarks, l:rec)
if !l:err
let l:err = s:initAutoList('u', "'A' to 'Z'", s:autoUMarks, l:rec)
endif
endif
endfunction
" ------------------------------------------------------------------------------
" eof

View File

@ -0,0 +1,47 @@
1234567890
0x20114203
asdasdzsdasdasdasDASDASDASDASDASdasdasdasdasdasdasdasdasdasdasdasd
asdasdzsdalksjdhadasdasdasdasdasdasdasdasdasdasdasdasdasdtsdasdasd
asdasdzsdaSDASDASDasdasdasdasdasdasdasdklajsghdahsldkhasdtsdasdasd
asasklzdasgoiasudgasipudhldasdasdasdasdasdasdasdascasdasdtsdasdasd
asdasdzsdasdasdasdasdasdasdasdasdasdasdasdasdasdascasdasdtsdasdasd
asdasdzsdasdasdasdasdasdaashkgdahgsauizfsdasdasdascasdasdtsdasdasd
asdasdasdasdasdasDASDAsdasdasaksgdlaskdjhaskljdhaskldjhjdasdasdasd
ĐitalicĐ Blue(asdasdasdasd) *****************
ĐĐboldĐĐ Yellow(asdasdasdd) ****** ******
ĐĐĐitalic boldĐĐĐ *** ***
Gray(gray) ** **
Red( +------------------*-----------------------------+ *
Can shitdows do this? | ** | **
) | *** | ***
đunderlineđ | ****** ******
| ***************** |
ßßreverseßß | |
ASD: | |
new | |
delete //this is a comment | |
and | |
or | |
not | |
as | |
if | |
else | |
switch | |
throw | |
case /*yay even more comments*/ +------------------------------------------------+
default
public
private
friend
protected
"asdajsdklasjbdkabjsd"
'a'
${asd}
true
false
#define my_macro ALKSHGDASLD\
KLASJDHKLAJSBDLKAJBSDKLJALSB\
ASJKLDBKLASBDVUIAAKGHBSJHBDF\
KLASDGASJHDUASTETTTOAISUHNVHK
10000000000000000000000000000
NOTE: do not note anything

View File

@ -0,0 +1,197 @@
#!/usr/bin/python
from __future__ import print_function
import os
import sys
import zipfile
import fnmatch
import subprocess
vimfiles_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),'..'))
import socket
hostname = socket.gethostname()
GIT=["git"]
# Recursive glob function, from
# http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python#2186565
def Rglob(path, match):
matches = []
for root, dirnames, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, match):
matches.append(os.path.join(root, filename))
return matches
def UpdateReleaseVersion():
release_file = os.path.join(vimfiles_dir,'plugin/TagHighlight/data/release.txt')
fh = open(release_file,'r')
lines = [i for i in fh]
fh.close()
release = 'INVALID'
fh = open(release_file, 'wb')
for line in lines:
if line.startswith('release:'):
parts = line.strip().split(':')
numbers = [int(i) for i in parts[1].split('.')]
release = '{0}.{1}.{2}'.format(numbers[0],numbers[1],numbers[2]+1)
fh.write('release:'+release+'\n')
else:
fh.write(line.strip() + '\n')
fh.close()
return release
version_info_initial = ['log','-1',"--format=format:release_revid:%H%nrelease_date:%ad","--date=iso"]
clean_info = ['status', '--porcelain']
def GenerateVersionInfo():
version_file = os.path.join(vimfiles_dir,'plugin/TagHighlight/data/version_info.txt')
args = GIT + clean_info
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout,stderr) = p.communicate()
status_lines = stdout
if len(status_lines) > 0:
clean = False
clean_line = "release_clean:0"
else:
clean = True
clean_line = "release_clean:1"
args = GIT + version_info_initial
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout,stderr) = p.communicate()
# Write as binary for consistent line endings
fh = open(version_file, 'wb')
fh.write(clean_line + "\n")
for line in stdout.split('\n'):
if line.startswith('release_'):
fh.write(line + '\n')
fh.close()
return version_file, clean
def MakeMainRelease(r):
# List of paths to include (either explicit files or paths to search)
paths = {
'.py': ['plugin/TagHighlight',__file__],
'.vim': ['plugin/TagHighlight.vim','autoload/TagHighlight'],
'.txt': ['plugin/TagHighlight/data','plugin/TagHighlight/instructions.txt', 'doc/TagHighlight.txt'],
'.spec': ['plugin/TagHighlight/TagHighlight.spec'],
}
filename = 'taghighlight_r{0}.zip'.format(r)
MakeZipFile(filename, paths)
def MakeZipFile(filename, paths):
# Create the zipfile
zipf = zipfile.ZipFile(os.path.join(vimfiles_dir, 'dist', filename), 'w')
# Collect the specified paths into a zip file
for ext, pathlist in paths.items():
for path in pathlist:
# Get the full path (specified relative to vimfiles directory)
full_path = os.path.join(vimfiles_dir, path)
if os.path.exists(full_path):
if os.path.isfile(full_path):
files = [full_path]
elif os.path.isdir(full_path):
files = Rglob(full_path, '*' + ext)
else:
print("Unrecognised path: " + full_path)
if len(files) > 0:
for f in files:
dirname = os.path.dirname(os.path.relpath(f,vimfiles_dir))
zipf.write(f,os.path.join(dirname, os.path.basename(f)), zipfile.ZIP_DEFLATED)
else:
print("No files found for path: " + full_path)
else:
print("Path does not exist: " + full_path)
# Close the zipfile
zipf.close()
def MakeLibraryPackage(r):
paths = {
'.txt': ['plugin/TagHighlight/standard_libraries'],
'.taghl': ['plugin/TagHighlight/standard_libraries'],
}
filename = 'taghighlight_standard_libraries_r{0}.zip'.format(r)
MakeZipFile(filename, paths)
def MakeCompiled(pyexe, pyinstaller_path, zipfilename, platform_dir):
initial_dir = os.getcwd()
os.chdir(os.path.join(vimfiles_dir, 'plugin/TagHighlight'))
args = pyexe + [os.path.join(pyinstaller_path, 'Build.py'), '-y', 'TagHighlight.spec']
p = subprocess.Popen(args)#, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout,stderr) = p.communicate()
zipf = zipfile.ZipFile(os.path.join(vimfiles_dir,'dist',zipfilename), 'w')
for f in Rglob(os.path.join(vimfiles_dir,'plugin/TagHighlight/Compiled/'+platform_dir),'*'):
dirname = os.path.dirname(os.path.relpath(f,vimfiles_dir))
zipf.write(f,os.path.join(dirname, os.path.basename(f)), zipfile.ZIP_DEFLATED)
zipf.close()
os.chdir(initial_dir)
def MakeWin32Compiled(r):
if 'WINPYTHON' in os.environ:
# Doesn't work with spaces in the path
# (doing the split to allow for running python
# with wine).
pyexe = os.environ['WINPYTHON'].split(' ')
else:
pyexe = ['python.exe']
pyinstaller_path = os.environ['WINPYINSTALLERDIR']
MakeCompiled(pyexe, pyinstaller_path, 'taghighlight_r{0}_win32.zip'.format(r), 'Win32')
def MakeLinuxCompiled(r):
if 'PYTHON' in os.environ:
# Doesn't work with spaces in the path
# (doing the split to allow for running python
# with wine).
pyexe = os.environ['PYTHON']
else:
pyexe = ['python']
pyinstaller_path = os.environ['PYINSTALLERDIR']
MakeCompiled(pyexe, pyinstaller_path, 'taghighlight_r{0}_linux.zip'.format(r), 'Linux')
def CheckInChanges(r):
args = GIT+['add','plugin/TagHighlight/data/release.txt']
p = subprocess.Popen(args)
(stdout,stderr) = p.communicate()
args = GIT+['commit','-m','Release build {0}'.format(r)]
p = subprocess.Popen(args)
(stdout,stderr) = p.communicate()
args = GIT+['tag','taghighlight-release-{0}'.format(r)]
p = subprocess.Popen(args)
(stdout,stderr) = p.communicate()
args = GIT+['push','origin','master','--tags']
p = subprocess.Popen(args)
(stdout,stderr) = p.communicate()
def PublishReleaseVersion():
# TODO
# This function will be used to push generated files to a remote location
# to make them available on the web
pass
def main():
version_file, clean = GenerateVersionInfo()
if clean:
new_release = UpdateReleaseVersion()
MakeMainRelease(new_release)
os.remove(version_file)
MakeWin32Compiled(new_release)
MakeLinuxCompiled(new_release)
MakeLibraryPackage(new_release)
CheckInChanges(new_release)
PublishReleaseVersion()
else:
print("Distribution not clean: check into Git before making release.")
os.remove(version_file)
if __name__ == "__main__":
main()

550
vim/.vim/doc/DrawIt.txt Normal file
View File

@ -0,0 +1,550 @@
DrawIt.txt* The DrawIt Tool Jan 05, 2018
Authors: Charles E. Campbell <NdrchipO@ScampbellPfamily.AbizM>
Sylvain Viart <molo@multimania.com>
(remove NOSPAM from Campbell's email first)
Copyright: Copyright (C) 2018 Charles E. Campbell
Permission is hereby granted to use and distribute this code,
with or without modifications, provided that this copyright
notice is copied with it. Like anything else that's free,
DrawIt.vim and DrawItPlugin.vim are provided *as is*; it comes
with no warranty of any kind, either expressed or implied. By
using this plugin, you agree that in no event will the copyright
holder be liable for any damages resulting from the use of this
software.
==============================================================================
1. Contents *drawit-contents* {{{1
1. Contents......................: |drawit-contents|
2. DrawIt Manual.................: |drawit|
3. DrawIt Usage..................: |drawit-usage|
Starting....................: |drawit-start|
Stopping....................: |drawit-stop|
User Map Protection.........: |drawit-protect|
Drawing.....................: |drawit-drawing|
Tip.........................: |drawit-tip|
Changing Drawing Characters.: |drawit-setdrawit|
Moving......................: |drawit-moving|
Erasing.....................: |drawit-erase|
Example.....................: |drawit-example|
Visual Block Mode...........: |drawit-visblock|
Brushes.....................: |drawit-brush|
DrawIt Modes................: |drawit-modes|
4. DrawIt History................: |drawit-history|
==============================================================================
2. DrawIt Manual *drawit* {{{1
*drawit-manual*
/===============+============================================================\
|| Starting & | ||
|| Stopping | Explanation Links: ||
++--------------+-----------------------------------------------------------++
|| \di | start DrawIt |drawit-start| ||
|| \ds | stop DrawIt |drawit-stop| ||
|| :DIstart | start DrawIt |drawit-start| ||
|| :DIstart S | start DrawIt in single-bar mode |drawit-start| ||
|| :DIstart D | start DrawIt in double-bar mode |drawit-start| ||
|| :DIsngl | start DrawIt in single-bar mode |drawit-start| |drawit-sngl| ||
|| :DIdbl | start DrawIt in double-bar mode |drawit-start| |drawit-dbl| ||
|| :DIstop | stop DrawIt |drawit-stop| ||
|| :DrawIt[!] | start/stop DrawIt |drawit-start| |drawit-stop| ||
|| | ||
++==============+===========================================================++
|| Maps | Explanation Links: ||
++--------------+-----------------------------------------------------------++
|| | The DrawIt routines use a replace, move, and ||
|| | replace/insert strategy. The package also lets one insert||
|| | spaces, draw arrows by using the following characters or ||
|| | keypad characters: ||
|| | ||
|| <left> | move and draw left |drawit-drawing| ||
|| <right> | move and draw right, inserting lines/space as needed ||
|| <up> | move and draw up, inserting lines/space as needed ||
|| <down> | move and draw down, inserting lines/space as needed ||
|| <s-left> | move cursor left |drawit-move| ||
|| <s-right> | move cursor right, inserting lines/space as needed ||
|| <s-up> | move cursor up, inserting lines/space as needed ||
|| <s-down> | move cursor down, inserting lines/space as needed ||
|| <space> | toggle into and out of erase mode ||
|| > | insert a > and move right (draw -> arrow) ||
|| < | insert a < and move left (draw <- arrow) ||
|| ^ | insert a ^ and move up (draw ^ arrow) ||
|| v | insert a v and move down (draw v arrow) ||
|| <pgdn> | replace with a \, move down and right, and insert a \ ||
|| <end> | replace with a /, move down and left, and insert a / ||
|| <pgup> | replace with a /, move up and right, and insert a / ||
|| <home> | replace with a \, move up and left, and insert a \ ||
|| \> | insert a fat > and move right (draw -> arrow) ||
|| \< | insert a fat < and move left (draw <- arrow) ||
|| \^ | insert a fat ^ and move up (draw ^ arrow) ||
|| \v | insert a fat v and move down (draw v arrow) ||
||<s-leftmouse> | drag and draw with current brush |drawit-brush| ||
||<c-leftmouse> | drag and move current brush |drawit-brush| ||
|| | ||
||==============+===========================================================++
||Visual Cmds | Explanation ||
||--------------+-----------------------------------------------------------++
|| | The drawing mode routines use visual-block mode to ||
|| | select endpoints for lines, arrows, and ellipses. Bresen- ||
|| | ham and Bresenham-like algorithms are used for this. ||
|| | ||
|| | These routines need a block of spaces, and so the canvas ||
|| | routine must first be used to create such a block. The ||
|| | canvas routine will query the user for the number of ||
|| | lines to hold |'textwidth'| spaces. ||
|| Links: | ||
|| \a |drawit-a| | draw arrow from corners of visual-block selected region ||
|| \b |drawit-b| | draw box on visual-block selected region ||
|| \c |drawit-c| | the canvas routine (will query user, see above) ||
|| \e |drawit-e| | draw an ellipse on visual-block selected region ||
|| \f |drawit-f| | flood figure with a character (you will be prompted) ||
|| \g |drawit-g| | draw grid (using previous spacing, or 10x10) ||
|| \l |drawit-l| | draw line from corners of visual-block selected region ||
|| \s |drawit-s| | spacer: appends spaces up to the usable window with ||
|| | ||
++===========+==============================================================++
|| Functions | Explanation Links: ||
++-----------+--------------------------------------------------------------++
|| :call SetDrawIt('vertical','horizontal','crossing','\','/','X','*') ||
|| | set drawing characters for motions for moving ||
|| | and for the ellipse drawing boundary |drawit-setdrawit| ||
|| default | motion ||
|| | | up/down, ||
|| - | left/right, ||
|| + | -| crossing, ||
|| \ | downright, ||
|| / | downleft, and ||
|| X | \/ crossing ||
++==========+============+==================================================++
|| Commands | Explanation Links: ||
++-----------------------+--------------------------------------------------++
|| :SetBrush a-z | sets brush (register) to given register ||
|| :'<,'>SetBrush a-z | yanks visual block to brush |drawit-brush||| ||
|| :DInrml | switch to normal mode |drawit-nrml| ||
|| :DIsngl | switch to single-line mode |drawit-sngl| ||
|| :DIdbl | switch to double-line mode |drawit-dbl| ||
|| :DIarrow | draw an arrow |:DIarrow| ||
|| :DIbox | draw a box |:DIbox| ||
|| :DIcanvas | generate a canvas |:DIcanvas| ||
|| :DIcircle | draw a circle |:DIcircle| ||
|| :DIellipse | draw a ellipse |:DIellipse| ||
|| :DIflood | flood figure with a character |:DIflood| ||
|| :DIflood | draw a line |:DIline| ||
|| :DIgrid dr dc | toggle a rough grid |:DIgrid| ||
|| :DIoff | turn DrawIt off |:DIoff| ||
|| :DIspacer | append spaces up to textwidth |:DIspacer| ||
\============================================================================/
==============================================================================
3. DrawIt Usage *drawit-usage* {{{1
INSTALLING *drawit-install*
DrawIt is distributed as a |vimball|; to install DrawIt: >
vi DrawIt.vba
:so %
:q
These commands will put DrawIt into your .vim/plugin and .vim/autoload
directories. Only a little bit of DrawIt (.vim/plugin/DrawItPlugin.vim)
is actually always loaded; only when DrawIt is used will the main portion of
DrawIt be loaded. Thus DrawIt supports fast vim startup.
STARTING *drawit-start* {{{2
\di (starts in normal drawing mode) *drawit-\di*
:DrawIt (starts in normal drawing mode) *drawit-DrawIt*
:DIstart (starts in normal drawing mode) *drawit-DIstart*
:DIstart S (starts in single-bar drawing mode)
:DIstart D (starts in double-bar drawing mode)
:DInrml (starts in normal drawing mode) *drawit-DInrml*
:DIsngl (starts in single-bar drawing mode) *drawit-DIsngl*
:DIdbl (starts in double-bar drawing mode) *drawit-DIdbl*
DrawIt supports a number of different ways to start up as shown above; in
addition, you may use gvim and the DrChip menu.
To stop DrawIt, use \ds (*d*rawit *s*top) or :DIstop.
DrawIt also supports the use of |mapleader|; with that, you may specify
what you with as the maps' leading kickoff character. This document
will use the default '\'.
With a trailing 'S', :DIstart will begin in single-bar mode (see |drawit-sngl|).
With a trailing 'D', :DIstart will begin in double-bar mode (see |drawit-dbl|).
Similarly, :DIsngl and :DIdbl will start DrawIt as well as begin in
single-bar or double-bar mode, respectively.
A message, "[DrawIt]", will appear on the message line.
*drawit-off*
STOPPING *drawit-stop* {{{2
\ds
:DrawIt!
:DIstop
:DIoff
When you are done with DrawIt, use \ds to stop DrawIt mode. Stopping DrawIt
will restore your usual options and remove the maps DrawIt set up.
A message, "[DrawIt off]", will appear on the message line.
*drawit-utf16*
*drawit-utf8* *drawit-unicode*
NORMAL, SINGLE BAR, AND DOUBLE BAR MODES *drawit-sngl* *drawit-dbl*
:DInrml :DIsngl :DIdbl
One may use these commands to start up Drawit in normal, single-bar, or
double-bar modes, respectively. When your |'encoding'| is utf-8 or utf-16,
DrawIt supports drawing with special box characters (single-bar, double_bar).
These commands are also used to switch to normal, single-bar, or double-bar
modes.
USER MAP PROTECTION *drawit-protect* {{{2
Starting DrawIt causes it to set up a number of maps which facilitate drawing.
DrawIt accommodates users with conflicting maps by saving both maps and user
options and before setting them to what DrawIt needs. When you stop DrawIt
(|drawit-stop|), DrawIt will restore the user's maps and options as they were
before DrawIt was started.
OPTIONS *drawit-options* {{{2
*g:drawit_insertmode*
g:drawit_insertmode : if this variable exists and is 1 then maps are
made which make cursor-control drawing available
while in insert mode, too. Otherwise, DrawIt's
maps only affect normal mode.
DRAWING *drawit-drawing* {{{2
After DrawIt is started, use the number pad or arrow keys to move the cursor
about. As the cursor moves, DrawIt will then leave appropriate "line"
characters behind as you move horizontally, vertically, or diagonally, and
will transparently enlarge your file to accommodate your drawing as needed.
The trail will consist of -, |, \, / characters (depending on which direction
and SetDrawIt() changes), and + and X characters where line crossings occur.
You may use h-j-k-l to move about your display and generally use editing
commands as you wish even while in DrawIt mode.
Another tool that may be used to convert Ascii-art into nice pictures is
available at https://github.com/christiangoltz/shaape .
CHANGING DRAWING CHARACTERS *drawit-setdrawit* {{{2
The SetDrawIt() function is available for those who wish to change the
characters that DrawIt uses. >
ex. :call SetDrawIt('*','*','*','*','*','*','*')
ex. :call SetDrawIt('-','|','-','\','/','/','*')
<
The first example shows how to change all the DrawIt drawing characters to
asterisks, and the second shows how to give crossing priority to - and /.
The default setting is equivalent to: >
:call SetDrawIt('|','-','+','\','/','X','*')
<
where SetDrawit()'s arguments refer, in order, to the >
vertical drawing character
horizontal drawing character
horizontal/vertical crossing drawing character
down right drawing character
down left drawing character
diagonal crossing drawing character
ellipse boundary drawing character
<
TIP *drawit-tip*
I have found that sometimes one or more of the <home>, <end>, <pageup>,
and <pagedown> keys give unique sequences but are not interpreted
properly by Vim. This problem impacts DrawIt as it uses those four
keys to signify diagonal moves/drawing. One solution I use is to
put into my <.vimrc> file mapings like:
map ^V... <home>
where the ellipsis (...) is the actual character sequence produced by
hitting the key. The way to generate such maps is to type "map ",
followed by three control-v presses, press the associated key, then
a space followed by the proper interpretation sequence (ie. <home>).
MOVING *drawit-move* *drawit-moving* {{{2
DrawIt supports shifting the arrow keys to cause motion of the cursor. The
motion of the cursor will not modify what's below the cursor. The cursor
will move and lines and/or spaces will be inserted to support the move as
required. Your terminal may not support shifted arrow keys, however, or Vim
may not catch them as such. For example, on the machine I use, shift-up
(<s-up>) produced <Esc>[161q, but vim didn't know that sequence was a <s-up>.
I merely made a nmap:
nmap <Esc>[161q <s-up>
and vim thereafter recognized the <s-up> command.
ERASING *drawit-erase* {{{2
<space>
The <space> key will toggle DrawIt's erase mode/DrawIt mode. When in [DrawIt
erase] mode, a message "[DrawIt erase]" will appear and the number pad will
now cause spaces to be drawn instead of the usual drawing characters. The
drawing behavior will be restored when the <space> key toggles DrawIt back
to regular DrawIt mode.
EXAMPLES *drawit-example* {{{2
Needless to say, the square spirals which follow were done with DrawIt and
a bit of block editing with Vim: >
+------------ -----------+ +------------ -----------+ +------------
|+----------+ +---------+| |+----------+ +---------+| |+----------+
||+--------+| |+-------+|| ||+--------+| |+-------+|| ||+--------+|
|||-------+|| ||+------||| |||-------+|| ||+------||| |||-------+||
||+-------+|| ||+------+|| ||+-------+|| ||+------+|| ||+-------+||
|+---------+| |+--------+| |+---------+| |+--------+| |+---------+|
+-----------+ +----------+ +-----------+ +----------+ +-----------+
VISUAL BLOCK MODE FOR ARROWS LINES BOXES AND ELLIPSES *drawit-visblock* {{{2
Visual-Block Maps: ~
(see |visual-block|)
\a : draw arrow from corners of visual-block selected region *drawit-a*
\b : draw box on visual-block selected region *drawit-b*
\c : the canvas routine (will query user, see above) *drawit-c*
\e : draw an ellipse on visual-block selected region *drawit-e*
\g : draw a grid (uses previous spacing, or 10x10) *drawit-g*
\f : flood figure with a character (you will be prompted) *drawit-f*
\l : draw line from corners of visual-block selected region *drawit-l*
\s : spacer: appends spaces up to the usable window width *drawit-s*
Commands: ~
*:DIarrow* : draw arrow from corners of visual-block selected region
*:DIbox* : draw box on visual-block selected region
*:DIcanvas* : the canvas routine (will query user, see above)
*:DIcircle* : draw an ellipse on visual-block selected region
*:DIellipse* : draw an ellipse on visual-block selected region
*:DIflood* : flood figure with a character (you will be prompted)
*:DIline* : draw line from corners of visual-block selected region
*:DIoff* : another way to turn DrawIt off
*:DIspacer* : spacer: appends spaces up to the usable window width
*:DIgrid* [ dr ] [ dc ] : displays a rough grid with spacing of drxdc
rows by colums. Use :DIgrid to turn the grid off.
You may find |'cursorcolumn'| and |'cursorline| of use, too,
when desiring to visually align your drawing.
Discussion: ~
The DrawIt package has been merged with Sylvain Viart's drawing package (by
permission) which provides DrawIt with visual-block selection of
starting/ending point drawing of arrows (\a), lines (\l), and boxes (\b).
Additionally Dr.Campbell wrote an ellipse drawing function using a visual
block specification (|drawit-e|).
One may create a block of spaces for these maps to operate in; the "canvas"
routine (\c) will help create such blocks. First, the s:Canvas() routine will
query the user for the number of lines s/he wishes to have, and will then fill
those lines with spaces out to the |'textwidth'| if the user has specified it;
otherwise, the display width will be used.
Although most of the maps use visual-block selection, that isn't true of the
\f map. Instead, it assume that you have already drawn some closed figure and
want to fill it with some character (flooding).
The Sylvain Viart functions and the ellipse drawing function depend upon using
visual block mode. As a typical use: >
Example: * \h
DrawIt asks: how many lines under the cursor? 10
DrawIt then appends 10 lines filled with blanks
out to the usable window width
* ctrl-v (move) \b
DrawIt then draws a box
* ctrl-v (move) \e
DrawIt then draws an ellipse
<
Select the first endpoint with ctrl-v and then move to the other endpoint.
One may then select \a for arrows, \b for boxes, \e for ellipses, or \l for
lines. The internal s:AutoCanvas() will convert tabs to spaces and will
extend with spaces as needed to support the visual block. Note that when
DrawIt is enabled, virtualedit is also enabled (to "all").
>
Examples:
__ _ *************** +-------+
\_ _/ **** **** | |
\_ _/ ** ---------> ** | |
\_ _/ **** **** | |
\__/ <------- *************** +-------+
\l \a \e and \a \b
<
*drawit-setbrush*
BRUSHES *drawit-brush* {{{2
>
:SetBrush [a-z]
<
Set the current brush to the selected brush register:
>
ex. :SetBrush b
:'<,'>SetBrush [a-z]
<
Select text for the brush by using visual-block mode: ctrl-v, move .
Then set the current text into the brush register: (default brush: a)
>
<leftmouse>
<
Select a visual-block region. One may use "ay, for example,
to yank selected text to register a.
>
<shift-leftmouse>
<
One may drag and draw with the current brush (default brush: a)
by holding down the shift key and the leftmouse button and moving
the mouse. Blanks in the brush are considered to be transparent.
>
<ctrl-leftmouse>
<
One may drag and move a selection with <ctrl-leftmouse>. First,
select the region using the <leftmouse>. Release the mouse button,
then press ctrl and the <leftmouse> button; while continuing to press
the button, move the mouse. The selected block of text will then
move along with the cursor.
>
\ra ... \rz
<
Replace text with the given register's contents (ie. the brush).
>
\pa ... \pz
<
Like \ra ... \rz, except that blanks are considered to be transparent.
Example: Draw the following >
\ \
o o
*
---
< Then use ctrl-v, move, "ay to grab a copy into register a.
By default, the current brush uses register a (change brush
with :SetBrush [reg]). Hold the <shift> and <leftbutton>
keys down and move the mouse; as you move, a copy of the
brush will be left behind.
DRAWIT MODES *drawit-modes* {{{2
-[DrawIt] regular DrawIt mode (|drawit-start|)
-[DrawIt off] DrawIt is off (|drawit-stop| )
-[DrawIt erase] DrawIt will erase using the number pad (|drawit-erase|)
g:DrChipTopLvlMenu: by default its "DrChip"; you may set this to whatever
you like in your <.vimrc>. This variable controls where
DrawIt's menu items are placed.
==============================================================================
4. History *drawit-history* {{{1
14 Dec 03, 2013 * added commands for visual block mode
|:DIarrow| |:DIbox| |:DIcanvas| etc
* Implemented |:DIgrid|
Oct 24, 2014 * added LineStyle submenu
Nov 18, 2015 * Extra tests handling mixed double-single line
drawing. (affects s:DrawCorner())
Dec 08, 2015 * (Kevin Ballard) pointed out that the canvas
spacing should preferably use window width
rather than &columns.
Jan 05, 2018 * :DIcanvas can take an optional argument
specifying the qty of lines (bypasses the
dialog)
13 Sep 05, 2013 * improved s:Strlen() -- now uses |strdisplaywidth()|
if available.
Sep 13, 2013 * (Paul Wagland) found a case where lines were
being drawn with the wrong character. This
affected the Bresenham-algorithm based
drawing facility (ie. lines and arrows
specified by visual blocks;
|drawit-a|, |drawit-l|).
12 Nov 16, 2012 * (Alexandre Viau) arrows weren't being drawn.
Fixed.
Nov 29, 2012 * (Kim Jang-hwan) reported that with
g:Align_xstrlen set to 3 that the cursor was
moved (linewise) after invocation. This
problem also afflicted DrawIt. Fixed.
11 Jan 21, 2010 * (Evan Stern) several places were using
hardcoded drawing characters instead of
b:di_... equivalents.
Feb 22, 2011 * for menus, &go =~# used to insure correct case
Sep 22, 2011 * ctrl-leftmouse (see |drawit-brush|) now moves the
selected text entirely, no longer leaving a copy
of the text where it was initially.
Nov 07, 2011 * included support for utf-8 box drawing characters
Nov 16, 2011 * included support for utf-8 single-double characters
Nov 16, 2011 * included support for cp437 box drawing characters
Dec 06, 2011 * included support for box and line drawing (\b, \l)
support for utf-8 / cp437 box drawing characters
Dec 06, 2011 * fat arrows now use utf-8 characters when available
Jan 30, 2012 * \f supported when using utf-8/cp437 box drawing
characters as boundary characters
10 Jun 12, 2008 * Fixed a bug with ctrl-leftmouse (which was leaving
a space in the original selected text)
Mar 24, 2009 * :DrawIt starts, :DrawIt! stops DrawIt mode.
Mar 24, 2009 * I've included <script> modifiers to the maps to
cause rhs remapping only with mappings local to
the script (see |:map-script|)
9 Sep 14, 2007 * Johann-Guenter Simon fixed a bug with s:DrawErase();
it called SetDrawIt() and that call hadn't been
updated to account for the new b:di_ellipse
parameter.
8 Feb 12, 2007 * fixed a bug which prevented multi-character user
maps from being restored properly
May 03, 2007 * Extended SetDrawIt() to handle b:di_ellipse, the
ellipse boundary drawing character
* Changed "Holer" to "Canvas", and wrote AutoCanvas(),
which allows one to use the visual-block drawing
maps without creating a canvas first.
* DrawIt implements using the ctrl-leftmouse to move
a visual-block selected region.
* Floods can now be done inside an ellipse
* DrawIt's maps are now all users of <buffer>
7 Feb 16, 2005 * now checks that "m" is in &go before attempting to
use menus
Aug 17, 2005 * report option workaround
Nov 01, 2005 * converted DrawIt to use autoload feature of vim 7.0
Dec 28, 2005 * now uses cecutil to save/restore user maps
Jan 18, 2006 * cecutil now updated to use keepjumps
Jan 23, 2006 * :DIstart and :DIstop commands provided; thus users
using "set noremap" can still use DrawIt.
Jan 26, 2006 * DrawIt menu entry now keeps its place
Apr 10, 2006 * Brushes were implemented
6 Feb 24, 2003 * The latest DrawIt now provides a fill function.
\f will ask for a character to fill the figure
surrounding the current cursor location. Plus
I suggest reading :he drawit-tip for those whose
home/pageup/pagedown/end keys aren't all working
properly with DrawIt.
08/18/03 * \p[a-z] and \r[a-z] implemented
08/04/03 * b:..keep variables renamed to b:di_..keep variables
StopDrawIt() now insures that erase mode is off
03/11/03 * included g:drawit_insertmode handling
02/21/03 * included flood function
12/11/02 * deletes trailing whitespace only if holer used
8/27/02 * fat arrowheads included
* shift-arrow keys move but don't modify
---------------------------------------------------------------------
vim:tw=78:ts=8:ft=help:fdm=marker

File diff suppressed because it is too large Load Diff

298
vim/.vim/doc/acp.jax Normal file
View File

@ -0,0 +1,298 @@
*acp.txt* 補完メニューの自動ポップアップ
Copyright (c) 2007-2009 Takeshi NISHIDA
AutoComplPop *autocomplpop* *acp*
概要 |acp-introduction|
インストール |acp-installation|
使い方 |acp-usage|
コマンド |acp-commands|
オプション |acp-options|
SPECIAL THANKS |acp-thanks|
CHANGELOG |acp-changelog|
あばうと |acp-about|
==============================================================================
概要 *acp-introduction*
このプラグインは、インサートモードで文字を入力したりカーソルを動かしたときに補
完メニューを自動的に開くようにします。しかし、続けて文字を入力するのを妨げたり
はしません。
==============================================================================
インストール *acp-installation*
ZIPファイルをランタイムディレクトリに展開します。
以下のようにファイルが配置されるはずです。
>
<your runtime directory>/plugin/acp.vim
<your runtime directory>/doc/acp.txt
...
<
もしランタイムディレクトリが他のプラグインとごた混ぜになるのが嫌なら、ファイル
を新規ディレクトリに配置し、そのディレクトリのパスを 'runtimepath' に追加して
ください。アンインストールも楽になります。
その後 FuzzyFinder のヘルプを有効にするためにタグファイルを更新してください。
詳しくは|add-local-help|を参照してください。
==============================================================================
使い方 *acp-usage*
このプラグインがインストールされていれば、自動ポップアップは vim の開始時から
有効になります。
カーソル直前のテキストに応じて、利用する補完の種類を切り替えます。デフォルトの
補完動作は次の通りです:
補完モード filetype カーソル直前のテキスト ~
キーワード補完 * 2文字のキーワード文字
ファイル名補完 * ファイル名文字 + パスセパレータ
+ 0文字以上のファイル名文字
オムニ補完 ruby ".", "::" or 単語を構成する文字以外 + ":"
オムニ補完 python "."
オムニ補完 xml "<", "</" or ("<" + ">"以外の文字列 + " ")
オムニ補完 html/xhtml "<", "</" or ("<" + ">"以外の文字列 + " ")
オムニ補完 css (":", ";", "{", "^", "@", or "!")
+ 0個または1個のスペース
さらに、設定を行うことで、ユーザー定義補完と snipMate トリガー補完
(|acp-snipMate|) を自動ポップアップさせることができます。
これらの補完動作はカスタマイズ可能です。
*acp-snipMate*
snipMate トリガー補完 ~
snipMate トリガー補完では、snipMate プラグイン
(http://www.vim.org/scripts/script.php?script_id=2540) が提供するスニペットの
トリガーを補完してそれを展開することができます。
この自動ポップアップを有効にするには、次の関数を plugin/snipMate.vim に追加す
る必要があります:
>
fun! GetSnipsInCurrentScope()
let snips = {}
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
call extend(snips, get(s:snippets, scope, {}), 'keep')
call extend(snips, get(s:multi_snips, scope, {}), 'keep')
endfor
return snips
endf
<
そして|g:acp_behaviorSnipmateLength|オプションを 1 にしてください。
この自動ポップアップには制限があり、カーソル直前の単語は大文字英字だけで構成さ
れていなければなりません。
*acp-perl-omni*
Perl オムニ補完 ~
AutoComplPop は perl-completion.vim
(http://www.vim.org/scripts/script.php?script_id=2852) をサポートしています。
この自動ポップアップを有効にするには、|g:acp_behaviorPerlOmniLength|オプション
を 0 以上にしてください。
==============================================================================
コマンド *acp-commands*
*:AcpEnable*
:AcpEnable
自動ポップアップを有効にします。
*:AcpDisable*
:AcpDisable
自動ポップアップを無効にします。
*:AcpLock*
:AcpLock
自動ポップアップを一時的に停止します。
別のスクリプトへの干渉を回避する目的なら、このコマンドと|:AcpUnlock|
を利用することを、|:AcpDisable|と|:AcpEnable| を利用するよりも推奨しま
す。
*:AcpUnlock*
:AcpUnlock
|:AcpLock| で停止された自動ポップアップを再開します。
==============================================================================
オプション *acp-options*
*g:acp_enableAtStartup* >
let g:acp_enableAtStartup = 1
<
真なら vim 開始時から自動ポップアップが有効になります。
*g:acp_mappingDriven* >
let g:acp_mappingDriven = 0
<
真なら|CursorMovedI|イベントではなくキーマッピングで自動ポップアップを
行うようにします。カーソルを移動するたびに補完が行われることで重いなど
の不都合がある場合に利用してください。ただし他のプラグインとの相性問題
や日本語入力での不具合が発生する可能性があります。(逆も然り。)
*g:acp_ignorecaseOption* >
let g:acp_ignorecaseOption = 1
<
自動ポップアップ時に、'ignorecase' に一時的に設定する値
*g:acp_completeOption* >
let g:acp_completeOption = '.,w,b,k'
<
自動ポップアップ時に、'complete' に一時的に設定する値
*g:acp_completeoptPreview* >
let g:acp_completeoptPreview = 0
<
真なら自動ポップアップ時に、 'completeopt' へ "preview" を追加します。
*g:acp_behaviorUserDefinedFunction* >
let g:acp_behaviorUserDefinedFunction = ''
<
ユーザー定義補完の|g:acp_behavior-completefunc|。空ならこの補完は行わ
れません。。
*g:acp_behaviorUserDefinedMeets* >
let g:acp_behaviorUserDefinedMeets = ''
<
ユーザー定義補完の|g:acp_behavior-meets|。空ならこの補完は行われません
*g:acp_behaviorSnipmateLength* >
let g:acp_behaviorSnipmateLength = -1
<
snipMate トリガー補完の自動ポップアップを行うのに必要なカーソルの直前
のパターン。
*g:acp_behaviorKeywordCommand* >
let g:acp_behaviorKeywordCommand = "\<C-n>"
<
キーワード補完のコマンド。このオプションには普通 "\<C-n>" か "\<C-p>"
を設定します。
*g:acp_behaviorKeywordLength* >
let g:acp_behaviorKeywordLength = 2
<
キーワード補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
ード文字数。負数ならこの補完は行われません。
*g:acp_behaviorKeywordIgnores* >
let g:acp_behaviorKeywordIgnores = []
<
文字列のリスト。カーソル直前の単語がこれらの内いずれかの先頭部分にマッ
チする場合、この補完は行われません。
例えば、 "get" で始まる補完キーワードが多過ぎて、"g", "ge", "get" を入
力したときの自動ポップアップがレスポンスの低下を引き起こしている場合、
このオプションに ["get"] を設定することでそれを回避することができます。
*g:acp_behaviorFileLength* >
let g:acp_behaviorFileLength = 0
<
ファイル名補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
ード文字数。負数ならこの補完は行われません。
*g:acp_behaviorRubyOmniMethodLength* >
let g:acp_behaviorRubyOmniMethodLength = 0
<
メソッド補完のための、Ruby オムニ補完の自動ポップアップを行うのに必要
なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
*g:acp_behaviorRubyOmniSymbolLength* >
let g:acp_behaviorRubyOmniSymbolLength = 1
<
シンボル補完のための、Ruby オムニ補完の自動ポップアップを行うのに必要
なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
*g:acp_behaviorPythonOmniLength* >
let g:acp_behaviorPythonOmniLength = 0
<
Python オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキ
ーワード文字数。負数ならこの補完は行われません。
*g:acp_behaviorPerlOmniLength* >
let g:acp_behaviorPerlOmniLength = -1
<
Perl オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキー
ワード文字数。負数ならこの補完は行われません。
See also: |acp-perl-omni|
*g:acp_behaviorXmlOmniLength* >
let g:acp_behaviorXmlOmniLength = 0
<
XML オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
ード文字数。負数ならこの補完は行われません。
*g:acp_behaviorHtmlOmniLength* >
let g:acp_behaviorHtmlOmniLength = 0
<
HTML オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキー
ワード文字数。負数ならこの補完は行われません。
*g:acp_behaviorCssOmniPropertyLength* >
let g:acp_behaviorCssOmniPropertyLength = 1
<
プロパティ補完のための、CSS オムニ補完の自動ポップアップを行うのに必要
なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
*g:acp_behaviorCssOmniValueLength* >
let g:acp_behaviorCssOmniValueLength = 0
<
値補完のための、CSS オムニ補完の自動ポップアップを行うのに必要なカーソ
ルの直前のキーワード文字数。負数ならこの補完は行われません。
*g:acp_behavior* >
let g:acp_behavior = {}
<
これは内部仕様がわかっている人向けのオプションで、他のオプションでの設
定より優先されます。
|Dictionary|型で、キーはファイルタイプに対応します。 '*' はデフォルト
を表します。値はリスト型です。補完候補が得られるまでリストの先頭アイテ
ムから順に評価します。各要素は|Dictionary|で詳細は次の通り:
"command": *g:acp_behavior-command*
補完メニューをポップアップするためのコマンド。
"completefunc": *g:acp_behavior-completefunc*
'completefunc' に設定する関数。 "command" が "<C-x><C-u>" のときだけ
意味があります。
"meets": *g:acp_behavior-meets*
この補完を行うかどうかを判断する関数の名前。この関数はカーソル直前の
テキストを引数に取り、補完を行うなら非 0 の値を返します。
"onPopupClose": *g:acp_behavior-onPopupClose*
この補完のポップアップメニューが閉じられたときに呼ばれる関数の名前。
この関数が 0 を返した場合、続いて行われる予定の補完は抑制されます。
"repeat": *g:acp_behavior-repeat*
真なら最後の補完が自動的に繰り返されます。
==============================================================================
あばうと *acp-about* *acp-contact* *acp-author*
作者: Takeshi NISHIDA <ns9tks@DELETE-ME.gmail.com>
ライセンス: MIT Licence
URL: http://www.vim.org/scripts/script.php?script_id=1879
http://bitbucket.org/ns9tks/vim-autocomplpop/
バグや要望など ~
こちらへどうぞ: http://bitbucket.org/ns9tks/vim-autocomplpop/issues/
==============================================================================
vim:tw=78:ts=8:ft=help:norl:

512
vim/.vim/doc/acp.txt Normal file
View File

@ -0,0 +1,512 @@
*acp.txt* Automatically opens popup menu for completions.
Copyright (c) 2007-2009 Takeshi NISHIDA
AutoComplPop *autocomplpop* *acp*
INTRODUCTION |acp-introduction|
INSTALLATION |acp-installation|
USAGE |acp-usage|
COMMANDS |acp-commands|
OPTIONS |acp-options|
SPECIAL THANKS |acp-thanks|
CHANGELOG |acp-changelog|
ABOUT |acp-about|
==============================================================================
INTRODUCTION *acp-introduction*
With this plugin, your vim comes to automatically opens popup menu for
completions when you enter characters or move the cursor in Insert mode. It
won't prevent you continuing entering characters.
==============================================================================
INSTALLATION *acp-installation*
Put all files into your runtime directory. If you have the zip file, extract
it to your runtime directory.
You should place the files as follows:
>
<your runtime directory>/plugin/acp.vim
<your runtime directory>/doc/acp.txt
...
<
If you disgust to jumble up this plugin and other plugins in your runtime
directory, put the files into new directory and just add the directory path to
'runtimepath'. It's easy to uninstall the plugin.
And then update your help tags files to enable fuzzyfinder help. See
|add-local-help| for details.
==============================================================================
USAGE *acp-usage*
Once this plugin is installed, auto-popup is enabled at startup by default.
Which completion method is used depends on the text before the cursor. The
default behavior is as follows:
kind filetype text before the cursor ~
Keyword * two keyword characters
Filename * a filename character + a path separator
+ 0 or more filename character
Omni ruby ".", "::" or non-word character + ":"
(|+ruby| required.)
Omni python "." (|+python| required.)
Omni xml "<", "</" or ("<" + non-">" characters + " ")
Omni html/xhtml "<", "</" or ("<" + non-">" characters + " ")
Omni css (":", ";", "{", "^", "@", or "!")
+ 0 or 1 space
Also, you can make user-defined completion and snipMate's trigger completion
(|acp-snipMate|) auto-popup if the options are set.
These behavior are customizable.
*acp-snipMate*
snipMate's Trigger Completion ~
snipMate's trigger completion enables you to complete a snippet trigger
provided by snipMate plugin
(http://www.vim.org/scripts/script.php?script_id=2540) and expand it.
To enable auto-popup for this completion, add following function to
plugin/snipMate.vim:
>
fun! GetSnipsInCurrentScope()
let snips = {}
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
call extend(snips, get(s:snippets, scope, {}), 'keep')
call extend(snips, get(s:multi_snips, scope, {}), 'keep')
endfor
return snips
endf
<
And set |g:acp_behaviorSnipmateLength| option to 1.
There is the restriction on this auto-popup, that the word before cursor must
consist only of uppercase characters.
*acp-perl-omni*
Perl Omni-Completion ~
AutoComplPop supports perl-completion.vim
(http://www.vim.org/scripts/script.php?script_id=2852).
To enable auto-popup for this completion, set |g:acp_behaviorPerlOmniLength|
option to 0 or more.
==============================================================================
COMMANDS *acp-commands*
*:AcpEnable*
:AcpEnable
enables auto-popup.
*:AcpDisable*
:AcpDisable
disables auto-popup.
*:AcpLock*
:AcpLock
suspends auto-popup temporarily.
For the purpose of avoiding interruption to another script, it is
recommended to insert this command and |:AcpUnlock| than |:AcpDisable|
and |:AcpEnable| .
*:AcpUnlock*
:AcpUnlock
resumes auto-popup suspended by |:AcpLock| .
==============================================================================
OPTIONS *acp-options*
*g:acp_enableAtStartup* >
let g:acp_enableAtStartup = 1
<
If non-zero, auto-popup is enabled at startup.
*g:acp_mappingDriven* >
let g:acp_mappingDriven = 0
<
If non-zero, auto-popup is triggered by key mappings instead of
|CursorMovedI| event. This is useful to avoid auto-popup by moving
cursor in Insert mode.
*g:acp_ignorecaseOption* >
let g:acp_ignorecaseOption = 1
<
Value set to 'ignorecase' temporarily when auto-popup.
*g:acp_completeOption* >
let g:acp_completeOption = '.,w,b,k'
<
Value set to 'complete' temporarily when auto-popup.
*g:acp_completeoptPreview* >
let g:acp_completeoptPreview = 0
<
If non-zero, "preview" is added to 'completeopt' when auto-popup.
*g:acp_behaviorUserDefinedFunction* >
let g:acp_behaviorUserDefinedFunction = ''
<
|g:acp_behavior-completefunc| for user-defined completion. If empty,
this completion will be never attempted.
*g:acp_behaviorUserDefinedMeets* >
let g:acp_behaviorUserDefinedMeets = ''
<
|g:acp_behavior-meets| for user-defined completion. If empty, this
completion will be never attempted.
*g:acp_behaviorSnipmateLength* >
let g:acp_behaviorSnipmateLength = -1
<
Pattern before the cursor, which are needed to attempt
snipMate-trigger completion.
*g:acp_behaviorKeywordCommand* >
let g:acp_behaviorKeywordCommand = "\<C-n>"
<
Command for keyword completion. This option is usually set "\<C-n>" or
"\<C-p>".
*g:acp_behaviorKeywordLength* >
let g:acp_behaviorKeywordLength = 2
<
Length of keyword characters before the cursor, which are needed to
attempt keyword completion. If negative value, this completion will be
never attempted.
*g:acp_behaviorKeywordIgnores* >
let g:acp_behaviorKeywordIgnores = []
<
List of string. If a word before the cursor matches to the front part
of one of them, keyword completion won't be attempted.
E.g., when there are too many keywords beginning with "get" for the
completion and auto-popup by entering "g", "ge", or "get" causes
response degradation, set ["get"] to this option and avoid it.
*g:acp_behaviorFileLength* >
let g:acp_behaviorFileLength = 0
<
Length of filename characters before the cursor, which are needed to
attempt filename completion. If negative value, this completion will
be never attempted.
*g:acp_behaviorRubyOmniMethodLength* >
let g:acp_behaviorRubyOmniMethodLength = 0
<
Length of keyword characters before the cursor, which are needed to
attempt ruby omni-completion for methods. If negative value, this
completion will be never attempted.
*g:acp_behaviorRubyOmniSymbolLength* >
let g:acp_behaviorRubyOmniSymbolLength = 1
<
Length of keyword characters before the cursor, which are needed to
attempt ruby omni-completion for symbols. If negative value, this
completion will be never attempted.
*g:acp_behaviorPythonOmniLength* >
let g:acp_behaviorPythonOmniLength = 0
<
Length of keyword characters before the cursor, which are needed to
attempt python omni-completion. If negative value, this completion
will be never attempted.
*g:acp_behaviorPerlOmniLength* >
let g:acp_behaviorPerlOmniLength = -1
<
Length of keyword characters before the cursor, which are needed to
attempt perl omni-completion. If negative value, this completion will
be never attempted.
See also: |acp-perl-omni|
*g:acp_behaviorXmlOmniLength* >
let g:acp_behaviorXmlOmniLength = 0
<
Length of keyword characters before the cursor, which are needed to
attempt XML omni-completion. If negative value, this completion will
be never attempted.
*g:acp_behaviorHtmlOmniLength* >
let g:acp_behaviorHtmlOmniLength = 0
<
Length of keyword characters before the cursor, which are needed to
attempt HTML omni-completion. If negative value, this completion will
be never attempted.
*g:acp_behaviorCssOmniPropertyLength* >
let g:acp_behaviorCssOmniPropertyLength = 1
<
Length of keyword characters before the cursor, which are needed to
attempt CSS omni-completion for properties. If negative value, this
completion will be never attempted.
*g:acp_behaviorCssOmniValueLength* >
let g:acp_behaviorCssOmniValueLength = 0
<
Length of keyword characters before the cursor, which are needed to
attempt CSS omni-completion for values. If negative value, this
completion will be never attempted.
*g:acp_behavior* >
let g:acp_behavior = {}
<
This option is for advanced users. This setting overrides other
behavior options. This is a |Dictionary|. Each key corresponds to a
filetype. '*' is default. Each value is a list. These are attempted in
sequence until completion item is found. Each element is a
|Dictionary| which has following items:
"command": *g:acp_behavior-command*
Command to be fed to open popup menu for completions.
"completefunc": *g:acp_behavior-completefunc*
'completefunc' will be set to this user-provided function during the
completion. Only makes sense when "command" is "<C-x><C-u>".
"meets": *g:acp_behavior-meets*
Name of the function which dicides whether or not to attempt this
completion. It will be attempted if this function returns non-zero.
This function takes a text before the cursor.
"onPopupClose": *g:acp_behavior-onPopupClose*
Name of the function which is called when popup menu for this
completion is closed. Following completions will be suppressed if
this function returns zero.
"repeat": *g:acp_behavior-repeat*
If non-zero, the last completion is automatically repeated.
==============================================================================
SPECIAL THANKS *acp-thanks*
- Daniel Schierbeck
- Ingo Karkat
==============================================================================
CHANGELOG *acp-changelog*
2.14.1
- Changed the way of auto-popup for avoiding an issue about filename
completion.
- Fixed a bug that popup menu was opened twice when auto-popup was done.
2.14
- Added the support for perl-completion.vim.
2.13
- Changed to sort snipMate's triggers.
- Fixed a bug that a wasted character was inserted after snipMate's trigger
completion.
2.12.1
- Changed to avoid a strange behavior with Microsoft IME.
2.12
- Added g:acp_behaviorKeywordIgnores option.
- Added g:acp_behaviorUserDefinedMeets option and removed
g:acp_behaviorUserDefinedPattern.
- Changed to do auto-popup only when a buffer is modified.
- Changed the structure of g:acp_behavior option.
- Changed to reflect a change of behavior options (named g:acp_behavior*)
any time it is done.
- Fixed a bug that completions after omni completions or snipMate's trigger
completion were never attempted when no candidate for the former
completions was found.
2.11.1
- Fixed a bug that a snipMate's trigger could not be expanded when it was
completed.
2.11
- Implemented experimental feature which is snipMate's trigger completion.
2.10
- Improved the response by changing not to attempt any completion when
keyword characters are entered after a word which has been found that it
has no completion candidate at the last attempt of completions.
- Improved the response by changing to close popup menu when <BS> was
pressed and the text before the cursor would not match with the pattern of
current behavior.
2.9
- Changed default behavior to support XML omni completion.
- Changed default value of g:acp_behaviorKeywordCommand option.
The option with "\<C-p>" cause a problem which inserts a match without
<CR> when 'dictionary' has been set and keyword completion is done.
- Changed to show error message when incompatible with a installed vim.
2.8.1
- Fixed a bug which inserted a selected match to the next line when
auto-wrapping (enabled with 'formatoptions') was performed.
2.8
- Added g:acp_behaviorUserDefinedFunction option and
g:acp_behaviorUserDefinedPattern option for users who want to make custom
completion auto-popup.
- Fixed a bug that setting 'spell' on a new buffer made typing go crazy.
2.7
- Changed naming conventions for filenames, functions, commands, and options
and thus renamed them.
- Added g:acp_behaviorKeywordCommand option. If you prefer the previous
behavior for keyword completion, set this option "\<C-n>".
- Changed default value of g:acp_ignorecaseOption option.
The following were done by Ingo Karkat:
- ENH: Added support for setting a user-provided 'completefunc' during the
completion, configurable via g:acp_behavior.
- BUG: When the configured completion is <C-p> or <C-x><C-p>, the command to
restore the original text (in on_popup_post()) must be reverted, too.
- BUG: When using a custom completion function (<C-x><C-u>) that also uses
an s:...() function name, the s:GetSidPrefix() function dynamically
determines the wrong SID. Now calling s:DetermineSidPrefix() once during
sourcing and caching the value in s:SID.
- BUG: Should not use custom defined <C-X><C-...> completion mappings. Now
consistently using unmapped completion commands everywhere. (Beforehand,
s:PopupFeeder.feed() used mappings via feedkeys(..., 'm'), but
s:PopupFeeder.on_popup_post() did not due to its invocation via
:map-expr.)
2.6:
- Improved the behavior of omni completion for HTML/XHTML.
2.5:
- Added some options to customize behavior easily:
g:AutoComplPop_BehaviorKeywordLength
g:AutoComplPop_BehaviorFileLength
g:AutoComplPop_BehaviorRubyOmniMethodLength
g:AutoComplPop_BehaviorRubyOmniSymbolLength
g:AutoComplPop_BehaviorPythonOmniLength
g:AutoComplPop_BehaviorHtmlOmniLength
g:AutoComplPop_BehaviorCssOmniPropertyLength
g:AutoComplPop_BehaviorCssOmniValueLength
2.4:
- Added g:AutoComplPop_MappingDriven option.
2.3.1:
- Changed to set 'lazyredraw' while a popup menu is visible to avoid
flickering.
- Changed a behavior for CSS.
- Added support for GetLatestVimScripts.
2.3:
- Added a behavior for Python to support omni completion.
- Added a behavior for CSS to support omni completion.
2.2:
- Changed not to work when 'paste' option is set.
- Fixed AutoComplPopEnable command and AutoComplPopDisable command to
map/unmap "i" and "R".
2.1:
- Fixed the problem caused by "." command in Normal mode.
- Changed to map "i" and "R" to feed completion command after starting
Insert mode.
- Avoided the problem caused by Windows IME.
2.0:
- Changed to use CursorMovedI event to feed a completion command instead of
key mapping. Now the auto-popup is triggered by moving the cursor.
- Changed to feed completion command after starting Insert mode.
- Removed g:AutoComplPop_MapList option.
1.7:
- Added behaviors for HTML/XHTML. Now supports the omni completion for
HTML/XHTML.
- Changed not to show expressions for CTRL-R =.
- Changed not to set 'nolazyredraw' while a popup menu is visible.
1.6.1:
- Changed not to trigger the filename completion by a text which has
multi-byte characters.
1.6:
- Redesigned g:AutoComplPop_Behavior option.
- Changed default value of g:AutoComplPop_CompleteOption option.
- Changed default value of g:AutoComplPop_MapList option.
1.5:
- Implemented continuous-completion for the filename completion. And added
new option to g:AutoComplPop_Behavior.
1.4:
- Fixed the bug that the auto-popup was not suspended in fuzzyfinder.
- Fixed the bug that an error has occurred with Ruby-omni-completion unless
Ruby interface.
1.3:
- Supported Ruby-omni-completion by default.
- Supported filename completion by default.
- Added g:AutoComplPop_Behavior option.
- Added g:AutoComplPop_CompleteoptPreview option.
- Removed g:AutoComplPop_MinLength option.
- Removed g:AutoComplPop_MaxLength option.
- Removed g:AutoComplPop_PopupCmd option.
1.2:
- Fixed bugs related to 'completeopt'.
1.1:
- Added g:AutoComplPop_IgnoreCaseOption option.
- Added g:AutoComplPop_NotEnableAtStartup option.
- Removed g:AutoComplPop_LoadAndEnable option.
1.0:
- g:AutoComplPop_LoadAndEnable option for a startup activation is added.
- AutoComplPopLock command and AutoComplPopUnlock command are added to
suspend and resume.
- 'completeopt' and 'complete' options are changed temporarily while
completing by this script.
0.4:
- The first match are selected when the popup menu is Opened. You can insert
the first match with CTRL-Y.
0.3:
- Fixed the problem that the original text is not restored if 'longest' is
not set in 'completeopt'. Now the plugin works whether or not 'longest' is
set in 'completeopt', and also 'menuone'.
0.2:
- When completion matches are not found, insert CTRL-E to stop completion.
- Clear the echo area.
- Fixed the problem in case of dividing words by symbols, popup menu is
not opened.
0.1:
- First release.
==============================================================================
ABOUT *acp-about* *acp-contact* *acp-author*
Author: Takeshi NISHIDA <ns9tks@DELETE-ME.gmail.com>
Licence: MIT Licence
URL: http://www.vim.org/scripts/script.php?script_id=1879
http://bitbucket.org/ns9tks/vim-autocomplpop/
Bugs/Issues/Suggestions/Improvements ~
Please submit to http://bitbucket.org/ns9tks/vim-autocomplpop/issues/ .
==============================================================================
vim:tw=78:ts=8:ft=help:norl:

751
vim/.vim/doc/easytags.txt Normal file
View File

@ -0,0 +1,751 @@
*easytags.txt* Automated tag generation and syntax highlighting in Vim
===============================================================================
Contents ~
1. Introduction |easytags-introduction|
2. Installation |easytags-installation|
1. A note about Windows |easytags-note-about-windows|
3. Commands |easytags-commands|
1. The |:UpdateTags| command
2. The |:HighlightTags| command
4. Options |easytags-options|
1. The |g:easytags_cmd| option
2. The |g:easytags_opts| option
3. The |g:easytags_async| option
4. The |g:easytags_syntax_keyword| option
5. The |g:easytags_languages| option
6. The |g:easytags_file| option
7. The |g:easytags_dynamic_files| option
8. The |g:easytags_by_filetype| option
9. The |g:easytags_events| option
10. The |g:easytags_always_enabled| option
11. The |g:easytags_on_cursorhold| option
12. The |g:easytags_updatetime_min| option
13. The |g:easytags_auto_update| option
14. The |g:easytags_auto_highlight| option
15. The |g:easytags_autorecurse| option
16. The |g:easytags_include_members| option
17. The |g:easytags_resolve_links| option
18. The |g:easytags_suppress_ctags_warning| option
19. The |g:easytags_suppress_report| option
5. Customizing the easytags plug-in |customizing-easytags-plug-in|
1. Passing custom command line arguments to Exuberant Ctags |easytags-passing-custom-command-line-arguments-to-exuberant-ctags|
2. Update & highlight tags immediately after save |easytags-update-highlight-tags-immediately-after-save|
3. How to customize the highlighting colors? |easytags-how-to-customize-highlighting-colors|
6. Faster syntax highlighting using Python |easytags-faster-syntax-highlighting-using-python|
1. The |g:easytags_python_enabled| option
2. The |g:easytags_python_script| option
7. Troubleshooting |easytags-troubleshooting|
8. vim-easytags is slow! |vim-easytags-is-slow|
1. |:HighlightTags| only works for the tags file created by |:UpdateTags| |easytags-highlighttags-only-works-for-tags-file-created-by-updatetags|
2. The plug-in complains that Exuberant Ctags isn't installed |easytags-plug-in-complains-that-exuberant-ctags-isnt-installed|
3. Vim locks up while the plug-in is running |easytags-vim-locks-up-while-plug-in-is-running|
4. Failed to highlight tags because pattern is too big! |easytags-failed-to-highlight-tags-because-pattern-is-too-big|
5. The plug-in doesn't seem to work in Cygwin |easytags-plug-in-doesnt-seem-to-work-in-cygwin|
9. Contact |easytags-contact|
10. License |easytags-license|
11. References |easytags-references|
===============================================================================
*easytags-introduction*
Introduction ~
Vim has long been my favorite text editor and combined with Exuberant Ctags [1]
it has the potential to provide most of what I expect from an integrated
development environment [2]. Exuberant Ctags is the latest incarnation of a
family of computer programs [3] that scan source code files to create an index
of identifiers (tags) and where they are defined. Vim uses this index (a so-
called tags file) to enable you to jump to the definition of any identifier
using the Control-] (see |CTRL-]|) mapping.
When you're familiar with integrated development environments you may recognize
this feature as "Go-to definition". One advantage of the combination of Vim and
Exuberant Ctags over integrated development environments is that Vim supports
syntax highlighting for over 500 file types [4] (!) and Exuberant Ctags can
generate tags for over 40 file types [5] as well...
There's just one problem: You have to manually keep your tags files up-to-date
and this turns out to be a royal pain in the ass! So I set out to write a Vim
plug-in that would do this boring work for me. When I finished the plug-in's
basic functionality (one automatic command and a call to |system()| later) I
became interested in dynamic syntax highlighting, so I added that as well to
see if it would work -- surprisingly well I'm happy to report!
===============================================================================
*easytags-installation*
Installation ~
Please refer to the installation instructions [6] available on GitHub.
Now try it out: Edit any file type supported by Exuberant Ctags and within ten
seconds the plug-in should create/update your tags file ('~/.vimtags' on UNIX,
'~/_vimtags' on Windows) with the tags defined in the file you just edited!
This means that whatever file you're editing in Vim (as long as it's on the
local file system), tags will always be available by the time you need them!
Additionally if the file you just opened is an AWK, C#, C, C++, Objective-C,
Java, Lua, Perl, PHP, Python, Ruby, Shell, Tcl or Vim source file you should
also notice that the function and/or type names defined in the file have been
syntax highlighted.
The 'easytags.vim' plug-in is intended to work automatically once it's
installed, but if you want to change how it works there are several options you
can change and commands you can execute from your own mappings and/or automatic
commands. These are all documented below.
Note that if the plug-in warns you 'ctags' isn't installed you'll have to
download it from its homepage [1], or if you're running Debian/Ubuntu you can
install it by executing the following shell command:
>
$ sudo apt-get install exuberant-ctags
<
-------------------------------------------------------------------------------
*easytags-note-about-windows*
A note about Windows ~
On Windows the |system()| function used by 'easytags.vim' causes a command
prompt window to pop up while Exuberant Ctags is executing. If this bothers you
then you can install my shell.vim [7] plug-in which includes a DLL [8] that
works around this issue. Once you've installed both plug-ins it should work out
of the box! Please let me know if this doesn't work for you.
===============================================================================
*easytags-commands*
Commands ~
-------------------------------------------------------------------------------
The *:UpdateTags* command
This command executes Exuberant Ctags [1] from inside Vim to update the global
tags file defined by |g:easytags_file|. When no arguments are given the tags
for the current file are updated, otherwise the arguments are passed on to
'ctags'. For example when you execute the Vim command ':UpdateTags -R ~/.vim'
(or ':UpdateTags -R ~\vimfiles' on Windows) the plug-in will execute 'ctags -R
~/.vim' for you (with some additional arguments, see the troubleshooting
section "|:HighlightTags| only works for the tags file created by
|:UpdateTags|" for more information).
When you execute this command like ':UpdateTags!' (including the bang!) then
all tags whose files are missing will be filtered from the global tags file.
Note that this command will be executed automatically every once in a while,
assuming you haven't changed |g:easytags_on_cursorhold|.
-------------------------------------------------------------------------------
The *:HighlightTags* command
When you execute this command while editing one of the supported file types
(see above) the relevant tags in the current file are highlighted. The tags to
highlight are gathered from all tags files known to Vim (through the |'tags'|
option).
Note that this command will be executed automatically every once in a while,
assuming you haven't changed |g:easytags_on_cursorhold|.
===============================================================================
*easytags-options*
Options ~
The easytags plug-in should work out of the box but if you don't like the
default configuration you can change how it works by setting the variables
documented below. Most of these variables can also be changed for specific
files by setting a buffer local variable instead of the global variable. For
example to disable automatic highlighting (enabled by default) only in Python
files you can add the following line to your |vimrc| script:
>
:autocmd FileType python let b:easytags_auto_highlight = 0
<
Note that buffer local variables always override global variables, so if you
want to undo this for a specific file you have to use |:unlet|:
>
:unlet b:easytags_auto_highlight
<
-------------------------------------------------------------------------------
The *g:easytags_cmd* option
The plug-in will try to determine the location where Exuberant Ctags is
installed on its own but this might not always work because any given
executable named 'ctags' in your '$PATH' might not in fact be Exuberant Ctags
but some older, more primitive 'ctags' implementation which doesn't support the
same command line options and thus breaks the easytags plug-in. If this is the
case you can set the global variable |g:easytags_cmd| to the location where
you've installed Exuberant Ctags, e.g.:
>
:let g:easytags_cmd = '/usr/local/bin/ctags'
<
If you rely entirely on language-specific configuration and don't have a
general ctags program, set this to the empty string.
-------------------------------------------------------------------------------
The *g:easytags_opts* option
If you need to pass custom command line option(s) to the program specified by
|g:easytags_cmd| you can set this option to a list of strings to be passed to
Exuberant Ctags. Make sure to only use options that are valid in any context,
for example the concatenation of |g:easytags_cmd|, |g:easytags_opts| and
'--list-languages' should work as expected. Here's an example:
>
:let g:easytags_opts = ['--options=$VIM\ctags\ctags.cnf']
<
The example above (based on issue 98 [9]) overrides the location of Exuberant
Ctags' configuration file. As you can see the command line option(s) may
contain environment variables, these will be expanded before passing the
options to Exuberant Ctags (to make sure it works in all environments).
-------------------------------------------------------------------------------
The *g:easytags_async* option
By default vim-easytags runs Exuberant Ctags and updates your tags file in the
foreground, blocking Vim in the process. As your tags files get larger this
becomes more annoying. It has been the number one complaint about vim-easytags
since I published the first release online.
In version 3.5 of the vim-easytags plug-in support for asynchronous tags file
updates was added. It's not enabled by default yet because I want to make sure
I'm not breaking the plug-in for the majority of users. However after I've
gathered some feedback I definitely want to make this the default mode.
By setting this option to true (1) you enable asynchronous tags file updates.
Good luck! ;-)
Note that asynchronous updates on Windows currently require the installation of
my vim-shell [7] plug-in (for obscure technical reasons that I want to fix but
don't know how yet).
-------------------------------------------------------------------------------
The *g:easytags_syntax_keyword* option
When you look into how the dynamic syntax highlighting in the vim-easytags
plug-in works you'll realize that vim-easytags is really abusing Vim's syntax
highlighting engine. This can cause Vim to slow down to a crawl, depending on
how big your tags files are. To make things worse in Vim 7.4 a new regex engine
was introduced which exacerbates the problem (the patterns generated by vim-
easytags bring out the worst of the new regex engine).
Since version 3.6 the vim-easytags plug-in tries to squeeze as much performance
as possible out of Vim by using keyword highlighting where this is possible
without sacrificing accuracy. If your Vim's syntax highlighting is still too
slow you can add the following to your |vimrc| script:
>
let g:easytags_syntax_keyword = 'always'
<
The default value of this option is 'auto' which means to use keyword
highlighting where this is possible without sacrificing accuracy. By changing
it to 'always' you're telling vim-easytags to sacrifice accuracy in order to
gain performance. Try it out and see what works best for you.
Please note that right now this 'feature' is not integrated with the
"accelerated Python syntax highlighting" feature, because I'm considering
ripping that out and replacing it with a _fast_ Vim script implementation.
-------------------------------------------------------------------------------
The *g:easytags_languages* option
Exuberant Ctags supports many languages and can be extended via regular
expression patterns, but for some languages separate tools with ctags-
compatible output exist (e.g. jsctags [10] for Javascript). To use these, the
executable and its arguments must be configured:
>
let g:easytags_languages = {
\ 'language': {
\ 'cmd': g:easytags_cmd,
\ 'args': [],
\ 'fileoutput_opt': '-f',
\ 'stdout_opt': '-f-',
\ 'recurse_flag': '-R'
\ }
\}
<
Each key is a special language definition. The key is a Vim file type in
lowercase. The above snippet shows the defaults; you only need to specify
options that differ.
-------------------------------------------------------------------------------
The *g:easytags_file* option
As mentioned above the plug-in will store your tags in '~/.vimtags' on UNIX and
'~/_vimtags' on Windows. To change the location of this file, set the global
variable |g:easytags_file|, e.g.:
>
:let g:easytags_file = '~/.vim/tags'
<
A leading '~' in the |g:easytags_file| variable is expanded to your current
home directory ('$HOME' on UNIX, '%USERPROFILE%' on Windows).
-------------------------------------------------------------------------------
The *g:easytags_dynamic_files* option
By default |:UpdateTags| only writes to the global tags file, but it can be
configured to look for project specific tags files by adding the following
lines to your |vimrc| script:
>
:set tags=./tags;
:let g:easytags_dynamic_files = 1
<
You can change the name of the tags file, the important thing is that it's
relative to your working directory or the buffer (using a leading './'). When
|g:easytags_dynamic_files| is set to 1 the easytags plug-in will write to the
first existing tags file seen by Vim (based on the |'tags'| option). In other
words: If a project specific tags file is found it will be used, otherwise the
plug-in falls back to the global tags file (or a file type specific tags file).
If you set |g:easytags_dynamic_files| to 2 the easytags plug-in will
automatically create a project specific tags file based on the first name in
the |'tags'| option. In this mode the global tags file and/or file type
specific tags files are only used for directories where you don't have write
permissions.
When you set |g:easytags_dynamic_files| to 2 new tags files are created in the
same directory as the file you're editing. If you want the tags files to be
created in your working directory instead then change Vim's |'cpoptions'|
option to include the lowercase letter 'd'.
The |'tags'| option is reevaluated each time the plug-in runs, so which tags
file is selected can differ depending on the buffer and working directory.
-------------------------------------------------------------------------------
The *g:easytags_by_filetype* option
By default all tags are stored in a global tags file. When the tags file grows
beyond a certain size Vim will be slowed down by the easytags plug-in because
it has to read and process a large number of tags very frequently.
To avoid this problem you can set |g:easytags_by_filetype| to the path of an
existing directory. The easytags plug-in will create separate tags files for
each file type in the configured directory. These tags files are automatically
registered by the easytags plug-in when the file type of a buffer is set.
Note that the |g:easytags_dynamic_files| option takes precedence over this
option.
If you already have a global tags file you can create file type specific tags
files from the global tags file using the command ':TagsByFileType'.
-------------------------------------------------------------------------------
The *g:easytags_events* option
This option can be used to customize the events that trigger the automatic
updating and highlighting performed by the easytags plug-in. The
|g:easytags_always_enabled| and |g:easytags_on_cursorhold| options are more
user friendly but limited ways to accomplish the same thing.
Here's an example: Say you want the easytags plug-in to automatically update &
highlight tags for the current file right after you save the file. You can
accomplish this by adding the following line to your |vimrc| script:
>
:let g:easytags_events = ['BufWritePost']
<
Note that if you set |g:easytags_events| in your |vimrc| script, the values of
the options |g:easytags_always_enabled| and |g:easytags_on_cursorhold| will be
ignored completely.
-------------------------------------------------------------------------------
The *g:easytags_always_enabled* option
By default the plug-in automatically generates and highlights tags when you
stop typing for a few seconds (this works using the |CursorHold| automatic
command). This means that when you edit a file, the dynamic highlighting won't
appear until you pause for a moment. If you don't like this you can configure
the plug-in to always enable dynamic highlighting:
>
:let g:easytags_always_enabled = 1
<
Be warned that after setting this option you'll probably notice why it's
disabled by default: Every time you edit a file in Vim, the plug-in will first
run Exuberant Ctags and then highlight the tags, and this slows Vim down quite
a lot. To make this less of a problem you can use the |g:easytags_async|
option.
Note: If you change this option it won't apply until you restart Vim, so you'll
have to set this option in your |vimrc| script.
-------------------------------------------------------------------------------
The *g:easytags_on_cursorhold* option
As I explained above the plug-in by default doesn't update or highlight your
tags until you stop typing for a moment. The plug-in tries hard to do the least
amount of work possible in this break but it might still interrupt your
workflow. If it does you can disable the periodic update:
>
:let g:easytags_on_cursorhold = 0
<
Note: Like the |g:easytags_always_enabled| option, if you change this option it
won't apply until you restart Vim, so you'll have to set this option in your
|vimrc| script.
-------------------------------------------------------------------------------
The *g:easytags_updatetime_min* option
Vim's |'updatetime'| option controls how often the easytags plug-in is
automatically executed. A lot of popular Vim plug-ins manipulate this option to
control how often they are called. Unfortunately some of those plug-ins set
|'updatetime'| to a very low value (less than a second) and this can break the
easytags plug-in. Because of this the easytags plug-in compensates by keeping
track of when it was last executed.
The default value of Vim's 'updatetime (see |'updatetime'|) option _and_ the
|g:easytags_updatetime_min| option is 4000 milliseconds (4 seconds).
If you know what you're doing and you really want the easytags plug-in to be
executed more than once every 4 seconds you can lower the minimum acceptable
updatetime by setting |g:easytags_updatetime_min| to the number of milliseconds
(an integer).
Note that although |g:easytags_updatetime_min| counts in milliseconds, the
easytags plug-in does not support subsecond granularity because it is limited
by Vim's |localtime()| function which has one-second resolution.
-------------------------------------------------------------------------------
The *g:easytags_auto_update* option
By default the plug-in automatically updates and highlights your tags when you
stop typing for a moment. If you want to disable automatic updating while
keeping automatic highlighting enabled you can set this option to false:
>
:let g:easytags_auto_update = 0
<
This disables all _automatic_ tags file updates (regardless of how they were
enabled) where automatic means _initiated by a Vim automatic command_.
-------------------------------------------------------------------------------
The *g:easytags_auto_highlight* option
By default the plug-in automatically updates and highlights your tags when you
stop typing for a moment. If you want to disable automatic highlighting while
keeping automatic updating enabled you can set this option to false:
>
:let g:easytags_auto_highlight = 0
<
This disables all _automatic_ tags highlighting (regardless of how it was
enabled) where automatic means _initiated by a Vim automatic command_.
-------------------------------------------------------------------------------
The *g:easytags_autorecurse* option
When the |:UpdateTags| command is executed automatically or without arguments,
it defaults to updating just the tags for the current file. If you'd rather
have it recursively scan everything below the directory of the current file
then set this option to true (1):
>
:let g:easytags_autorecurse = 1
<
You have to explicitly enable this option because it should only be used while
navigating around small directory trees. Imagine always having this option
enabled and then having to edit a file in e.g. the root of your home directory:
The 'easytags.vim' plug-in would freeze Vim for a long time while you'd have to
wait for Exuberant Ctags to scan thousands of files...
Note that when you enable this option the 'easytags.vim' plug-in might ignore
other options like |g:easytags_resolve_links|. This is an implementation detail
which I intend to fix.
-------------------------------------------------------------------------------
The *g:easytags_include_members* option
Exuberant Ctags knows how to generate tags for struct/class members in C++ and
Java source code but doesn't do so by default because it can more than double
the size of your tags files, thus taking much longer to read/write the tags
file. When you enable the |g:easytags_include_members| option from your |vimrc|
script (before the 'easytags.vim' plug-in is loaded):
>
:let g:easytags_include_members = 1
<
Exuberant Ctags will be instructed to include struct/class members using the '
--extra=+q' command line argument and the 'easytags.vim' plug-in will highlight
them using the 'cMember' highlighting group. Because most color schemes don't
distinguish the Identifier and Type (see |group-name|) highlighting groups all
members will now probably look like type definitions. You can change that by
executing either of the following Vim commands (from your vimrc script, a file
type plug-in, etc.):
>
" If you like one of the existing styles you can link them:
highlight link cMember Special
" You can also define your own style if you want:
highlight cMember gui=italic
<
-------------------------------------------------------------------------------
The *g:easytags_resolve_links* option
UNIX has symbolic links [11] and hard links [12], both of which conflict with
the concept of having one unique location for every identifier. With regards to
hard links there's not much anyone can do, but because I use symbolic links
quite a lot I've added this option. It's disabled by default since it has a
small performance impact and might not do what unknowing users expect it to:
When you enable this option the plug-in will resolve symbolic links in
pathnames, which means your tags file will only contain entries with canonical
pathnames [13]. To enable this option (which I strongly suggest doing when you
run UNIX and use symbolic links) execute the following Vim command:
>
:let g:easytags_resolve_links = 1
<
-------------------------------------------------------------------------------
The *g:easytags_suppress_ctags_warning* option
If this is set and not false, it will suppress the warning on startup if ctags
is not found or not recent enough.
>
:let g:easytags_suppress_ctags_warning = 1
<
-------------------------------------------------------------------------------
The *g:easytags_suppress_report* option
If this is set and not false, it will suppress the report displayed on tag
updates.
>
:let g:easytags_suppress_report = 1
<
===============================================================================
*customizing-easytags-plug-in*
Customizing the easytags plug-in ~
Advanced users may wish to customize how the easytags plug-in works beyond the
point of changing configuration defaults. This section contains some hints
about this. If you have suggestions, please feel free to submit them.
-------------------------------------------------------------------------------
*easytags-passing-custom-command-line-arguments-to-exuberant-ctags*
Passing custom command line arguments to Exuberant Ctags ~
You may want to run Exuberant Ctags with specific command line options, for
example the code_complete [14] plug-in requires the signature field to be
present. To do this you can create a configuration file for Exuberant Ctags,
e.g. '~/.ctags' on UNIX or '%USERPROFILE%\ctags.cnf' on Windows. The file
should contain one command line option per line. See the Exuberant Ctags manual
[15] for details.
-------------------------------------------------------------------------------
*easytags-update-highlight-tags-immediately-after-save*
Update & highlight tags immediately after save ~
By default the easytags plug-in automatically updates & highlights tags for the
current file after several seconds of inactivity. This is done to prevent the
easytags plug-in from interrupting your workflow.
If you want the easytags plug-in to automatically update & highlight tags for
the current file right after you save the file, you can add the following line
to your |vimrc| script:
>
:let g:easytags_events = ['BufWritePost']
<
-------------------------------------------------------------------------------
*easytags-how-to-customize-highlighting-colors*
How to customize the highlighting colors? ~
The easytags plug-in defines new highlighting groups for dynamically
highlighted tags. These groups are linked to Vim's default groups so that
they're colored out of the box, but if you want you can change the styles. To
do so use a 'highlight' command such as the ones given a few paragraphs back.
Of course you'll need to change the group name. Here are the group names used
by the easytags plug-in:
- **AWK**: 'awkFunctionTag'
- **C#:**'csClassOrStructTag', 'csMethodTag'
- **C, C++, Objective C:**'cTypeTag', 'cEnumTag', 'cPreProcTag',
'cFunctionTag', 'cMemberTag'
- **Java:**'javaClassTag', 'javaInterfaceTag', 'javaMethodTag'
- **Lua:**'luaFuncTag'
- **Perl:**'perlFunctionTag'
- **PHP:**'phpFunctionsTag', 'phpClassesTag'
- **Python:**'pythonFunctionTag', 'pythonMethodTag', 'pythonClassTag'
- **Ruby:**'rubyModuleNameTag', 'rubyClassNameTag', 'rubyMethodNameTag'
- **Shell**: 'shFunctionTag'
- **Tcl**: 'tclCommandTag'
- **Vim:**'vimAutoGroupTag', 'vimCommandTag', 'vimFuncNameTag',
'vimScriptFuncNameTag'
As you can see each of these names ends in 'Tag' to avoid conflicts with the
syntax modes shipped with Vim. And about the singular/plural confusion: I've
tried to match the existing highlighting groups defined by popular syntax modes
(except of course for the 'Tag' suffix).
===============================================================================
*easytags-faster-syntax-highlighting-using-python*
Faster syntax highlighting using Python ~
The Vim script implementation of dynamic syntax highlighting is quite slow on
large tags files. When the Python Interface to Vim is enabled the easytags
plug-in will therefor automatically use a Python script that performs dynamic
syntax highlighting about twice as fast as the Vim script implementation. The
following options are available to change the default configuration.
-------------------------------------------------------------------------------
The *g:easytags_python_enabled* option
To disable the Python implementation of dynamic syntax highlighting you can set
this option to false (0).
-------------------------------------------------------------------------------
The *g:easytags_python_script* option
This option defines the pathname of the script that contains the Python
implementation of dynamic syntax highlighting.
===============================================================================
*easytags-troubleshooting*
Troubleshooting ~
===============================================================================
*vim-easytags-is-slow*
vim-easytags is slow! ~
Yes, I know. I'm trying to make it faster but that's far from trivial. In the
process of trying to speed up vim-easytags I've added reporting of elapsed time
in several ways. If Vim seems very slow and you suspect this plug-in might be
the one to blame, increase Vim's verbosity level:
>
:set vbs=1
<
Every time the plug-in executes it will time how long the execution takes and
add the results to Vim's message history, which you can view by executing the
|:messages| command. If you want a more fine grained impression of the time
spent by vim-easytags on various operations you can call the
'xolox#easytags#why_so_slow()' function:
>
:call xolox#easytags#why_so_slow()
easytags.vim 3.6.4: Timings since you started Vim:
- 0.094937 seconds updating tags
- 1.850201 seconds highlighting tags
- 0.035167 seconds highlighting tags using ':syntax match')
- 0.493910 seconds highlighting tags using ':syntax keyword')
- 0.413160 seconds filtering tags for highlighting (stage 1)
- 0.141747 seconds filtering tags for highlighting (stage 2)
<
-------------------------------------------------------------------------------
*easytags-highlighttags-only-works-for-tags-file-created-by-updatetags*
:HighlightTags only works for the tags file created by :UpdateTags ~
If you want to create tags files and have their tags highlighted by the
'easytags.vim' plug-in then you'll have to create the tags file with certain
arguments to Exuberant Ctags:
>
$ ctags --fields=+l --c-kinds=+p --c++-kinds=+p ...
<
The '--fields=+l' argument makes sure that Exuberant Ctags includes a
'language:...' property with each entry in the tags file. This is required by
the |:HighlightTags| command so it can filter tags by their file type. The
other two arguments make sure Exuberant Ctags generates tags for function
prototypes in C/C++ source code.
If you have the |g:easytags_include_members| option enabled (its off by
default) then you'll also need to add the '--extra=+q' argument so that
Exuberant Ctags generates tags for structure/class members.
-------------------------------------------------------------------------------
*easytags-plug-in-complains-that-exuberant-ctags-isnt-installed*
The plug-in complains that Exuberant Ctags isn't installed ~
After a Mac OS X user found out the hard way that the 'ctags' executable isn't
always Exuberant Ctags and we spend a few hours debugging the problem I added
proper version detection: The plug-in executes 'ctags --version' when Vim is
started to verify that Exuberant Ctags 5.5 or newer is installed. If it isn't
Vim will show the following message on startup:
>
easytags.vim: Plug-in not loaded because Exuberant Ctags isn't installed!
Please download & install Exuberant Ctags from http://ctags.sf.net
<
If the installed Exuberant Ctags version is too old the plug-in will complain:
>
easytags.vim: Plug-in not loaded because Exuberant Ctags 5.5
or newer is required while you have version %s installed!
<
If you have the right version of Exuberant Ctags installed but the plug-in
still complains, try executing the following command from inside Vim:
>
:!which ctags
<
If this doesn't print the location where you installed Exuberant Ctags it means
your system already had a 'ctags' executable but it isn't compatible with
Exuberant Ctags 5.5 and you'll need to set the |g:easytags_cmd| option (see
above) so the plug-in knows which 'ctags' to run.
-------------------------------------------------------------------------------
*easytags-vim-locks-up-while-plug-in-is-running*
Vim locks up while the plug-in is running ~
Once or twice now in several years I've experienced Exuberant Ctags getting
into an infinite loop when given garbage input. In my case this happened by
accident a few days ago :-|. Because my plug-in executes 'ctags' in the
foreground this will block Vim indefinitely! If this happens you might be able
to kill 'ctags' by pressing Control-C (see |CTRL-C|) but if that doesn't work
you can also kill it without stopping Vim using a task manager or the 'pkill'
command (available on most UNIX systems):
>
$ pkill -KILL ctags
<
-------------------------------------------------------------------------------
*easytags-failed-to-highlight-tags-because-pattern-is-too-big*
Failed to highlight tags because pattern is too big! ~
If the 'easytags.vim' plug-in fails to highlight your tags and the error
message mentions that the pattern is too big, your tags file has grown too
large for Vim to be able to highlight all tagged identifiers! I've had this
happen to me with 50 KB patterns because I added most of the headers in
'/usr/include/' to my tags file. Internally Vim raises the error |E339|:
Pattern too long and unfortunately the only way to avoid this problem once it
occurs is to reduce the number of tagged identifiers...
In my case the solution was to move most of the tags from '/usr/include/' over
to project specific tags files which are automatically loaded by Vim when I
edit files in different projects because I've set the |'tags'| option as
follows:
>
:set tags=./.tags;,~/.vimtags
<
Once you've executed the above command, Vim will automatically look for a file
named '.tags' in the directory of the current file. Because of the ';' Vim also
recurses upwards so that you can nest files arbitrarily deep under your project
directories.
-------------------------------------------------------------------------------
*easytags-plug-in-doesnt-seem-to-work-in-cygwin*
The plug-in doesn't seem to work in Cygwin ~
If you want to use the plug-in with Vim under Cygwin [16], you need to have the
Cygwin version of Ctags installed instead of the Windows version (thanks to
Alex Zuroff for reporting this!).
===============================================================================
*easytags-contact*
Contact ~
If you have questions, bug reports, suggestions, etc. the author can be
contacted at peter@peterodding.com. The latest version is available at
http://peterodding.com/code/vim/easytags/ and http://github.com/xolox/vim-
easytags. If you like this plug-in please vote for it on Vim Online [17].
===============================================================================
*easytags-license*
License ~
This software is licensed under the MIT license [18]. © 2015 Peter Odding
<peter@peterodding.com> and Ingo Karkat.
Thanks go out to everyone who has helped to improve the vim-easytags plug-in
(whether through pull requests, bug reports or personal e-mails).
===============================================================================
*easytags-references*
References ~
[1] http://ctags.sourceforge.net/
[2] http://en.wikipedia.org/wiki/Integrated_development_environment
[3] http://en.wikipedia.org/wiki/Ctags
[4] http://ftp.vim.org/vim/runtime/syntax/
[5] http://ctags.sourceforge.net/languages.html
[6] https://github.com/xolox/vim-easytags/blob/master/INSTALL.md
[7] http://peterodding.com/code/vim/shell/
[8] http://en.wikipedia.org/wiki/Dynamic-link_library
[9] https://github.com/xolox/vim-easytags/issues/98
[10] https://npmjs.org/package/jsctags
[11] http://en.wikipedia.org/wiki/Symbolic_link
[12] http://en.wikipedia.org/wiki/Hard_link
[13] http://en.wikipedia.org/wiki/Canonicalization
[14] http://www.vim.org/scripts/script.php?script_id=1764
[15] http://ctags.sourceforge.net/ctags.html#FILES
[16] http://en.wikipedia.org/wiki/Cygwin
[17] http://www.vim.org/scripts/script.php?script_id=3114
[18] http://en.wikipedia.org/wiki/MIT_License
vim: ft=help

160
vim/.vim/doc/markx.txt Normal file
View File

@ -0,0 +1,160 @@
*markx.txt* MarkX : Mark placement enhancements
*markx*
Author: Richard Bentley-Green
Version: 22/03/2023
==============================================================================
CONTENTS *markx-contents*
Introduction |markx-introduction|
Mappings |markx-mappings|
Commands |markx-commands|
==============================================================================
INTRODUCTION *markx-introduction*
The primary purpose of MarkX is to automatically place a sign in the left
margin for each mark that is set, and to ensure that the displayed signs
reflect the on-going state as marks are added and removed
MarkX also includes some functions to make auto-selection and placement of
marks, so you don't have to remember which marks you've used
`This help page is intended only as a quick reference to the mappings - See the`
`README file for complete details, inc. configuration`
==============================================================================
MAPPINGS *markx-mappings*
In the following description *[N]* indicates Normal mode, and *[V]* indicates
visual selection mode. The name of each mapping is shown as [name] to
allow it to be overridden/manually set
In the following description, `*` represents a single mark name
- The marks 'a' to 'z' and all the 'punctuation' marks are 'local' to the
buffer
- The marks 'A' to 'Z' and '0' to '9' are 'global' and only one of each
exists in a vim session
- Only the marks 'a' to 'z', 'A' to 'Z and the 6 'punctuation' marks
' ` < > [ ] can be controlled (set/deleted) by the user
PLACING MARKS~
`m*` *[N/V]* Set the mark `*` at the current cursor position. This is the
only mapping that overrides a standard vim operation. It only does
this so that an associated sign can be placed when a mark is set.
Other than that, it should operate in exactly the same way as the
standard command
Note that this operation will set the mark regardless of whether
SelX is configured to set a sign for it or not. This is also true
of other mappings/commands that set marks
See `:help m` for further details
[MarkXAdd]
`<leader>mm` *[N]* Auto-place a mark in the range 'a' to 'z' (or a subset of
this - see `g:MarkxAutoLMarks`).
Auto-placement starts with the first mark (by default 'a') with
subsequent auto-placements placing successive marks in order. The
selection wraps-around back to the start again once the list is
exhausted
Auto-placement shall always attempt to use a currently unplaced
mark. As such, it will skip any marks in the sequence if they are
not free. If there are no free marks in the range 'a' to 'z' then
the operation shall fail and issue a warning. This behaviour can
be changed by enabling the `g:MarkxAutoLForce` configuration
setting. If this is set then the auto-placement shall start to
recycle (move) existing marks when there are no free ones
remaining
[MarkXAdda]
`<leader>mM` *[N]* Auto-place a mark in the range 'A' to 'Z' (or a subset of
this - see `g:MarkxAutoUMarks`)
In all other respects, this operates in the same way as
`<leader>mm`. See also the `g:MarkxAutoUForce` configuration setting
[MarkXAddA]
DELETING MARKS~
`<leader>md*` *[N]* Delete the mark `*`. 'Local' marks are only deleted from the
current buffer. 'Global' marks will be deleted regardless of which
buffer they are assigned to (if any)
[MarkXDel]
`<leader>ma ` *[N]* Delete all the marks 'a' to 'z' (or the subset of this
range as specified by the `g:MarkxDisplayMarks` configuration
option)
If the `g:MarkxConfirmDelAll` option is set then confirmation shall
be sought before proceeding with the operation
[MarkXDelAllL]
`<leader>mA ` *[N]* This operates exactly the same as `<leader>ma` but for the marks
'A' to 'Z'
[MarkXDelAllU]
`<leader>mp ` *[N]* This operates exactly the same as `<leader>ma` but for the marks
' ` < > [ ]
[MarkXDelAllP]
`leader>mq ` *[N]* This operates exactly the same as `<leader>ma` but only for
the auto-placement marks 'a' to 'z'. This only makes sense if the
configuration `g:MarkxAutoLMarks` is defined to be a subset of the
whole mark list. Otherwise it operates exactly as `<leader>ma`
[MarkXDelAllAutoL]
`leader>mQ ` *[N]* This operates exactly the same as `<leader>mA` but only for
the auto-placement marks 'A' to 'Z'. This only makes sense if the
configuration `g:MarkxAutoUMarks` is defined to be a subset of the
whole mark list. Otherwise it operates exactly as `<leader>mA`
[MarkXDelAllAutoU]
REFRESH DISPLAY~
The following shouldn't be necessary in normal use, but nonetheless...
`<leader>m~` *[N]* Re-assess all marks in the current buffer and add, move or
delete any associated signs as required
[MarkXRefresh]
`<leader>m#` *[N]* Re-assess all marks in all buffers and add, move or delete
any associated signs as required
[MarkXRefreshAll]
OTHER~
`<leader>m@` *[N]* Toggle 'Display signs for ALL currently placed marks'.
This operates per-buffer and when active, overrides any
configuration that specifies which marks to display signs for,
instead displaying signs for ALL marks of ALL types
==============================================================================
COMMANDS *markx-commands*
A number of the configuration settings are evaluated dynamically as and when
the effected mappings are used. The following commands will toggle these
configuration settings
For full details of these configuration settings, see the `README` file
`MarkXToggleAutoForce`
Toggle the `g:MarkxAutoLForce` configuration setting. This controls
whether or not auto-selection shall move (recycle) existing mapped marks
or not
`MarkXToggleSteponAuto`
Toggle the `g:MarkxSteponAuto` configuration setting. This controls
whether or not the auto-selection mappings' mark selection is adjusted
by manual mark placement or not
`MarkXToggleDelAllConfirm`
Toggle the `g:MarkxConfirmDelAll` configuration setting. This controls
whether or not confirmation shall be sought for the 'delete all' mappings;
`<leader>ma`, `<leader>mA`, `<leader>mp` `<leader>mq`, and `<leader>mQ`
`MarkXToggleDelUGlobal`
Toggle the `g:MarkxDelAllUGlobal` configuration settingv. This controls
whether or not the `<leader>mA` and `<leader>mQ` mappings shall operate
only on the local buffer or globally

1204
vim/.vim/doc/misc.txt Normal file

File diff suppressed because it is too large Load Diff

20
vim/.vim/doc/tags Normal file
View File

@ -0,0 +1,20 @@
[N/V] markx.txt /*[N\/V]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[N] markx.txt /*[N]*
[V] markx.txt /*[V]*
markx markx.txt /*markx*
markx-commands markx.txt /*markx-commands*
markx-contents markx.txt /*markx-contents*
markx-introduction markx.txt /*markx-introduction*
markx-mappings markx.txt /*markx-mappings*
markx.txt markx.txt /*markx.txt*

View File

@ -0,0 +1 @@
au Bufread,BufNewFile *.cdd,*.note,*.dream,*.bingo,*.copypasta,*.README,*.list,*.fun,*.joke,*.txt set filetype=cdd

View File

@ -0,0 +1,3 @@
au BufRead,BufNewFile *.hsc set filetype=haskell
au BufRead,BufNewFile *.bpk set filetype=haskell
au BufRead,BufNewFile *.hsig set filetype=haskell

View File

@ -0,0 +1,87 @@
" Vim plugin for showing matching html tags.
" Maintainer: Greg Sexton <gregsexton@gmail.com>
" Credits: Bram Moolenar and the 'matchparen' plugin from which this draws heavily.
if exists("b:did_ftplugin")
finish
endif
augroup matchhtmlparen
autocmd! CursorMoved,CursorMovedI,WinEnter <buffer> call s:Highlight_Matching_Pair()
augroup END
fu! s:Highlight_Matching_Pair()
" Remove any previous match.
if exists('w:tag_hl_on') && w:tag_hl_on
2match none
let w:tag_hl_on = 0
endif
" Avoid that we remove the popup menu.
" Return when there are no colors (looks like the cursor jumps).
if pumvisible() || (&t_Co < 8 && !has("gui_running"))
return
endif
"get html tag under cursor
let tagname = s:GetCurrentCursorTag()
if tagname == ""|return|endif
if tagname[0] == '/'
let position = s:SearchForMatchingTag(tagname[1:], 0)
else
let position = s:SearchForMatchingTag(tagname, 1)
endif
call s:HighlightTagAtPosition(position)
endfu
fu! s:GetCurrentCursorTag()
"returns the tag under the cursor, includes the '/' if on a closing tag.
let c_col = col('.')
let matched = matchstr(getline('.'), '\(<[^<>]*\%'.c_col.'c.\{-}>\)\|\(\%'.c_col.'c<.\{-}>\)')
if matched == "" || matched =~ '/>$'
return ""
endif
let tagname = matchstr(matched, '<\zs.\{-}\ze[ >]')
return tagname
endfu
fu! s:SearchForMatchingTag(tagname, forwards)
"returns the position of a matching tag or [0 0]
let starttag = '<'.a:tagname.'.\{-}/\@<!>'
let midtag = ''
let endtag = '</'.a:tagname.'.\{-}'.(a:forwards?'':'\zs').'>'
let flags = 'nW'.(a:forwards?'':'b')
" When not in a string or comment ignore matches inside them.
let skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
\ '=~? "htmlString\\|htmlCommentPart"'
execute 'if' skip '| let skip = 0 | endif'
" Limit the search to lines visible in the window.
let stopline = a:forwards ? line('w$') : line('w0')
let timeout = 300
" The searchpairpos() timeout parameter was added in 7.2
if v:version >= 702
return searchpairpos(starttag, midtag, endtag, flags, skip, stopline, timeout)
else
return searchpairpos(starttag, midtag, endtag, flags, skip, stopline)
endif
endfu
fu! s:HighlightTagAtPosition(position)
if a:position == [0, 0]
return
endif
let [m_lnum, m_col] = a:position
exe '2match MatchParen /\(\%' . m_lnum . 'l\%' . m_col . 'c<\zs.\{-}\ze[ >]\)\|'
\ .'\(\%' . line('.') . 'l\%' . col('.') . 'c<\zs.\{-}\ze[ >]\)\|'
\ .'\(\%' . line('.') . 'l<\zs[^<> ]*\%' . col('.') . 'c.\{-}\ze[ >]\)\|'
\ .'\(\%' . line('.') . 'l<\zs[^<>]\{-}\ze\s[^<>]*\%' . col('.') . 'c.\{-}>\)/'
let w:tag_hl_on = 1
endfu

View File

@ -0,0 +1 @@
au Bufread,BufNewFile *.idln set filetype=idln

1
vim/.vim/ftdetect/rc.vim Normal file
View File

@ -0,0 +1 @@
au Bufread,BufNewFile *.rc set filetype=sh

View File

@ -0,0 +1,2 @@
runtime! ftplugin/html.vim

BIN
vim/.vim/markx.tar.gz Normal file

Binary file not shown.

458
vim/.vim/markx/README Normal file
View File

@ -0,0 +1,458 @@
*markx.txt* MarkX : Mark placement enhancements
*markx*
Author: Richard Bentley-Green
Version: 22/03/2023
Contact: vim@knockknock.org.uk (bug reports and comments welcome)
The latest version of this plugin can be found at http://knockknock.org.uk
NOTE
If you set the filetype of this README file to 'help' then (assuming you have
syntax highlighting enabled), you should find it easier to read. ie;-
:set filetype=help
==============================================================================
INTRODUCTION *markx-introduction*
The primary purpose of MarkX is to automatically place a sign in the left
margin for each mark that is set, and to ensure that the displayed signs
reflect the on-going state as marks are added and removed
MarkX also includes some functions to make auto-selection and placement of
marks, so you don't have to remember which marks you've used
A version change list may be found at the end of this file
Lastly, if you find any problems, or something isn't clear then PLEASE let me
know so I can fix it - email is at the top of this file
==============================================================================
SOME CONCEPTS AND RULES *markx-concepts*
It is important to understand some basic concepts in order to make full sense
of the configuration options and to use MarkX effectively.
* MarkX does not take it on itself to automatically set or delete any marks;
marks are only set and deleted via explicit user commands
* Some marks are local to each buffer. These are 'a' to 'z' and all 13 of the
'punctuation' marks; ' < > [ ] ` " ( ) . ^ { }
* The remaining marks are global and only one instance of each of these are
ever set in a vim instance. These are 'A' to 'Z' and '0' to '9'
* Whilst the positions of all marks can be shown by MarkX (via signs placed in
the left margin), only a subset of the marks can be controlled (set and
deleted) by the user. These are 'a' to 'z', 'A' to 'Z and the 6
'punctuation' marks ' ` < > [ ]
* The marks '0' to '9 and the 7 'punctuation' marks " ( ) . ^ { } are
controlled internally by vim
* If you are unfamiliar with how marks work, `:help marks` is required reading
*IMPORTANT* MarkX does not explicitly open or close the left margin where the
signs are placed. Instead, it relies on the built-in functionality
to automatically do this. This is controlled by the `signcolumn`
setting. MarkX assumes this is set to `auto` (the vim default).
Other values will also work (except 'no')
For further details, see `:help signcolumn` (note that the available
options and the behaviour of this setting differs between vim and
neovim)
==============================================================================
OPERATION *markx-operation*
When a mark is set or removed via any of the mappings described below, MarkX
shall update the left margin immediately to ensure that an appropriate sign
(if any) is placed, moved, removed as required
There are several other standard vim commands to set and delete marks though
and it's not possible/practical to intercept all these and adjust the sign
display immediately in all cases. For this reason, various events are also
acted upon and used to trigger a refresh of the signs in either the current
buffer or all buffers displayed in the current tab. MarkX listens for quite a
few of these events but they shouldn't all trigger at once and so any overhead
incurred should be (hopefully) negligible and unnoticeable to the user
One event in particular forms a back-stop; the 'CursorHold' event. This is
triggered when vim is idle (typically triggering 4 seconds after the last
key press, but this can be modified; see `:help updatetime`. There are many
normal editing activities that can cause marks to move or be removed, plus
Markx does not intercept all the standard vim mark setting/deleting commands
and mappings.
Therefore, MarkX relies on the 'CursorHold' event to eventually trigger,
at which time it will refresh the signs associated with all marks for all
buffers in the currently displayed tab. As a result, you will see a delay
sometimes between changes to marks and the update of any associated sign
==============================================================================
OPTIONS AND CONFIGURATION *markx-options*
There are a number of options that may be set in `.vimrc` that alter the
standard behaviour of MarkX
*IMPORTANT* On startup, the marks specified by `g:MarkxDisplayMarks`,
`g:MarkxAutoLMarks` and `g:MarkxAutoUMarks` (if defined) are checked
to ensure they are valid. Warnings are displayed if there are any
problems. Failure to heed these warnings and correct the problems
indicated is likely to result in unpredictable MarkX behaviour
and/or runtime errors being reported
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxSetDefaultMaps` (defaults to 1)
If set to 1 then defaults mappings shall be set. Otherwise, no mapping at all
shall be set and the user is free to selectively set whatever mappings they
wish
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxDisplayMarks` (defaults to include all marks; that is 'a' to z',
'A' to 'Z', all 13 of the 'punctuation' marks, ' < > [ ] ` " ( ) . ^ { }
and '0' to '9')
This is a string that defines which marks should have signs placed to
indicate their locations in the buffer. By default, all marks have signs
displayed to indicate their positions but it's common to want to restrict
this to just 'a' to 'z' and 'A' to 'Z' and (maybe) a couple of the
'punctuation' marks in order to prevent clutter in the margin
*Note:* The order of the characters (mark names) within the string is not
important for indicating the marks' locations, but becomes important
if `g:MarkxAutoLMarks` or `g:MarkxAutoUMarks` are not also specified
(see below)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxAutoLMarks` (defaults to include all marks 'a' to z', or if
`g:MarkxDisplayMarks` is specified then as many of the marks 'a' to 'z'
that are defined within that string)
This indicates which of the local marks 'a' to 'z' are eligible for auto-
selection via the `<leader>mm` key mapping. It is usual to allow all the
marks 'a' to 'z' but this option allows the user to specify a sub-set
instead. In this way, the excluded marks are safe from being accidentally
moved by the `<leader>mm` mapping.
*Note:* If both this option and `g:MarkxDisplayMarks` are defined, note that
this option MUST be a subset of `g:MarkxDisplayMarks`; it cannot
include any marks that are not also specified in `g:MarkxDisplayMarks`
*Note:* The order of the characters (mark names) within this string are
relevant; the auto-placement will always start with the first and step
on to the next mark name in the order specified
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxAutoUMarks` (defaults to include all marks 'A' to Z', or if
`g:MarkxDisplayMarks` is specified then as many of the marks 'A' to 'Z'
that are defined within that string)
This operates in exactly the same was as `g:MarkxAutoLMarks` but for the
global marks 'A' to 'Z'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxPriorL` (defaults to 10)
Indicates the priority to set all signs for the marks 'a' to 'z'. The vim
default is 10. Higher values indicate higher priority
`g:MarkxPriorU` (defaults to 10)
Indicates the priority to set all signs for the marks 'A' to 'Z'
`g:MarkxPriorP` (defaults to 10)
Indicates the priority to set all signs for all 'punctuation' marks
`g:MarkxPriorN` (defaults to 10)
Indicates the priority to set all signs for the marks '0' to '9'
Collectively, adjusting these priorities allows some control over which mark
shall have a visible sign in the margin if more than one mark is set on the
same line. It may also be useful to set these to resolve conflicts with other
plugins that place signs
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxSignTrail` (defaults to '')
Each sign that is placed in the margin is composed of a single character (the
mark name). Setting this option allows a trailing character to be added (so,
for example, if this were set to '>' then instead of the 'a' mark position
being indicated by the sign 'a', it would be indicated by 'a>'
If defined, this must only be a single character
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxAutoLForce` (defaults to 0)
When auto-placing a local ('a' to 'z') mark, MarkX will use the next
available (ie, currently undefined) mark
If `g:MarkxAutoLForce` is 0 and there are no more free marks available then
the auto-placemnt will issue a warning and will not place a mark; the user
must delete at least one currently defined mark before auto-placement will
work again
If `g:MarkxAutoLForce` is 1 and there are no more free marks available then
the auto-placemnt will start to recycle (reposition) existing marks. MarkX
tries to select the oldest mark to reposition but even so, this will result
in the previous position being lost
*Note:* that this configuration is dynamically evaluated each time an auto-
placement command is issued
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxAutoUForce` (defaults to 0)
This operates in the same way as `g:MarkxAutoLForce` but for the global marks
'A' to 'Z'
*Note:* Auto-placing the global ('A' to 'Z') marks will never result in a
mark being moved from one buffer to another. However, they might
be recycled if they are associated with a file that is not currently
loaded
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`g:MarkxSteponAuto` (defaults to 0)
This controls how the auto-placement feature behaves following the manual
placement of a mark. It is best described with an example;-
Consider that auto-placement of a local ('a' to 'z') mark was made via the
`<leader>mm` mapping and this resulted in the mark 'c' being placed
Now consider that a manual mark is placed (say 'q') with the mapping `mq`
If `g:MarkxSteponAuto` was set to 0 then a following auto-placement would
place the mark 'd' (assuming it is eligible for placement); ie, auto-placement
would simply continue from where it left-off
If `g:MarkxSteponAuto` was set to 1 then a following auto-placement would
place the mark 'r' (assuming it is eligible for placement); ie, the auto-
placement function is reset to follow-on from the last manually placed mark
This option is also considered for the `<leader>mM` mapping as well
*Note:* that this configuration is dynamically evaluated each time a non-auto
placement command is issued
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`MarkxConfirmDelAll` (defaults to 0)
If set to 1 then when using the 'delete all' mappings, `<leader>ma`,
`<leader>mA`, `<leader>mp`, `<leader>mq` or `<leader>mQ`, then ask for
confirmation before continuing with the operation
*Note:* that this configuration is dynamically evaluated each time a 'delete
all' command is issued
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`MarkxDelAllUGlobal` (defaults to 0)
If set to 0 then the `<leader>mA` and `<leader>mQ` mappings will only delete
'A' to 'Z' marks that are placed in the current buffer
If set to 1 then these commands shall delete ALL 'A' to 'Z' marks, regardless
of which buffer they are placed in (if any)
*Note:* that this configuration is dynamically evaluated each time a 'delete
all' command is issued
==============================================================================
COLOURS *markx-colours*
The signs related to each of the mark "types" are displayed in different
colours in the left margin. These colours are defined by default but you can
override the colours by setting your own if you wish. The colour highlight
names and the mark "types" they refer to are;-
'MarkXL' - 'a' to 'z'
'MarkXU' - 'A' to 'Z'
'MarkXN' - '0' to '9'
'MarkXP' - The 13 'punctuation' marks ' < > [ ] ` " ( ) . ^ { }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Two colours are used for status line output; `StatusMsg` and `WarningMsg`.
`WarningMsg` is a vim standard colour so should already be defined. `StatusMsg`
is not a standard colour though and if not already defined is linked to the
colour 'Normal'
==============================================================================
MAPPINGS *markx-mappings*
In the following description *[N]* indicates Normal mode, and *[V]* indicates
visual selection mode. The name of each mapping is shown as [name] to
allow it to be overridden/manually set
In the following description, `*` represents a single mark name
- The marks 'a' to 'z' and all the 'punctuation' marks are 'local' to the
buffer
- The marks 'A' to 'Z' and '0' to '9' are 'global' and only one of each
exists in a vim session
- Only the marks 'a' to 'z', 'A' to 'Z and the 6 'punctuation' marks
' ` < > [ ] can be controlled (set/deleted) by the user
PLACING MARKS~
`m*` *[N/V]* Set the mark `*` at the current cursor position. This is the
only mapping that overrides a standard vim operation. It only does
this so that an associated sign can be placed when a mark is set.
Other than that, it should operate in exactly the same way as the
standard command
Note that this operation will set the mark regardless of whether
SelX is configured to set a sign for it or not. This is also true
of other mappings/commands that set marks
See `:help m` for further details
[MarkXAdd]
`<leader>mm` *[N]* Auto-place a mark in the range 'a' to 'z' (or a subset of
this - see `g:MarkxAutoLMarks`).
Auto-placement starts with the first mark (by default 'a') with
subsequent auto-placements placing successive marks in order. The
selection wraps-around back to the start again once the list is
exhausted
Auto-placement shall always attempt to use a currently unplaced
mark. As such, it will skip any marks in the sequence if they are
not free. If there are no free marks in the range 'a' to 'z' then
the operation shall fail and issue a warning. This behaviour can
be changed by enabling the `g:MarkxAutoLForce` configuration
setting. If this is set then the auto-placement shall start to
recycle (move) existing marks when there are no free ones
remaining
[MarkXAdda]
`<leader>mM` *[N]* Auto-place a mark in the range 'A' to 'Z' (or a subset of
this - see `g:MarkxAutoUMarks`)
In all other respects, this operates in the same way as
`<leader>mm`. See also the `g:MarkxAutoUForce` configuration setting
[MarkXAddA]
DELETING MARKS~
`<leader>md*` *[N]* Delete the mark `*`. 'Local' marks are only deleted from the
current buffer. 'Global' marks will be deleted regardless of which
buffer they are assigned to (if any)
[MarkXDel]
`<leader>ma ` *[N]* Delete all the marks 'a' to 'z' (or the subset of this
range as specified by the `g:MarkxDisplayMarks` configuration
option)
If the `g:MarkxConfirmDelAll` option is set then confirmation shall
be sought before proceeding with the operation
[MarkXDelAllL]
`<leader>mA ` *[N]* This operates exactly the same as `<leader>ma` but for the marks
'A' to 'Z'
[MarkXDelAllU]
`<leader>mp ` *[N]* This operates exactly the same as `<leader>ma` but for the marks
' ` < > [ ]
[MarkXDelAllP]
`leader>mq ` *[N]* This operates exactly the same as `<leader>ma` but only for
the auto-placement marks 'a' to 'z'. This only makes sense if the
configuration `g:MarkxAutoLMarks` is defined to be a subset of the
whole mark list. Otherwise it operates exactly as `<leader>ma`
[MarkXDelAllAutoL]
`leader>mQ ` *[N]* This operates exactly the same as `<leader>mA` but only for
the auto-placement marks 'A' to 'Z'. This only makes sense if the
configuration `g:MarkxAutoUMarks` is defined to be a subset of the
whole mark list. Otherwise it operates exactly as `<leader>mA`
[MarkXDelAllAutoU]
REFRESH DISPLAY~
The following shouldn't be necessary in normal use, but nonetheless...
`<leader>m~` *[N]* Re-assess all marks in the current buffer and add, move or
delete any associated signs as required
[MarkXRefresh]
`<leader>m#` *[N]* Re-assess all marks in all buffers and add, move or delete
any associated signs as required
[MarkXRefreshAll]
OTHER~
`<leader>m@` *[N]* Toggle 'Display signs for ALL currently placed marks'.
This operates per-buffer and when active, overrides any
configuration that specifies which marks to display signs for,
instead displaying signs for ALL marks of ALL types
==============================================================================
COMMANDS *markx-commands*
A number of the configuration settings are evaluated dynamically as and when
the effected mappings are used. The following commands will toggle these
configuration settings
For full details of these configuration settings, see above
`MarkXToggleAutoForce`
Toggle the `g:MarkxAutoLForce` configuration setting. This controls
whether or not auto-selection shall move (recycle) existing mapped marks
or not
`MarkXToggleSteponAuto`
Toggle the `g:MarkxSteponAuto` configuration setting. This controls
whether or not the auto-selection mappings' mark selection is adjusted
by manual mark placement or not
`MarkXToggleDelAllConfirm`
Toggle the `g:MarkxConfirmDelAll` configuration setting. This controls
whether or not confirmation shall be sought for the 'delete all' mappings;
`<leader>ma`, `<leader>mA`, `<leader>mp` `<leader>mq`, and `<leader>mQ`
`MarkXToggleDelUGlobal`
Toggle the `g:MarkxDelAllUGlobal` configuration settingv. This controls
whether or not the `<leader>mA` and `<leader>mQ` mappings shall operate
only on the local buffer or globally
==============================================================================
MISCELLANEOUS *markx-misc*
A variable `b:MarkxAutoa` is created per-buffer to keep track of the
auto-placement of marks 'a' to 'z' (these operate per-buffer). This variable
is only created as and when required
A variable `b:MarkxDispAll` is created per-buffer to record the status of the
'display all marks' toggle; see `<leader>m@`. This variable is only created as
and when required
==============================================================================
VERSION LIST *markx-version*
18/03/2022
- Initial release
10/04/2022
- Added `<leader>m@` mapping to toggle displaying of signs for ALL marks
- Corrected a number of comparisons which should be case-sensitive but may not
be in some vim configurations
- Corrected some configuration names - oops!
16/04/20202
- Corrected help filename - was .doc, should be .txt
08/05/2022
- Added protection against an error that can occur if '&secure' is set. I don't
really understand this, but the fix seems to address the problem. I saw the
issue when using the vim-abolish plugin by Tim Pope. To reproduce the error,
when over a word, press 'cr' and then wait until the 'CursorHold' event kicks
in, which causes markx#RefreshAll() to execute
06/03/2023
- Suppress auto-scan/refresh if the current buffer is the 'Command Line' (ref.
`q:`). Trying to scan in this case causes an error to be output.
Trivial typo correction to documentation (not important)
22/03/2023
- Correction typo in docs for 'm' mapping
--eof--

View File

@ -0,0 +1,376 @@
"Check for Python Support"
if !has('python')
com! -nargs=* CoVim echoerr "Error: CoVim requires vim compiled with +python"
finish
endif
com! -nargs=* CoVim py CoVim.command(<f-args>)
"Needs to be set on connect, MacVim overrides otherwise"
function! SetCoVimColors ()
hi CursorUser gui=bold term=bold cterm=bold
hi Cursor1 ctermbg=DarkRed ctermfg=White guibg=DarkRed guifg=White gui=bold term=bold cterm=bold
hi Cursor2 ctermbg=DarkBlue ctermfg=White guibg=DarkBlue guifg=White gui=bold term=bold cterm=bold
hi Cursor3 ctermbg=DarkGreen ctermfg=White guibg=DarkGreen guifg=White gui=bold term=bold cterm=bold
hi Cursor4 ctermbg=DarkCyan ctermfg=White guibg=DarkCyan guifg=White gui=bold term=bold cterm=bold
hi Cursor5 ctermbg=DarkMagenta ctermfg=White guibg=DarkMagenta guifg=White gui=bold term=bold cterm=bold
hi Cursor6 ctermbg=Brown ctermfg=White guibg=Brown guifg=White gui=bold term=bold cterm=bold
hi Cursor7 ctermbg=LightRed ctermfg=Black guibg=LightRed guifg=Black gui=bold term=bold cterm=bold
hi Cursor8 ctermbg=LightBlue ctermfg=Black guibg=LightBlue guifg=Black gui=bold term=bold cterm=bold
hi Cursor9 ctermbg=LightGreen ctermfg=Black guibg=LightGreen guifg=Black gui=bold term=bold cterm=bold
hi Cursor10 ctermbg=LightCyan ctermfg=Black guibg=LightCyan guifg=Black gui=bold term=bold cterm=bold
hi Cursor0 ctermbg=LightYellow ctermfg=Black guibg=LightYellow guifg=Black gui=bold term=bold cterm=bold
endfunction
if !exists("CoVim_default_name")
let CoVim_default_name = 0
endif
if !exists("CoVim_default_port")
let CoVim_default_port = 0
endif
python << EOF
import vim
import os
import json
import warnings
from twisted.internet.protocol import ClientFactory, Protocol
from twisted.internet import reactor
from threading import Thread
from time import sleep
# Ignore Warnings
warnings.filterwarnings('ignore', '.*', UserWarning)
warnings.filterwarnings('ignore', '.*', DeprecationWarning)
# Find the server path
CoVimServerPath = vim.eval('expand("<sfile>:h")') + '/CoVimServer.py'
## CoVim Protocol
class CoVimProtocol(Protocol):
def __init__(self, fact):
self.fact = fact
def send(self, event):
self.transport.write(event)
def connectionMade(self):
self.send(CoVim.username)
def dataReceived(self, data_string):
def to_utf8(d):
if isinstance(d, dict):
# no dict comprehension in python2.5/2.6
d2 = {}
for key, value in d.iteritems():
d2[to_utf8(key)] = to_utf8(value)
return d2
elif isinstance(d, list):
return map(to_utf8, d)
elif isinstance(d, unicode):
return d.encode('utf-8')
else:
return d
def clean_data_string(d_s):
bad_data = d_s.find("}{")
if bad_data > -1:
d_s = d_s[:bad_data+1]
return d_s
data_string = clean_data_string(data_string)
packet = to_utf8(json.loads(data_string))
if 'packet_type' in packet.keys():
data = packet['data']
if packet['packet_type'] == 'message':
if data['message_type'] == 'error_newname_taken':
CoVim.disconnect()
print 'ERROR: Name already in use. Please try a different name'
if data['message_type'] == 'error_newname_invalid':
CoVim.disconnect()
print 'ERROR: Name contains illegal characters. Only numbers, letters, underscores, and dashes allowed. Please try a different name'
if data['message_type'] == 'connect_success':
CoVim.setupWorkspace()
if 'buffer' in data.keys():
CoVim.vim_buffer = data['buffer']
vim.current.buffer[:] = CoVim.vim_buffer
CoVim.addUsers(data['collaborators'])
print 'Success! You\'re now connected [Port '+str(CoVim.port)+']'
if data['message_type'] == 'user_connected':
CoVim.addUsers([data['user']])
print data['user']['name']+' connected to this document'
if data['message_type'] == 'user_disconnected':
CoVim.remUser(data['name'])
print data['name']+' disconnected from this document'
if packet['packet_type'] == 'update':
if 'buffer' in data.keys() and data['name'] != CoVim.username:
b_data = data['buffer']
CoVim.vim_buffer = vim.current.buffer[:b_data['start']] \
+ b_data['buffer'] \
+ vim.current.buffer[b_data['end']-b_data['change_y']+1:]
vim.current.buffer[:] = CoVim.vim_buffer
if 'updated_cursors' in data.keys():
# We need to update your own cursor as soon as possible, then update other cursors after
for updated_user in data['updated_cursors']:
if CoVim.username == updated_user['name'] and data['name'] != CoVim.username:
vim.current.window.cursor = (updated_user['cursor']['y'], updated_user['cursor']['x'])
for updated_user in data['updated_cursors']:
if CoVim.username != updated_user['name']:
vim.command(':call matchdelete('+str(CoVim.collab_manager.collaborators[updated_user['name']][1]) + ')')
vim.command(':call matchadd(\''+CoVim.collab_manager.collaborators[updated_user['name']][0]+'\', \'\%' + str(updated_user['cursor']['x']) + 'v.\%'+str(updated_user['cursor']['y'])+'l\', 10, ' + str(CoVim.collab_manager.collaborators[updated_user['name']][1]) + ')')
#data['cursor']['x'] = max(1,data['cursor']['x'])
#print str(data['cursor']['x'])+', '+str(data['cursor']['y'])
vim.command(':redraw')
#CoVimFactory - Handles Socket Communication
class CoVimFactory(ClientFactory):
def buildProtocol(self, addr):
self.p = CoVimProtocol(self)
return self.p
def startFactory(self):
self.isConnected = True
def stopFactory(self):
self.isConnected = False
def buff_update(self):
d = {
"packet_type": "update",
"data": {
"cursor": {
"x": max(1, vim.current.window.cursor[1]),
"y": vim.current.window.cursor[0]
},
"name": CoVim.username
}
}
d = self.create_update_packet(d)
data = json.dumps(d)
self.p.send(data)
def cursor_update(self):
d = {
"packet_type": "update",
"data": {
"cursor": {
"x": max(1, vim.current.window.cursor[1]+1),
"y": vim.current.window.cursor[0]
},
"name": CoVim.username
}
}
d = self.create_update_packet(d)
data = json.dumps(d)
self.p.send(data)
def create_update_packet(self, d):
current_buffer = vim.current.buffer[:]
if current_buffer != CoVim.vim_buffer:
cursor_y = vim.current.window.cursor[0] - 1
change_y = len(current_buffer) - len(CoVim.vim_buffer)
change_x = 0
if len(CoVim.vim_buffer) > cursor_y-change_y and cursor_y-change_y >= 0 \
and len(current_buffer) > cursor_y and cursor_y >= 0:
change_x = len(current_buffer[cursor_y]) - len(CoVim.vim_buffer[cursor_y-change_y])
limits = {
'from': max(0, cursor_y-abs(change_y)),
'to': min(len(vim.current.buffer)-1, cursor_y+abs(change_y))
}
d_buffer = {
'start': limits['from'],
'end': limits['to'],
'change_y': change_y,
'change_x': change_x,
'buffer': vim.current.buffer[limits['from']:limits['to']+1],
'buffer_size': len(current_buffer)
}
d['data']['buffer'] = d_buffer
CoVim.vim_buffer = current_buffer
return d
def clientConnectionLost(self, connector, reason):
#THIS IS A HACK
if hasattr(CoVim, 'buddylist'):
CoVim.disconnect()
print 'Lost connection.'
def clientConnectionFailed(self, connector, reason):
CoVim.disconnect()
print 'Connection failed.'
#Manage Collaborators
class CollaboratorManager:
def __init__(self):
self.collab_id_itr = 4
self.reset()
def reset(self):
self.collab_color_itr = 1
self.collaborators = {}
self.buddylist_highlight_ids = []
def addUser(self, user_obj):
if user_obj['name'] == CoVim.username:
self.collaborators[user_obj['name']] = ('CursorUser', 4000)
else:
self.collaborators[user_obj['name']] = ('Cursor' + str(self.collab_color_itr), self.collab_id_itr)
self.collab_id_itr += 1
self.collab_color_itr = (self.collab_id_itr-3) % 11
vim.command(':call matchadd(\''+self.collaborators[user_obj['name']][0]+'\', \'\%' + str(user_obj['cursor']['x']) + 'v.\%'+str(user_obj['cursor']['y'])+'l\', 10, ' + str(self.collaborators[user_obj['name']][1]) + ')')
self.refreshCollabDisplay()
def remUser(self, name):
vim.command('call matchdelete('+str(self.collaborators[name][1]) + ')')
del(self.collaborators[name])
self.refreshCollabDisplay()
def refreshCollabDisplay(self):
buddylist_window_width = int(vim.eval('winwidth(0)'))
CoVim.buddylist[:] = ['']
x_a = 1
line_i = 0
vim.command("1wincmd w")
for match_id in self.buddylist_highlight_ids:
vim.command('call matchdelete('+str(match_id) + ')')
self.buddylist_highlight_ids = []
for name in self.collaborators.keys():
x_b = x_a + len(name)
if x_b > buddylist_window_width:
line_i += 1
x_a = 1
x_b = x_a + len(name)
CoVim.buddylist.append('')
vim.command('resize '+str(line_i+1))
CoVim.buddylist[line_i] += name+' '
self.buddylist_highlight_ids.append(vim.eval('matchadd(\''+self.collaborators[name][0]+'\',\'\%<'+str(x_b)+'v.\%>'+str(x_a)+'v\%'+str(line_i+1)+'l\',10,'+str(self.collaborators[name][1]+2000)+')'))
x_a = x_b + 1
vim.command("wincmd p")
#Manage all of CoVim
class CoVimScope:
def initiate(self, addr, port, name):
#Check if connected. If connected, throw error.
if hasattr(self, 'fact') and self.fact.isConnected:
print 'ERROR: Already connected. Please disconnect first'
return
if not port and hasattr(self, 'port') and self.port:
port = self.port
if not addr and hasattr(self, 'addr') and self.addr:
addr = self.addr
if not addr or not port or not name:
print 'Syntax Error: Use form :Covim connect <server address> <port> <name>'
return
port = int(port)
addr = str(addr)
vim.command('autocmd VimLeave * py CoVim.quit()')
if not hasattr(self, 'connection'):
self.addr = addr
self.port = port
self.username = name
self.vim_buffer = []
self.fact = CoVimFactory()
self.collab_manager = CollaboratorManager()
self.connection = reactor.connectTCP(addr, port, self.fact)
self.reactor_thread = Thread(target=reactor.run, args=(False,))
self.reactor_thread.start()
print 'Connecting...'
elif (hasattr(self, 'port') and port != self.port) or (hasattr(self, 'addr') and addr != self.addr):
print 'ERROR: Different address/port already used. To try another, you need to restart Vim'
else:
self.collab_manager.reset()
self.connection.connect()
print 'Reconnecting...'
def createServer(self, port, name):
vim.command(':silent execute "!'+CoVimServerPath+' '+port+' &>/dev/null &"')
sleep(0.5)
self.initiate('localhost', port, name)
def setupWorkspace(self):
vim.command('call SetCoVimColors()')
vim.command(':autocmd!')
vim.command('autocmd CursorMoved <buffer> py reactor.callFromThread(CoVim.fact.cursor_update)')
vim.command('autocmd CursorMovedI <buffer> py reactor.callFromThread(CoVim.fact.buff_update)')
vim.command('autocmd VimLeave * py CoVim.quit()')
vim.command("1new +setlocal\ stl=%!'CoVim-Collaborators'")
self.buddylist = vim.current.buffer
self.buddylist_window = vim.current.window
vim.command("wincmd j")
def addUsers(self, list):
map(self.collab_manager.addUser, list)
def remUser(self, name):
self.collab_manager.remUser(name)
def refreshCollabDisplay(self):
self.collab_manager.refreshCollabDisplay()
def command(self, arg1=False, arg2=False, arg3=False, arg4=False):
default_name = vim.eval('CoVim_default_name')
default_name_string = " - default: '"+default_name+"'" if default_name != '0' else ""
default_port = vim.eval('CoVim_default_port')
default_port_string = " - default: "+default_port if default_port != '0' else ""
if arg1 == "connect":
if arg2 and arg3 and arg4:
self.initiate(arg2, arg3, arg4)
elif arg2 and arg3 and default_name != '0':
self.initiate(arg2, arg3, default_name)
elif arg2 and default_port != '0' and default_name != '0':
self.initiate(arg2, default_port, default_name)
else:
print "usage :CoVim connect [host address / 'localhost'] [port"+default_port_string+"] [name"+default_name_string+"]"
elif arg1 == "disconnect":
self.disconnect()
elif arg1 == "quit":
self.exit()
elif arg1 == "start":
if arg2 and arg3:
self.createServer(arg2, arg3)
elif arg2 and default_name != '0':
self.createServer(arg2, default_name)
elif default_port != '0' and default_name != '0':
self.createServer(default_port, default_name)
else:
print "usage :CoVim start [port"+default_port_string+"] [name"+default_name_string+"]"
else:
print "usage: CoVim [start] [connect] [disconnect] [quit]"
def exit(self):
if hasattr(self, 'buddylist_window') and hasattr(self, 'connection'):
self.disconnect()
vim.command('q')
else:
print "ERROR: CoVim must be running to use this command"
def disconnect(self):
if hasattr(self, 'buddylist'):
vim.command("1wincmd w")
vim.command("q!")
self.collab_manager.buddylist_highlight_ids = []
for name in self.collab_manager.collaborators.keys():
if name != CoVim.username:
vim.command(':call matchdelete('+str(self.collab_manager.collaborators[name][1]) + ')')
del(self.buddylist)
if hasattr(self, 'buddylist_window'):
del(self.buddylist_window)
if hasattr(self, 'connection'):
reactor.callFromThread(self.connection.disconnect)
print 'Successfully disconnected from document!'
else:
print "ERROR: CoVim must be running to use this command"
def quit(self):
reactor.callFromThread(reactor.stop)
CoVim = CoVimScope()
EOF

259
vim/.vim/plugin/CoVimServer.py Executable file
View File

@ -0,0 +1,259 @@
#!/usr/bin/env python2
import re
import json
import argparse
from twisted.internet.protocol import Factory, Protocol
#from twisted.protocols.basic import LineReceiver
from twisted.internet import reactor
parser = argparse.ArgumentParser(description='Start a CoVim server.')
parser.add_argument('-p', '--persist', action='store_true',
help='Keep server running if all users disconnect')
parser.add_argument('port', type=int, nargs='?', default=8555,
help='Port number to run on')
def name_validate(strg, search=re.compile(r'[^0-9a-zA-Z\-\_]').search):
return not bool(search(strg))
class React(Protocol):
def __init__(self, factory):
self.factory = factory
self.state = "GETNAME"
def dataReceived(self, data):
if self.state == "GETNAME":
self.handle_GETNAME(data)
else:
self.handle_BUFF(data)
def handle_GETNAME(self, name):
# Handle duplicate name
if userManager.has_user(name):
d = {
'packet_type': 'message',
'data': {
'message_type': 'error_newname_taken'
}
}
self.transport.write(json.dumps(d))
return
# Handle spaces in name
if not name_validate(name):
d = {
'packet_type': 'message',
'data': {
'message_type': 'error_newname_invalid'
}
}
self.transport.write(json.dumps(d))
return
# Name is Valid, Add to Document
self.user = User(name, self)
userManager.add_user(self.user)
self.state = "CHAT"
d = {
'packet_type': 'message',
'data': {
'message_type': 'connect_success',
'name': name,
'collaborators': userManager.all_users_to_json()
}
}
if userManager.is_multi():
d['data']['buffer'] = self.factory.buff
self.transport.write(json.dumps(d))
print 'User "{user_name}" Connected'.format(user_name=self.user.name)
# Alert other Collaborators of new user
d = {
'packet_type': 'message',
'data': {
'message_type': 'user_connected',
'user': self.user.to_json()
}
}
self.user.broadcast_packet(d)
def handle_BUFF(self, data_string):
def to_utf8(d):
if isinstance(d, dict):
# no dict comprehension in python2.5/2.6
d2 = {}
for key, value in d.iteritems():
d2[to_utf8(key)] = to_utf8(value)
return d2
elif isinstance(d, list):
return map(to_utf8, d)
elif isinstance(d, unicode):
return d.encode('utf-8')
else:
return d
def clean_data_string(d_s):
bad_data = d_s.find("}{")
if bad_data > -1:
d_s = d_s[:bad_data+1]
return d_s
data_string = clean_data_string(data_string)
d = to_utf8(json.loads(data_string))
data = d['data']
update_self = False
if 'cursor' in data.keys():
user = userManager.get_user(data['name'])
user.update_cursor(data['cursor']['x'], data['cursor']['y'])
d['data']['updated_cursors'] = [user.to_json()]
del d['data']['cursor']
if 'buffer' in data.keys():
b_data = data['buffer']
#TODO: Improve Speed: If change_y = 0, just replace that one line
#print ' \\n '.join(self.factory.buff[:b_data['start']])
#print ' \\n '.join(b_data['buffer'])
#print ' \\n '.join(self.factory.buff[b_data['end']-b_data['change_y']+1:])
self.factory.buff = self.factory.buff[:b_data['start']] \
+ b_data['buffer'] \
+ self.factory.buff[b_data['end']-b_data['change_y']+1:]
d['data']['updated_cursors'] += userManager.update_cursors(b_data, user)
update_self = True
self.user.broadcast_packet(d, update_self)
def connectionLost(self, reason):
if hasattr(self, 'user'):
userManager.rem_user(self.user)
if userManager.is_empty():
print 'All users disconnected. Shutting down...'
reactor.stop()
class ReactFactory(Factory):
def __init__(self):
self.buff = []
def initiate(self, port):
self.port = port
print 'Now listening on port {port}...'.format(port=port)
reactor.listenTCP(port, self)
reactor.run()
def buildProtocol(self, addr):
return React(self)
class Cursor:
def __init__(self):
self.x = 1
self.y = 1
def to_json(self):
return {
'x': self.x,
'y': self.y
}
class User:
def __init__(self, name, protocol):
self.name = name
self.protocol = protocol
self.cursor = Cursor()
def to_json(self):
return {
'name': self.name,
'cursor': self.cursor.to_json()
}
def broadcast_packet(self, obj, send_to_self=False):
obj_json = json.dumps(obj)
#print obj_json
for name, user in userManager.users.iteritems():
if user.name != self.name or send_to_self:
user.protocol.transport.write(obj_json)
#TODO: don't send yourself your own buffer, but del on a copy doesn't work
def update_cursor(self, x, y):
self.cursor.x = x
self.cursor.y = y
class UserManager:
def __init__(self):
self.users = {}
def is_empty(self):
return not self.users
def is_multi(self):
return len(self.users) > 1
def has_user(self, search_name):
return self.users.get(search_name)
def add_user(self, u):
self.users[u.name] = u
def get_user(self, u_name):
try:
return self.users[u_name]
except KeyError:
raise Exception('user doesnt exist')
def rem_user(self, user):
if self.users.get(user.name):
d = {
'packet_type': 'message',
'data': {
'message_type': 'user_disconnected',
'name': user.name
}
}
user.broadcast_packet(d)
print 'User "{user_name}" Disconnected'.format(user_name=user.name)
del self.users[user.name]
def all_users_to_json(self):
return [user.to_json() for user in userManager.users.values()]
def update_cursors(self, buffer_data, u):
return_arr = []
y_target = u.cursor.y
x_target = u.cursor.x
for user in userManager.users.values():
updated = False
if user != u:
if user.cursor.y > y_target:
user.cursor.y += buffer_data['change_y']
updated = True
if user.cursor.y == y_target and user.cursor.x > x_target:
user.cursor.x = max(1, user.cursor.x + buffer_data['change_x'])
updated = True
if user.cursor.y == y_target - 1 and user.cursor.x > x_target \
and buffer_data['change_y'] == 1:
user.cursor.y += 1
user.cursor.x = max(1, user.cursor.x + buffer_data['change_x'])
updated = True
#TODO: If the line was just split?
if updated:
return_arr.append(user.to_json())
return return_arr
userManager = UserManager()
if __name__ == '__main__':
args = parser.parse_args()
Server = ReactFactory()
Server.initiate(args.port)

View File

@ -0,0 +1,76 @@
" DrawItPlugin.vim: a simple way to draw things in Vim -- just put this file in
" your plugin directory, use \di to start (\ds to stop), and
" just move about using the cursor keys.
"
" You may also use visual-block mode to select endpoints and
" draw lines, arrows, and ellipses.
"
" Date: Nov 28, 2012
" Author: Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" DrawIt.vim is provided *as is* and comes with no warranty
" of any kind, either expressed or implied. By using this
" plugin, you agree that in no event will the copyright
" holder be liable for any damages resulting from the use
" of this software.
"
" Required: this script requires Vim 7.0 (or later) {{{1
" To Enable: simply put this plugin into your ~/.vim/plugin directory {{{2
"
" GetLatestVimScripts: 40 1 :AutoInstall: DrawIt.vim
"
" (Zeph 3:1,2 WEB) Woe to her who is rebellious and polluted, the {{{1
" oppressing city! She didn't obey the voice. She didn't receive
" correction. She didn't trust in Yahweh. She didn't draw near to her God.
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp || exists("g:loaded_DrawItPlugin")
finish
endif
let g:loaded_DrawItPlugin = "v14"
let s:keepcpo = &cpo
set cpo&vim
" ---------------------------------------------------------------------
" Public Interface: {{{1
" commands:
com! -nargs=0 -bang DrawIt set lz|if <bang>0|call DrawIt#DrawItStop()|else|call DrawIt#DrawItStart()|endif|set nolz
com! -nargs=? DIstart set lz|call DrawIt#DrawItStart(<q-args>)|set nolz
com! -nargs=0 DIstop set lz|call DrawIt#DrawItStop()|set nolz
" commands: available only when not pre-defined
sil! com -nargs=0 DInrml call DrawIt#SetMode('N')
sil! com -nargs=0 DIsngl call DrawIt#SetMode('S')
sil! com -nargs=0 DIdbl call DrawIt#SetMode('D')
" maps: users may override these maps by defining their own mappings in their .vimrc
" to <Plug>DrawItStart and/or <Plug>DrawItStop. By default:
" \di : start DrawIt
" \ds : stop DrawIt
if !hasmapto('<Plug>DrawItStart')
map <unique> <Leader>di <Plug>DrawItStart
endif
noremap <silent> <Plug>DrawItStart :set lz<cr>:call DrawIt#DrawItStart()<cr>:set nolz<cr>
if !hasmapto('<Plug>DrawItStop')
map <unique> <Leader>ds <Plug>DrawItStop
endif
noremap <silent> <Plug>DrawItStop :set lz<cr>:call DrawIt#DrawItStop()<cr>:set nolz<cr>
" ---------------------------------------------------------------------
" DrChip Menu Support: {{{1
if has("gui_running") && has("menu") && &go =~# 'm'
if !exists("g:DrChipTopLvlMenu")
let g:DrChipTopLvlMenu= "DrChip."
endif
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Start\ DrawIt<tab>\\di <Leader>di'
endif
" ---------------------------------------------------------------------
" Cleanup And Modelines:
" vim: fdm=marker
let &cpo= s:keepcpo
unlet s:keepcpo

155
vim/.vim/plugin/HiTags/hitags.py Executable file
View File

@ -0,0 +1,155 @@
#!/bin/env python3
import sys
import re
import csv
from subprocess import run, PIPE
input_filename = ''
preprocessor='clang -fdirectives-only -E {input_} -o {output}'
tags_filename = 'vim.tags'
polution_directory = './'
def print2(s):
print(s, file=sys.stderr)
def usage(name, x):
print2("Usage: {0} <options>".format(name))
print2("\t-h")
print2("\t-i <file>")
print2("\t-p <cmd>")
print2("\t-t <path>")
exit(x)
def opts(args):
global input_filename, preprocessor, polution_directory
try:
i = args.index("--help") if "--help" in args else -1
if i != -1:
usage(args[0], 1)
else:
for idx, arg in enumerate(args[1:]):
if arg in ("-h", "--help"):
usage(args[0], 0)
elif arg == "-i":
input_filename = args[idx + 2]
elif arg == "-p":
preprocessor = args[idx + 2]
elif arg == "-t":
polution_directory = args[idx + 2]
except IndexError:
usage(args[0], 1)
if input_filename == '':
usage(args[0], 1)
def hi(group):
return 'syn keyword\t\tHiTag{group} {{kw}}'.format(group=group)
targets = [
{
'type': 'v',
'out': hi('Special')
},
{
'type': 'f',
'out': hi('Function')
},
{
'type': 'p',
'out': hi('Function')
},
{
'type': 't',
'out': hi('Type')
},
{
'type': 's',
'out': hi('Type')
},
{
'type': 'd',
'out': hi('Constant')
},
{
'type': 'x',
'out': hi('Identifier')
},
]
PATTERN_INDEX = 1 - 1
TYPE_INDEX = 4 - 1
def do_ignore(row):
IGNORE_IF_BEGINS_WITH = '!_'
for i in IGNORE_IF_BEGINS_WITH:
if row[0][0] == i:
return True
if row[PATTERN_INDEX].find('operator') != -1:
return True
return False
def render(target, pattern):
return target['out'].format(kw=pattern)
def mimetype(filename):
# Totally broken, it's left here as a reminder to not do this:
# cmd = "file -i {input_}".format(input_=filename)
cmd = "mimetype {input_}".format(input_=filename)
r = run(cmd, shell=True, stdout=PIPE)
r = r.stdout.decode('ascii').split(' ')[1].strip()
return r
def preprocessfile(filename):
global preprocessor, polution_directory
output = polution_directory + "/" + "tags.i"
run(preprocessor.format(input_=filename, output=output), shell=True)
return output
def file2tags(filename, flags):
global tags_filename, polution_directory
ctags_command = "ctags --recurse --extras=+F --kinds-C=+px {extras} -o {output} {input_}"
output = polution_directory + "/" + tags_filename
cmd = ctags_command.format(extras=flags, output=output, input_=filename)
run(cmd, shell=True)
return output
def tags2hi(filename):
output = set()
print2(filename)
try:
with open(filename) as f:
csv_reader = csv.reader(f, delimiter='\t')
for row in csv_reader:
if do_ignore(row):
continue
for t in targets:
try:
if t['type'] == row[TYPE_INDEX]:
output.add(render(t, re.escape(row[PATTERN_INDEX])))
except:
print2(row)
except FileNotFoundError as e:
print2(sys.argv[0] + ": No such file or directory '{0}'.".format(filename))
exit(1)
return output
def main(argv):
global input_filename
opts(argv)
mime = mimetype(input_filename)
language = ''
flags = ''
if mime == 'text/x-csrc' or mime == 'text/x-chdr':
language = 'C'
elif mime == 'text/x-c++src' or mime == 'text/x-c++hdr':
language = 'C++'
if language != '':
input_filename = preprocessfile(input_filename)
flags += ' --language-force={0} '.format(language)
output = tags2hi(file2tags(input_filename, flags))
output = sorted(output)
output = '\n'.join(output)
print(output)
if __name__ == '__main__':
raise SystemExit(main(sys.argv))

View File

@ -0,0 +1,57 @@
# 1 "/home/anon/Swap/tests/comp.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 375 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "/usr/include/gentoo/fortify.h" 1
# 3 "/usr/include/gentoo/fortify.h" 3
#define __GENTOO_HAS_FEATURE(x) __has_feature(x)
#define __GENTOO_NOT_FREESTANDING 1
# 22 "/usr/include/gentoo/fortify.h" 3
#undef __GENTOO_HAS_FEATURE
#undef __GENTOO_NOT_FREESTANDING
# 2 "<built-in>" 2
# 1 "/usr/include/gentoo/maybe-stddefs.h" 1
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 19 "/usr/include/stdc-predef.h" 3 4
#define _STDC_PREDEF_H 1
# 42 "/usr/include/stdc-predef.h" 3 4
#define __STDC_IEC_559__ 1
#define __STDC_IEC_60559_BFP__ 201404L
#define __STDC_IEC_559_COMPLEX__ 1
#define __STDC_IEC_60559_COMPLEX__ 201404L
#define __STDC_ISO_10646__ 201706L
# 5 "/usr/include/gentoo/maybe-stddefs.h" 2
# 3 "<built-in>" 2
# 1 "/home/anon/Swap/tests/comp.c" 2
char * {
i = "asd",
};

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,11 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
!_TAG_PROC_CWD /home/anon/ //
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 5.9.0 //

170
vim/.vim/plugin/acp.vim Normal file
View File

@ -0,0 +1,170 @@
"=============================================================================
" Copyright (c) 2007-2009 Takeshi NISHIDA
"
" GetLatestVimScripts: 1879 1 :AutoInstall: AutoComplPop
"=============================================================================
" LOAD GUARD {{{1
if exists('g:loaded_acp')
finish
elseif v:version < 702
echoerr 'AutoComplPop does not support this version of vim (' . v:version . ').'
finish
endif
let g:loaded_acp = 1
" }}}1
"=============================================================================
" FUNCTION: {{{1
"
function s:defineOption(name, default)
if !exists(a:name)
let {a:name} = a:default
endif
endfunction
"
function s:makeDefaultBehavior()
let behavs = {
\ '*' : [],
\ 'ruby' : [],
\ 'python' : [],
\ 'perl' : [],
\ 'xml' : [],
\ 'html' : [],
\ 'xhtml' : [],
\ 'css' : [],
\ }
"---------------------------------------------------------------------------
if !empty(g:acp_behaviorUserDefinedFunction) &&
\ !empty(g:acp_behaviorUserDefinedMeets)
for key in keys(behavs)
call add(behavs[key], {
\ 'command' : "\<C-x>\<C-u>",
\ 'completefunc' : g:acp_behaviorUserDefinedFunction,
\ 'meets' : g:acp_behaviorUserDefinedMeets,
\ 'repeat' : 0,
\ })
endfor
endif
"---------------------------------------------------------------------------
for key in keys(behavs)
call add(behavs[key], {
\ 'command' : "\<C-x>\<C-u>",
\ 'completefunc' : 'acp#completeSnipmate',
\ 'meets' : 'acp#meetsForSnipmate',
\ 'onPopupClose' : 'acp#onPopupCloseSnipmate',
\ 'repeat' : 0,
\ })
endfor
"---------------------------------------------------------------------------
for key in keys(behavs)
call add(behavs[key], {
\ 'command' : g:acp_behaviorKeywordCommand,
\ 'meets' : 'acp#meetsForKeyword',
\ 'repeat' : 0,
\ })
endfor
"---------------------------------------------------------------------------
for key in keys(behavs)
call add(behavs[key], {
\ 'command' : "\<C-x>\<C-f>",
\ 'meets' : 'acp#meetsForFile',
\ 'repeat' : 1,
\ })
endfor
"---------------------------------------------------------------------------
call add(behavs.ruby, {
\ 'command' : "\<C-x>\<C-o>",
\ 'meets' : 'acp#meetsForRubyOmni',
\ 'repeat' : 0,
\ })
"---------------------------------------------------------------------------
call add(behavs.python, {
\ 'command' : "\<C-x>\<C-o>",
\ 'meets' : 'acp#meetsForPythonOmni',
\ 'repeat' : 0,
\ })
"---------------------------------------------------------------------------
call add(behavs.perl, {
\ 'command' : "\<C-x>\<C-o>",
\ 'meets' : 'acp#meetsForPerlOmni',
\ 'repeat' : 0,
\ })
"---------------------------------------------------------------------------
call add(behavs.xml, {
\ 'command' : "\<C-x>\<C-o>",
\ 'meets' : 'acp#meetsForXmlOmni',
\ 'repeat' : 1,
\ })
"---------------------------------------------------------------------------
call add(behavs.html, {
\ 'command' : "\<C-x>\<C-o>",
\ 'meets' : 'acp#meetsForHtmlOmni',
\ 'repeat' : 1,
\ })
"---------------------------------------------------------------------------
call add(behavs.xhtml, {
\ 'command' : "\<C-x>\<C-o>",
\ 'meets' : 'acp#meetsForHtmlOmni',
\ 'repeat' : 1,
\ })
"---------------------------------------------------------------------------
call add(behavs.css, {
\ 'command' : "\<C-x>\<C-o>",
\ 'meets' : 'acp#meetsForCssOmni',
\ 'repeat' : 0,
\ })
"---------------------------------------------------------------------------
return behavs
endfunction
" }}}1
"=============================================================================
" INITIALIZATION {{{1
"-----------------------------------------------------------------------------
call s:defineOption('g:acp_enableAtStartup', 0)
call s:defineOption('g:acp_mappingDriven', 0)
call s:defineOption('g:acp_ignorecaseOption', 1)
call s:defineOption('g:acp_completeOption', '.,w,b,k')
call s:defineOption('g:acp_completeoptPreview', 0)
call s:defineOption('g:acp_behaviorUserDefinedFunction', '')
call s:defineOption('g:acp_behaviorUserDefinedMeets', '')
call s:defineOption('g:acp_behaviorSnipmateLength', -1)
call s:defineOption('g:acp_behaviorKeywordCommand', "\<C-n>")
call s:defineOption('g:acp_behaviorKeywordLength', 2)
call s:defineOption('g:acp_behaviorKeywordIgnores', [])
call s:defineOption('g:acp_behaviorFileLength', 0)
call s:defineOption('g:acp_behaviorRubyOmniMethodLength', 0)
call s:defineOption('g:acp_behaviorRubyOmniSymbolLength', 1)
call s:defineOption('g:acp_behaviorPythonOmniLength', 0)
call s:defineOption('g:acp_behaviorPerlOmniLength', -1)
call s:defineOption('g:acp_behaviorXmlOmniLength', 0)
call s:defineOption('g:acp_behaviorHtmlOmniLength', 0)
call s:defineOption('g:acp_behaviorCssOmniPropertyLength', 1)
call s:defineOption('g:acp_behaviorCssOmniValueLength', 0)
call s:defineOption('g:acp_behavior', {})
"-----------------------------------------------------------------------------
call extend(g:acp_behavior, s:makeDefaultBehavior(), 'keep')
"-----------------------------------------------------------------------------
command! -bar -narg=0 AcpEnable call acp#enable()
command! -bar -narg=0 AcpDisable call acp#disable()
command! -bar -narg=0 AcpLock call acp#lock()
command! -bar -narg=0 AcpUnlock call acp#unlock()
"-----------------------------------------------------------------------------
" legacy commands
command! -bar -narg=0 AutoComplPopEnable AcpEnable
command! -bar -narg=0 AutoComplPopDisable AcpDisable
command! -bar -narg=0 AutoComplPopLock AcpLock
command! -bar -narg=0 AutoComplPopUnlock AcpUnlock
"-----------------------------------------------------------------------------
if g:acp_enableAtStartup
AcpEnable
endif
"-----------------------------------------------------------------------------
" }}}1
"=============================================================================
" vim: set fdm=marker:

601
vim/.vim/plugin/cecutil.vim Normal file
View File

@ -0,0 +1,601 @@
" cecutil.vim : save/restore window position
" save/restore mark position
" save/restore selected user maps
" Author: Charles E. Campbell
" Version: 18k ASTRO-ONLY
" Date: Nov 22, 2017
"
" Saving Restoring Destroying Marks: {{{1
" call SaveMark(markname) let savemark= SaveMark(markname)
" call RestoreMark(markname) call RestoreMark(savemark)
" call DestroyMark(markname)
" commands: SM RM DM
"
" Saving Restoring Destroying Window Position: {{{1
" call SaveWinPosn() let winposn= SaveWinPosn()
" call RestoreWinPosn() call RestoreWinPosn(winposn)
" \swp : save current window/buffer's position
" \rwp : restore current window/buffer's previous position
" commands: SWP RWP
"
" Saving And Restoring User Maps: {{{1
" call SaveUserMaps(mapmode,maplead,mapchx,suffix)
" call RestoreUserMaps(suffix)
"
" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
"
" You believe that God is one. You do well. The demons also {{{1
" believe, and shudder. But do you want to know, vain man, that
" faith apart from works is dead? (James 2:19,20 WEB)
"redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp || exists("g:loaded_cecutil")
finish
endif
let g:loaded_cecutil = "v18k"
let s:keepcpo = &cpo
set cpo&vim
"if exists("g:loaded_Decho") " Decho
" DechoRemOn
"endif " Decho
" =======================
" Public Interface: {{{1
" =======================
" ---------------------------------------------------------------------
" Map Interface: {{{2
if !hasmapto('<Plug>SaveWinPosn')
map <unique> <Leader>swp <Plug>SaveWinPosn
endif
if !hasmapto('<Plug>RestoreWinPosn')
map <unique> <Leader>rwp <Plug>RestoreWinPosn
endif
nmap <silent> <Plug>SaveWinPosn :call SaveWinPosn()<CR>
nmap <silent> <Plug>RestoreWinPosn :call RestoreWinPosn()<CR>
" ---------------------------------------------------------------------
" Command Interface: {{{2
com! -bar -nargs=0 SWP call SaveWinPosn()
com! -bar -nargs=? RWP call RestoreWinPosn(<args>)
com! -bar -nargs=1 SM call SaveMark(<q-args>)
com! -bar -nargs=1 RM call RestoreMark(<q-args>)
com! -bar -nargs=1 DM call DestroyMark(<q-args>)
com! -bar -nargs=1 WLR call s:WinLineRestore(<q-args>)
if v:version < 630
let s:modifier= "sil! "
else
let s:modifier= "sil! keepj "
endif
" ===============
" Functions: {{{1
" ===============
" ---------------------------------------------------------------------
" SaveWinPosn: {{{2
" let winposn= SaveWinPosn() will save window position in winposn variable
" call SaveWinPosn() will save window position in b:cecutil_winposn{b:cecutil_iwinposn}
" let winposn= SaveWinPosn(0) will *only* save window position in winposn variable (no stacking done)
fun! SaveWinPosn(...)
" echomsg "Decho: SaveWinPosn() a:0=".a:0
let savedposn= winsaveview()
if a:0 == 0
if !exists("b:cecutil_iwinposn")
let b:cecutil_iwinposn= 1
else
let b:cecutil_iwinposn= b:cecutil_iwinposn + 1
endif
" echomsg "Decho: saving posn to SWP stack"
let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn
endif
return savedposn
"" echomsg "Decho: SaveWinPosn() a:0=".a:0
" if line("$") == 1 && getline(1) == ""
"" echomsg "Decho: SaveWinPosn : empty buffer"
" return ""
" endif
" let so_keep = &l:so
" let siso_keep = &siso
" let ss_keep = &l:ss
" setlocal so=0 siso=0 ss=0
" let swline = line(".") " save-window line in file
" let swcol = col(".") " save-window column in file
" if swcol >= col("$")
" let swcol= swcol + virtcol(".") - virtcol("$") " adjust for virtual edit (cursor past end-of-line)
" endif
" let swwline = winline() - 1 " save-window window line
" let swwcol = virtcol(".") - wincol() " save-window window column
" let savedposn = ""
"" echomsg "Decho: sw[".swline.",".swcol."] sww[".swwline.",".swwcol."]"
" let savedposn = "call GoWinbufnr(".winbufnr(0).")"
" let savedposn = savedposn."|".s:modifier.swline
" let savedposn = savedposn."|".s:modifier."norm! 0z\<cr>"
" if swwline > 0
" let savedposn= savedposn.":".s:modifier."call s:WinLineRestore(".(swwline+1).")\<cr>"
" endif
" if swwcol > 0
" let savedposn= savedposn.":".s:modifier."norm! 0".swwcol."zl\<cr>"
" endif
" let savedposn = savedposn.":".s:modifier."call cursor(".swline.",".swcol.")\<cr>"
" " save window position in
" " b:cecutil_winposn_{iwinposn} (stack)
" " only when SaveWinPosn() is used
" if a:0 == 0
" if !exists("b:cecutil_iwinposn")
" let b:cecutil_iwinposn= 1
" else
" let b:cecutil_iwinposn= b:cecutil_iwinposn + 1
" endif
"" echomsg "Decho: saving posn to SWP stack"
" let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn
" endif
" let &l:so = so_keep
" let &siso = siso_keep
" let &l:ss = ss_keep
"" if exists("b:cecutil_iwinposn") " Decho
"" echomsg "Decho: b:cecutil_winpos{".b:cecutil_iwinposn."}[".b:cecutil_winposn{b:cecutil_iwinposn}."]"
"" else " Decho
"" echomsg "Decho: b:cecutil_iwinposn doesn't exist"
"" endif " Decho
"" echomsg "Decho: SaveWinPosn [".savedposn."]"
" return savedposn
endfun
" ---------------------------------------------------------------------
" RestoreWinPosn: {{{2
" call RestoreWinPosn()
" call RestoreWinPosn(winposn)
fun! RestoreWinPosn(...)
if line("$") == 1 && getline(1) == ""
return ""
endif
if a:0 == 0 || type(a:1) != 4
" use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists
if exists("b:cecutil_iwinposn") && exists("b:cecutil_winposn{b:cecutil_iwinposn}")
try
call winrestview(b:cecutil_winposn{b:cecutil_iwinposn})
catch /^Vim\%((\a\+)\)\=:E749/
" ignore empty buffer error messages
endtry
" normally drop top-of-stack by one
" but while new top-of-stack doesn't exist
" drop top-of-stack index by one again
if b:cecutil_iwinposn >= 1
unlet b:cecutil_winposn{b:cecutil_iwinposn}
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
while b:cecutil_iwinposn >= 1 && !exists("b:cecutil_winposn{b:cecutil_iwinposn}")
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
endwhile
if b:cecutil_iwinposn < 1
unlet b:cecutil_iwinposn
endif
endif
else
echohl WarningMsg
echomsg "***warning*** need to SaveWinPosn first!"
echohl None
endif
else " handle input argument
" echomsg "Decho: using input a:1<".a:1.">"
" use window position passed to this function
call winrestview(a:1)
" remove a:1 pattern from b:cecutil_winposn{b:cecutil_iwinposn} stack
if exists("b:cecutil_iwinposn")
let jwinposn= b:cecutil_iwinposn
while jwinposn >= 1 " search for a:1 in iwinposn..1
if exists("b:cecutil_winposn{jwinposn}") " if it exists
if a:1 == b:cecutil_winposn{jwinposn} " and the pattern matches
unlet b:cecutil_winposn{jwinposn} " unlet it
if jwinposn == b:cecutil_iwinposn " if at top-of-stack
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 " drop stacktop by one
endif
endif
endif
let jwinposn= jwinposn - 1
endwhile
endif
endif
"" echomsg "Decho: RestoreWinPosn() a:0=".a:0
"" echomsg "Decho: getline(1)<".getline(1).">"
"" echomsg "Decho: line(.)=".line(".")
" if line("$") == 1 && getline(1) == ""
"" echomsg "Decho: RestoreWinPosn : empty buffer"
" return ""
" endif
" let so_keep = &l:so
" let siso_keep = &l:siso
" let ss_keep = &l:ss
" setlocal so=0 siso=0 ss=0
" if a:0 == 0 || a:1 == ""
" " use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists
" if exists("b:cecutil_iwinposn") && exists("b:cecutil_winposn{b:cecutil_iwinposn}")
"" echomsg "Decho: using stack b:cecutil_winposn{".b:cecutil_iwinposn."}<".b:cecutil_winposn{b:cecutil_iwinposn}.">"
" try
" exe s:modifier.b:cecutil_winposn{b:cecutil_iwinposn}
" catch /^Vim\%((\a\+)\)\=:E749/
" " ignore empty buffer error messages
" endtry
" " normally drop top-of-stack by one
" " but while new top-of-stack doesn't exist
" " drop top-of-stack index by one again
" if b:cecutil_iwinposn >= 1
" unlet b:cecutil_winposn{b:cecutil_iwinposn}
" let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
" while b:cecutil_iwinposn >= 1 && !exists("b:cecutil_winposn{b:cecutil_iwinposn}")
" let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
" endwhile
" if b:cecutil_iwinposn < 1
" unlet b:cecutil_iwinposn
" endif
" endif
" else
" echohl WarningMsg
" echomsg "***warning*** need to SaveWinPosn first!"
" echohl None
" endif
" else " handle input argument
"" echomsg "Decho: using input a:1<".a:1.">"
" " use window position passed to this function
" exe a:1
" " remove a:1 pattern from b:cecutil_winposn{b:cecutil_iwinposn} stack
" if exists("b:cecutil_iwinposn")
" let jwinposn= b:cecutil_iwinposn
" while jwinposn >= 1 " search for a:1 in iwinposn..1
" if exists("b:cecutil_winposn{jwinposn}") " if it exists
" if a:1 == b:cecutil_winposn{jwinposn} " and the pattern matches
" unlet b:cecutil_winposn{jwinposn} " unlet it
" if jwinposn == b:cecutil_iwinposn " if at top-of-stack
" let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 " drop stacktop by one
" endif
" endif
" endif
" let jwinposn= jwinposn - 1
" endwhile
" endif
" endif
" " Seems to be something odd: vertical motions after RWP
" " cause jump to first column. The following fixes that.
" " Note: was using wincol()>1, but with signs, a cursor
" " at column 1 yields wincol()==3. Beeping ensued.
" let vekeep= &ve
" set ve=all
" if virtcol('.') > 1
" exe s:modifier."norm! hl"
" elseif virtcol(".") < virtcol("$")
" exe s:modifier."norm! lh"
" endif
" let &ve= vekeep
" let &l:so = so_keep
" let &l:siso = siso_keep
" let &l:ss = ss_keep
"" echomsg "Decho: RestoreWinPosn"
endfun
" ---------------------------------------------------------------------
" s:WinLineRestore: {{{2
fun! s:WinLineRestore(swwline)
" echomsg "Decho: s:WinLineRestore(swwline=".a:swwline.")"
while winline() < a:swwline
let curwinline= winline()
exe s:modifier."norm! \<c-y>"
if curwinline == winline()
break
endif
endwhile
" echomsg "Decho: s:WinLineRestore"
endfun
" ---------------------------------------------------------------------
" GoWinbufnr: go to window holding given buffer (by number) {{{2
" Prefers current window; if its buffer number doesn't match,
" then will try from topleft to bottom right
fun! GoWinbufnr(bufnum)
" call Dfunc("GoWinbufnr(".a:bufnum.")")
if winbufnr(0) == a:bufnum
" call Dret("GoWinbufnr : winbufnr(0)==a:bufnum")
return
endif
winc t
let first=1
while winbufnr(0) != a:bufnum && (first || winnr() != 1)
winc w
let first= 0
endwhile
" call Dret("GoWinbufnr")
endfun
" ---------------------------------------------------------------------
" SaveMark: sets up a string saving a mark position. {{{2
" For example, SaveMark("a")
" Also sets up a global variable, g:savemark_{markname}
fun! SaveMark(markname)
" call Dfunc("SaveMark(markname<".string(a:markname).">)")
let markname= a:markname
if strpart(markname,0,1) !~ '\a'
let markname= strpart(markname,1,1)
endif
" call Decho("markname=".string(markname))
let lzkeep = &lz
set lz
if 1 <= line("'".markname) && line("'".markname) <= line("$")
let winposn = SaveWinPosn(0)
exe s:modifier."norm! `".markname
let savemark = SaveWinPosn(0)
let g:savemark_{markname} = savemark
let savemark = markname.string(savemark)
call RestoreWinPosn(winposn)
else
let g:savemark_{markname} = ""
let savemark = ""
endif
let &lz= lzkeep
" call Dret("SaveMark : savemark<".savemark.">")
return savemark
endfun
" ---------------------------------------------------------------------
" RestoreMark: {{{2
" call RestoreMark("a") -or- call RestoreMark(savemark)
fun! RestoreMark(markname)
" call Dfunc("RestoreMark(markname<".a:markname.">)")
if strlen(a:markname) <= 0
" call Dret("RestoreMark : no such mark")
return
endif
let markname= strpart(a:markname,0,1)
if markname !~ '\a'
" handles 'a -> a styles
let markname= strpart(a:markname,1,1)
endif
" call Decho("markname=".markname." strlen(a:markname)=".strlen(a:markname))
let lzkeep = &lz
set lz
let winposn = SaveWinPosn(0)
if strlen(a:markname) <= 2
if exists("g:savemark_{markname}")
" use global variable g:savemark_{markname}
" call Decho("use savemark list")
call RestoreWinPosn(g:savemark_{markname})
exe "norm! m".markname
endif
else
" markname is a savemark command (string)
" call Decho("use savemark command")
let markcmd= strpart(a:markname,1)
call RestoreWinPosn(winposn)
exe "norm! m".markname
endif
call RestoreWinPosn(winposn)
let &lz = lzkeep
" call Dret("RestoreMark")
endfun
" ---------------------------------------------------------------------
" DestroyMark: {{{2
" call DestroyMark("a") -- destroys mark
fun! DestroyMark(markname)
" call Dfunc("DestroyMark(markname<".a:markname.">)")
" save options and set to standard values
let reportkeep= &report
let lzkeep = &lz
set lz report=10000
let markname= strpart(a:markname,0,1)
if markname !~ '\a'
" handles 'a -> a styles
let markname= strpart(a:markname,1,1)
endif
" call Decho("markname=".markname)
let curmod = &mod
let winposn = SaveWinPosn(0)
1
let lineone = getline(".")
exe "k".markname
d
put! =lineone
let &mod = curmod
call RestoreWinPosn(winposn)
" restore options to user settings
let &report = reportkeep
let &lz = lzkeep
" call Dret("DestroyMark")
endfun
" ---------------------------------------------------------------------
" QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{2
" However, <q-args> doesn't split at all, so this one returns a list
" with splits at all whitespace (only!), plus a leading length-of-list.
" The resulting list: qarglist[0] corresponds to a:0
" qarglist[i] corresponds to a:{i}
fun! QArgSplitter(qarg)
" call Dfunc("QArgSplitter(qarg<".a:qarg.">)")
let qarglist = split(a:qarg)
let qarglistlen = len(qarglist)
let qarglist = insert(qarglist,qarglistlen)
" call Dret("QArgSplitter ".string(qarglist))
return qarglist
endfun
" ---------------------------------------------------------------------
" ListWinPosn: {{{2
"fun! ListWinPosn() " Decho
" if !exists("b:cecutil_iwinposn") || b:cecutil_iwinposn == 0 " Decho
" call Decho("nothing on SWP stack") " Decho
" else " Decho
" let jwinposn= b:cecutil_iwinposn " Decho
" while jwinposn >= 1 " Decho
" if exists("b:cecutil_winposn{jwinposn}") " Decho
" call Decho("winposn{".jwinposn."}<".b:cecutil_winposn{jwinposn}.">") " Decho
" else " Decho
" call Decho("winposn{".jwinposn."} -- doesn't exist") " Decho
" endif " Decho
" let jwinposn= jwinposn - 1 " Decho
" endwhile " Decho
" endif " Decho
"endfun " Decho
"com! -nargs=0 LWP call ListWinPosn() " Decho
" ---------------------------------------------------------------------
" SaveUserMaps: this function sets up a script-variable (s:restoremap) {{{2
" which can be used to restore user maps later with
" call RestoreUserMaps()
"
" mapmode - see :help maparg for details (n v o i c l "")
" ex. "n" = Normal
" The letters "b" and "u" are optional prefixes;
" The "u" means that the map will also be unmapped
" The "b" means that the map has a <buffer> qualifier
" ex. "un" = Normal + unmapping
" ex. "bn" = Normal + <buffer>
" ex. "bun" = Normal + <buffer> + unmapping
" ex. "ubn" = Normal + <buffer> + unmapping
" maplead - see mapchx
" mapchx - "<something>" handled as a single map item.
" ex. "<left>"
" - "string" a string of single letters which are actually
" multiple two-letter maps (using the maplead:
" maplead . each_character_in_string)
" ex. maplead="\" and mapchx="abc" saves user mappings for
" \a, \b, and \c
" Of course, if maplead is "", then for mapchx="abc",
" mappings for a, b, and c are saved.
" - :something handled as a single map item, w/o the ":"
" ex. mapchx= ":abc" will save a mapping for "abc"
" suffix - a string unique to your plugin
" ex. suffix= "DrawIt"
fun! SaveUserMaps(mapmode,maplead,mapchx,suffix)
" call Dfunc("SaveUserMaps(mapmode<".a:mapmode."> maplead<".a:maplead."> mapchx<".a:mapchx."> suffix<".a:suffix.">)")
if !exists("s:restoremap_{a:suffix}")
" initialize restoremap_suffix to null string
let s:restoremap_{a:suffix}= ""
endif
" set up dounmap: if 1, then save and unmap (a:mapmode leads with a "u")
" if 0, save only
let mapmode = a:mapmode
let dounmap = 0
let dobuffer = ""
while mapmode =~# '^[bu]'
if mapmode =~# '^u'
let dounmap = 1
let mapmode = strpart(a:mapmode,1)
elseif mapmode =~# '^b'
let dobuffer = "<buffer> "
let mapmode = strpart(a:mapmode,1)
endif
endwhile
" call Decho("dounmap=".dounmap." dobuffer<".dobuffer.">")
" save single map :...something...
if strpart(a:mapchx,0,1) == ':'
" call Decho("save single map :...something...")
let amap= strpart(a:mapchx,1)
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let amap = a:maplead.amap
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:sil! ".mapmode."unmap ".dobuffer.amap
if maparg(amap,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:".mapmode."map ".dobuffer.amap." ".maprhs
endif
if dounmap
exe "sil! ".mapmode."unmap ".dobuffer.amap
endif
" save single map <something>
elseif strpart(a:mapchx,0,1) == '<'
" call Decho("save single map <something>")
let amap = a:mapchx
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
" call Decho("amap[[".amap."]]")
endif
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|sil! ".mapmode."unmap ".dobuffer.amap
if maparg(a:mapchx,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".dobuffer.amap." ".maprhs
endif
if dounmap
exe "sil! ".mapmode."unmap ".dobuffer.amap
endif
" save multiple maps
else
" call Decho("save multiple maps")
let i= 1
while i <= strlen(a:mapchx)
let amap= a:maplead.strpart(a:mapchx,i-1,1)
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|sil! ".mapmode."unmap ".dobuffer.amap
if maparg(amap,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".dobuffer.amap." ".maprhs
endif
if dounmap
exe "sil! ".mapmode."unmap ".dobuffer.amap
endif
let i= i + 1
endwhile
endif
" call Dret("SaveUserMaps : s:restoremap_".a:suffix.": ".s:restoremap_{a:suffix})
endfun
" ---------------------------------------------------------------------
" RestoreUserMaps: {{{2
" Used to restore user maps saved by SaveUserMaps()
fun! RestoreUserMaps(suffix)
" call Dfunc("RestoreUserMaps(suffix<".a:suffix.">)")
if exists("s:restoremap_{a:suffix}")
let s:restoremap_{a:suffix}= substitute(s:restoremap_{a:suffix},'|\s*$','','e')
if s:restoremap_{a:suffix} != ""
" call Decho("exe ".s:restoremap_{a:suffix})
exe "sil! ".s:restoremap_{a:suffix}
endif
unlet s:restoremap_{a:suffix}
endif
" call Dret("RestoreUserMaps")
endfun
" ==============
" Restore: {{{1
" ==============
let &cpo= s:keepcpo
unlet s:keepcpo
" ================
" Modelines: {{{1
" ================
" vim: ts=4 fdm=marker

View File

@ -0,0 +1,327 @@
" File: closetag.vim
" Summary: Functions and mappings to close open HTML/XML tags
" Uses: <C-_> -- close matching open tag
" Author: Steven Mueller <diffusor@ugcs.caltech.edu>
" Last Modified: Tue May 24 13:29:48 PDT 2005
" Version: 0.9.1
" XXX - breaks if close attempted while XIM is in preedit mode
" TODO - allow usability as a global plugin -
" Add g:unaryTagsStack - always contains html tags settings
" and g:closetag_default_xml - user should define this to default to xml
" When a close is attempted but b:unaryTagsStack undefined,
" use b:closetag_html_style to determine if the file is to be treated
" as html or xml. Failing that, check the filetype for xml or html.
" Finally, default to g:closetag_html_style.
" If the file is html, let b:unaryTagsStack=g:unaryTagsStack
" otherwise, let b:unaryTagsStack=""
" TODO - make matching work for all comments
" -- kinda works now, but needs syn sync minlines to be very long
" -- Only check whether in syntax in the beginning, then store comment tags
" in the tagstacks to determine whether to move into or out of comment mode
" TODO - The new normal mode mapping clears recent messages with its <ESC>, and
" it doesn't fix the null-undo issue for vim 5.7 anyway.
" TODO - make use of the following neat features:
" -- the ternary ?: operator
" -- :echomsg and :echoerr
" -- curly brace expansion for variables and function name definitions?
" -- check up on map <blah> \FuncName
"
" Description:
" This script eases redundant typing when writing html or xml files (even if
" you're very good with ctrl-p and ctrl-n :). Hitting ctrl-_ will initiate a
" search for the most recent open tag above that is not closed in the
" intervening space and then insert the matching close tag at the cursor. In
" normal mode, the close tag is inserted one character after cursor rather than
" at it, as if a<C-_> had been used. This allows putting close tags at the
" ends of lines while in normal mode, but disallows inserting them in the
" first column.
"
" For HTML, a configurable list of tags are ignored in the matching process.
" By default, the following tags will not be matched and thus not closed
" automatically: area, base, br, dd, dt, hr, img, input, link, meta, and
" param.
"
" For XML, all tags must have a closing match or be terminated by />, as in
" <empty-element/>. These empty element tags are ignored for matching.
"
" Comment checking is now handled by vim's internal syntax checking. If tag
" closing is initiated outside a comment, only tags outside of comments will
" be matched. When closing tags in comments, only tags within comments will
" be matched, skipping any non-commented out code (wee!). However, the
" process of determining the syntax ID of an arbitrary position can still be
" erroneous if a comment is not detected because the syntax highlighting is
" out of sync, or really slow if syn sync minlines is large.
" Set the b:closetag_disable_synID variable to disable this feature if you
" have really big chunks of comment in your code and closing tags is too slow.
"
" If syntax highlighting is not enabled, comments will not be handled very
" well. Commenting out HTML in certain ways may cause a "tag mismatch"
" message and no completion. For example, '<!--a href="blah">link!</a-->'
" between the cursor and the most recent unclosed open tag above causes
" trouble. Properly matched well formed tags in comments don't cause a
" problem.
"
" Install:
" To use, place this file in your standard vim scripts directory, and source
" it while editing the file you wish to close tags in. If the filetype is not
" set or the file is some sort of template with embedded HTML, you may force
" HTML style tag matching by first defining the b:closetag_html_style buffer
" variable. Otherwise, the default is XML style tag matching.
"
" Example:
" :let b:closetag_html_style=1
" :source ~/.vim/scripts/closetag.vim
"
" For greater convenience, load this script in an autocommand:
" :au Filetype html,xml,xsl source ~/.vim/scripts/closetag.vim
"
" Also, set noignorecase for html files or edit b:unaryTagsStack to match your
" capitalization style. You may set this variable before or after loading the
" script, or simply change the file itself.
"
" Configuration Variables:
"
" b:unaryTagsStack Buffer local string containing a whitespace
" seperated list of element names that should be
" ignored while finding matching closetags. Checking
" is done according to the current setting of the
" ignorecase option.
"
" b:closetag_html_style Define this (as with let b:closetag_html_style=1)
" and source the script again to set the
" unaryTagsStack to its default value for html.
"
" b:closetag_disable_synID Define this to disable comment checking if tag
" closing is too slow. This can be set or unset
" without having to source again.
"
" Changelog:
" May 24, 2005 Tuesday
" * Changed function names to be script-local to avoid conflicts with other
" scripts' stack implementations.
"
" June 07, 2001 Thursday
" * Added comment handling. Currently relies on synID, so if syn sync
" minlines is small, the chance for failure is high, but if minlines is
" large, tagclosing becomes rather slow...
"
" * Changed normal mode closetag mapping to use <C-R> in insert mode
" rather than p in normal mode. This has 2 implications:
" - Tag closing no longer clobbers the unnamed register
" - When tag closing fails or finds no match, no longer adds to the undo
" buffer for recent vim 6.0 development versions.
" - However, clears the last message when closing tags in normal mode
"
" * Changed the closetag_html_style variable to be buffer-local rather than
" global.
"
" * Expanded documentation
"------------------------------------------------------------------------------
" User configurable settings
"------------------------------------------------------------------------------
" if html, don't close certain tags. Works best if ignorecase is set.
" otherwise, capitalize these elements according to your html editing style
if !exists("b:unaryTagsStack") || exists("b:closetag_html_style")
if &filetype == "html" || exists("b:closetag_html_style")
let b:unaryTagsStack="area base br dd dt hr img input link meta param"
else " for xsl and xsl
let b:unaryTagsStack=""
endif
endif
" Has this already been loaded?
if exists("loaded_closetag")
finish
endif
let loaded_closetag=1
" set up mappings for tag closing
inoremap <C-_> <C-R>=GetCloseTag()<CR>
map <C-_> a<C-_><ESC>
"------------------------------------------------------------------------------
" Tag closer - uses the stringstack implementation below
"------------------------------------------------------------------------------
" Returns the most recent unclosed tag-name
" (ignores tags in the variable referenced by a:unaryTagsStack)
function! GetLastOpenTag(unaryTagsStack)
" Search backwards through the file line by line using getline()
" Overall strategy (moving backwards through the file from the cursor):
" Push closing tags onto a stack.
" On an opening tag, if the tag matches the stack top, discard both.
" -- if the tag doesn't match, signal an error.
" -- if the stack is empty, use this tag
let linenum=line(".")
let lineend=col(".") - 1 " start: cursor position
let first=1 " flag for first line searched
let b:TagStack="" " main stack of tags
let startInComment=s:InComment()
let tagpat='</\=\(\k\|[-:]\)\+\|/>'
" Search for: closing tags </tag, opening tags <tag, and unary tag ends />
while (linenum>0)
" Every time we see an end-tag, we push it on the stack. When we see an
" open tag, if the stack isn't empty, we pop it and see if they match.
" If no, signal an error.
" If yes, continue searching backwards.
" If stack is empty, return this open tag as the one that needs closing.
let line=getline(linenum)
if first
let line=strpart(line,0,lineend)
else
let lineend=strlen(line)
endif
let b:lineTagStack=""
let mpos=0
let b:TagCol=0
" Search the current line in the forward direction, pushing any tags
" onto a special stack for the current line
while (mpos > -1)
let mpos=matchend(line,tagpat)
if mpos > -1
let b:TagCol=b:TagCol+mpos
let tag=matchstr(line,tagpat)
if exists("b:closetag_disable_synID") || startInComment==s:InCommentAt(linenum, b:TagCol)
let b:TagLine=linenum
call s:Push(matchstr(tag,'[^<>]\+'),"b:lineTagStack")
endif
"echo "Tag: ".tag." ending at position ".mpos." in '".line."'."
let lineend=lineend-mpos
let line=strpart(line,mpos,lineend)
endif
endwhile
" Process the current line stack
while (!s:EmptystackP("b:lineTagStack"))
let tag=s:Pop("b:lineTagStack")
if match(tag, "^/") == 0 "found end tag
call s:Push(tag,"b:TagStack")
"echo linenum." ".b:TagStack
elseif s:EmptystackP("b:TagStack") && !s:Instack(tag, a:unaryTagsStack) "found unclosed tag
return tag
else
let endtag=s:Peekstack("b:TagStack")
if endtag == "/".tag || endtag == "/"
call s:Pop("b:TagStack") "found a open/close tag pair
"echo linenum." ".b:TagStack
elseif !s:Instack(tag, a:unaryTagsStack) "we have a mismatch error
echohl Error
echon "\rError:"
echohl None
echo " tag mismatch: <".tag."> doesn't match <".endtag.">. (Line ".linenum." Tagstack: ".b:TagStack.")"
return ""
endif
endif
endwhile
let linenum=linenum-1 | let first=0
endwhile
" At this point, we have exhausted the file and not found any opening tag
echo "No opening tags."
return ""
endfunction
" Returns closing tag for most recent unclosed tag, respecting the
" current setting of b:unaryTagsStack for tags that should not be closed
function! GetCloseTag()
let tag=GetLastOpenTag("b:unaryTagsStack")
if tag == ""
return ""
else
return "</".tag.">"
endif
endfunction
" return 1 if the cursor is in a syntactically identified comment field
" (fails for empty lines: always returns not-in-comment)
function! s:InComment()
return synIDattr(synID(line("."), col("."), 0), "name") =~ 'Comment'
endfunction
" return 1 if the position specified is in a syntactically identified comment field
function! s:InCommentAt(line, col)
return synIDattr(synID(a:line, a:col, 0), "name") =~ 'Comment'
endfunction
"------------------------------------------------------------------------------
" String Stacks
"------------------------------------------------------------------------------
" These are strings of whitespace-separated elements, matched using the \< and
" \> patterns after setting the iskeyword option.
"
" The sname argument should contain a symbolic reference to the stack variable
" on which method should operate on (i.e., sname should be a string containing
" a fully qualified (ie: g:, b:, etc) variable name.)
" Helper functions
function! s:SetKeywords()
let g:IsKeywordBak=&iskeyword
let &iskeyword="33-255"
endfunction
function! s:RestoreKeywords()
let &iskeyword=g:IsKeywordBak
endfunction
" Push el onto the stack referenced by sname
function! s:Push(el, sname)
if !s:EmptystackP(a:sname)
exe "let ".a:sname."=a:el.' '.".a:sname
else
exe "let ".a:sname."=a:el"
endif
endfunction
" Check whether the stack is empty
function! s:EmptystackP(sname)
exe "let stack=".a:sname
if match(stack,"^ *$") == 0
return 1
else
return 0
endif
endfunction
" Return 1 if el is in stack sname, else 0.
function! s:Instack(el, sname)
exe "let stack=".a:sname
call s:SetKeywords()
let m=match(stack, "\\<".a:el."\\>")
call s:RestoreKeywords()
if m < 0
return 0
else
return 1
endif
endfunction
" Return the first element in the stack
function! s:Peekstack(sname)
call s:SetKeywords()
exe "let stack=".a:sname
let top=matchstr(stack, "\\<.\\{-1,}\\>")
call s:RestoreKeywords()
return top
endfunction
" Remove and return the first element in the stack
function! s:Pop(sname)
if s:EmptystackP(a:sname)
echo "Error! Stack ".a:sname." is empty and can't be popped."
return ""
endif
exe "let stack=".a:sname
" Find the first space, loc is 0-based. Marks the end of 1st elt in stack.
call s:SetKeywords()
let loc=matchend(stack,"\\<.\\{-1,}\\>")
exe "let ".a:sname."=strpart(stack, loc+1, strlen(stack))"
let top=strpart(stack, match(stack, "\\<"), loc)
call s:RestoreKeywords()
return top
endfunction
function! s:Clearstack(sname)
exe "let ".a:sname."=''"
endfunction

Some files were not shown because too many files have changed in this diff Show More