Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2017-05-03 16:10:13 +03:00
commit c78cb78ff0
72 changed files with 3570 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
homedir/.vim/.netrwhist
homedir/.vim/syntax
homedir/.bashrc.d/99-local
homedir/.config/zsh.d/local
homedir/.ncmpcpp/error.log

23
homedir/.Xresources Normal file
View File

@ -0,0 +1,23 @@
! Xft settings ---------------------------------------------------------------
Xft.dpi: 95
!Xft.antialias: true
!Xft.rgba: rgb
!Xft.hinting: true
!Xft.hintstyle: hintslight
! rofi
rofi.key-run: Mod4+r
rofi.lines: 3
rofi.bw: 2
rofi.separator-style: solid
rofi.hide-scrollbar: true
rofi.glob: true
rofi.width: 33
rofi.bc: #467EC2
rofi.fg: #f9f9f9
rofi.bg: #29303A
rofi.hlbg: #467EC2
rofi.font: Terminus 12
rofi.opacity: 85

44
homedir/.bashrc Normal file
View File

@ -0,0 +1,44 @@
# vim: ft=sh
# Do nothing if not interactive
[[ "$PS1" ]] || return
# Modules
mpath=( $HOME/.config/bash.d )
function msg { printf '%s\n' "$*"; }
function err { printf '%s\n' "$*" >&2; }
function use {
while (( $# )); do
case $1 in
(-n) flag_nofail=1;;
(--) shift; break;;
(*) break;;
esac
shift
done
declare mname=$1
for p in "${mpath[@]}"; do
if [[ -f "$mpath/$mname" ]]; then
if source "$mpath/$mname"; then
msg "Loaded: $mname"
else
err "Something went wrong while loading $mname"
(( flag_nofail )) || return 1
fi
else
err "Module $mname not found"
(( flag_nofail )) || return 1
fi
done
return 0
}
use common
use colours
use config
use -n local
use prompt

View File

@ -0,0 +1,30 @@
# Colours
# Console colours
# Black 0;30 Dark Gray 1;30
# Blue 0;34 Light Blue 1;34
# Green 0;32 Light Green 1;32
# Cyan 0;36 Light Cyan 1;36
# Red 0;31 Light Red 1;31
# Purple 0;35 Light Purple 1;35
# Brown 0;33 Yellow 1;33
# Light Gray 0;37 White 1;37
c_black="\[\033[0;30m\]"
c_blue="\[\033[0;34m\]"
c_green="\[\033[0;32m\]"
c_cyan="\[\033[0;36m\]"
c_red="\[\033[0;31m\]"
c_purple="\[\033[0;35m\]"
c_brown="\[\033[0;33m\]"
c_lightgray="\[\033[0;37m\]"
c_darkgray="\[\033[1;30m\]"
c_lightblue="\[\033[1;34m\]"
c_lightgreen="\[\033[1;32m\]"
c_lightcyan="\[\033[1;36m\]"
c_lightred="\[\033[1;31m\]"
c_lightpurple="\[\033[1;35m\]"
c_yellow="\[\033[1;33m\]"
c_white="\[\033[1;37m\]"
c_reset="\[\e[00m\]"

View File

@ -0,0 +1,41 @@
#!/bin/bash
echo() { printf '%s\n' "$*"; }
msg() { printf '%s\n' "$*"; }
err() { printf '%s\n' "$*" >&2; }
set_title() { printf '\033]0;%s\007' "$1"; }
trap_error() { err "The command has returned a non-zero exit code ($?)."; }
x() { exec xinit -- -nolisten tcp vt9; }
is_coreutils() {
declare out
out=$( df --version 2>/dev/null )
(( $? )) && {
err 'df --version exited with an error. This is not GNU coreutils'
return 3
}
[[ "$out" =~ 'GNU coreutils' ]] || {
err 'Version output does not contain "GNU coreutils". This is not GNU coreutils.'
return 1
}
}
fuck() { sudo $(history -p \!\!); }
err() { printf '%s\n' "$*"; }
is_function() {
[[ $(type -t "$1") == 'function' ]]
}
if is_coreutils; then
ls() { $(type -P ls) -l -hb --group-directories-first --color=auto "$@"; }
mv() { $(type -P mv) -v "$@"; }
cp() { $(type -P cp) -v "$@"; }
rm() { $(type -P rm) -v "$@"; }
fi

View File

@ -0,0 +1,28 @@
# BASH options
bash_opts=(
'checkwinsize' 'histappend' 'autocd'
'checkhash'
)
shopt -s "${bash_opts[@]}"
shopt -u sourcepath
PROMPT_COMMAND='set_prompt'
HISTCONTROL="$HISTCONTROL${HISTCONTROL+,}ignoredups"
HISTCONTROL='ignoreboth'
# Environment
export LC_ALL='en_US.UTF-8'
export EDITOR='editor'
export WINEARCH='win32'
# GPG
GPG_TTY=$(tty)
export GPG_TTY
#export TERM='xterm-256color'
export COLORTERM='xterm-256color'
# Specific to this setup
alias dotfiles_pull='git -C ~/git/dotfiles pull'
alias dotfiles_push='git -C ~/git/dotfiles commit -a; git -C ~/git/dotfiles push'

View File

@ -0,0 +1,3 @@
# SSH
SSH_AUTH_SOCK="/tmp/${USER}-ssh-auth.sock"
export SSH_AUTH_SOCK

View File

@ -0,0 +1,75 @@
#!/bin/bash
set_prompt() {
last_exitcode="$?"
declare checkmark fancy_x timestamp git_prompt_msg git_status_short git_status_colour git_unstaged git_untracked
PS1="${c_reset}"
# Set a fancy symbol to indicate the last exitcode
if (( last_exitcode )); then
last_exitcode_indicator="${c_red}!${c_reset}"
else
last_exitcode_indicator="${c_green}.${c_reset}"
fi
# Set the username colour
if (( UID )); then
user_colour="${c_green}"
user_indicator='$'
else
user_colour="${c_red}"
user_indicator='#'
fi
user_indicator='>'
# Set the git prompt message
git rev-parse --git-dir &>/dev/null && {
git_current_branch="$(git rev-parse --abbrev-ref HEAD)"
while read; do
case "$REPLY" in
(' M'*|A*|D*) git_unstaged=1;;
(\?\?*) git_untracked=1;;
esac
done < <( git status --short )
(( git_unstaged )) && {
git_status_short+='c'
git_status_colour="${c_red}"
}
(( git_untracked )) && {
git_status_short+='f'
git_status_colour="${c_red}"
}
git_status_short=${git_status_short:-ok}
git_status_colour=${git_status_colour:-"${c_green}"}
git_prompt_msg="(${c_cyan}$git_current_branch${c_reset}[${git_status_colour}${git_status_short}${c_reset}]) "
}
set_title "${USER}@${HOSTNAME}"
if [[ "$PWD" == "$HOME" ]]; then
prompt_pwd='~'
elif [[ "$PWD" =~ ^"$HOME" ]]; then
prompt_pwd="~/${PWD##*${HOME}/}"
else
prompt_pwd="$PWD"
fi
prompt=(
"${c_reset}"
"[${last_exitcode_indicator}]"
"${user_colour}${USER}${c_reset}@${c_lightblue}${HOSTNAME}"
"$prompt_pwd"
"${git_prompt_msg}${user_colour}${user_indicator}"
"$c_reset"
)
PS1="${prompt[@]}"
}

View File

@ -0,0 +1,9 @@
#!/usr/bin/bash
while read -r _ _ did wid _; do
for d in "$@"; do
if [[ $d == "$did" ]]; then
bspc node "$wid" -t floating
fi
done
done < <( bspc subscribe node_manage )

View File

@ -0,0 +1,45 @@
#!/usr/bin/bash
usage() {
printf 'No help available'
}
main() {
while (( $# )); do
case "$1" in
(-h) usage;;
(-d) desktop=$2; shift;;
(--) shift; break;;
(*) break;;
esac
shift
done
setting=$1
shift
desktop=${desktop:-"focused"}
case "$setting" in
(padding)
if [[ "$1" =~ ^(north|west|south|east)$ ]]; then
direction=$1
fi
if [[ "$direction" ]]; then
bspc config -d "$desktop" "${direction}_padding" "$1"
else
for d in top bottom right left; do
bspc config -d "$desktop" "${d}_padding" "$1"
done
fi
;;
(gaps)
bspc config -d "$desktop" window_gap "$1"
;;
esac
}
main "$@"

View File

@ -0,0 +1,43 @@
#!/usr/bin/bash
ensure_dir() {
declare d
for d in "$@"; do
if ! [[ -d "$d" ]]; then
if ! mkdir -p "$d"; then
return $?
fi
fi
done
return 0
}
# Set XDG_RUNTIME_DIR
if ! [[ "$XDG_RUNTIME_DIR" ]]; then
XDG_RUNTIME_DIR="/run/user/$UID"
fi
# Define some workdirs
bspwm_rundir="$XDG_RUNTIME_DIR/bspwm"
bspwm_statedir="$bspwm_rundir/state"
# Ensure the workdirs exist
ensure_dir "$bspwm_rundir" "$bspwm_statedir" || exit $?
case "$1" in
(save)
# Save state
bspc query -T > "$bspwm_statedir/tree"
bspc query -H > "$bspwm_statedir/hist"
bspc query -S > "$bspwm_statedir/stack"
;;
(restore)
# Restore state, if any
[[ -f "$bspwm_statedir/tree" ]] && bspc restore -T "$bspwm_statedir/tree"
[[ -f "$bspwm_statedir/hist" ]] && bspc restore -H "$bspwm_statedir/hist"
[[ -f "$bspwm_statedir/stack" ]] && bspc restore -S "$bspwm_statedir/stack"
;;
esac

67
homedir/.config/bspwm/bspwmrc Executable file
View File

@ -0,0 +1,67 @@
#!/usr/bin/env bash
nullexec() {
"$@" &>/dev/null
}
PATH+=":$HOME/.config/alternatives"
PATH+=":$HOME/.config/bspwm/bin"
# Cursor for the root window
xsetroot -cursor_name left_ptr
# Global config
bspc config focused_sticky_border_color "#030061"
bspc config focused_border_color "#467EC2"
bspc config normal_border_color "#1f1f1f"
bspc config urgent_border_color "#f9f9f9"
bspc config window_gap "9"
bspc config border_width '2'
bspc config split_ratio '0.52'
bspc config borderless_monocle 'false'
bspc config gapless_monocle 'false'
bspc config focus_by_distance 'true'
bspc config ignore_ewmh_focus 'true'
bspc config initial_polarity 'second_child'
bspc config auto_cancel 'true'
bspc config click_to_focus 'true'
# Workspaces and monitors
bspc monitor -d 1 2 3 4 5 6 7 8 9 h
# Float some bastards
bspfloat 1 &
# Individual padding
for d in 1 3; do
bspset -d "$d" padding 48
done
# Clear the rules before adding any
while read -r rule _; do bspc rule -r "$rule"; done < <(bspc rule -l)
# Now add the rules
bspc rule -a Steam state=floating desktop=^8
bspc rule -a Firefox:Navigator state=tiled desktop=^2
bspc rule -a \*:Hearthstone.exe desktop=^5
bspc rule -a \* state=floating
# start some services
services=( sxhkd dunst )
for s in "${services[@]}"; do
if ! service "$s" status; then
service "$s" start
fi
done
# Always restart the panel
service moltenbar restart
nullexec browser &
nullexec terminal &
nullexec telegram &
nullexec dropbox &
terminal -e 'ssh-add-all' &
terminal -e 'sudo wrkvpn' &

View File

@ -0,0 +1,72 @@
#
# bspwm hotkeys
#
super + {_,shift + } w
bspc node {-c,-k}
super + q
bspc node -t '~fullscreen'
super + {j,k}
bspc node -f {next,prev}.local
control + {h,j,k,l}
bspc node {@east -r -32,@south -r +32,@south -r -32,@east -r +32}
super + {_,shift + } space
bspc node -t '~'{tiled,floating}
super + Return
bspc node -s biggest
super + {1-9,h}
bspc desktop -f {1-9,h}
super + shift + {1-9,h}
bspc node -d {1-9,h}
super + m
bspc monitor -f next
super + shift + m
bspc node -m next
super + t
bspc desktop -l next
super + shift + t
bspc node -t '~pseudo_tiled'
super + x
terminal
super + {r,u,p}
dmenu-extras -l 9 {run,bmark,pass}
super + z
ssm lockd lock
Print
snap -f
super + {Left,Up,Right,Down}
bspc node --presel-dir '~'{west,north,east,south}
super + {_,shift + } c
win-hd-center {1280x720,854x480}
super + {a,s,n,p}
mpc {play,stop,next,prev}
super + bracketright
bspc node '@/' -R 90
super + f
bspc rule -a \* -o state=floating
super + XF86AudioLowerVolume
amixer -c 0 set PCM 2dB-
super + XF86AudioRaiseVolume
amixer -c 0 set PCM 2dB+

View File

@ -0,0 +1,8 @@
# vim: ft=sh
colour_fg='#f9f9f9'
colour_fg_active=$colour_fg
colour_bg='#1f1f1f'
colour_bg_active='#467EC2'
colour_urgent='#f9f9f9'

View File

@ -0,0 +1 @@
common_x_fontspec='-*-terminesspowerline-medium-*-normal-*-14-*-*-*-*-*-iso10646-*'

View File

@ -0,0 +1,246 @@
[global]
font = xos4 Terminus 12
# Allow a small subset of html markup:
# <b>bold</b>
# <i>italic</i>
# <s>strikethrough</s>
# <u>underline</u>
#
# For a complete reference see
# <http://developer.gnome.org/pango/stable/PangoMarkupFormat.html>.
# If markup is not allowed, those tags will be stripped out of the
# message.
allow_markup = yes
# The format of the message. Possible variables are:
# %a appname
# %s summary
# %b body
# %i iconname (including its path)
# %I iconname (without its path)
# %p progress value if set ([ 0%] to [100%]) or nothing
# Markup is allowed
format = "<b>%s</b>\n%b"
# Sort messages by urgency.
sort = yes
# Show how many messages are currently hidden (because of geometry).
indicate_hidden = yes
# Alignment of message text.
# Possible values are "left", "center" and "right".
alignment = left
# The frequency with wich text that is longer than the notification
# window allows bounces back and forth.
# This option conflicts with "word_wrap".
# Set to 0 to disable.
bounce_freq = 0
# Show age of message if message is older than show_age_threshold
# seconds.
# Set to -1 to disable.
show_age_threshold = 60
# Split notifications into multiple lines if they don't fit into
# geometry.
word_wrap = yes
# Ignore newlines '\n' in notifications.
ignore_newline = no
# The geometry of the window:
# [{width}]x{height}[+/-{x}+/-{y}]
# The geometry of the message window.
# The height is measured in number of notifications everything else
# in pixels. If the width is omitted but the height is given
# ("-geometry x2"), the message window expands over the whole screen
# (dmenu-like). If width is 0, the window expands to the longest
# message displayed. A positive x is measured from the left, a
# negative from the right side of the screen. Y is measured from
# the top and down respectevly.
# The width can be negative. In this case the actual width is the
# screen width minus the width defined in within the geometry option.
geometry = "500x32-710+32"
# Shrink window if it's smaller than the width. Will be ignored if
# width is 0.
shrink = no
# The transparency of the window. Range: [0; 100].
# This option will only work if a compositing windowmanager is
# present (e.g. xcompmgr, compiz, etc.).
transparency = 25
# Don't remove messages, if the user is idle (no mouse or keyboard input)
# for longer than idle_threshold seconds.
# Set to 0 to disable.
idle_threshold = 120
# Which monitor should the notifications be displayed on.
monitor = 0
# Display notification on focused monitor. Possible modes are:
# mouse: follow mouse pointer
# keyboard: follow window with keyboard focus
# none: don't follow anything
#
# "keyboard" needs a windowmanager that exports the
# _NET_ACTIVE_WINDOW property.
# This should be the case for almost all modern windowmanagers.
#
# If this option is set to mouse or keyboard, the monitor option
# will be ignored.
follow = mouse
# Should a notification popped up from history be sticky or timeout
# as if it would normally do.
sticky_history = yes
# Maximum amount of notifications kept in history
history_length = 20
# Display indicators for URLs (U) and actions (A).
show_indicators = yes
# The height of a single line. If the height is smaller than the
# font height, it will get raised to the font height.
# This adds empty space above and under the text.
line_height = 0
# Draw a line of "separatpr_height" pixel height between two
# notifications.
# Set to 0 to disable.
separator_height = 2
# Padding between text and separator.
padding = 8
# Horizontal padding.
horizontal_padding = 8
# Define a color for the separator.
# possible values are:
# * auto: dunst tries to find a color fitting to the background;
# * foreground: use the same color as the foreground;
# * frame: use the same color as the frame;
# * anything else will be interpreted as a X color.
separator_color = frame
# Print a notification on startup.
# This is mainly for error detection, since dbus (re-)starts dunst
# automatically after a crash.
startup_notification = true
# dmenu path.
dmenu = /usr/bin/dmenu -p dunst:
#dmenu = /usr/bin/rofi -dmenu
# Browser for opening urls in context menu.
browser = /usr/bin/firefox -new-tab
# Align icons left/right/off
icon_position = off
# Paths to default icons.
icon_folders = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/
[frame]
width = 2
color = "#467EC2"
[shortcuts]
# Shortcuts are specified as [modifier+][modifier+]...key
# Available modifiers are "ctrl", "mod1" (the alt-key), "mod2",
# "mod3" and "mod4" (windows-key).
# Xev might be helpful to find names for keys.
# Close notification.
close = ctrl+space
# Close all notifications.
close_all = ctrl+shift+space
# Redisplay last message(s).
# On the US keyboard layout "grave" is normally above TAB and left
# of "1".
history = mod4+d
# Context menu.
context = mod4+shift+d
[urgency_low]
# IMPORTANT: colors have to be defined in quotation marks.
# Otherwise the "#" and following would be interpreted as a comment.
background = "#1f1f1f"
foreground = "#f9f9f9"
timeout = 10
[urgency_normal]
background = "#1f1f1f"
foreground = "#f9f9f9"
timeout = 10
[urgency_critical]
background = "#78090C"
foreground = "#f9f9f9"
timeout = 0
# Every section that isn't one of the above is interpreted as a rules to
# override settings for certain messages.
# Messages can be matched by "appname", "summary", "body", "icon", "category",
# "msg_urgency" and you can override the "timeout", "urgency", "foreground",
# "background", "new_icon" and "format".
# Shell-like globbing will get expanded.
#
# SCRIPTING
# You can specify a script that gets run when the rule matches by
# setting the "script" option.
# The script will be called as follows:
# script appname summary body icon urgency
# where urgency can be "LOW", "NORMAL" or "CRITICAL".
#
# NOTE: if you don't want a notification to be displayed, set the format
# to "".
# NOTE: It might be helpful to run dunst -print in a terminal in order
# to find fitting options for rules.
#[espeak]
# summary = "*"
# script = dunst_espeak.sh
#[script-test]
# summary = "*script*"
# script = dunst_test.sh
#[ignore]
# # This notification will not be displayed
# summary = "foobar"
# format = ""
#[signed_on]
# appname = Pidgin
# summary = "*signed on*"
# urgency = low
#
#[signed_off]
# appname = Pidgin
# summary = *signed off*
# urgency = low
#
#[says]
# appname = Pidgin
# summary = *says*
# urgency = critical
#
#[twitter]
# appname = Pidgin
# summary = *twitter.com*
# urgency = normal
#
# vim: ft=cfg

View File

@ -0,0 +1,12 @@
#!/usr/bin/zsh
frozenbar_cfgdir="$XDG_CONFIG_HOME/frozenbar"
declare e cmd position=1
declare -a cmds
while IFS=':' read -r name _ cmd args; do
cmds+=( "$cmd" ${(s: :)args} )
done < "$frozenbar_cfgdir/rc.d/simple_launcher.rc"
$cmds[$1]

View File

@ -0,0 +1 @@
/home/fbt/git/frozenbar/mod

View File

@ -0,0 +1,139 @@
# vim: ft=zsh
# Which modules to load
mods=(
bspwm_desktop_pager
bspwm_taskbar
network_status
date
load
)
# Define the *look* of your panel here
function panel_draw {
panel_data=(
"$out[bspwm_desktop_pager]"
"$out[bspwm_taskbar]"
"%{r}"
"%{F$panel_bg_focused}%{F-}%{B$panel_bg_focused}"
""
"LA: $out[load]"
""
"Network: $out[network_status]"
" "
"$out[date]"
""
"%{B-}"
)
printf '%s\n' "$panel_data"
}
function panel_pre_start {
# Set bspwm top padding
bspc config top_padding "$(( panel_h + bspwm_window_gap ))"
}
function panel_post_start {
# Set the layer on which lemonbar resides
xdo above -t $( xdo id -n root ) $( xdo id -a $panel_window_name )
}
function panel_cleanup_misc {
# Reset bspwm top padding
bspc config top_padding 0
}
# General config
# ==============
# fifo location
#panel_fifo="$XDG_RUNTIME_DIR/frozenbar.fifo"
# Window name
panel_window_name='frozenbar'
## Colours
# I source a common config so that all my scripts share the same colours
source ~/.config/common/colours
panel_fg_normal=$colour_fg
panel_fg_focused=$colour_fg_active
panel_bg_normal=$colour_bg
panel_bg_focused=$colour_bg_active
## Fonts
panel_fontspec='-*-terminesspowerline-medium-*-normal-*-14-*-*-*-*-*-iso10646-*'
## Get root window data to automatically set up the panel's dimensions and position
get_rootwin_data
## We use bspwm, and we need to know its settings
source ~/.config/common/bspwm
## Set the panel dimensions and position
panel_h='14'
panel_w=$(( root_win_w - ( bspwm_window_gap * 2 ) ))
panel_geometry="${panel_w}x${panel_h}+${bspwm_window_gap}+${bspwm_window_gap}"
## How many clickable areas are available to use:
panel_clickable_areas='128'
# Module configs
# ==============
# bspwm_desktop_pager
# -------------------
declare -A bspwm_desktop_pager
bspwm_desktop_pager[colour_focused]=$panel_bg_focused
bspwm_desktop_pager[show_empty_tags]=0
declare -a bspwm_desktop_pager_blacklist
bspwm_desktop_pager_blacklist=( 'h' )
# bspwm_taskbar
# -------------
declare -A bspwm_taskbar
declare -a bspwm_taskbar_blacklist
bspwm_taskbar[focused_only]=0
bspwm_taskbar[counter]=1
bspwm_taskbar[fg_normal]='#bebebe'
bspwm_taskbar[fg_focused]=$panel_fg_normal
bspwm_taskbar[start]="%{F$panel_bg_normal}%{B$panel_bg_focused}%{F-} "
bspwm_taskbar[end]="%{F$panel_bg_focused} %{B-}%{F-}"
bspwm_taskbar[max_size]=132
bspwm_taskbar_blacklist=( 'h' )
# bspwm_date
# ----------
declare -A date
date[format]='%A, %Y.%m.%d %H:%M:%S'
# simple_launcher
# ---------------
declare -A simple_launcher
simple_launcher[start]="%{F$panel_bg_normal}%{B$panel_bg_focused}%{F-}"
simple_launcher[end]="%{F$panel_bg_focused} %{B-}%{F-}"
# network_status
# --------------
mod_network_status_check_rate=10
mod_network_status_ok='%{F#00FF00}ok%{F-}'
mod_network_status_warn='%{F#FFFF00}WARN%{F-}'
mod_network_status_fail='%{F#FF0000}FAIL%{F-}'
network_status_hosts=(
de-ber-as20647.anchors.atlas.ripe.net
nl-ams-as1101.anchors.atlas.ripe.net
uk-boh-as196745.anchors.atlas.ripe.net
)
out[network_status]='%{F#FFFF00}checking...%{F-}'
# mod_load
# --------
mod_load_crit=4
mod_load_warn=3
mod_load_warn_colour='#FFFF00'
mod_load_crit_colour='#FF0000'
mod_load_ok_colour='#00FF00'

View File

@ -0,0 +1,2 @@
browser::browser
terminal::terminal

View File

@ -0,0 +1 @@
/home/fbt/git/moltenbar/mod

View File

@ -0,0 +1,58 @@
# vim: ft=yaml sw=2 et
#geometry: '1262x14+9+9'
height: 14
gap: 9
fontspec: '-*-terminesspowerline-medium-*-normal-*-14-*-*-*-*-*-iso10646-*'
window_name: 'moltenbar'
active_areas: '128'
modules:
- bspwm_pager
- date
- bspwm_taskbar
- load_average
- network
- newmail
format: "<%= @panel_data['bspwm_pager'] %><%= @panel_data['bspwm_taskbar'] %>%{r}%{F<%= @config['colours']['bg_focused'] %>} %{F-}%{B<%= @config['colours']['bg_focused'] %>} New mail: <%= @panel_data['newmail'] %> LA: <%= @panel_data['load_average'] %> Network: <%= @panel_data['network'] %> <%= @panel_data['date'] %> %{B-}"
colours:
fg: '#f9f9f9'
fg_focused: '#f9f9f9'
bg: '#001f1f1f'
bg_focused: '#467EC2'
# Module settings
mod:
bspwm_pager:
colour_focused: '#f9f9f9'
show_empty_desktops: false
# monitors:
# - "WMHDMI1"
blacklist:
-h
bspwm_taskbar:
begin: "%{F<%= @config['colours']['bg'] %>}%{B<%= @config['colours']['bg_focused'] %>}%{F-} "
end: "%{F<%= @config['colours']['bg_focused'] %>} %{B-} "
date:
format: '%A, %Y.%m.%d %H:%M:%S'
load_average:
warn_value: 3
crit_value: 4
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
network:
hosts:
- de-ber-as20647.anchors.atlas.ripe.net
- nl-ams-as1101.anchors.atlas.ripe.net
- uk-boh-as196745.anchors.atlas.ripe.net
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
newmail:
ok_message: "*"
ok_colour: "#00FF00"
crit_message: "***"
crit_colour: "#FF0000"
maildirs:
- /home/fbt/sync/maildir/.ops
- /home/fbt/sync/maildir/.inbox

View File

@ -0,0 +1 @@
../bspwm/sxhkdrc

View File

@ -0,0 +1,29 @@
super + x
terminal
super + j
zwm-focus
super + w
killw $(pfw)
super + Return
zwm-tile
super + r
dmenu_run -fn '-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*' -nb '#222222' -nf '#bbbbbb' -sb '#005577'
super + m
zwm-monocle
super + t
zwm-tile
super + l
lock
super + {1-9}
zwm-tags switch {1-9}
super + shift + {1-9}
zwm-tags mv {1-9}

View File

@ -0,0 +1,41 @@
[options]
font = xos4 terminus 10
#allow_bold = false
cursor_blink = off
cursor_shape = ibeam
browser = browser
mouse_autohide = true
audible_bell = true
[hints]
font = terminus 10
roundness = 0.0
[colors]
foreground = #839496
foreground_bold = #eee8d5
foreground_dim = #888888
background = #141414
#background = rgba(18, 21, 26, 0.9)
cursor = #93a1a1
# if unset, will reverse foreground and background
#highlight = #839496
# colors from color0 to color254 can be set
color0 = #073642
color1 = #dc322f
color2 = #859900
color3 = #b58900
color4 = #268bd2
color5 = #d33682
color6 = #2aa198
color7 = #eee8d5
color8 = #002b36
color9 = #cb4b16
color10 = #586e75
color11 = #657b83
color12 = #839496
color13 = #6c71c4
color14 = #93a1a1
color15 = #fdf6e3

View File

@ -0,0 +1,22 @@
# Gotham color scheme
[colors]
foreground = #98d1ce
foreground_bold = #98d1ce
cursor = #98d1ce
background = #0a0f14
color0 = #0a0f14
color8 = #10151b
color1 = #c33027
color9 = #d26939
color2 = #26a98b
color10 = #081f2d
color3 = #edb54b
color11 = #245361
color4 = #195465
color12 = #093748
color5 = #4e5165
color13 = #888ba5
color6 = #33859d
color14 = #599caa
color7 = #98d1ce
color15 = #d3ebe9

View File

@ -0,0 +1,27 @@
[colors]
foreground = #839496
foreground_bold = #eee8d5
foreground_dim = #888888
background = #00141A
cursor = #93a1a1
# if unset, will reverse foreground and background
#highlight = #839496
# colors from color0 to color254 can be set
color0 = #073642
color1 = #dc322f
color2 = #859900
color3 = #b58900
color4 = #268bd2
color5 = #d33682
color6 = #2aa198
color7 = #eee8d5
color8 = #002b36
color9 = #cb4b16
color10 = #586e75
color11 = #657b83
color12 = #839496
color13 = #6c71c4
color14 = #93a1a1
color15 = #fdf6e3

View File

@ -0,0 +1,4 @@
#!/usr/bin/env watchman
service_command='/bin/compton'
service_args=( --vsync opengl -f -D 3 -e 1.0 )

View File

@ -0,0 +1,4 @@
#!/usr/bin/env watchman
#service_respawn='true'
service_command='/usr/bin/dunst'

View File

@ -0,0 +1,4 @@
#!/bin/env watchman
service_command='/usr/bin/jackd'
service_args=( -d alsa )

View File

@ -0,0 +1,5 @@
#!/usr/bin/env watchman
service_respawn='true'
service_command="$HOME/bin/lockd"
service_args=( -- i3lock-extra -s -o ~/pics/lock.png -g -p )

View File

@ -0,0 +1,21 @@
#!/usr/bin/env watchman
#service_respawn='true'
service_command='/home/fbt/bin/moltenbar'
service_depends_ready=( compton )
post_start() {
# Die if the thing didn't start
timer 5 nullexec xdo id -a moltenbar || return 1
# Set the layer on which lemonbar resides
xdo above -t $( xdo id -n root ) $( xdo id -a moltenbar )
# Set the top badding for bspwm
bspc config top_padding $(( 14 + 9 )) &>/tmp/debug.log
}
pre_stop() {
bspc config top_padding 0
}

View File

@ -0,0 +1,4 @@
#!/usr/bin/env watchman
#service_respawn='true'
service_command="$HOME/bin/mpc-notify"

View File

@ -0,0 +1,8 @@
#!/usr/bin/env ssm
service_tmpfiles=( "/run/user/$UID/mpd:dir" )
service_respawn=1
service_command='/usr/bin/mpd'
service_args=( --no-daemon -v )
post_start() { ready; }

View File

@ -0,0 +1,21 @@
#!/usr/bin/env watchman
privoxy_configfile="$HOME/.config/privoxy/config"
service_respawn='true'
service_command='/usr/bin/privoxy'
service_args=( --no-daemon "$privoxy_configfile" )
privoxy::configtest() {
"$service_command" --config-test "${service_args[@]}"
}
restart() {
privoxy::configtest || {
watchman.err "Config test failed, not restarting!"
return 1
}
stop
start
}

View File

@ -0,0 +1,14 @@
#!/bin/env watchman
service_depends=( jackd )
service_command='/usr/bin/pulseaudio'
service_args=(
--realtime=false
--exit-idle-time=-1
-L module-jack-sink
-L module-jack-source
-L module-native-protocol-tcp
)
stop () { "$service_command" -k; }

View File

@ -0,0 +1,5 @@
#!/usr/bin/env watchman
service_respawn='true'
service_command='/usr/bin/crond'
service_args=( -n -f ~/.config/crontab )

View File

@ -0,0 +1,5 @@
#!/usr/bin/watchman
service_respaen=true
service_command='/usr/bin/ssh'
service_args=( -i ~/.ssh/proxy/id_ecdsa -ND 8080 proxy@malganis.priv )

View File

@ -0,0 +1,4 @@
#!/usr/bin/env watchman
service_command='/usr/bin/ssh-agent'
service_args=( -d -a "/tmp/${USER}-ssh-auth.sock" )

View File

@ -0,0 +1,5 @@
#!/usr/bin/env watchman
#service_respawn='true'
service_command='/usr/bin/sxhkd'
service_reload_signal='USR1'

View File

@ -0,0 +1,4 @@
#!/bin/env watchman
#service_respawn='true'
service_command='/usr/bin/syncthing'

View File

@ -0,0 +1,4 @@
#!/bin/env watchman
service_command='/usr/bin/transmission-daemon'
service_args=( -f )

View File

@ -0,0 +1,5 @@
#!/usr/bin/env watchman
#service_respawn='true'
service_command='/usr/bin/ufwd'
service_args=( -n -c -- -p )

View File

@ -0,0 +1,54 @@
# Basic zsh configuration
# vim: ft=zsh
# Custom completion
fpath=( /etc/zsh/completion $fpath )
# Completion
setopt noautomenu nomenucomplete
# Interactive comments
setopt interactive_comments
# Disable autocd
unsetopt autocd
# Command completion
autoload -U compinit
compinit
# Complete dotfiles
_comp_options+=( globdots )
# History
setopt HIST_IGNORE_DUPS
HISTFILE=~/.zsh_history
SAVEHIST=9001
HISTSIZE=9001
HISTCONTROL=erasedups
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S"
# Fix retarded things
NULLCMD=true
READNULLCMD=true
# Locale
export LC_ALL='en_US.UTF-8'
# dotfiles config
dotfiles_dir="$HOME/git/dotfiles"
# PATH
set_misc_path "$HOME/ruby/bin" "$HOME/games/bin" "$HOME/.config/alternatives" "$HOME/.local/bin" "$HOME/bin" "$HOME/.gem/ruby/2.3.0/bin/"
# GPG
GPG_TTY=$(tty)
export GPG_TTY
# EDITOR
EDITOR=vim
export EDITOR
# jspass completion
compdef _pass jspass

View File

@ -0,0 +1,24 @@
# Functions common to other modules
# vim: ft=zsh
# Run the supplied command and null all the output
function nullexec {
"$@" &>/dev/null
}
# Compile all includes
function newconf {
for i in ~/.zshrc ~/.config/zsh.d/*; do
if ! [[ $i =~ .+\.zwc ]]; then
msg "Compiling $i..."
zcompile $i
fi
done
}
# set PATH from misc_path
function set_misc_path {
for p in $@; do
PATH="$p:$PATH"
done
}

View File

@ -0,0 +1,14 @@
# Functions for manipulating my dotfiles repo
# vim: ft=zsh
function dotfiles() {
declare act=$1
case $act in
pull|diff) git -C $dotfiles_dir $1;;
push)
git -C $dotfiles_dir commit -a
git -C $dotfiles_dir push
;;
esac
}

View File

@ -0,0 +1,8 @@
# Helper functions
xcopy() { xclip -selection clipboard }
xpaste() { xclip -selection clipboard -o }
xclip() {
/usr/bin/xclip -selection clipboard "$@"
}

View File

@ -0,0 +1,28 @@
# Keys
# vim: ft=zsh
bindkey -e
declare -A key
key[Home]=$terminfo[khome]
key[End]=$terminfo[kend]
key[Delete]=$terminfo[kdch1]
declare -A bindings
bindings=(
Home 'beginning-of-line'
End 'end-of-line'
Delete 'delete-char'
^R 'history-incremental-search-backward'
)
for b in ${(k)bindings}; do
if [[ $key[$b] ]]; then
bindkey $key[$b] $bindings[$b]
fi
done
function zle-line-init () { echoti smkx; }
function zle-line-finish () { echoti rmkx; }
zle -N zle-line-init
zle -N zle-line-finish

View File

@ -0,0 +1,8 @@
# Local zsh config, not to be synced.
# vim: ft=zsh
# SSH
SSH_AUTH_SOCK="/tmp/${USER}-ssh-auth.sock"
export SSH_AUTH_SOCK
function x { exec xinit -- -nolisten tcp vt9; }

View File

@ -0,0 +1,128 @@
# Prompt
# vim: ft=zsh
autoload -U colors && colors
nullexec() { "$@" &>/dev/null; }
precmd.title() {
printf '%b' "\e]2;$1\a"
}
precmd.svn() {
if [[ -f .novcsprompt ]]; then
return 0
fi
if nullexec svn info; then
while IFS= read -r line; do
case $line in
(M*|A*|D*) svn_unstaged=1;;
(\!*) svn_missing=1;;
(\?*) svn_untracked=1;;
esac
done < <( svn st )
(( svn_unstaged )) && {
svn_st+='c'
svn_st_col='red'
}
(( svn_missing )) && {
svn_st+='m'
svn_st_col='red'
}
(( svn_untracked )) && {
svn_st+='f'
svn_st_col='red'
}
svn_st_col=${svn_st_col:-"green"}
svn_st=${svn_st:-"ok"}
printf '%s' "(%F{cyan}svn%f:%F{$svn_st_col}$svn_st%f) "
fi
}
precmd.git() {
declare git_unstaged git_untracked git_status_short git_status_colour git_prompt_msg
if [[ -f .novcsprompt ]]; then
return 0
fi
if git rev-parse --git-dir &>/dev/null; then
git_current_branch=$(git rev-parse --abbrev-ref HEAD)
while IFS= read -r line; do
case $line in
' M'*|A*|D*) git_unstaged=1;;
\?\?*) git_untracked=1;;
esac
done < <( git status --short )
(( git_unstaged )) && {
git_status_short+='c'
git_status_colour='red'
}
(( git_untracked )) && {
git_status_short+='f'
git_status_colour='red'
}
git_status_short=${git_status_short:-"ok"}
git_status_colour=${git_status_colour:-"green"}
git_prompt_msg="(%F{cyan}$git_current_branch%f[%F{$git_status_colour}${git_status_short}%f]) "
printf '%s' $git_prompt_msg
fi
}
rprompt() {
{ precmd.svn; precmd.git } > "$XDG_RUNTIME_DIR/zsh_rprompt_$$.tmp"
kill -s USR1 $$
}
TRAPUSR1() {
prompt_async_data=$(<"$XDG_RUNTIME_DIR/zsh_rprompt_$$.tmp")
draw_prompt
zle && zle reset-prompt
}
draw_prompt() {
prompt_custom=(
"%F{$cmd_colour}$cmd_msg%f"
"%F{$user_colour}$USER%f@$HOST"
"${PWD//$HOME/~}"
"$prompt_async_data%F{$user_colour}>%f"
)
PROMPT=" $prompt_custom "
}
precmd() {
declare last_exit_code=$?
declare -g cmd_colour cmd_msg
if (( last_exit_code )); then
cmd_colour='red'
cmd_msg='!'
else
cmd_colour='green'
cmd_msg='.'
fi
if (( UID )); then
user_colour='green'
else
user_colour='red'
fi
precmd.title "$USER@$HOST ${PWD//$HOME/~}"
draw_prompt
rprompt &!
}

View File

@ -0,0 +1,7 @@
# Functions meant to be used interactively.
# vim: ft=zsh
# Source the .zshrc again
function reload {
exec zsh -i
}

View File

@ -0,0 +1,6 @@
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
export XDG_DATA_HOME=$HOME/.local/share
export XDG_CACHE_HOME=$HOME/.cache
export XDG_RUNTIME_DIR=/run/user/$UID
export XDG_CONFIG_HOME=$HOME/.config

View File

@ -0,0 +1,59 @@
# vim: ft=zsh
# Modules
function msg {
if ! (( flag_quiet )); then
printf '%s\n' "$*"
fi
}
function err { msg "$*" >&2; }
function modpath {
case $1 in
(=) ZSHRC_MODPATH=( "$@" );;
(*) ZSHRC_MODPATH+=( "$@" );;
esac
export ZSHRC_MODPATH
}
function use {
declare flag_nofail flag_quiet mname m_nofirst
while (( $# )); do
case $1 in
(-n) flag_nofail=1;;
(-q) flag_quiet=1;;
(--) shift; break;;
(*) break;;
esac
shift
done
printf '[zshrc] Loading modules: '
for mname in $@; do
if ! (( m_nofirst )); then
printf '%s' $mname
else
printf ', %s' $mname
fi
for p in $ZSHRC_MODPATH; do
if [[ -f $p/$mname ]]; then
if ! source $p/$mname; then
printf '(fail)'
fi
else
printf '(not found)'
fi
done
m_nofirst=1
done
printf '\n'
}
# Default ZSHRC_MODPATH
modpath "$HOME/.config/zsh.d/modules"

View File

@ -0,0 +1,70 @@
#!/bin/bash
# Resources
resources=( '/etc/X11/xinit/.Xresources' "$HOME/.Xresources" )
modmaps=( '/etc/X11/xinit/.Xmodmap' "$HOME/.Xmodmap" )
# Set DPI
xrandr --dpi 95
for r in "${resources[@]}"; do
if [[ -f "$r" ]]; then
xrdb -merge "$r"
fi
done
for m in modmaps; do
if [[ -f "$m" ]]; then
xmodmap "$m"
fi
done
# Common services
common_services+=( pulseaudio lockd )
for i in "${common_services[@]}"; do
service "$i" start
done
# Fonts
xset +fp /usr/share/fonts/local
# Screensaver settings
xset -dpms
xset s 300
xset s noblank
xset s noexpose
# Solid black root window
# chameleon is available at https://github.com/fbt/misc
chameleon -C '#151515'
# Set a wallpaper if it exists
if [[ -f "$HOME/wallpaper.png" ]]; then
chameleon "$HOME/wallpaper.png"
fi
# Input settings
setxkbmap "min(us),min(ru)" -option "lv3:rwin_switch,grp:caps_toggle,grp_led:caps,compose:ralt,terminate:ctrl_alt_bksp"
xmodmap -e 'remove lock = Caps_Lock' \
-e 'keycode 135 = KP_Insert' \
-e 'keycode 49 = Escape asciitilde'
# Start a dbus session
if ! [[ "$DBUS_SESSION_BUS_ADDRESS" ]]; then
export $(dbus-launch)
fi
# Some nvidia tweaks
export VDPAU_NVIDIA_NO_OVERLAY=1
#export __GL_THREADED_OPTIMIZATIONS=1
nvidia-settings -l
nvidia-settings -a InitialPixmapPlacement=2
# Custom functions
services() {
for i in "${session_services[@]}"; do
service "$i" "$1"
done
}
return 0

View File

@ -0,0 +1,6 @@
# A simple dwm session
PATH+=":$HOME/.config/bspwm/bin"
start_session() {
exec bspwm
}

View File

@ -0,0 +1 @@
bspwm

View File

@ -0,0 +1,13 @@
# A simple dwm session
session.cleanup() { service dwm-status stop; }
trap session.cleanup EXIT
start_session() {
wmname LG3D
service dwm-status start
while true; do
dwm
done
}

View File

@ -0,0 +1,5 @@
# Start nothing, the DM will start it for us
start_session() {
:
}

View File

@ -0,0 +1,16 @@
# A simple dwm session
session.cleanup() {
service zwm-daemon stop
service sxhkd stop
}
trap session.cleanup EXIT
start_session() {
rm -r "/tmp/$USER/zwm"
service zwm-daemon start
service sxhkd start
sleep infinity
}

9
homedir/.gitconfig Normal file
View File

@ -0,0 +1,9 @@
[user]
name = fbt
email = fbt@fleshless.org
[push]
default = simple
[alias]
ci = commit -a
co = checkout
st = status --short

3
homedir/.inputrc Normal file
View File

@ -0,0 +1,3 @@
$include /etc/inputrc
set completion-ignore-case On

71
homedir/.ncmpcpp/config Normal file
View File

@ -0,0 +1,71 @@
### Colours
## - 0 - default window color (discards all other colors)
## - 1 - black
## - 2 - red
## - 3 - green
## - 4 - yellow
## - 5 - blue
## - 6 - magenta
## - 7 - cyan
## - 8 - white
## - 9 - end of current color
###
visualizer_in_stereo = yes
#visualizer_sample_multiplier = 1
#visualizer_sync_interval = 30
## Available values: spectrum, wave.
visualizer_type = spectrum
visualizer_look = ●▊
#song_columns_list_format = (20)[]{a} (50)[]{tr} (6f)[]{NE}
#song_columns_list_format = (7f)[]{NEr} (20)[]{a} (80)[white]{tr} (6f)[]{l}
# Playlist look
playlist_display_mode = "classic"
song_list_format = " {%a}|{%A} - %t "
now_playing_prefix = "$8"
now_playing_suffix = "$9"
selected_item_prefix = "$4"
selected_item_suffix = "$9"
#playlist_separate_albums = no
#progressbar_look = "▃▃ "
progressbar_look = "▄▄ "
progressbar_boldness = yes
header_visibility = no
statusbar_visibility = no
titles_visibility = no
## Screens available for use: help, playlist, browser, search_engine,
## media_library, playlist_editor, tag_editor, outputs, visualizer, clock.
startup_screen = playlist
mouse_support = no
external_editor = vim
use_console_editor = yes
##### colors definitions #####
colors_enabled = yes
empty_tag_color = cyan
header_window_color = default
volume_color = default
state_line_color = default
state_flags_color = default
main_window_color = default
color1 = white
color2 = green
main_window_highlight_color = white
progressbar_color = black
progressbar_elapsed_color = default
statusbar_color = default
alternative_ui_separator_color = black
active_column_color = red
visualizer_color = blue
window_border_color = green
active_window_border = red

View File

@ -0,0 +1,422 @@
"=============================================================================
" Copyright (c) 2007-2009 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
" }}}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: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 l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
\ '&spell', 0)
call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
\ '&completeopt', 'menuone' . (g:acp_completeoptPreview ? ',preview' : ''))
call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
\ '&complete', g:acp_completeOption)
call l9#tempvariables#set(s:TEMP_VARIABLES_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 l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
\ '&lazyredraw', !g:acp_mappingDriven)
" NOTE: 'textwidth' must be restored after <C-e>.
call l9#tempvariables#set(s:TEMP_VARIABLES_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 l9#tempvariables#end(s:TEMP_VARIABLES_GROUP0)
if a:fGroup1
call l9#tempvariables#end(s:TEMP_VARIABLES_GROUP1)
endif
endfunction
"
function s:setCompletefunc()
if exists('s:behavsCurrent[s:iBehavs].completefunc')
call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP0,
\ '&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:TEMP_VARIABLES_GROUP0 = "AutoComplPop0"
let s:TEMP_VARIABLES_GROUP1 = "AutoComplPop1"
let s:lockCount = 0
let s:behavsCurrent = []
let s:iBehavs = 0
let s:snipItems = {}
" }}}1
"=============================================================================
" vim: set fdm=marker:

View File

@ -0,0 +1,244 @@
" 'apprentice.vim' -- Vim color scheme.
" Maintainer: Romain Lafourcade (romainlafourcade@gmail.com)
" Essentially a streamlining and conversion to xterm colors of
" 'sorcerer' by Jeet Sukumaran (jeetsukumaran@gmailcom)
" MADE-UP NAME HEX RGB XTERM ANSI
" ========================================================================
" almost black #1c1c1c rgb(28, 28, 28) 234 0
" darker grey #262626 rgb(38, 38, 38) 235 background color
" dark grey #303030 rgb(48, 48, 48) 236 8
" grey #444444 rgb(68, 68, 68) 238 8
" medium grey #585858 rgb(88, 88, 88) 240 8
" light grey #6c6c6c rgb(108, 108, 108) 242 7
" lighter grey #bcbcbc rgb(188, 188, 188) 250 foreground color
" white #ffffff rgb(255, 255, 255) 231 15
" purple #5f5f87 rgb(95, 95, 135) 60 5
" light purple #8787af rgb(135, 135, 175) 103 13
" green #5f875f rgb(95, 135, 95) 65 2
" light green #87af87 rgb(135, 175, 135) 108 10
" aqua #5f8787 rgb(95, 135, 135) 66 6
" light aqua #5fafaf rgb(95, 175, 175) 73 14
" blue #5f87af rgb(95, 135, 175) 67 4
" light blue #8fafd7 rgb(143, 175, 215) 110 12
" red #af5f5f rgb(175, 95, 95) 131 1
" orange #ff8700 rgb(255, 135, 0) 208 9
" ocre #87875f rgb(135, 135, 95) 101 3
" yellow #ffffaf rgb(255, 255, 175) 229 11
hi clear
if exists('syntax_on')
syntax reset
endif
set background=dark
let colors_name = 'apprentice'
if &t_Co >= 256 || has('gui_running')
hi Normal ctermbg=235 ctermfg=250 guibg=#262626 guifg=#bcbcbc cterm=NONE gui=NONE
set background=dark
hi Comment ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE
hi Constant ctermbg=NONE ctermfg=208 guibg=NONE guifg=#ff8700 cterm=NONE gui=NONE
hi Error ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=reverse gui=reverse
hi Identifier ctermbg=NONE ctermfg=67 guibg=NONE guifg=#5f87af cterm=NONE gui=NONE
hi Ignore ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE
hi PreProc ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=NONE gui=NONE
hi Special ctermbg=NONE ctermfg=65 guibg=NONE guifg=#5f875f cterm=NONE gui=NONE
hi Statement ctermbg=NONE ctermfg=110 guibg=NONE guifg=#8fafd7 cterm=NONE gui=NONE
hi String ctermbg=NONE ctermfg=108 guibg=NONE guifg=#87af87 cterm=NONE gui=NONE
hi Todo ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=reverse gui=reverse
hi Type ctermbg=NONE ctermfg=103 guibg=NONE guifg=#8787af cterm=NONE gui=NONE
hi Underlined ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=underline gui=underline
hi LineNr ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE
hi NonText ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE
hi Pmenu ctermbg=238 ctermfg=250 guibg=#444444 guifg=#bcbcbc cterm=NONE gui=NONE
hi PmenuSbar ctermbg=240 ctermfg=NONE guibg=#585858 guifg=NONE cterm=NONE gui=NONE
hi PmenuSel ctermbg=66 ctermfg=235 guibg=#5f8787 guifg=#262626 cterm=NONE gui=NONE
hi PmenuThumb ctermbg=66 ctermfg=66 guibg=#5f8787 guifg=#5f8787 cterm=NONE gui=NONE
hi ErrorMsg ctermbg=131 ctermfg=235 guibg=#af5f5f guifg=#262626 cterm=NONE gui=NONE
hi ModeMsg ctermbg=108 ctermfg=235 guibg=#87af87 guifg=#262626 cterm=NONE gui=NONE
hi MoreMsg ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=NONE gui=NONE
hi Question ctermbg=NONE ctermfg=108 guibg=NONE guifg=#87af87 cterm=NONE gui=NONE
hi WarningMsg ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=NONE gui=NONE
hi TabLine ctermbg=238 ctermfg=101 guibg=#444444 guifg=#87875f cterm=NONE gui=NONE
hi TabLineFill ctermbg=238 ctermfg=238 guibg=#444444 guifg=#444444 cterm=NONE gui=NONE
hi TabLineSel ctermbg=101 ctermfg=235 guibg=#87875f guifg=#262626 cterm=NONE gui=NONE
hi Cursor ctermbg=242 ctermfg=NONE guibg=#6c6c6c guifg=NONE cterm=NONE gui=NONE
hi CursorColumn ctermbg=236 ctermfg=NONE guibg=#303030 guifg=NONE cterm=NONE gui=NONE
hi CursorLine ctermbg=236 ctermfg=NONE guibg=#303030 guifg=NONE cterm=NONE gui=NONE
hi CursorLineNr ctermbg=236 ctermfg=73 guibg=#303030 guifg=#5fafaf cterm=NONE gui=NONE
hi helpLeadBlank ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE
hi helpNormal ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE
hi StatusLine ctermbg=101 ctermfg=235 guibg=#87875f guifg=#262626 cterm=NONE gui=NONE
hi StatusLineNC ctermbg=238 ctermfg=101 guibg=#444444 guifg=#87875f cterm=NONE gui=italic
hi Visual ctermbg=110 ctermfg=235 guibg=#8fafd7 guifg=#262626 cterm=NONE gui=NONE
hi VisualNOS ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=underline gui=underline
hi FoldColumn ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE
hi Folded ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE
hi VertSplit ctermbg=238 ctermfg=238 guibg=#444444 guifg=#444444 cterm=NONE gui=NONE
hi WildMenu ctermbg=110 ctermfg=235 guibg=#8fafd7 guifg=#262626 cterm=NONE gui=NONE
hi Function ctermbg=NONE ctermfg=229 guibg=NONE guifg=#ffffaf cterm=NONE gui=NONE
hi SpecialKey ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE
hi Title ctermbg=NONE ctermfg=231 guibg=NONE guifg=#ffffff cterm=NONE gui=NONE
hi DiffAdd ctermbg=108 ctermfg=235 guibg=#87af87 guifg=#262626 cterm=NONE gui=NONE
hi DiffChange ctermbg=60 ctermfg=235 guibg=#5f5f87 guifg=#262626 cterm=NONE gui=NONE
hi DiffDelete ctermbg=131 ctermfg=235 guibg=#af5f5f guifg=#262626 cterm=NONE gui=NONE
hi DiffText ctermbg=103 ctermfg=235 guibg=#8787af guifg=#262626 cterm=NONE gui=NONE
hi IncSearch ctermbg=131 ctermfg=235 guibg=#af5f5f guifg=#262626 cterm=NONE gui=NONE
hi Search ctermbg=229 ctermfg=235 guibg=#ffffaf guifg=#262626 cterm=NONE gui=NONE
hi Directory ctermbg=NONE ctermfg=73 guibg=NONE guifg=#5fafaf cterm=NONE gui=NONE
hi MatchParen ctermbg=234 ctermfg=229 guibg=#1c1c1c guifg=#ffffaf cterm=NONE gui=NONE
hi SpellBad ctermbg=NONE ctermfg=131 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#af5f5f
hi SpellCap ctermbg=NONE ctermfg=73 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#5fafaf
hi SpellLocal ctermbg=NONE ctermfg=65 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#5f875f
hi SpellRare ctermbg=NONE ctermfg=208 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#ff8700
hi ColorColumn ctermbg=131 ctermfg=NONE guibg=#af5f5f guifg=NONE cterm=NONE gui=NONE
hi signColumn ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE
elseif &t_Co == 8 || $TERM !~# '^linux' || &t_Co == 16
set t_Co=16
hi Normal ctermbg=NONE ctermfg=15 cterm=NONE
set background=dark
hi Comment ctermbg=NONE ctermfg=8 cterm=NONE
hi Constant ctermbg=NONE ctermfg=9 cterm=NONE
hi Function ctermbg=NONE ctermfg=11 cterm=NONE
hi Identifier ctermbg=NONE ctermfg=4 cterm=NONE
hi PreProc ctermbg=NONE ctermfg=6 cterm=NONE
hi Special ctermbg=NONE ctermfg=2 cterm=NONE
hi Statement ctermbg=NONE ctermfg=12 cterm=NONE
hi String ctermbg=NONE ctermfg=10 cterm=NONE
hi Todo ctermbg=NONE ctermfg=NONE cterm=reverse
hi Type ctermbg=NONE ctermfg=13 cterm=NONE
hi Error ctermbg=NONE ctermfg=1 cterm=reverse
hi Ignore ctermbg=NONE ctermfg=NONE cterm=NONE
hi Underlined ctermbg=NONE ctermfg=6 cterm=underline
hi LineNr ctermbg=0 ctermfg=7 cterm=NONE
hi NonText ctermbg=NONE ctermfg=8 cterm=NONE
hi Pmenu ctermbg=8 ctermfg=15 cterm=NONE
hi PmenuSbar ctermbg=7 ctermfg=NONE cterm=NONE
hi PmenuSel ctermbg=6 ctermfg=0 cterm=NONE
hi PmenuThumb ctermbg=6 ctermfg=NONE cterm=NONE
hi ErrorMsg ctermbg=1 ctermfg=0 cterm=NONE
hi ModeMsg ctermbg=2 ctermfg=0 cterm=NONE
hi MoreMsg ctermbg=NONE ctermfg=6 cterm=NONE
hi Question ctermbg=NONE ctermfg=10 cterm=NONE
hi WarningMsg ctermbg=NONE ctermfg=1 cterm=NONE
hi TabLine ctermbg=8 ctermfg=3 cterm=NONE
hi TabLineFill ctermbg=8 ctermfg=0 cterm=NONE
hi TabLineSel ctermbg=3 ctermfg=0 cterm=NONE
hi Cursor ctermbg=NONE ctermfg=NONE cterm=NONE
hi CursorColumn ctermbg=8 ctermfg=NONE cterm=NONE
hi CursorLine ctermbg=NONE ctermfg=NONE cterm=underline
hi CursorLineNr ctermbg=0 ctermfg=14 cterm=NONE
hi helpLeadBlank ctermbg=NONE ctermfg=NONE cterm=NONE
hi helpNormal ctermbg=NONE ctermfg=NONE cterm=NONE
hi StatusLine ctermbg=3 ctermfg=0 cterm=NONE
hi StatusLineNC ctermbg=8 ctermfg=0 cterm=NONE
hi Visual ctermbg=12 ctermfg=0 cterm=NONE
hi VisualNOS ctermbg=NONE ctermfg=NONE cterm=underline
hi FoldColumn ctermbg=0 ctermfg=8 cterm=NONE
hi Folded ctermbg=0 ctermfg=8 cterm=NONE
hi VertSplit ctermbg=8 ctermfg=8 cterm=NONE
hi WildMenu ctermbg=12 ctermfg=0 cterm=NONE
hi SpecialKey ctermbg=NONE ctermfg=8 cterm=NONE
hi Title ctermbg=NONE ctermfg=15 cterm=NONE
hi DiffAdd ctermbg=2 ctermfg=0 cterm=NONE
hi DiffChange ctermbg=6 ctermfg=0 cterm=NONE
hi DiffDelete ctermbg=1 ctermfg=0 cterm=NONE
hi DiffText ctermbg=11 ctermfg=0 cterm=NONE
hi IncSearch ctermbg=1 ctermfg=0 cterm=NONE
hi Search ctermbg=11 ctermfg=0 cterm=NONE
hi Directory ctermbg=NONE ctermfg=14 cterm=NONE
hi MatchParen ctermbg=0 ctermfg=11 cterm=NONE
hi SpellBad ctermbg=NONE ctermfg=1 cterm=undercurl
hi SpellCap ctermbg=NONE ctermfg=3 cterm=undercurl
hi SpellLocal ctermbg=NONE ctermfg=2 cterm=undercurl
hi SpellRare ctermbg=NONE ctermfg=5 cterm=undercurl
hi ColorColumn ctermbg=1 ctermfg=NONE cterm=NONE
hi SignColumn ctermbg=0 ctermfg=8 cterm=NONE
endif
hi link Boolean Constant
hi link Character Constant
hi link Conceal Normal
hi link Conditional Statement
hi link Debug Special
hi link Define PreProc
hi link Delimiter Special
hi link Exception Statement
hi link Float Number
hi link HelpCommand Statement
hi link HelpExample Statement
hi link Include PreProc
hi link Keyword Statement
hi link Label Statement
hi link Macro PreProc
hi link Number Constant
hi link Operator Statement
hi link PreCondit PreProc
hi link Repeat Statement
hi link SpecialChar Special
hi link SpecialComment Special
hi link StorageClass Type
hi link Structure Type
hi link Tag Special
hi link Typedef Type
hi link htmlEndTag htmlTagName
hi link htmlLink Function
hi link htmlSpecialTagName htmlTagName
hi link htmlTag htmlTagName
hi link xmlTag Statement
hi link xmlTagName Statement
hi link xmlEndTag Statement
hi link markdownItalic Preproc
hi link diffBDiffer WarningMsg
hi link diffCommon WarningMsg
hi link diffDiffer WarningMsg
hi link diffIdentical WarningMsg
hi link diffIsA WarningMsg
hi link diffNoEOL WarningMsg
hi link diffOnly WarningMsg
hi link diffRemoved WarningMsg
hi link diffAdded String

519
homedir/.vim/doc/acp.txt Normal file
View File

@ -0,0 +1,519 @@
*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 are disgusted to make your runtime directory confused with a lot of
plugins, put each of the plugins into a directory individually and just add
the directory path to 'runtimepath'. It's easy to uninstall plugins.
Then update your help tags files to enable help for this plugin. See
|add-local-help| for details.
Requirements: ~
- L9 library (vimscript #3252)
==============================================================================
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*
3.0: [TODO]
- From this version, L9 library (vimscript #3252) is required.
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:

1
homedir/.vim/init.vim Symbolic link
View File

@ -0,0 +1 @@
/home/fbt/.vimrc

View File

@ -0,0 +1,542 @@
scriptencoding utf-8
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" AutoClose.vim - Automatically close pair of characters: ( with ), [ with ], { with }, etc.
" Version: 2.0
" Author: Thiago Alves <talk@thiagoalves.com.br>
" Maintainer: Thiago Alves <talk@thiagoalves.com.br>
" URL: http://thiagoalves.com.br
" Licence: This script is released under the Vim License.
" Last modified: 02/02/2011
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" check if script is already loaded
if !exists("g:debug_AutoClose") && exists("g:loaded_AutoClose")
finish "stop loading the script"
endif
let g:loaded_AutoClose = 1
let s:global_cpo = &cpo " store compatible-mode in local variable
set cpo&vim " go into nocompatible-mode
if !exists('g:AutoClosePreserveDotReg')
let g:AutoClosePreserveDotReg = 1
endif
if g:AutoClosePreserveDotReg
" Because dot register preservation code remaps escape we have to remap
" some terminal specific escape sequences first
if &term =~ 'xterm' || &term =~ 'rxvt' || &term =~ 'screen' || &term =~ 'linux' || &term =~ 'gnome'
imap <silent> <Esc>OA <Up>
imap <silent> <Esc>OB <Down>
imap <silent> <Esc>OC <Right>
imap <silent> <Esc>OD <Left>
imap <silent> <Esc>OH <Home>
imap <silent> <Esc>OF <End>
imap <silent> <Esc>[5~ <PageUp>
imap <silent> <Esc>[6~ <PageDown>
endif
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Functions
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! s:GetCharAhead(len)
if col('$') == col('.')
return "\0"
endif
return strpart(getline('.'), col('.')-2 + a:len, 1)
endfunction
function! s:GetCharBehind(len)
if col('.') == 1
return "\0"
endif
return strpart(getline('.'), col('.') - (1 + a:len), 1)
endfunction
function! s:GetNextChar()
return s:GetCharAhead(1)
endfunction
function! s:GetPrevChar()
return s:GetCharBehind(1)
endfunction
" used to implement automatic deletion of closing character when opening
" counterpart is deleted and by space expansion
function! s:IsEmptyPair()
let l:prev = s:GetPrevChar()
let l:next = s:GetNextChar()
return (l:next != "\0") && (get(b:AutoClosePairs, l:prev, "\0") == l:next)
endfunction
function! s:GetCurrentSyntaxRegion()
return synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
endfunction
function! s:GetCurrentSyntaxRegionIf(char)
let l:origin_line = getline('.')
let l:changed_line = strpart(l:origin_line, 0, col('.')-1) . a:char . strpart(l:origin_line, col('.')-1)
call setline('.', l:changed_line)
let l:region = synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
call setline('.', l:origin_line)
return l:region
endfunction
function! s:IsForbidden(char)
let l:result = index(b:AutoCloseProtectedRegions, s:GetCurrentSyntaxRegion()) >= 0
if l:result
return l:result
endif
let l:region = s:GetCurrentSyntaxRegionIf(a:char)
let l:result = index(b:AutoCloseProtectedRegions, l:region) >= 0
return l:result || l:region == 'Comment'
endfunction
function! s:AllowQuote(char, isBS)
let l:result = 1
if b:AutoCloseSmartQuote
let l:initPos = 1 + (a:isBS ? 1 : 0)
let l:charBehind = s:GetCharBehind(l:initPos)
let l:prev = l:charBehind
let l:backSlashCount = 0
while l:charBehind == '\'
let l:backSlashCount = l:backSlashCount + 1
let l:charBehind = s:GetCharBehind(l:initPos + l:backSlashCount)
endwhile
if l:backSlashCount % 2
let l:result = 0
else
if a:char == "'" && l:prev =~ '[a-zA-Z0-9]'
let l:result = 0
endif
endif
endif
return l:result
endfunction
function! s:CountQuotes(char)
let l:currPos = col('.')-1
let l:line = strpart(getline('.'), 0, l:currPos)
let l:result = 0
if l:currPos >= 0
for [q,closer] in items(b:AutoClosePairs)
" only consider twin pairs
if q != closer | continue | endif
if b:AutoCloseSmartQuote != 0
let l:regex = q . '[ˆ\\' . q . ']*(\\.[ˆ\\' . q . ']*)*' . q
else
let l:regex = q . '[ˆ' . q . ']*' . q
endif
let l:closedQuoteIdx = match(l:line, l:regex)
while l:closedQuoteIdx >= 0
let l:matchedStr = matchstr(l:line, l:regex, l:closedQuoteIdx)
let l:line = strpart(l:line, 0, l:closedQuoteIdx) . strpart(l:line, l:closedQuoteIdx + strlen(l:matchedStr))
let l:closedQuoteIdx = match(l:line, l:regex)
endwhile
endfor
for c in split(l:line, '\zs')
if c == a:char
let l:result = l:result + 1
endif
endfor
endif
return l:result
endfunction
" The auto-close buffer is used in a fix of the redo functionality.
" As we insert characters after cursor, we remember them and at the moment
" that vim would normally collect the last entered string into dot register
" (:help ".) - i.e. when esc or a motion key is typed in insert mode - we
" erase the inserted symbols and pretend that we have just now typed them.
" This way vim picks them up into dot register as well and user can repeat the
" typed bit with . command.
function! s:PushBuffer(char)
if !exists("b:AutoCloseBuffer")
let b:AutoCloseBuffer = []
endif
call insert(b:AutoCloseBuffer, a:char)
endfunction
function! s:PopBuffer()
if exists("b:AutoCloseBuffer") && len(b:AutoCloseBuffer) > 0
call remove(b:AutoCloseBuffer, 0)
endif
endfunction
function! s:EmptyBuffer()
if exists("b:AutoCloseBuffer")
let b:AutoCloseBuffer = []
endif
endfunction
function! s:FlushBuffer()
let l:result = ''
if exists("b:AutoCloseBuffer")
let l:len = len(b:AutoCloseBuffer)
if l:len > 0
let l:result = join(b:AutoCloseBuffer, '') . repeat("\<Left>", l:len)
let b:AutoCloseBuffer = []
call s:EraseNCharsAtCursor(l:len)
endif
endif
return l:result
endfunction
function! s:InsertStringAtCursor(str)
let l:line = getline('.')
let l:column = col('.')-2
if l:column < 0
call setline('.', a:str . l:line)
else
call setline('.', l:line[:l:column] . a:str . l:line[l:column+1:])
endif
endfunction
function! s:EraseNCharsAtCursor(len)
let l:line = getline('.')
let l:column = col('.')-2
if l:column < 0
call setline('.', l:line[a:len + 1:])
else
call setline('.', l:line[:l:column] . l:line[l:column + a:len + 1:])
endif
endfunction
" returns the opener, after having inserted its closer if necessary
function! s:InsertPair(opener)
if ! b:AutoCloseOn || ! has_key(b:AutoClosePairs, a:opener) || s:IsForbidden(a:opener)
return a:opener
endif
let l:save_ve = &ve
set ve=all
let l:next = s:GetNextChar()
" only add closing pair before space or any of the closepair chars
let close_before = '\s\|\V\[,.;' . escape(join(keys(b:AutoClosePairs) + values(b:AutoClosePairs), ''), ']').']'
if (l:next == "\0" || l:next =~ close_before) && s:AllowQuote(a:opener, 0)
call s:InsertStringAtCursor(b:AutoClosePairs[a:opener])
call s:PushBuffer(b:AutoClosePairs[a:opener])
endif
exec "set ve=" . l:save_ve
return a:opener
endfunction
" returns the closer, after having eaten identical one if necessary
function! s:ClosePair(closer)
let l:save_ve = &ve
set ve=all
if b:AutoCloseOn && s:GetNextChar() == a:closer
call s:EraseNCharsAtCursor(1)
call s:PopBuffer()
endif
exec "set ve=" . l:save_ve
return a:closer
endfunction
" in case closer is identical with its opener - heuristically decide which one
" is being typed and act accordingly
function! s:OpenOrCloseTwinPair(char)
if s:CountQuotes(a:char) % 2 == 0
" act as opening char
return s:InsertPair(a:char)
else
" act as closing char
return s:ClosePair(a:char)
endif
endfunction
" maintain auto-close buffer when delete key is pressed
function! s:Delete()
let l:save_ve = &ve
set ve=all
if exists("b:AutoCloseBuffer") && len(b:AutoCloseBuffer) > 0 && b:AutoCloseBuffer[0] == s:GetNextChar()
call s:PopBuffer()
endif
exec "set ve=" . l:save_ve
return "\<Del>"
endfunction
" when backspace is pressed:
" - erase an empty pair if backspacing from inside one
" - maintain auto-close buffer
function! s:Backspace()
let l:save_ve = &ve
let l:prev = s:GetPrevChar()
let l:next = s:GetNextChar()
set ve=all
if b:AutoCloseOn && s:IsEmptyPair() && (l:prev != l:next || s:AllowQuote(l:prev, 1))
call s:EraseNCharsAtCursor(1)
call s:PopBuffer()
endif
exec "set ve=" . l:save_ve
return "\<BS>"
endfunction
function! s:Space()
if b:AutoCloseOn && s:IsEmptyPair()
call s:PushBuffer("\<Space>")
return "\<Space>\<Space>\<Left>"
else
return "\<Space>"
endif
endfunction
function! s:Enter()
if has_key(b:AutoClosePumvisible, 'ENTER') && pumvisible()
let b:snippet_chosen = 1
return b:AutoClosePumvisible['ENTER']
elseif b:AutoCloseOn && s:IsEmptyPair() && stridx( b:AutoCloseExpandEnterOn, s:GetPrevChar() ) >= 0
return "\<CR>\<Esc>O"
endif
return "\<CR>"
endfunction
function! s:ToggleAutoClose()
let b:AutoCloseOn = !b:AutoCloseOn
if b:AutoCloseOn
echo "AutoClose ON"
else
echo "AutoClose OFF"
endif
endfunction
" Parse a whitespace separated line of pairs
" single characters are assumed to be twin pairs (closer identical to
" opener)
function! AutoClose#ParsePairs(string)
if type(a:string) == type({})
return a:string
elseif type(a:string) != type("")
echoerr "AutoClose#ParsePairs(): Argument not a dictionary or a string"
return {}
endif
let l:dict = {}
for pair in split(a:string)
" strlen is length in bytes, we want in (wide) characters
let l:pairLen = strlen(substitute(pair,'.','x','g'))
if l:pairLen == 1
" assume a twin pair
let l:dict[pair] = pair
elseif l:pairLen == 2
let l:dict[pair[0]] = pair[1]
else
echoerr "AutoClose: Bad pair string - a pair longer then two character"
echoerr " `- String: " . a:sring
echoerr " `- Pair: " . pair . " Pair len: " . l:pairLen
endif
endfor
return l:dict
endfunction
" this function is made visible for the sake of users
function! AutoClose#DefaultPairs()
return AutoClose#ParsePairs(g:AutoClosePairs)
endfunction
function! s:ModifyPairsList(list, pairsToAdd, openersToRemove)
return filter(
\ extend(a:list, AutoClose#ParsePairs(a:pairsToAdd), "force"),
\ "stridx(a:openersToRemove,v:key)<0")
endfunction
function! AutoClose#DefaultPairsModified(pairsToAdd,openersToRemove)
return s:ModifyPairsList(AutoClose#DefaultPairs(), a:pairsToAdd, a:openersToRemove)
endfunction
" Define variables (in the buffer namespace).
function! s:DefineVariables()
" All the following variables can be set per buffer or global.
" The buffer namespace is used internally
let defaults = {
\ 'AutoClosePairs': AutoClose#DefaultPairs(),
\ 'AutoCloseProtectedRegions': ["Comment", "String", "Character"],
\ 'AutoCloseSmartQuote': 1,
\ 'AutoCloseOn': 1,
\ 'AutoCloseSelectionWrapPrefix': '<LEADER>a',
\ 'AutoClosePumvisible': {"ENTER": "\<C-Y>", "ESC": "\<C-E>"},
\ 'AutoCloseExpandEnterOn': "",
\ 'AutoCloseExpandSpace': 1,
\ }
" Let the user define if he/she wants the plugin to do special actions when the
" popup menu is visible and a movement key is pressed.
" Movement keys used in the menu get mapped to themselves
" (Up/Down/PageUp/PageDown).
for key in s:movementKeys
if key == 'ENTER' || key == 'ESC'
continue
endif
let defaults['AutoClosePumvisible'][key] = ''
endfor
for key in s:pumMovementKeys
if key == 'ENTER' || key == 'ESC'
continue
endif
let defaults['AutoClosePumvisible'][key] = '<'.key.'>'
endfor
if exists ('b:AutoClosePairs') && type('b:AutoClosePairs') == type("")
let tmp = AutoClose#ParsePairs(b:AutoClosePairs)
unlet b:AutoClosePairs
let b:AutoClosePairs = tmp
endif
" Now handle/assign values
for key in keys(defaults)
if key == 'AutoClosePumvisible'
let tempVisible = defaults['AutoClosePumvisible']
if exists('g:AutoClosePumvisible') && type(eval('g:AutoClosePumvisible')) == type(defaults['AutoClosePumvisible'])
for childKey in keys(g:AutoClosePumvisible)
let tempVisible[toupper(childKey)] = g:AutoClosePumvisible[childKey]
endfor
endif
if exists('b:AutoClosePumvisible') && type(eval('b:AutoClosePumvisible')) == type(defaults['AutoClosePumvisible'])
for childKey in keys(b:AutoClosePumvisible)
let tempVisible[toupper(childKey)] = b:AutoClosePumvisible[childKey]
endfor
endif
let b:AutoClosePumvisible = tempVisible
else
if exists('b:'.key) && type(eval('b:'.key)) == type(defaults[key])
continue
elseif exists('g:'.key) && type(eval('g:'.key)) == type(defaults[key])
exec 'let b:' . key . ' = g:' . key
else
exec 'let b:' . key . ' = ' . string(defaults[key])
endif
endif
endfor
endfunction
function! s:CreatePairsMaps()
" create appropriate maps to defined open/close characters
for key in keys(b:AutoClosePairs)
let opener = s:keyName(key)
let closer = s:keyName(b:AutoClosePairs[key])
let quoted_opener = s:quoteAndEscape(opener)
let quoted_closer = s:quoteAndEscape(closer)
exec "xnoremap <buffer> <silent> ". b:AutoCloseSelectionWrapPrefix
\ . opener . " <Esc>`>a" . closer . "<Esc>`<i" . opener . "<Esc>"
exec "xnoremap <buffer> <silent> ". b:AutoCloseSelectionWrapPrefix
\ . closer . " <Esc>`>a" . closer . "<Esc>`<i" . opener . "<Esc>"
if key == b:AutoClosePairs[key]
exec "inoremap <buffer> <silent> " . opener
\ . " <C-R>=<SID>OpenOrCloseTwinPair(" . quoted_opener . ")<CR>"
else
exec "inoremap <buffer> <silent> " . opener
\ . " <C-R>=<SID>InsertPair(" . quoted_opener . ")<CR>"
exec "inoremap <buffer> <silent> " . closer
\ . " <C-R>=<SID>ClosePair(" . quoted_closer . ")<CR>"
endif
endfor
endfunction
function! s:CreateExtraMaps()
" Extra mapping
inoremap <buffer> <silent> <BS> <C-R>=<SID>Backspace()<CR>
inoremap <buffer> <silent> <Del> <C-R>=<SID>Delete()<CR>
if b:AutoCloseExpandSpace
inoremap <buffer> <silent> <Space> <C-R>=<SID>Space()<CR>
endif
if len(b:AutoCloseExpandEnterOn) > 0
inoremap <buffer> <silent> <CR> <C-R>=<SID>Enter()<CR>
endif
if g:AutoClosePreserveDotReg
" Fix the re-do feature by flushing the char buffer on key movements (including Escape):
for key in s:movementKeys
let l:pvisiblemap = b:AutoClosePumvisible[key]
let key = "<".key.">"
let l:currentmap = maparg(key,"i")
if (l:currentmap=="")|let l:currentmap=key|endif
if len(l:pvisiblemap)
exec "inoremap <buffer> <silent> <expr> " . key . " pumvisible() ? '" . l:pvisiblemap . "' : '<C-R>=<SID>FlushBuffer()<CR>" . l:currentmap . "'"
else
exec "inoremap <buffer> <silent> " . key . " <C-R>=<SID>FlushBuffer()<CR>" . l:currentmap
endif
endfor
" Flush the char buffer on mouse click:
inoremap <buffer> <silent> <LeftMouse> <C-R>=<SID>FlushBuffer()<CR><LeftMouse>
inoremap <buffer> <silent> <RightMouse> <C-R>=<SID>FlushBuffer()<CR><RightMouse>
endif
endfunction
function! s:CreateMaps()
silent doautocmd FileType
call s:DefineVariables()
call s:CreatePairsMaps()
call s:CreateExtraMaps()
let b:loaded_AutoClose = 1
endfunction
function! s:IsLoadedOnBuffer()
return (exists("b:loaded_AutoClose") && b:loaded_AutoClose)
endfunction
" map some characters to their key names
function! s:keyName(char)
let s:keyNames = {'|': '<Bar>', ' ': '<Space>'}
return get(s:keyNames,a:char,a:char)
endfunction
" escape some characters for use in strings
function! s:quoteAndEscape(char)
let s:escapedChars = {'"': '\"'}
return '"' . get(s:escapedChars,a:char,a:char) . '"'
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Configuration
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let s:AutoClosePairs_FactoryDefaults = AutoClose#ParsePairs("() {} [] ` \" '")
if !exists("g:AutoClosePairs_add") | let g:AutoClosePairs_add = "" | endif
if !exists("g:AutoClosePairs_del") | let g:AutoClosePairs_del = "" | endif
if !exists("g:AutoClosePairs")
let g:AutoClosePairs = s:ModifyPairsList(
\ s:AutoClosePairs_FactoryDefaults,
\ g:AutoClosePairs_add,
\ g:AutoClosePairs_del )
endif
let s:movementKeys = split('ESC UP DOWN LEFT RIGHT HOME END PAGEUP PAGEDOWN')
" list of keys that get mapped to themselves for pumvisible()
let s:pumMovementKeys = split('UP DOWN PAGEUP PAGEDOWN')
if has("gui_macvim")
call extend(s:movementKeys, split("D-LEFT D-RIGHT D-UP D-DOWN M-LEFT M-RIGHT M-UP M-DOWN"))
endif
augroup <Plug>(autoclose)
autocmd!
autocmd BufNewFile,BufRead,BufEnter * if !<SID>IsLoadedOnBuffer() | call <SID>CreateMaps() | endif
autocmd InsertEnter * call <SID>EmptyBuffer()
autocmd BufEnter * if mode() == 'i' | call <SID>EmptyBuffer() | endif
augroup END
" Define convenient commands
command! AutoCloseOn :let b:AutoCloseOn = 1
command! AutoCloseOff :let b:AutoCloseOn = 0
command! AutoCloseToggle :call s:ToggleAutoClose()
" vim:sw=4:sts=4:

5
homedir/.vimperatorrc Normal file
View File

@ -0,0 +1,5 @@
"3.8.2 (created: 2014/02/13 23:52:43)
source! /home/fbt/.vimperatorrc.local
" vim: set ft=vimperator:

View File

@ -0,0 +1,11 @@
:set gui=nonavigation
:set autocomplete=false
:map O :tabopen
:map P :set apptab<CR>
:map D :tabclose!<CR>
highlight CmdLine background: #29303A; color: #f9f9f9; transition: all 0.25s;
highlight CompItem[selected] background: #3A4452; color: #f9f9f9;
highlight Filter font-style: italic; color: red;
highlight Normal background: #29303A; color: #f9f9f9; transition: all 0.25s;
highlight InfoMsg background: #29303A; color: magenta;

46
homedir/.vimrc Normal file
View File

@ -0,0 +1,46 @@
" Personal vim config
scriptencoding utf-8
set encoding=utf-8
set backspace=2
set modeline
set nocompatible
set cindent
set tabstop=3
set shiftwidth=3
set noexpandtab
set scrolloff=6
set cursorline
set listchars=tab:».,trail:.
set mouse=
set number
set relativenumber
syntax enable
set background=dark
"colorscheme apprentice
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif "
" Custom mappings
nmap rr "_dd
nmap <leader>l :setlocal list!<cr>
" visual mode mappings
vmap r "_d
vmap R "_dP
"set foldmethod=indent
" set fmr={,}
"set foldnestmax=1

15
homedir/.zshrc Normal file
View File

@ -0,0 +1,15 @@
# vim: ft=zsh
source "$HOME/.config/zsh.d/zshrc"
# Load modules
use \
core \
xdg \
config \
keys \
dotfiles \
prompt \
helpers \
local \
shell

View File

@ -0,0 +1,45 @@
.tabbrowser-tab {
font: 14px xos4 terminus, Monospace !important;
color: #bebebe !important;
border: none !important;
background: #29303A !important;
min-height: 0 !important;
}
.tabbrowser-tab[selected] {
color: #f9f9f9 !important;
background: #3A4452 !important;
}
.tab-icon-image:not([pinned]) { display: none !important; }
#TabsToolbar {
background: #29303A !important;
}
/* these styles are required to cover narrow scrollbars. */
.tabbrowser-tabs[treestyletab-mode="vertical"]
.scrollbox-innerbox {
background: #29303A !important;
}
.tabbrowser-tabs[treestyletab-tabbar-position="left"][treestyletab-invert-scrollbar="true"]
.scrollbox-innerbox {
background: #29303A !important;
}
statusbar,
menubar,
toolbox,
toolbar {
border-style: none !important;
}
toolbar {
border-width: 0px !important;
border-bottom: 1px solid #29303A !important;
}
/* toolbar {
border-bottom: 1px solid red !important;
} */