├── inputrc ├── vim └── UltiSnips │ ├── bib.snippets │ ├── sh.snippets │ └── tex.snippets ├── sh.d ├── djvu2pdfall ├── get_urandom ├── get_epoch ├── udate ├── upto ├── timed ├── popc ├── djvu2pdf ├── fmv ├── impl ├── prompts.sh ├── repeat └── lean_new ├── bashrc ├── zathurarc ├── README.md ├── philosophy.md ├── LICENCE ├── latexmkrc ├── tex.vim ├── shrc ├── lean_new ├── habiShell.vim └── vimrc /inputrc: -------------------------------------------------------------------------------- 1 | set enable-bracketed-paste on 2 | # Respect default shortcuts. 3 | $include /etc/inputrc 4 | 5 | ## arrow up 6 | "\e[A":history-search-backward 7 | ## arrow down 8 | "\e[B":history-search-forward 9 | -------------------------------------------------------------------------------- /vim/UltiSnips/bib.snippets: -------------------------------------------------------------------------------- 1 | snippet bibar "Bibliographic Item" b 2 | @article{${1:citation key}, 3 | author = { $2 }, 4 | title = { $3 }, 5 | journal = { $4 }, 6 | year = { $5 }, 7 | publisher = { $4 }, 8 | } 9 | endsnippet 10 | -------------------------------------------------------------------------------- /sh.d/djvu2pdfall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dt="$(date "+%a--%d-%b-%Y--%H.%M.%S--%Z")" 3 | 4 | for f in *.djvu; do 5 | noext="${f%".djvu"}" 6 | if ! [ -f "${noext}.pdf" ]; then 7 | ddjvu -format=pdf "$f" "${noext}.pdf" 2>> "djvu2pdf.errors.${dt}" || : 8 | fi 9 | done 10 | -------------------------------------------------------------------------------- /sh.d/get_urandom: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Usage: get_urandom [LENGTH=32] [CLASS='[:graph:]'] 4 | # Print random string of given length and POSIX char class. 5 | # Requires /dev/urandom. 6 | 7 | tr -dc "${2:-"[:graph:]"}" &1 2>&3 15 | { 16 | eval "$@" >&3 17 | kill 0 18 | } | 19 | { 20 | sleep "${sleeptime}" 21 | kill 0 22 | } 23 | ' sh "$@" 24 | -------------------------------------------------------------------------------- /sh.d/timed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Usage: timed TIMES COMMAND 4 | # Repeat COMMAND TIMES times and calculate clock time with accuracy 5 | # roughly in seconds. 6 | 7 | if ! [ 0 -lt "$1" ]; then 8 | printf '%s\n' "First argument must be a positive integer." >&2 9 | exit 1 10 | fi 11 | 12 | epoch="$(get_epoch)" 13 | times="$1" 14 | shift 15 | 16 | repeat "${times}" "$@" >/dev/null 2>&1 17 | printf '%s\n' "$(($(get_epoch) - epoch))" 18 | -------------------------------------------------------------------------------- /sh.d/popc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Usage : popc BINARY_STRING 4 | # Silly popcount to demonstrate a use of IFS that can bite you if 5 | # you do not quote all the variables you don't want to split. 6 | { 7 | binv="$(printf '%s' "${1}" | tr -c 1 0)" 8 | binc="${#binv}" 9 | count() { printf '%s\n' "$((binc + 1 - $#))" ;} 10 | saved="${IFS}" 11 | IFS=0 12 | count 1${binv}1 13 | IFS="${saved}" 14 | } 15 | # We do not run the code in a subshell to forget IFS because popcount 16 | # needs to be highly efficient (≖ ᴗ ≖ ) 17 | -------------------------------------------------------------------------------- /sh.d/djvu2pdf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Usage: djvu2pdf FILE 4 | # Convert FILE from djvu to pdf format. 5 | 6 | dt="$(\date "+%a-%d.%b.%Y-%H.%M.%S.%Z")" 7 | f="$1" 8 | noext="${f%".djvu"}" 9 | 10 | if [ -f "${noext}.pdf" ]; then 11 | printf '%s\n' "PDF document of the given file already exists." >&2 12 | exit 1 13 | fi 14 | 15 | ddjvu -format=pdf "$f" "${noext}.pdf" 2>> "djvu2pdf.errors.${dt}" 16 | 17 | if [ 0 -ne "$?" ]; then 18 | printf '%s\n' "Exiting with errors; logged in ./djvu2pdf.errors.${dt}" >&2 19 | exit 1 20 | fi 21 | exit 22 | -------------------------------------------------------------------------------- /zathurarc: -------------------------------------------------------------------------------- 1 | set synctex true 2 | set synctex-editor-command "vim --remote-silent +%{line} %{input}" 3 | 4 | set statusbar-h-padding 10 5 | set statusbar-v-padding 10 6 | set statusbar-fg "#000000" 7 | set statusbar-bg "#FFFFF0" 8 | set page-padding 1 9 | set default-bg "#FFFFF0" 10 | set recolor true 11 | set recolor-lightcolor "#FFFFF0" 12 | set recolor-darkcolor "#000000" 13 | set selection-clipboard clipboard 14 | set completion-fg "$000000" 15 | set completion-bg "$FFFDD" 16 | set inputbar-bg "#FF9300" 17 | set inputbar-fg "#000000" 18 | set notification-error-bg "#FFFFF0" 19 | set notification-bg "#FFFFF0" 20 | set notification-warning-bg "#FFFFF0" 21 | set highlight-color "#FFBA00" 22 | set highlight-active-color "#FFBA99" 23 | set guioptions "" 24 | -------------------------------------------------------------------------------- /sh.d/fmv: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Usage: fmv 'PATTERN' DIRECTORY 4 | # Move all normal files in the current directory that match the 5 | # `find` PATTERN to DIRECTORY non-recursively. 6 | # 7 | # Warning: do not forget to quote PATTERN if it contains glob 8 | # characters. 9 | # 10 | 11 | errorx() { printf 'Error: %s\n' "${*:-"unknown error."}" >&2 ; exit 1 ;} 12 | 13 | if [ 2 -eq "$#" ]; then 14 | if [ -d "$2" ] && [ -w "$2" ]; then 15 | command find ./ ! -name . -prune -type f -name "$1" \ 16 | ! -exec test -f "${2%/}/"{} \; \ 17 | -exec printf '%s\n' "Moving file '{}' to folder $2" \; \ 18 | -exec mv -- {} "$2" \; ; 19 | else 20 | errorx "invalid or inaccessible directory." 21 | fi 22 | else 23 | errorx "invalid number of arguments." 24 | fi 25 | exit 26 | -------------------------------------------------------------------------------- /sh.d/impl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Usage: impl [SCRIPT := impl] 4 | # Print the source code for SCRIPT if available. 5 | 6 | errex() { printf '%s\n' "$@" >&2; exit 1; } 7 | 8 | if ! command -v command >/dev/null 2>&1; then 9 | errex "\`command -v\` is not available." 10 | fi 11 | 12 | full="$(command -v "${1:-"impl"}")" 13 | 14 | if [ -z "${full}" ]; then 15 | errex "\`command -v\` did not find script." 16 | elif ! [ -f "${full}" ]; then 17 | errex "\`command -v\` returned invalid file." 18 | elif ! [ -r "${full}" ]; then 19 | errex "Script not readable." 20 | fi 21 | 22 | ftype="$(file -- "${full}")" 23 | 24 | test "${ftype#*"text"}" = "${ftype}" && 25 | errex "\`command -v\` did not return a text file." 26 | 27 | if command -v bat >/dev/null 2>&1; then 28 | bat --theme Coldark-Cold --style full -- "${full}" 29 | else 30 | cat -- "${full}" 31 | fi 32 | 33 | exit 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dotfiles 2 | 3 | This repository contains a pared-down version of my dotfiles, including 4 | Vim and UltiSnips configuration. Use at your own risk! 5 | 6 | The contents of this repository are part of what powers the post I 7 | made on unixporn linked below: 8 | 9 | https://www.reddit.com/r/unixporn/comments/jtjol5/cinnamon_latex_workflow_in_vim/ 10 | 11 | If you are interested in this aesthetic, please check the first two 12 | minutes of https://www.reddit.com/r/unixporn/comments/ek3cyc/cinnamon_soft_mood_and_latex_workflow/ 13 | 14 | # Credits 15 | 16 | Much of the Python code involved in the snippets comes from Honza's 17 | master list : https://github.com/honza/vim-snippets 18 | 19 | The implementation of the ```math()``` context comes (to my 20 | knowledge) from Gilles Castel who has a website dedicated to 21 | advanced Latex typesetting in Vim: https://castel.dev/ 22 | -------------------------------------------------------------------------------- /philosophy.md: -------------------------------------------------------------------------------- 1 | # Guiding principles 2 | 3 | 4 | * All principles are guidelines. Feel free to break them if they 5 | become a hindrance. 6 | 7 | * Automate whatever you can, starting with the most cognitively 8 | tedious tasks that are done most frequently. These may or may 9 | not be the "slowest" tasks. 10 | 11 | * Aim for composability of snippets; think about how your 12 | snippets will expand while you are in another snippet. 13 | 14 | * Minimize nuisance navigation: design snippets that place you 15 | where you are supposed to edit text, and guide you to their exit 16 | cleanly. 17 | 18 | * Eliminate low-level typesetting. You should not have to manually 19 | open or close an environment, enter a backslash, open and close 20 | command brackets, indent text, and so on. 21 | 22 | * Use composable visual tokens for latex symbols as much as 23 | possible. In general, use tokens that trigger your memory the 24 | best. 25 | 26 | * Exploit vertical space for long equation groups, and tame 27 | horizontal space. Use folds to handle long environments. 28 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 see AUTHORS 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | 22 | -------------------------------------------------------------------------------- /latexmkrc: -------------------------------------------------------------------------------- 1 | $pdf_mode = 1; 2 | $silent = 1; 3 | $aux_dir = "./.aux"; 4 | $out_dir = "./out"; 5 | $lualatex = "lualatex -file-line-error %O %S"; 6 | $pdflatex = "lualatex -file-line-error %O %S"; #for compatibility with borked versions 7 | 8 | # $pdf_mode explanation: 9 | # If zero, do NOT generate a pdf version of the document. If equal to 1, generate a pdf version of 10 | # the document using pdflatex, using the command specified by the $pdflatex variable. If equal to 2, 11 | # generate a pdf version of the document from the ps file, by using the command specified by the 12 | # $ps2pdf variable. If equal to 3, generate a pdf version of the document from the dvi file, by using 13 | # the command specified by the $dvipdf variable. If equal to 4, generate a pdf version of the docu- 14 | # ment using lualatex, using the command specified by the $lualatex variable. If equal to 5, gener- 15 | # ate a pdf version (and an xdv version) of the document using xelatex, using the commands speci- 16 | # fied by the $xelatex and xdvipdfmx variables. 17 | # In $pdf_mode=2, it is ensured that .dvi and .ps files are also made. In $pdf_mode=3, it is ensured 18 | # that a .dvi file is also made. But this may be overridden by the document. 19 | -------------------------------------------------------------------------------- /sh.d/prompts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | return='↵' 4 | export OLDPS1="$PS1" 5 | 6 | B='\033[1m' 7 | R='\033[0m' 8 | r='\033[31m' 9 | g='\033[32m' 10 | b='\033[34m' 11 | 12 | rgb() { printf "\033[38;2;${1};${2};${3}m"; } 13 | rgbb() { printf "\033[48;2;${1};${2};${3}m"; } 14 | 15 | colf() { printf "\033[38;5;${1}m"; } 16 | colb() { printf "\033[48;5;${1}m"; } 17 | 18 | Y="$(colf 3)" 19 | M="$(colf 5)" 20 | 21 | git_prompt() { 22 | if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then 23 | branch_name=$(git symbolic-ref -q HEAD) 24 | branch_name=${branch_name##refs/heads/} 25 | branch_name=${branch_name:-HEAD} 26 | 27 | printf '%s' " ➛ " 28 | 29 | if [[ $(git status 2> /dev/null | tail -n1) = *"nothing to commit"* ]]; then 30 | printf "${B}${b}%s${R}" "$branch_name" 31 | elif [[ $(git status 2> /dev/null | head -n5) = *"Changes to be committed"* ]]; then 32 | printf "${B}${b}%s${r}?${R}" "${branch_name}" 33 | else 34 | printf "${B}${b}%s${r}*${R}" "${branch_name}" 35 | fi 36 | fi 37 | } 38 | 39 | export PS1="${B}${b}┌─[${R}${B}\s:${R}\!${B}${b}] ─ [${g}\u${R}${B}@${R}${r}\H${R}:${TTY#*/*/}${B}${b}] ─ [${R}${B}\w${R}"'$(git_prompt)'"${B}${b}] ─ [${R}${Y}\d, \t${B}${b}] ─ [${R}"'$?'"${B}${b}]\n└─[${M}⌾${b}]${R} " 40 | -------------------------------------------------------------------------------- /tex.vim: -------------------------------------------------------------------------------- 1 | " Make zathura default view and latex default tex flavor 2 | let g:tex_flavor='latex' 3 | let g:vimtex_view_method = 'zathura' 4 | 5 | " I do not use tags; use C-T to open Vimtex TOC 6 | nnoremap :VimtexTocOpen 7 | 8 | setlocal tabstop=2 9 | setlocal shiftwidth=2 10 | 11 | " Customize search in tex files 12 | nnoremap gg gg/\\begin{document}:C 13 | nnoremap G G$?\\end{document}:C 14 | 15 | " Preparatory function to use with ref and eqref 16 | fu! MyHandler(_) abort 17 | call feedkeys("\\", 'in') 18 | endfu 19 | 20 | " Enable folds in vimtex 21 | let g:vimtex_fold_enabled=1 22 | 23 | " Runaway whitespace is a fact of life in latex 24 | let g:airline#extensions#whitespace#enabled = 0 25 | 26 | " No vimtex indent 27 | let g:vimtex_indent_enabled = 0 28 | 29 | " Folding small files 30 | let g:fastfold_minlines = 0 31 | 32 | " Use lualatex as default latex compiler 33 | let g:vimtex_compiler_engine = 'lualatex' 34 | 35 | " Do not open quickfix window for warnings 36 | let g:vimtex_quickfix_open_on_warning = 0 37 | 38 | "Spellchecking on 39 | setlocal spell 40 | setlocal spelllang=en,el 41 | 42 | let g:vimtex_compiler_latexmk = { 43 | \ 'aux_dir' : './.aux', 44 | \ 'out_dir' : './out', 45 | \ 'callback' : 1, 46 | \ 'continuous' : 1, 47 | \ 'executable' : 'latexmk', 48 | \ 'hooks' : [], 49 | \ 'options' : [ 50 | \ '-silent', 51 | \ '-file-line-error', 52 | \ '-synctex=1', 53 | \ '-shell-escape', 54 | \ '-interaction=nonstopmode', 55 | \ ], 56 | \} 57 | -------------------------------------------------------------------------------- /sh.d/repeat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Usage: repeat TIMES COMMAND 4 | # Repeat COMMAND a given number of TIMES. 5 | 6 | eval_full_quotes=' 7 | s/\\/\\\\/g ; s/\"/\\\"/g ; s//\\>/g ; 8 | s/\$/\\\$/g ; s/\[/\\\[/g ; s/*/\\*/g ; s/?/\\?/g ; 9 | s/|/\\|/g ; s/&/\\&/g ; s/~/\\~/g ; s/=/\\=/g ; 10 | s/;/\\;/g ; s/ /\\ /g ; s/%/\\%/g ; s/`/\\`/g ; 11 | s/(/\\(/g ; s/)/\\)/g ; s/{/\\{/g ; s/}/\\}/g ; 12 | s/#/\\#/g ; s/'"'"'/\\'"'"'/g' 13 | 14 | errorx() { printf 'Error: %s\n' "${*:-"unknown error."}" >&2; exit 1; } 15 | 16 | absolute_threshold=1000 # tunable 17 | 18 | if [ "${1}" -lt "${absolute_threshold}" ]; then 19 | _rep() { 20 | rep_times="$((2 * $1))" 21 | rep_string="$2" 22 | output="" 23 | while [ 0 -lt "${rep_times}" ]; do 24 | test 1 -eq "$(((rep_times /= 2) % 2))" && output="${output}${rep_string}" 25 | rep_string="${rep_string}${rep_string}" 26 | done 27 | printf '%s' "${output}" 28 | } 29 | else 30 | _rep() { 31 | awk -v t="$1" -v s="$2" ' 32 | BEGIN { 33 | while (0 < t) { 34 | r = t % 2 35 | if (r == 1) o = o s 36 | t = (t - r) / 2 37 | s = s s 38 | } 39 | printf "%s", o 40 | }' 41 | } 42 | fi 43 | 44 | { 45 | times="$1" 46 | shift 47 | 48 | test 0 -lt "${times}" || errorx "First argument must be a positive integer." 49 | test 0 -lt "$#" || errorx "No command given to repeat." 50 | 51 | max_arg="${ARG_MAX:-"$(getconf ARG_MAX)"}" 52 | 53 | repeat_command="$*" 54 | command_length="${#repeat_command}" 55 | full_length="$((command_length + 2))" # count semicolon and space 56 | split_threshold="$((times * full_length))" 57 | 58 | # experimentally derived slacks to work around `eval` bugs; need tuning 59 | 60 | if [ "${max_arg}" -le "${split_threshold}" ]; then 61 | : "$(( (slack_factor = 20 ) + \ 62 | (arg_split = slack_factor * full_length ) + \ 63 | (block_size = max_arg / arg_split ) + \ 64 | (blocks = times / block_size + 1 ) + \ 65 | (remainder = (block_size + (times % block_size)) % block_size) ))" 66 | 67 | eval_string="$(_rep "${block_size}" "${repeat_command}; " | sed -e "${eval_full_quotes}")" 68 | 69 | while [ 0 -lt "$((blocks -= 1))" ]; do 70 | eval eval "${eval_string}" 71 | done 72 | 73 | eval_string="$(_rep "${remainder}" "${repeat_command}; " | sed -e "${eval_full_quotes}")" 74 | eval eval "${eval_string}" 75 | else 76 | eval_string="$(_rep "${times}" "${repeat_command}; " | sed -e "${eval_full_quotes}")" 77 | eval eval "${eval_string}" 78 | fi 79 | } 80 | 81 | exit 82 | -------------------------------------------------------------------------------- /shrc: -------------------------------------------------------------------------------- 1 | # shellcheck disable=SC2164 # cd is handled 2 | # shellcheck disable=SC2142 # not an error 3 | # shellcheck disable=SC2059 # these variables are part of fmtstr 4 | # shellcheck disable=SC2016 # we don't want the code to be run at definition 5 | 6 | # UUID to check if this file has been sourced 7 | export SHRC_UUID='56751b2a-c93f-4b80-a324-c49574eea33b' 8 | 9 | # color definitions and control codes 10 | export undo='\033[0m' 11 | export reset='\033[0m' 12 | 13 | export red='\033[31m' 14 | export green='\033[32m' 15 | export blue='\033[34m' 16 | 17 | export bold='\033[1m' 18 | export cross='\033[9m' 19 | export ital='\033[3m' 20 | export over='\033[53m' 21 | export under='\033[4m' 22 | 23 | export B='\033[1m' 24 | export R='\033[0m' 25 | 26 | # RGB foreground and background 27 | rgb() { printf "\033[38;2;${1};${2};${3}m"; } 28 | rgbb() { printf "\033[48;2;${1};${2};${3}m"; } 29 | 30 | # 256 color fore/back ground 31 | colf() { printf "\033[38;5;${1}m"; } 32 | colb() { printf "\033[48;5;${1}m"; } 33 | 34 | # append to PATH 35 | append_path() { 36 | test -d "$1" || return 1 37 | case ":${PATH}:" in 38 | *:"$1":*) : ;; 39 | *) PATH="${PATH:+$PATH:}$1" ;; 40 | esac 41 | } 42 | 43 | # set envars 44 | append_path "${HOME}/.sh.d" 45 | export PATH 46 | export TMPDIR='/tmp' 47 | export EDITOR='vim' 48 | export nl=' 49 | ' 50 | export tab=' ' 51 | export tb=' ' 52 | export sp=' ' 53 | export DEFAULT_IFS="${sp}${tb}${nl}" 54 | export FZF_DEFAULT_COMMAND='rg --files --hidden --follow' 55 | export TERM=xterm-256color 56 | export XDG_CONFIG_HOME="${HOME}/.config" 57 | export XDG_CACHE_HOME="${HOME}/.cache" 58 | export now='date +"%d_%b_%y__%H:%M:%S"' 59 | export DEBUG=false 60 | 61 | TTY=$(tty) 62 | export TTY 63 | 64 | # error handing primitive; invoke via `die` alias 65 | fatal_string="${bold}Fatal error [${red}%s${reset}${bold}] on line ${green}%s${reset}${bold} in '${blue}%s${reset}${bold}':${reset} %s\n" 66 | __errex() { 67 | printf "${fatal_string}" \ 68 | "${1:-"?"}" \ 69 | "${2:-"?"}" \ 70 | "${3:-"undetermined script"}" \ 71 | "${4:-"undetermined error"}" >&2 ; 72 | exit "${1:-1}" 73 | } 74 | 75 | # debug handling primitive; invoke via `debug` alias 76 | __debug() { 77 | "${DEBUG}" && 78 | printf 'Debug line %s in '"'"'%s'"'"': %s\n' \ 79 | "${1:-"?"}" \ 80 | "${2:-"undetermined script"}" \ 81 | "${3:-"(empty debug message)"}" >&2 ; 82 | } 83 | 84 | # message handling primitive; invoke via `msg|warn` alias 85 | message_string="${bold}[${reset}${blue}%s${reset}:%s${bold}]${reset} ${bold}%s:${reset} %s\n" 86 | __message() { 87 | printf "${message_string}" \ 88 | "${2:-"script"}" \ 89 | "${3:-"?"}" \ 90 | "${1:-"message"}" \ 91 | "${4:-"(empty $1)"}" >&2 ; 92 | } 93 | 94 | # error message primitive; invoke via `error` alias 95 | error_string="${bold}[${reset}${blue}%s${reset}:%s${bold}]${reset} ${bold}%s[${red}${bold}%s${reset}${bold}]:${reset} %s\n" 96 | __error() { 97 | printf "${error_string}" \ 98 | "${2:-"script"}" \ 99 | "${3:-"?"}" \ 100 | "${1:-"error"}" \ 101 | "${4:-"?"}" \ 102 | "${5:-"(empty error)"}" >&2 ; 103 | } 104 | 105 | # suppress output, get only error code 106 | quiet() { "$@" >/dev/null 2>&1 ;} 107 | ok() { "$@" >/dev/null 2>&1 ;} 108 | 109 | # suppress error code, get only output 110 | noerr() { "$@" 2>/dev/null || : ;} 111 | 112 | # printf shortcuts 113 | out() { printf '%s\n' "$@" ;} 114 | raw() { printf '%s\n' "$*" ;} 115 | 116 | alias die='__errex "$?" "${LINENO}" "$0"' 117 | alias debug='__debug "${LINENO}" "$0"' 118 | alias msg='__message message "$0" "${LINENO}"' 119 | alias warn='__message warning "$0" "${LINENO}"' 120 | alias error='__error error "$0" "${LINENO}" "$?"' 121 | alias scr='screenkey -g 400x400+1500+600' 122 | alias sx='startx' 123 | alias bb='bc -l <&2 ; 36 | exit "${1:-1}" 37 | } 38 | alias die='__errex "$?" "${LINENO}" "$0"' 39 | 40 | __outex() { 41 | abandon_string="${d}Abandoning script '$b%s$s$d' at line $g%s$s$d with code [$r%s$s$d]:$s %s\n" 42 | printf "${abandon_string}" \ 43 | "${1:-"undetermined script"}" \ 44 | "${2:-"?"}" \ 45 | "${3:-"?"}" \ 46 | "${4:-"undetermined reason"}" >&2 ; 47 | exit "${3:-1}" 48 | } 49 | alias bye='__outex "$0" "${LINENO}" "$?"' 50 | 51 | set_raw_chars() { 52 | smash="$*" 53 | raw_chars= 54 | while [ -n "${smash}" ]; do 55 | remains="${smash#?}" 56 | raw_chars="${raw_chars}${smash%%"${remains}"} " 57 | smash="${remains}" 58 | done 59 | } 60 | 61 | set_pascal() { 62 | set_upper() { 63 | case "$*" in 64 | a) upper="A" ;; b) upper="B" ;; c) upper="C" ;; 65 | d) upper="D" ;; e) upper="E" ;; f) upper="F" ;; 66 | g) upper="G" ;; h) upper="H" ;; i) upper="I" ;; 67 | j) upper="J" ;; k) upper="K" ;; l) upper="L" ;; 68 | m) upper="M" ;; n) upper="N" ;; o) upper="O" ;; 69 | p) upper="P" ;; q) upper="Q" ;; r) upper="R" ;; 70 | s) upper="S" ;; t) upper="T" ;; u) upper="U" ;; 71 | v) upper="V" ;; w) upper="W" ;; x) upper="X" ;; 72 | y) upper="Y" ;; z) upper="Z" ;; *) upper="$*" ;; 73 | esac 74 | } 75 | set_upper "$1" 76 | pascal="${upper}" 77 | shift 78 | while [ "$#" -gt 0 ]; do 79 | if [ "$1" = "_" ]; then 80 | shift 81 | set_upper "$1" 82 | pascal="${pascal}${upper}" 83 | else 84 | pascal="${pascal}$1" 85 | fi 86 | shift 87 | done 88 | } 89 | 90 | ## Initial checks 91 | 92 | out "-- Checking elan default toolchain..." 93 | 94 | elan toolchain list | tee /dev/tty | grep -qFe 'stable (default)' || { 95 | out "----------------------------------------------" \ 96 | "Warning: default elan toolchain is not stable!" \ 97 | "Always install elan with the stable toolchain." \ 98 | "----------------------------------------------" \ 99 | "Continue anyway? " ; 100 | 101 | read -r response || die "Unable to read response." 102 | 103 | case "${response}" in 104 | y|Y|yes|Yes|YES) : ;; 105 | *) bye "rejecting toolchain." ;; 106 | esac 107 | } 108 | 109 | grep -qE '^[[:alnum:]_]+$' <| lakefile.lean || die "unable to write new lakefile." 142 | import Lake 143 | open Lake DSL 144 | 145 | package «$*» where 146 | -- Settings applied to both builds and interactive editing 147 | leanOptions := #[ 148 | ⟨\`pp.unicode.fun, true⟩ -- pretty-prints \`fun a ↦ b\` 149 | ] 150 | -- add any additional package configuration options here 151 | 152 | lean_lib «${pascal}» where 153 | 154 | /-! 155 | mathlib ensures batteries, Cli, Qq, aesop, proofwidgets and importGraph 156 | -/ 157 | require alloy from git "https://github.com/tydeu/lean4-alloy.git" 158 | require mathlib from git "https://github.com/leanprover-community/mathlib4.git" 159 | 160 | @[default_target] 161 | lean_exe $* where 162 | root := \`Main 163 | LAKEFILE 164 | 165 | out "-- Created new lakefile; if the build fails, check syntax compatibility." \ 166 | "-- The original file generated by lake is 'lakefile.original'." ; 167 | 168 | out 'def main : IO Unit :=' ' IO.println "Clean main!"' >| Main.lean || 169 | die "failed to create Main.lean" 170 | 171 | out "-- Directory ready; trying to build..." 172 | 173 | ## Try build 174 | 175 | lake build && 176 | ./.lake/build/bin/$* 177 | 178 | exit 179 | -------------------------------------------------------------------------------- /sh.d/lean_new: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # shellcheck disable=SC2086 # deliberate splitting 4 | # shellcheck disable=SC2059 # deliberate format variable 5 | # shellcheck disable=SC2142 # deliberate function in alias 6 | # shellcheck disable=SC2317 # code is reachable; shellcheck is wrong 7 | # 8 | # Usage: lean_new PROJECT 9 | # Creates new Lean 4 project named PROJECT in current directory 10 | # with mathlib dependency and an executable default target. 11 | # 12 | # It tries to ensure that lake and elan have the expected behavior 13 | # in order for the project to build and informs the user of any known 14 | # pitfalls. 15 | 16 | ## Preliminaries 17 | set -u 18 | 19 | unset -v raw_chars pascal upper 20 | 21 | r='\033[31m' #red 22 | b='\033[34m' #blue 23 | g='\033[32m' #green 24 | d='\033[1m' #bold 25 | s='\033[0m' #reset 26 | 27 | out() { printf '%s\n' "$@"; } 28 | 29 | __errex() { 30 | fatal_string="${d}Fatal error [$r%s$s$d] on line $g%s$s$d in '$b%s$s$d':$s %s\n" 31 | printf "${fatal_string}" \ 32 | "${1:-"?"}" \ 33 | "${2:-"?"}" \ 34 | "${3:-"undetermined script"}" \ 35 | "${4:-"undetermined error"}" >&2 ; 36 | exit "${1:-1}" 37 | } 38 | alias die='__errex "$?" "${LINENO}" "$0"' 39 | 40 | __outex() { 41 | abandon_string="${d}Abandoning script '$b%s$s$d' at line $g%s$s$d with code [$r%s$s$d]:$s %s\n" 42 | printf "${abandon_string}" \ 43 | "${1:-"undetermined script"}" \ 44 | "${2:-"?"}" \ 45 | "${3:-"?"}" \ 46 | "${4:-"undetermined reason"}" >&2 ; 47 | exit "${3:-1}" 48 | } 49 | alias bye='__outex "$0" "${LINENO}" "$?"' 50 | 51 | set_raw_chars() { 52 | smash="$*" 53 | raw_chars= 54 | while [ -n "${smash}" ]; do 55 | remains="${smash#?}" 56 | raw_chars="${raw_chars}${smash%%"${remains}"} " 57 | smash="${remains}" 58 | done 59 | } 60 | 61 | set_pascal() { 62 | set_upper() { 63 | case "$*" in 64 | a) upper="A" ;; b) upper="B" ;; c) upper="C" ;; 65 | d) upper="D" ;; e) upper="E" ;; f) upper="F" ;; 66 | g) upper="G" ;; h) upper="H" ;; i) upper="I" ;; 67 | j) upper="J" ;; k) upper="K" ;; l) upper="L" ;; 68 | m) upper="M" ;; n) upper="N" ;; o) upper="O" ;; 69 | p) upper="P" ;; q) upper="Q" ;; r) upper="R" ;; 70 | s) upper="S" ;; t) upper="T" ;; u) upper="U" ;; 71 | v) upper="V" ;; w) upper="W" ;; x) upper="X" ;; 72 | y) upper="Y" ;; z) upper="Z" ;; *) upper="$*" ;; 73 | esac 74 | } 75 | set_upper "$1" 76 | pascal="${upper}" 77 | shift 78 | while [ "$#" -gt 0 ]; do 79 | if [ "$1" = "_" ]; then 80 | shift 81 | set_upper "$1" 82 | pascal="${pascal}${upper}" 83 | else 84 | pascal="${pascal}$1" 85 | fi 86 | shift 87 | done 88 | } 89 | 90 | ## Initial checks 91 | 92 | out "-- Checking elan default toolchain..." 93 | 94 | elan toolchain list | tee /dev/tty | grep -qFe 'stable (default)' || { 95 | out "----------------------------------------------" \ 96 | "Warning: default elan toolchain is not stable!" \ 97 | "Always install elan with the stable toolchain." \ 98 | "----------------------------------------------" \ 99 | "Continue anyway? " ; 100 | 101 | read -r response || die "Unable to read response." 102 | 103 | case "${response}" in 104 | y|Y|yes|Yes|YES) : ;; 105 | *) bye "rejecting toolchain." ;; 106 | esac 107 | } 108 | 109 | grep -qE '^[[:alnum:]_]+$' <| lakefile.lean || die "unable to write new lakefile." 142 | import Lake 143 | open Lake DSL 144 | 145 | package «$*» where 146 | -- Settings applied to both builds and interactive editing 147 | leanOptions := #[ 148 | ⟨\`pp.unicode.fun, true⟩ -- pretty-prints \`fun a ↦ b\` 149 | ] 150 | -- add any additional package configuration options here 151 | 152 | /-! 153 | ## mathlib ensures batteries, Cli, Qq, aesop, proofwidgets and importGraph 154 | -/ 155 | 156 | require alloy from git "https://github.com/tydeu/lean4-alloy.git" 157 | require mathlib from git "https://github.com/leanprover-community/mathlib4.git" 158 | 159 | @[default_target] 160 | lean_exe $* where 161 | root := \`Main 162 | LAKEFILE 163 | 164 | out "-- Created new lakefile; if the build fails, check syntax compatibility." \ 165 | "-- The original file generated by lake is 'lakefile.original'." ; 166 | 167 | out 'def main : IO Unit :=' ' IO.println "Clean main!"' >| Main.lean || 168 | die "failed to create Main.lean" 169 | 170 | ### Personal choice: single file development by default. 171 | rm -rf -- "${pascal}.lean" "${pascal}" 172 | 173 | out "-- Directory clean; trying to build..." 174 | 175 | ## Try build 176 | 177 | lake build && 178 | ./.lake/build/bin/$* 179 | 180 | exit 181 | -------------------------------------------------------------------------------- /habiShell.vim: -------------------------------------------------------------------------------- 1 | " Vim color file 2 | " A version of nuvola.vim colorscheme, original by Dr. J. Pfefferl 3 | " I changed some colors and added some highlights for C and Vim 7 4 | 5 | " vim: tw=0 ts=4 sw=4 6 | " Maintainer: Christian Habermann 7 | " Email: christian( at )habermann-net( point )de 8 | " Version: 1.2 9 | " History: 1.2: nicer colors for paren matching 10 | " 1.1: Vim 7 support added (completion, spell checker, paren, tabs) 11 | " 1.0: initial version 12 | " 13 | " Intro {{{1 14 | set background=light 15 | hi clear 16 | if exists("syntax_on") 17 | syntax reset 18 | endif 19 | let g:colors_name = "habiShell" 20 | 21 | " Normal {{{1 22 | hi Normal ctermfg=black ctermbg=NONE guifg=black guibg=#F9F5F9 23 | 24 | " Search {{{1 25 | hi IncSearch cterm=UNDERLINE ctermfg=black ctermbg=229 gui=UNDERLINE guifg=Black guibg=#FFE568 26 | hi Search term=reverse cterm=UNDERLINE ctermfg=black ctermbg=229 gui=NONE guifg=Black guibg=#FFE568 27 | 28 | " Messages {{{1 29 | hi ErrorMsg gui=BOLD guifg=#EB1513 guibg=NONE 30 | hi! link WarningMsg ErrorMsg 31 | hi ModeMsg gui=BOLD guifg=#0070ff guibg=NONE 32 | hi MoreMsg guibg=NONE guifg=seagreen 33 | hi! link Question MoreMsg 34 | 35 | " Split area {{{1 36 | hi StatusLine term=BOLD,reverse cterm=NONE ctermfg=Yellow ctermbg=DarkGray gui=BOLD guibg=#56A0EE guifg=white 37 | hi StatusLineNC gui=NONE guibg=#56A0EE guifg=#E9E9F4 38 | hi! link VertSplit StatusLineNC 39 | hi WildMenu gui=UNDERLINE guifg=#56A0EE guibg=#E9E9F4 40 | 41 | " Diff {{{1 42 | hi DiffText gui=NONE guifg=#f83010 guibg=#ffeae0 43 | hi DiffChange gui=NONE guifg=#006800 guibg=#d0ffd0 44 | hi DiffDelete gui=NONE guifg=#2020ff guibg=#c8f2ea 45 | hi! link DiffAdd DiffDelete 46 | 47 | " Cursor {{{1 48 | hi Cursor gui=none guifg=black guibg=orange 49 | "hi lCursor gui=NONE guifg=#f8f8f8 guibg=#8000ff 50 | hi CursorIM gui=NONE guifg=#f8f8f8 guibg=#8000ff 51 | 52 | " Fold {{{1 53 | hi Folded gui=NONE guibg=#B5EEB5 guifg=black ctermfg=green ctermbg=NONE 54 | "hi FoldColumn gui=NONE guibg=#9FD29F guifg=black 55 | hi! link FoldColumn Folded 56 | 57 | " Other {{{1 58 | hi Directory gui=NONE guifg=#0000ff guibg=NONE 59 | hi LineNr gui=NONE guifg=#8080a0 guibg=NONE 60 | hi NonText gui=BOLD guifg=#4000ff guibg=#EFEFF7 61 | "hi SpecialKey gui=NONE guifg=#A35B00 guibg=NONE 62 | hi Title gui=BOLD guifg=#1014AD guibg=NONE 63 | hi Visual term=reverse ctermfg=yellow ctermbg=grey gui=NONE guifg=Black guibg=#BDDFFF 64 | hi VisualNOS term=reverse ctermfg=yellow ctermbg=grey gui=UNDERLINE guifg=Black guibg=#BDDFFF 65 | 66 | " Syntax group {{{1 67 | hi Comment term=BOLD ctermfg=darkgray guifg=darkcyan 68 | hi Constant term=UNDERLINE ctermfg=cyan guifg=#B91F49 69 | hi Error term=REVERSE ctermfg=15 ctermbg=9 guibg=Red guifg=White 70 | hi Identifier term=UNDERLINE ctermfg=Blue guifg=Blue 71 | hi Number term=UNDERLINE ctermfg=red gui=NONE guifg=#00C226 72 | hi PreProc term=UNDERLINE ctermfg=5 guifg=#1071CE 73 | hi Special term=BOLD ctermfg=1 guifg=red2 74 | hi Statement term=BOLD ctermfg=6 gui=NONE guifg=#F06F00 75 | hi Tag term=BOLD ctermfg=DarkGreen guifg=DarkGreen 76 | hi Todo term=STANDOUT ctermbg=Yellow ctermfg=blue guifg=Blue guibg=Yellow 77 | hi Type term=UNDERLINE ctermfg=6 gui=NONE guifg=Blue 78 | hi! link String Constant 79 | hi! link Character Constant 80 | hi! link Boolean Constant 81 | hi! link Float Number 82 | hi! link Function Identifier 83 | hi! link Conditional Statement 84 | hi! link Repeat Statement 85 | hi! link Label Statement 86 | hi! link Operator Statement 87 | hi! link Keyword Statement 88 | hi! link Exception Statement 89 | hi! link Include PreProc 90 | hi! link Define PreProc 91 | hi! link Macro PreProc 92 | hi! link PreCondit PreProc 93 | hi! link StorageClass Type 94 | hi! link Structure Type 95 | hi! link Typedef Type 96 | hi! link SpecialChar Special 97 | hi! link Delimiter Special 98 | hi! link SpecialComment Special 99 | hi! link Debug Special 100 | 101 | " HTML {{{1 102 | hi htmlLink gui=UNDERLINE guifg=#0000ff guibg=NONE 103 | hi htmlBold gui=BOLD 104 | hi htmlBoldItalic gui=BOLD,ITALIC 105 | hi htmlBoldUnderline gui=BOLD,UNDERLINE 106 | hi htmlBoldUnderlineItalic gui=BOLD,UNDERLINE,ITALIC 107 | hi htmlItalic gui=ITALIC 108 | hi htmlUnderline gui=UNDERLINE 109 | hi htmlUnderlineItalic gui=UNDERLINE,ITALIC 110 | 111 | " Tabs {{{1 112 | highlight TabLine term=underline cterm=underline ctermfg=0 ctermbg=7 gui=underline guibg=LightGrey 113 | highlight TabLineFill term=reverse cterm=reverse gui=reverse 114 | highlight TabLineSel term=bold cterm=bold gui=bold 115 | 116 | " Spell Checker {{{1 117 | if v:version >= 700 118 | highlight SpellBad term=reverse ctermfg=red ctermbg=NONE gui=undercurl guisp=Red 119 | highlight SpellCap term=reverse ctermfg=red ctermbg=NONE gui=undercurl guisp=Blue 120 | highlight SpellRare term=reverse ctermfg=red ctermbg=NONE gui=undercurl guisp=Magenta 121 | highlight SpellLocale term=underline ctermbg=11 gui=undercurl guisp=DarkCyan 122 | endif 123 | 124 | " Completion {{{1 125 | highlight Pmenu ctermbg=11 guifg=Black guibg=#BDDFFF 126 | highlight PmenuSel ctermbg=3 guifg=Black guibg=Orange 127 | highlight PmenuSbar ctermbg=3 guifg=#CCCCCC guibg=#CCCCCC 128 | highlight PmenuThumb cterm=reverse gui=reverse guifg=Black guibg=#AAAAAA 129 | 130 | " Misc {{{1 131 | highlight KDE guifg=magenta gui=NONE 132 | highlight mySpecialSymbols guifg=magenta gui=NONE 133 | 134 | 135 | highlight MatchParen term=reverse ctermbg=11 gui=bold guibg=#B5EEB5 guifg=black 136 | 137 | 138 | " vim600:foldmethod=marker 139 | hi VertSplit ctermbg=230 ctermfg=230 140 | "hi VertSplit guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE 141 | -------------------------------------------------------------------------------- /vim/UltiSnips/sh.snippets: -------------------------------------------------------------------------------- 1 | priority 0 2 | 3 | snippet copyright "Copyright notice and license" b 4 | # © `date +%Y` [COPYRIGHT HOLDER]. All rights reserved. 5 | # 6 | # This program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of 9 | # the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License along with this program. If not, see 18 | # . 19 | endsnippet 20 | 21 | snippet [ "test in bracket mode" 22 | [ ${1:${VISUAL:condition}} ] 23 | endsnippet 24 | 25 | snippet $( "Subshell" iA 26 | \$( $0 ) 27 | endsnippet 28 | 29 | snippet (( "arithmetic expression" iA 30 | "\$(( $0 ))" 31 | endsnippet 32 | 33 | snippet "(\w+)\$\$" "variable" rA 34 | "\$\{`!p snip.rv = match.group(1)`\}" 35 | endsnippet 36 | 37 | snippet "(\w+)@\$" "expanded variable" rA 38 | \$\{`!p snip.rv = match.group(1)`\} 39 | endsnippet 40 | 41 | snippet $$ "variable" A 42 | "\$\{$0\}" 43 | endsnippet 44 | 45 | snippet @$ "expanded variable" iA 46 | \$\{$0\} 47 | endsnippet 48 | 49 | snippet "(\w+)@@" "function" rA 50 | `!p snip.rv = match.group(1)`() 51 | { 52 | $0 53 | } 54 | endsnippet 55 | 56 | snippet date "Date format" w 57 | date +"Date: %A, %d of %B, %Y. Time: %T %Z." 58 | endsnippet 59 | 60 | snippet << "Heredoc" iA 61 | <<-'${1:${VISUAL}}' 62 | $0 63 | $1 64 | endsnippet 65 | 66 | snippet ?? "Ternary expression" A 67 | \$(( ${1:CONDITION} ? ${2:TRUE} : ${3:FALSE} ))$0 68 | endsnippet 69 | 70 | snippet find "Find template" b 71 | find -H "${1:${VISUAL:\${PWD}}}" \ 72 | ${2:! -name "$1"} \ 73 | -${3:DEPTH_OR_PRUNE} \ 74 | -type "${4:FILETYPE}" \ 75 | -path "${5:PATH_PATTERNS}" \ 76 | -name "${6:FILE_PATTERNS}" \ 77 | -o -name "${7:$2}" \ 78 | ! -name "${8:NEG_PATTERNS}" \ 79 | -perm "${9:MODES}" \ 80 | -user "${10:USERNAME}" -group "${11:GROUPNAME}" \ 81 | -size "${12:BLOCKS_OR_cHARS}" \ 82 | -atime "${13:ACCESS_TIME_AFTER_INIT}" \ 83 | -ctime "${14:CHANGE_TIME_AFTER_INIT}" \ 84 | -mtime "${15:MODIF_TIME_AFTER_INIT}" \ 85 | -newer "${16:COMPARISON_FILE}" \ 86 | -links "${17:NUMBER_OF_LINKS}" \ 87 | -exec "${18:SINGLE_EXEC}" \; \ 88 | -exec "${19:BATCH_EXEC}" {} + \ 89 | -print ; 90 | endsnippet 91 | 92 | snippet ps "ps template" b 93 | ps \ 94 | -a "${1:ALL_TERMINAL_PROCS}" \ 95 | -A "${2:ALL_PROCS}" \ 96 | -U "${3:USERLIST}" \ 97 | -G "${4:GROUPLIST}" \ 98 | -p "${5:PROCIDLIST}" \ 99 | -t "${6:TERMINALLIST}" \ 100 | -o ${0:PSOUT} ; 101 | endsnippet 102 | 103 | snippet psout "ps output entries" 104 | "pid user group tty time etime nice pcpu vsz cmd" 105 | endsnippet 106 | 107 | snippet stdin "stdin" w 108 | /dev/stdin 109 | endsnippet 110 | 111 | snippet stdout "stdout" w 112 | /dev/stdout 113 | endsnippet 114 | 115 | snippet stderr "stderr" w 116 | /dev/stderr 117 | endsnippet 118 | 119 | snippet >x "redirect to dev/null" w 120 | >/dev/null 121 | endsnippet 122 | 123 | snippet >> "redirect stderr to out" 124 | 2>&1 125 | endsnippet 126 | 127 | snippet >>x "trash outputs" 128 | >/dev/null 2>&1 129 | endsnippet 130 | 131 | snippet '' "single quotes" A 132 | '$0' 133 | endsnippet 134 | 135 | snippet "" "double quotes" A 136 | "$0" 137 | endsnippet 138 | 139 | snippet "([^=\s]+)''" "single quotes" Ar 140 | '`!p snip.rv = match.group(1)`' 141 | endsnippet 142 | 143 | snippet "([^=\s]+)\"\"" "double quotes" Ar 144 | "`!p snip.rv = match.group(1)`" 145 | endsnippet 146 | 147 | snippet XP "Excise variable prefix" 148 | "\$\{${VISUAL}##*${0:PRESUF}\}" 149 | endsnippet 150 | 151 | snippet XS "Excise variable suffix" 152 | "\$\{${VISUAL}%%${0:SUFPRE}*\}" 153 | endsnippet 154 | 155 | snippet ifi "small one-line if" A 156 | if ${1:CONDITION}; then ${0:ACTION}; fi 157 | endsnippet 158 | 159 | snippet csc "small one-line case" A 160 | case ${1:VARIABLE} in ${2:PATTERN}) ${0:ACTION};; esac 161 | endsnippet 162 | 163 | snippet "(\w+):\((.+)\)->\((.+)\)" "simple case" r 164 | case "\$\{`!p snip.rv = match.group(1)`\}" in `!p snip.rv = match.group(2)`) `!p snip.rv = match.group(3)` ;; 165 | endsnippet 166 | 167 | snippet while "while loop" b 168 | while ${1:CONDITIONAL}; 169 | do 170 | $0 171 | done 172 | endsnippet 173 | 174 | snippet for "for loop" b 175 | for ${1:VARNAME} in ${2:ARRAY}; 176 | do 177 | $0 178 | done 179 | endsnippet 180 | 181 | snippet if "if clause" b 182 | if ${1:CONDITION}; 183 | then 184 | ${2:ACTION} 185 | fi 186 | endsnippet 187 | 188 | snippet case "case clause" b 189 | case ${1:VARIABLE} in 190 | ${2:PATTERN}) ${3:ACTION} ;; 191 | esac 192 | endsnippet 193 | 194 | snippet usage "Docopt compatible usage function" b 195 | usage() 196 | { 197 | cat <<-USAGESTRING 198 | ${1:UTILITY_NAME} 199 | 200 | Usage: 201 | ${2:$1} new ... 202 | ${3:$1} [-s ] ship move 203 | ${4:$1} -h|-u 204 | ${5:$1} -v 205 | 206 | Options: 207 | -h|-u Show this screen and exit. 208 | -v Print version and exit. 209 | -s knots Speed in knots [default: 10]. 210 | USAGESTRING 211 | } 212 | endsnippet 213 | 214 | snippet getopts "getopts pattern" b 215 | while getopts ":e:huv" option 216 | do 217 | case "${option}" in 218 | e) echo "$OPTARG" ;; 219 | h|u) echo usage ; exit ;; 220 | v) echo version 1.0 ; exit ;; 221 | :) echo 'missing argument' ;; 222 | ?) exit 1 ;; 223 | esac 224 | done 225 | shift "$((OPTIND - 1))" 226 | endsnippet 227 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | " Activate syntax highlighting 2 | syntax on 3 | 4 | " Activate filetype plugin 5 | filetype plugin on 6 | 7 | " ~/.vim/pack/vendor/start/{FastFold,fzf,fzf.vim,goyo.vim,limelight.vim, \ 8 | " traces.vim,ultisnips,vim-easy-align,vim-easymotion,vim-fugitive,vim-pencil, \ 9 | " vim-sandwich,vimtex} 10 | " 11 | " ~/.vim/pack/vendor/opt/unicode.vim 12 | 13 | " set defaults 14 | set nocompatible " turn off vi compatibility mode 15 | set history=5000 " keep 5000 lines of command line history 16 | set ruler " show the cursor position all the time 17 | set showcmd " display incomplete commands 18 | set incsearch " enable incremental searching 19 | set number " enable line numbers 20 | set rnu " set relative line numbers 21 | set encoding=utf8 " set utf8 encoding 22 | set textwidth=100 " set text width to 100 chars 23 | set nowrapscan " do not loop back to beginning when scanning 24 | set winaltkeys=no " do not capture alt keys 25 | set laststatus=2 " always show statusline 26 | set noswapfile " ban swapfiles 27 | set tabstop=4 " set four spaces per tab 28 | set shiftwidth=4 " set indent width to 4 29 | set linebreak " line breaks are a must 30 | set hlsearch " Activate highlight search 31 | set ttimeoutlen=100 " Set small timeout 32 | set timeoutlen=500 " Set small timeout 33 | set fillchars+=fold:\. " Make fold demarcations pretty 34 | set autochdir " automatically change pwd to current file 35 | set spelllang=en,el " set global spelling languages 36 | set fillchars+=vert:\ " Trailing space; make invisible 37 | set fillchars+=vert:\║ " pretty separators 38 | set fillchars+=stl:═ " pretty separators 39 | set fillchars+=stlnc:═ " pretty separators 40 | set fillchars+=eob:\. " pretty separators 41 | set belloff=all " shut up for the love of fuck 42 | set nobackup " do not keep a backup file 43 | set undofile " keep an undo file (undo changes after closing) 44 | set background=light " set light preference 45 | set backspace=indent,eol,start " Enable familiar backspace settings 46 | set t_RB= t_RF= t_RV= t_u7= 47 | 48 | " Cursor switching between normal and insert modes 49 | let &t_SI = "\e[6 q" 50 | let &t_EI = "\e[2 q" 51 | 52 | " Mouse settings 53 | if has('mouse') 54 | set mouse=a 55 | endif 56 | 57 | " Diff settings for viewing file changes 58 | if !exists(":DiffOrig") 59 | command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis 60 | \ | wincmd p | diffthis 61 | endif 62 | 63 | "Compatibility check 64 | if has('langmap') && exists('+langnoremap') 65 | set langnoremap 66 | endif 67 | 68 | if has("autocmd") 69 | augroup vimrcExecute 70 | autocmd! 71 | autocmd! BufReadPost * 72 | \ if line("'\"") >= 1 && line("'\"") <= line("$") | 73 | \ exe "normal! g`\"" | 74 | \ endif 75 | 76 | " Turn on tex settings for lit files 77 | autocmd! BufNewFile,BufRead *.lit setfiletype tex 78 | 79 | "Re-source vimrc files on write 80 | autocmd! BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif 81 | 82 | augroup END 83 | endif 84 | 85 | " Commands 86 | command! C let @/ = "" " Clear highlighting 87 | command! Hidetab set nolist " Hide all list markers 88 | command! Showtab set list | set listchars=eol:·,tab:⍿·,trail:× " Show tabs and other markers 89 | 90 | " Default UltiSnips folder 91 | let g:UltiSnipsSnippetDirectories = [$HOME.'/.vim/UltiSnips'] 92 | 93 | " Keybindings for UltiSnips 94 | let g:UltiSnipsExpandTrigger = "" 95 | let g:UltiSnipsJumpForwardTrigger = "" 96 | let g:UltiSnipsJumpBackwardTrigger = "" 97 | let g:UltiSnipsEditSplit = "vertical" 98 | 99 | " Custom colorscheme 100 | colorscheme habiShell 101 | 102 | " Transparent Statusline and separators 103 | hi StatusLine cterm=NONE ctermfg=NONE ctermbg=NONE 104 | hi StatusLineNC cterm=NONE ctermfg=NONE ctermbg=NONE 105 | hi StatusLineTerm cterm=NONE ctermfg=NONE ctermbg=NONE 106 | hi StatusLineTermNC cterm=NONE ctermfg=NONE ctermbg=NONE 107 | hi VertSplit cterm=NONE ctermfg=NONE ctermbg=NONE 108 | 109 | " Toggle relative numbers 110 | function! NumberToggle() 111 | if(&relativenumber == 1) 112 | set rnu! 113 | else 114 | set rnu 115 | endif 116 | endfunc 117 | 118 | "Toggle vertical centering of cursor 119 | function! ScrollOffToggle() 120 | if(&scrolloff == 999) 121 | set scrolloff=0 122 | else 123 | set scrolloff=999 124 | endif 125 | endfunc 126 | 127 | " Color for out of focus sections with limelight 128 | let g:limelight_conceal_ctermfg = 'gray' 129 | 130 | " Regex for limelight to include % demarcations 131 | let g:limelight_bop = '\(^\s*$\n\|^\s*%$\n\)\zs' 132 | let g:limelight_eop = '\ze\(^$\|^\s*%$\)' 133 | 134 | " hi priority limelight 135 | let g:limelight_priority = -1 136 | 137 | " goyo 1 + textwidth 138 | let g:goyo_width = 1 + &textwidth 139 | 140 | set statusline= 141 | set statusline+=%#LineNr# 142 | set statusline+=═ 143 | set statusline+=═╡\ %f\ ╞═ 144 | set statusline+=%m 145 | set statusline+=%=╡ 146 | set statusline+=\ %y 147 | set statusline+=\ %{&fileencoding?&fileencoding:&encoding} 148 | set statusline+=\[%{&fileformat}\] 149 | set statusline+=\ %p%% 150 | set statusline+=\ %l:%c 151 | set statusline+=\ ╞══ 152 | 153 | " Preformatting and window styling for comfy typing. 154 | noremap :Goyo 155 | noremap :call ScrollOffToggle() 156 | noremap :Limelight!! 157 | "noremap gg49OG49o50% 158 | 159 | "Make CTRL-B insert word in dictionary; useful. 160 | inoremap u[s1zg``au 161 | 162 | " Set CTRL-F to correct last spelling mistake 163 | " with independent undo from the rest of the document. 164 | imap u[s1z=`]au 165 | nmap [s1z= 166 | 167 | xmap ga (EasyAlign) " Start interactive EasyAlign in visual mode (e.g. vipga) 168 | nmap ga (EasyAlign) " Start interactive EasyAlign for a motion/text object (e.g. gaip) 169 | 170 | " Comfortable easymotion binding 171 | nmap (easymotion-bd-W) 172 | 173 | " Fold motions using arrow keys 174 | nnoremap z zj 175 | nnoremap z zk 176 | 177 | " Insert newlines without leaving normal mode 178 | nnoremap oo o 179 | nnoremap OO Oj 180 | 181 | " Quick Unicode insert with ctrl-shift-u 182 | " This should probably be replaced with 183 | " a table-menu-style plugin. 184 | inoremap u 185 | -------------------------------------------------------------------------------- /vim/UltiSnips/tex.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | extends texmath 4 | 5 | global !p 6 | 7 | texMathZones = ['texMathRegion' + x for x in ['', 'X', 'XX', 'Env', 'EnvStarred', 'Ensured']] 8 | texIgnoreMathZones = ['texMathTextArg'] 9 | 10 | texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')") 11 | texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')") 12 | 13 | ignore = texIgnoreMathZoneIds[0] 14 | 15 | def math(): 16 | synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))") 17 | try: 18 | first = next(i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds) 19 | return first != ignore 20 | except StopIteration: 21 | return False 22 | 23 | def create_table(snip): 24 | rows = snip.buffer[snip.line].split('x')[0] 25 | cols = snip.buffer[snip.line].split('x')[1] 26 | 27 | int_val = lambda string: int(''.join(s for s in string if s.isdigit())) 28 | 29 | rows = int_val(rows) 30 | cols = int_val(cols) 31 | 32 | offset = cols + 1 33 | old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1] 34 | 35 | snip.buffer[snip.line] = '' 36 | 37 | final_str = old_spacing + "\\begin{tabular}{|" + "|".join(['$' + str(i + 1) for i in range(cols)]) + "|}\n" 38 | 39 | for i in range(rows): 40 | final_str += old_spacing + '\t' 41 | final_str += " & ".join(['$' + str(i * cols + j + offset) for j in range(cols)]) 42 | 43 | final_str += " \\\\\\\n" 44 | 45 | final_str += old_spacing + "\\end{tabular}\n$0" 46 | 47 | snip.expand_anon(final_str) 48 | 49 | def create_matrix_n(snip): 50 | mac = re.search('(\w)mat(\d+)x(\d+)', snip.buffer[snip.line]) 51 | mc = mac.group(1) 52 | rows = int(mac.group(2)) 53 | cols = int(mac.group(3)) 54 | 55 | offset = cols + 1 56 | old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1] 57 | 58 | 59 | final_str = snip.buffer[snip.line][0:-len(mac.group(0))] + "\\begin{" + mc + "matrix}\n" 60 | 61 | 62 | snip.buffer[snip.line] = '' 63 | for i in range(rows): 64 | final_str += old_spacing + '\t' 65 | final_str += " & ".join(['$' + str(i * cols + j + offset) for j in range(cols)]) 66 | 67 | final_str += " \\\\\\\n" 68 | 69 | final_str += old_spacing + "\\end{" + mc + "matrix}$0" 70 | 71 | snip.expand_anon(final_str) 72 | 73 | 74 | def create_diag_n(snip): 75 | mac = re.search('diagram(\d+)x(\d+)', snip.buffer[snip.line]) 76 | 77 | rows = int(mac.group(1)) 78 | cols = int(mac.group(2)) 79 | 80 | offset = cols + 1 81 | old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1] 82 | 83 | final_str = snip.buffer[snip.line][0:-len(mac.group(0))] + "\\begin{tikzcd}\n" 84 | 85 | seprr = " &\n"+old_spacing + '\t' 86 | sepll = " &\n" + old_spacing + '\t' + "$" 87 | sepr = " & " 88 | sepl = " & $" 89 | snip.buffer[snip.line] = '' 90 | for i in range(rows-1): 91 | final_str += old_spacing + '\t ' 92 | final_str += seprr.join([('$' + str(i * cols + j + offset)\ 93 | +' \\arrow{r}{$'+str((cols+1)*(rows+1) + i*cols + j + offset)\ 94 | +'} \\arrow[swap]{d}{$'+str((cols+1)*(rows+1)*(cols+1)*(rows+1)+(cols+1)*(rows+1)+ i*cols+j+offset)+'}')\ 95 | for j in range(cols-1)]) 96 | final_str = final_str + sepll + str(i*cols + cols-1 + offset)\ 97 | +' \\arrow[swap]{d}{$'+str( (cols+1)*(rows+1)*(cols+1)*(rows+1)+ (cols+1)*(rows+1)+ (i+1)*cols-1+offset)+'}' 98 | final_str += " \\\\\\\n" 99 | 100 | final_str += old_spacing + '\t' 101 | final_str += seprr.join([('$' + str(rows * cols + j + offset)\ 102 | +' \\arrow{r}{$'+str((cols+1)*(rows+1) + rows*cols + j + offset)\ 103 | +'}')\ 104 | for j in range(cols-1)]) 105 | final_str = final_str + sepll + str(rows*cols + cols-1 + offset) 106 | final_str += " \\\\\\\n" 107 | 108 | final_str += old_spacing + "\\end{tikzcd}$0" 109 | 110 | snip.expand_anon(final_str) 111 | 112 | def add_row(snip): 113 | row_len = int(''.join(s for s in snip.buffer[snip.line] if s.isdigit())) 114 | old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1] 115 | 116 | snip.buffer[snip.line] = '' 117 | 118 | final_str = old_spacing 119 | final_str += " & ".join(['$' + str(j + 1) for j in range(row_len)]) 120 | final_str += " \\\\\\" 121 | 122 | snip.expand_anon(final_str) 123 | 124 | def create_std_hor_vector_n(snip): 125 | tac = re.search('vec(\d+)', snip.buffer[snip.line]) 126 | entries = int(tac.group(1)) 127 | pieces = snip.buffer[snip.line].split(tac.group(0)) 128 | final_str = pieces[0] + "( " 129 | snip.buffer[snip.line] = '' 130 | final_str += " , ".join(['$' + str(j+1) for j in range(entries)]) 131 | final_str += " ) $0 " + pieces[1] 132 | snip.expand_anon(final_str) 133 | 134 | def create_std_vert_vector_n(snip): 135 | tac = re.search('(\w+)vecv(\d+)', snip.buffer[snip.line]) 136 | tok = tac.group(1) 137 | entries = int(tac.group(2)) 138 | pieces = snip.buffer[snip.line].split(tac.group(0)) 139 | snip.buffer[snip.line] = '' 140 | final_str = pieces[0] + "\\begin{"+tok+"matrix} $1 \\\\\\\\ " 141 | final_str += " \\\\\\\\ ".join(['$' + str(j+2) for j in range(entries-1)]) 142 | final_str += " \\end{"+tok+"matrix} $0 " + pieces[1] 143 | snip.expand_anon(final_str) 144 | 145 | def create_mod_n(snip): 146 | tac = re.search('mod(\d+)', snip.buffer[snip.line]) 147 | entries = int(tac.group(1)) 148 | pieces = snip.buffer[snip.line].split(tac.group(0)) 149 | snip.buffer[snip.line] = '' 150 | final_str = pieces[0] + '\\begin{align}\n' 151 | final_str += \ 152 | "\\\\\\\\\n".join([pieces[0]+'\t$' + str(2*(j+1)) + ' \\equiv $' + str(2*(j+1)+1) \ 153 | + '\\pmod{$1}' for j in range(entries)]) 154 | final_str += '\n' + pieces[0] + '\\end{align}' + pieces[1] 155 | snip.expand_anon(final_str) 156 | 157 | endglobal 158 | 159 | snippet copyright "Copyright notice and license" b 160 | % © `date +%Y` [COPYRIGHT HOLDER]. All rights reserved. 161 | % 162 | % This program is free software: you can redistribute it and/or 163 | % modify it under the terms of the GNU General Public License as 164 | % published by the Free Software Foundation, either version 3 of 165 | % the License, or (at your option) any later version. 166 | % 167 | % This program is distributed in the hope that it will be useful, 168 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 169 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 170 | % GNU General Public License for more details. 171 | % 172 | % You should have received a copy of the GNU General Public 173 | % License along with this program. If not, see 174 | % . 175 | endsnippet 176 | 177 | snippet "b(egin)?" "begin{} / end{}" br 178 | \begin{${1:something}} 179 | ${0:${VISUAL}} 180 | \end{$1} 181 | endsnippet 182 | 183 | snippet abst "abstract environment" b 184 | \begin{abstract} 185 | $0 186 | \end{abstract} 187 | endsnippet 188 | 189 | snippet tab "tabular / array environment" b 190 | \begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}} 191 | $3${2/(?<=.)(c|l|r)|./(?1: & )/g} 192 | \end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} 193 | endsnippet 194 | 195 | pre_expand "create_table(snip)" 196 | snippet "tabular(\d+)x(\d+)" "Generate table of *width* by *height*" r 197 | endsnippet 198 | 199 | pre_expand "create_mod_n(snip)" 200 | snippet "mod(\d+)" "Modulo list" rb 201 | endsnippet 202 | 203 | pre_expand "create_matrix_n(snip)" 204 | snippet "(\w)mat(\d+)x(\d+)" "Generate matrix of *width* by *height*" rb 205 | endsnippet 206 | 207 | pre_expand "create_diag_n(snip)" 208 | snippet "diagram(\d+)x(\d+)" "Generate diagram of *width* by *height*" rb 209 | endsnippet 210 | 211 | 212 | pre_expand "create_std_hor_vector_n(snip)" 213 | snippet "vec(\d+)" "Generate vector with d entries" r 214 | endsnippet 215 | 216 | pre_expand "create_std_vert_vector_n(snip)" 217 | snippet "(\w+)vecv(\d+)" "Generate vertical vector with d entries" r 218 | endsnippet 219 | 220 | pre_expand "add_row(snip)" 221 | snippet "tr(\d+)" "Add table row of dimension ..." r 222 | endsnippet 223 | 224 | snippet table "Table environment" b 225 | \begin{table}[${1:htpb}] 226 | \centering 227 | \caption{${2:caption}} 228 | \label{tab:${3:label}} 229 | \begin{${4:t}${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${5:c}} 230 | $6${5/(?<=.)(c|l|r)|./(?1: & )/g} 231 | \end{$4${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} 232 | \end{table} 233 | endsnippet 234 | 235 | snippet fig "Figure environment" b 236 | \begin{figure}[${2:htpb}] 237 | \centering 238 | \includegraphics 239 | [width=${3:0.8}\linewidth] 240 | {${4:name.ext}} 241 | \caption{${4/(\w+)\.\w+/\u$1/}$5} 242 | \label{fig:${4/(\w+)\.\w+/$1/}} 243 | \end{figure} 244 | endsnippet 245 | 246 | snippet enum "Enumerate" b 247 | \begin{enumerate} 248 | \item $0 249 | \end{enumerate} 250 | endsnippet 251 | 252 | snippet item "Itemize" b 253 | \begin{itemize} 254 | \item $0 255 | \end{itemize} 256 | endsnippet 257 | 258 | snippet desc "Description" b 259 | \begin{description} 260 | \item[$1] $0 261 | \end{description} 262 | endsnippet 263 | 264 | snippet it "Individual item" b 265 | \item $0 266 | endsnippet 267 | 268 | snippet part "Part" b 269 | \part{${1:part name}}% 270 | \label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}} 271 | 272 | $0 273 | endsnippet 274 | 275 | snippet cha "Chapter" b 276 | \chapter{${1:chapter name}}% 277 | \label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 278 | 279 | $0 280 | endsnippet 281 | 282 | snippet sec "Section" 283 | \section{${1:${VISUAL:section name}}}% 284 | \label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 285 | 286 | $0 287 | endsnippet 288 | 289 | snippet sec* "Section" 290 | \section*{${1:${VISUAL:section name}}}% 291 | \label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 292 | 293 | $0 294 | endsnippet 295 | 296 | 297 | snippet ssec "Subsection" 298 | \subsection{${1:${VISUAL:subsection name}}}% 299 | \label{sub:${0:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 300 | endsnippet 301 | 302 | snippet ssec* "Subsection" 303 | \subsection*{${1:${VISUAL:subsection name}}}% 304 | \label{sub:${0:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 305 | endsnippet 306 | 307 | snippet sssec "Subsubsection" 308 | \subsubsection{${1:${VISUAL:subsubsection name}}}% 309 | \label{ssub:${0:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 310 | endsnippet 311 | 312 | snippet sssec* "Subsubsection" 313 | \subsubsection*{${1:${VISUAL:subsubsection name}}}% 314 | \label{ssub:${0:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 315 | endsnippet 316 | 317 | snippet par "Paragraph" 318 | \paragraph{${1:${VISUAL:paragraph name}}}% 319 | \label{par:${0:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 320 | endsnippet 321 | 322 | snippet spar "Subparagraph" 323 | \subparagraph{${1:${VISUAL:subparagraph name}}}% 324 | \label{par:${0:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 325 | endsnippet 326 | 327 | snippet cases "Multi-line definition" b 328 | ${1:OBJECT} = 329 | \begin{cases} 330 | ${2:DEFINITION} & ${3:CONDITION} \\\ 331 | ${4:DEFINITION} & ${0:CONDITION} 332 | \end{cases} 333 | endsnippet 334 | 335 | snippet ac "Acroynm normal" b 336 | \ac{${1:acronym}} 337 | $0 338 | endsnippet 339 | 340 | snippet acl "Acroynm expanded" b 341 | \acl{${1:acronym}} 342 | $0 343 | endsnippet 344 | 345 | snippet pac "Package" b 346 | \usepackage`!p snip.rv='[' if t[1] else ""`${1:options}`!p snip.rv = ']' if t[1] else ""`{${2:package}} 347 | endsnippet 348 | 349 | snippet ( "Long parenthesis with single symbol" 350 | \left(${1:${VISUAL:contents}}\right)$0 351 | endsnippet 352 | 353 | snippet "mint(ed)?( (\S+))?" "Minted code typeset" br 354 | \begin{listing} 355 | \begin{minted}[linenos,numbersep=5pt,frame=lines,framesep=2mm]{${1:`!p 356 | snip.rv = match.group(3) if match.group(2) is not None else "language"`}} 357 | ${2:${VISUAL:code}} 358 | \end{minted} 359 | \caption{${3:caption name}} 360 | \label{lst:${4:${3/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 361 | \end{listing} 362 | 363 | $0 364 | endsnippet 365 | # vim:ft=snippets: 366 | snippet | "Paired verticals" b 367 | \left\vert 368 | $0 369 | \right\vert 370 | endsnippet 371 | 372 | snippet (( "Paired parens" b 373 | \left( 374 | $0 375 | \right) 376 | endsnippet 377 | 378 | snippet [[ "Paired brackets" b 379 | \left[ 380 | $0 381 | \right] 382 | endsnippet 383 | 384 | snippet {{ "Paired curly brackets" b 385 | \left\\{ 386 | $0 387 | \right\\} 388 | endsnippet 389 | 390 | snippet dx "Integration element" w 391 | \,\mrm{d}{$0} 392 | endsnippet 393 | 394 | snippet _^ "Sub/superscript" iA 395 | _{$1}^{$0} 396 | endsnippet 397 | 398 | snippet Ix "Full integral" 399 | \int$2 400 | $0 401 | \,\mathrm{d}{$1} 402 | endsnippet 403 | 404 | snippet I "Single integral" 405 | \int 406 | endsnippet 407 | 408 | snippet II "Double integral" 409 | \iint 410 | endsnippet 411 | 412 | snippet III "Triple integral" 413 | \iiint 414 | endsnippet 415 | 416 | snippet OI "Line integral" 417 | \oint 418 | endsnippet 419 | 420 | snippet \- "setminus" i 421 | \setminus 422 | endsnippet 423 | 424 | snippet -\ "back slash quotient" i 425 | \backslash 426 | endsnippet 427 | 428 | snippet |x "Semidirect product" i 429 | \ltimes 430 | endsnippet 431 | 432 | snippet x| "Semidirect product" i 433 | \rtimes 434 | endsnippet 435 | 436 | snippet xx "small product" wA 437 | \times 438 | endsnippet 439 | 440 | context "math()" 441 | snippet ox "Direct product, small" wA 442 | \otimes 443 | endsnippet 444 | 445 | snippet Ox "Direct product, big" wA 446 | \bigotimes 447 | endsnippet 448 | 449 | snippet o. "Direct dot, small" wA 450 | \odot 451 | endsnippet 452 | 453 | snippet Ox "Direct dot, big" wA 454 | \bigodot 455 | endsnippet 456 | 457 | snippet o+ "Direct sum, small" wA 458 | \oplus 459 | endsnippet 460 | 461 | snippet O+ "Direct sum, large" wA 462 | \bigoplus 463 | endsnippet 464 | 465 | snippet vv "vee" wA 466 | \vee 467 | endsnippet 468 | 469 | snippet VV "big vee" wA 470 | \bigvee 471 | endsnippet 472 | 473 | snippet WW "big wedge" wA 474 | \bigwedge 475 | endsnippet 476 | 477 | snippet ww "wedge" wA 478 | \wedge 479 | endsnippet 480 | 481 | snippet "B((\\)?\w+)" "Bold math" wr 482 | \mathbf{`!p snip.rv = match.group(1)`} 483 | endsnippet 484 | 485 | snippet "\*(.+)\*" "Emphasis" wr 486 | \emph{`!p snip.rv = match.group(1)`} 487 | endsnippet 488 | 489 | snippet subst "Underline with substack" w 490 | _{\substack{ 491 | $1 \\\\\\\\ 492 | $0 }} 493 | endsnippet 494 | 495 | snippet lfl "Floor" wA 496 | \lfloor $0 \rfloor 497 | endsnippet 498 | 499 | snippet lcl "Ceiling" wA 500 | \lceil $0 \rceil 501 | endsnippet 502 | 503 | snippet .... "Dots" iA 504 | \ldots 505 | endsnippet 506 | 507 | snippet *.. "Dots" iA 508 | \cdots 509 | endsnippet 510 | 511 | snippet |.. "Vertical dots" iA 512 | \vdots 513 | endsnippet 514 | snippet \.. "Diagonal dots" iA 515 | \ddots 516 | endsnippet 517 | 518 | snippet ^! "Dagger" iA 519 | \dagger 520 | endsnippet 521 | 522 | snippet binom "Binomial coefficient" 523 | \binom{$1}{$0} 524 | endsnippet 525 | 526 | snippet Binom "Large Binomial coefficient" 527 | \binom {$1} 528 | {$0} 529 | endsnippet 530 | 531 | snippet ^ "Hat" w 532 | \hat{$0} 533 | endsnippet 534 | 535 | snippet ^w "Widehat" w 536 | \widehat{$0} 537 | endsnippet 538 | 539 | snippet "([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])\^" "hat" r 540 | \hat{`!p snip.rv = match.group(1)`} 541 | endsnippet 542 | 543 | snippet "([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])\^w" "widehat" rA 544 | \widehat{`!p snip.rv = match.group(1)`} 545 | endsnippet 546 | 547 | snippet ^. "Dot" 548 | \dot{$0} 549 | endsnippet 550 | 551 | snippet ^- "Bar" 552 | \bar{$0} 553 | endsnippet 554 | 555 | snippet ^-- "Overline" i 556 | \overline{$0} 557 | endsnippet 558 | 559 | snippet "([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])\^-" "bar" ri 560 | \overline{`!p snip.rv = match.group(1)`} 561 | endsnippet 562 | 563 | snippet "([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])\^--" "overline" rA 564 | \overline{`!p snip.rv = match.group(1)`} 565 | endsnippet 566 | 567 | snippet ^~~ "Widetilde" w 568 | \widetilde{$0} 569 | endsnippet 570 | 571 | snippet "([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])\^~~" "wide tilde" rA 572 | \widetilde{`!p snip.rv = match.group(1)`} 573 | endsnippet 574 | 575 | snippet "([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])\^~" "tilde" r 576 | \tilde{`!p snip.rv = match.group(1)`} 577 | endsnippet 578 | 579 | snippet ^-> "Vector" w 580 | \vec{$0} 581 | endsnippet 582 | 583 | snippet "([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])\^-\>" "vector" rA 584 | \vec{`!p snip.rv = match.group(1)`} 585 | endsnippet 586 | 587 | snippet "\:(\S+)-\|(\S+)\:" "Note over relation" irA 588 | \overset{`!p snip.rv = match.group(1)`}{`!p snip.rv = match.group(2)`} 589 | endsnippet 590 | 591 | snippet "\:(\S+)\|-(\S+)\:" "Note under relation" irA 592 | \underset{`!p snip.rv = match.group(2)`}{`!p snip.rv = match.group(1)`} 593 | endsnippet 594 | 595 | snippet "\:(\S+)\{\|(\S+)\:" "Note over bracket" irA 596 | \overbrace{`!p snip.rv = match.group(2)`}^{`!p snip.rv = match.group(1)`} 597 | endsnippet 598 | 599 | snippet "\:(\S+)\|\}(\S+)\:" "Note under bracket" irA 600 | \underbrace{`!p snip.rv = match.group(1)`}_{`!p snip.rv = match.group(2)`} 601 | endsnippet 602 | 603 | snippet ~ "asymptotic" 604 | \sim 605 | endsnippet 606 | 607 | snippet ~- "equivalence" iA 608 | \simeq 609 | endsnippet 610 | 611 | snippet )( "same order" 612 | \asymp 613 | endsnippet 614 | 615 | snippet ~= "congruence" iA 616 | \cong 617 | endsnippet 618 | 619 | snippet -= "equivalence" iA 620 | \equiv 621 | endsnippet 622 | 623 | snippet ! "Negation" i 624 | \not 625 | endsnippet 626 | 627 | snippet stackr "Stacked relations" wA 628 | \stackrel{$1}{$0} 629 | endsnippet 630 | 631 | snippet [] "Bracket" iA 632 | [$0] 633 | endsnippet 634 | 635 | snippet {} "Curly" iA 636 | {$0} 637 | endsnippet 638 | 639 | snippet () "Parens" iA 640 | ($0) 641 | endsnippet 642 | 643 | snippet -> "arrow" wA 644 | \rightarrow 645 | endsnippet 646 | 647 | snippet => "thick arrow" iA 648 | \Rightarrow 649 | endsnippet 650 | 651 | snippet <- "left arrow" 652 | \leftarrow 653 | endsnippet 654 | 655 | snippet <= "left thick arrow" 656 | \Leftarrow 657 | endsnippet 658 | 659 | snippet <-> "bi arrow" iA 660 | \leftrightarrow 661 | endsnippet 662 | 663 | snippet <=> "bi arrow" iA 664 | \Leftrightarrow 665 | endsnippet 666 | 667 | snippet --> "long arrow" iA 668 | \longrightarrow 669 | endsnippet 670 | 671 | snippet <-- "long left arrow" i 672 | \longleftarrow 673 | endsnippet 674 | 675 | snippet <--> "long bi arrow" iA 676 | \longleftrightarrow 677 | endsnippet 678 | 679 | snippet ^| "up arrow" iA 680 | \uparrow 681 | endsnippet 682 | 683 | snippet v| "down arrow" iA 684 | \downarrow 685 | endsnippet 686 | 687 | snippet v/ "sw arrow" wA 688 | \swarrow 689 | endsnippet 690 | snippet ^\ "nw arrow" wA 691 | \nwarrow 692 | endsnippet 693 | snippet ^/ "ne arrow" wA 694 | \nearrow 695 | endsnippet 696 | snippet v\ "se arrow" wA 697 | \searrow 698 | endsnippet 699 | 700 | snippet (-> "hook arrow" iA 701 | \hookrightarrow 702 | endsnippet 703 | 704 | snippet <-) "hook arrow" iA 705 | \hookleftarrow 706 | endsnippet 707 | 708 | snippet |-> "maps to" iA 709 | \mapsto 710 | endsnippet 711 | 712 | snippet lim-> "direct limit" iA 713 | \varinjlim 714 | endsnippet 715 | 716 | snippet lim<- "inverse limit" iA 717 | \varprojlim 718 | endsnippet 719 | 720 | snippet o/ "Empty set" wA 721 | \emptyset 722 | endsnippet 723 | 724 | snippet "c([A-Z])" "math calligraphic" r 725 | \mathcal{`!p snip.rv = match.group(1)`} 726 | endsnippet 727 | 728 | snippet "f([A-Za-z])" "math fraktur" r 729 | \mf{`!p snip.rv = match.group(1)`} 730 | endsnippet 731 | 732 | snippet "scr([A-Z])" "math script" r 733 | \ms{`!p snip.rv = match.group(1)`} 734 | endsnippet 735 | 736 | snippet "m([A-Z])" "math blackboard" r 737 | \mathbb{`!p snip.rv = match.group(1)`} 738 | endsnippet 739 | 740 | snippet "b([A-Za-z])" "math bold" r 741 | \mathbf{`!p snip.rv = match.group(1)`} 742 | endsnippet 743 | 744 | snippet acton "Action" wA 745 | \curvearrowright 746 | endsnippet 747 | 748 | snippet S "Series" w 749 | \sum 750 | endsnippet 751 | 752 | snippet S8 "Series with infinite upper bound" wA 753 | \sum_{$0}^{\infty} 754 | endsnippet 755 | 756 | snippet P "Product with finite bounds" w 757 | \prod 758 | endsnippet 759 | 760 | snippet P8 "Product with infinite upper bound" wA 761 | \prod_{$0}^{\infty} 762 | endsnippet 763 | 764 | snippet "(\w*)rot" "2x2 Rotation matrix" r 765 | \begin{`!p snip.rv = match.group(1)`matrix} 766 | \cos{${1:\theta}} & \sin{$1} \\\\ 767 | -\sin{$1} & \cos{$1} \\\\ 768 | \end{`!p snip.rv = match.group(1)`matrix}$0 769 | endsnippet 770 | 771 | snippet $$ "inline math mode" Aw 772 | \$ $1 \$ 773 | $0 774 | endsnippet 775 | 776 | snippet !! "inline math mode" A 777 | \$$0\$ 778 | endsnippet 779 | 780 | snippet "(\S+)!!" "inline math mode" Ar 781 | \$`!p snip.rv = match.group(1)`\$ 782 | endsnippet 783 | 784 | snippet << "Asymptotically smaller" iA 785 | \ll 786 | endsnippet 787 | 788 | snippet >> "Asymptotically greater" iA 789 | \gg 790 | endsnippet 791 | 792 | snippet <> "small angle bracket" iA 793 | \langle $0 \rangle 794 | endsnippet 795 | 796 | snippet <.> "angle bracket" iA 797 | \left\langle 798 | $0 799 | \right\rangle 800 | endsnippet 801 | 802 | snippet T "inline math text" w 803 | \textrm{$0} 804 | endsnippet 805 | 806 | snippet "T:(\S+)" "inline math text formatted" ir 807 | \textrm{ `!p snip.rv = match.group(1)` } 808 | endsnippet 809 | 810 | snippet "M:(\S+)" "inline math text formatted" ir 811 | \mathrm{`!p snip.rv = match.group(1)`} 812 | endsnippet 813 | 814 | snippet class "Document class template" 815 | \documentclass[${1:11pt}]\{${2:article}\} 816 | endsnippet 817 | 818 | snippet packs "Inclusion of common packages in preamble" 819 | %────────────┤ Common packages for LaTeX documents ├───────────────────────────────────────────────╮ 820 | %│ 821 | \usepackage {amsmath, amssymb, amsfonts, mathrsfs, amsthm, graphicx, hyperref, microtype} %│ 822 | %│ 823 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 824 | endsnippet 825 | 826 | snippet envs "user defined environments" 827 | %────────────┤ Environments ├───────────────────────────────────────────────╮ 828 | %│ 829 | \newtheorem{${1:theorem}}{${2:Theorem}}[${3:section}] %│ 830 | \theoremstyle{definition} \newtheorem{definition} [$1] {Definition} %│ 831 | \theoremstyle{plain} \newtheorem{lemma} [$1] {Lemma} %│ 832 | \theoremstyle{plain} \newtheorem{proposition} [$1] {Proposition} %│ 833 | \theoremstyle{remark} \newtheorem{remark} [$1] {Remark} %│ 834 | \theoremstyle{plain} \newtheorem{corollary} [$1] {Corollary} %│ 835 | \theoremstyle{remark} \newtheorem{example} [$1] {Example} %│ 836 | %│ 837 | %───────────────────────────────────────────────────────────────────────────╯ 838 | $0 839 | endsnippet 840 | 841 | snippet thm "Theorem environment" b 842 | % 843 | \begin{theorem} 844 | \label{thm:$1} 845 | $0 846 | \end{theorem} 847 | % 848 | endsnippet 849 | snippet Prop "Named proposition" b 850 | % 851 | \begin{proposition}[${1:${VISUAL:proposition name}}] 852 | \label{prop:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 853 | $0 854 | \end{proposition} 855 | % 856 | endsnippet 857 | 858 | snippet Lem "Named lemma" b 859 | % 860 | \begin{lemma}[${1:${VISUAL:lemma name}}] 861 | \label{lem:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 862 | $0 863 | \end{lemma} 864 | % 865 | endsnippet 866 | 867 | snippet Def "Named defintion" b 868 | % 869 | \begin{definition}[${1:${VISUAL:definition name}}] 870 | \label{def:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 871 | $0 872 | \end{definition} 873 | % 874 | endsnippet 875 | 876 | snippet Cor "Named corollary" b 877 | % 878 | \begin{corollary}[${1:${VISUAL:corollary name}}] 879 | \label{cor:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 880 | $0 881 | \end{corollary} 882 | % 883 | endsnippet 884 | 885 | snippet Thm "Named theorem" b 886 | % 887 | \begin{theorem}[${1:${VISUAL:Theorem name}}] 888 | \label{thm:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 889 | $0 890 | \end{theorem} 891 | % 892 | endsnippet 893 | 894 | snippet def "Definition environment" b 895 | % 896 | \begin{definition} 897 | $0 898 | \end{definition} 899 | % 900 | endsnippet 901 | snippet rem "Remark environment" b 902 | % 903 | \begin{remark} 904 | $0 905 | \end{remark} 906 | % 907 | endsnippet 908 | snippet cor "Corollary environment" b 909 | % 910 | \begin{corollary} 911 | $0 912 | \end{corollary} 913 | % 914 | endsnippet 915 | snippet prop "Proposition environment" b 916 | % 917 | \begin{proposition} 918 | $0 919 | \end{proposition} 920 | % 921 | endsnippet 922 | snippet lem "Lemma environment" b 923 | % 924 | \begin{lemma} 925 | $0 926 | \end{lemma} 927 | % 928 | endsnippet 929 | snippet exam "Example environment" b 930 | % 931 | \begin{example} 932 | $0 933 | \end{example} 934 | % 935 | endsnippet 936 | 937 | snippet plain "Plain document template" b 938 | \documentclass[11pt]{article} 939 | 940 | \usepackage{./build/standard} 941 | 942 | \title{$1} 943 | \author{$2} 944 | 945 | \begin{document} 946 | \maketitle 947 | 948 | \begin{abstract} 949 | $3 950 | \end{abstract} 951 | 952 | \section{${4:${VISUAL:section name}}}% 953 | \label{sec:${5:${4/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} 954 | 955 | $0 956 | 957 | \nocite{*} 958 | \bibliography{${6:`!p snip.rv = snip.basename`}} 959 | \bibliographystyle{plain} 960 | \end{document} 961 | endsnippet 962 | 963 | snippet problemdoc "Problem template" b 964 | \documentclass[11pt]{article} 965 | 966 | %---Common packages--- 967 | 968 | \usepackage{amsmath, amssymb, amsfonts, mathrsfs, amsthm} 969 | 970 | \usepackage[backend=bibtex,style=verbose-trad2]{biblatex} 971 | 972 | %---User defined environments------------- 973 | 974 | \newtheorem{theorem}{Theorem}[section] 975 | \theoremstyle{plain} \newtheorem{lemma} [theorem] {Lemma} 976 | \theoremstyle{plain} \newtheorem{proposition} [theorem] {Proposition} 977 | \theoremstyle{plain} \newtheorem{corollary} [theorem] {Corollary} 978 | \theoremstyle{remark} \newtheorem{example} [theorem] {Example} 979 | \theoremstyle{remark} \newtheorem{remark} [theorem] {Remark} 980 | \theoremstyle{definition} \newtheorem{definition} [theorem] {Definition} 981 | \theoremstyle{definition} \newtheorem*{problem} {$1} 982 | \theoremstyle{definition} \newtheorem*{solution} {Solution} 983 | 984 | \title {$2} 985 | \author {$3} 986 | 987 | \begin{document} 988 | \maketitle 989 | \begin{problem} 990 | $4 991 | \end{problem} 992 | \begin{solution} 993 | $5 994 | \end{solution} 995 | $0 996 | \end{document} 997 | endsnippet 998 | 999 | snippet proof "Standard proof environment from amsthm" b 1000 | \begin{proof} 1001 | $0 1002 | \end{proof} 1003 | endsnippet 1004 | 1005 | snippet fq "Quadratic polynomial" 1006 | ${1:a}${2:x}^2 ${3:+b}$2 ${0:+c} 1007 | endsnippet 1008 | 1009 | snippet eq "Simple equation environment" b 1010 | % 1011 | \begin{equation*} 1012 | $0 1013 | \end{equation*} 1014 | % 1015 | endsnippet 1016 | snippet eqn "Labeled equation environment" bA 1017 | % 1018 | \begin{equation} 1019 | \label{eq:$1} 1020 | $0 1021 | \end{equation} 1022 | % 1023 | endsnippet 1024 | 1025 | snippet ald "Aligned sub-environment for equation" bA 1026 | \begin{aligned} 1027 | $0 1028 | \end{aligned} 1029 | endsnippet 1030 | 1031 | snippet == "Unaligned equation item" bA 1032 | ${1/./ /ga} ${2:EQ_LEFT} 1033 | ${1:=} ${0:EQ_RIGHT} 1034 | endsnippet 1035 | 1036 | snippet spl "Split" 1037 | \begin{split} 1038 | ${1:SP_LEFT} &${2:SEPARATOR} 1039 | \\\\ ${0:SP_RIGHT} &$2 1040 | \end{split} 1041 | endsnippet 1042 | 1043 | snippet al "Simple equation alignment environment" b 1044 | % 1045 | \begin{align*} 1046 | $0 1047 | \end{align*} 1048 | % 1049 | endsnippet 1050 | 1051 | snippet alnit "Equation alignment item" A 1052 | \label{eq:$1} 1053 | ${2/./ /ga} ${3:AL_LEFT} 1054 | &$2 ${0:AL_RIGHT} \\\\ 1055 | endsnippet 1056 | 1057 | snippet aln "Labeled equation alignment environment" b 1058 | % 1059 | \begin{align} 1060 | $0 1061 | \end{align} 1062 | % 1063 | endsnippet 1064 | 1065 | snippet alit "Simple equation alignment item" A 1066 | ${1/./ /ga} ${2:AL_LEFT} 1067 | &$1 ${0:AL_RIGHT} 1068 | \\\\ 1069 | endsnippet 1070 | 1071 | snippet eqs "Unaligned bunch of equations" bA 1072 | % 1073 | \begin{gather*} 1074 | $0 1075 | \end{gather*} 1076 | % 1077 | endsnippet 1078 | 1079 | snippet commtr "Commutative triangle, right aligned" A 1080 | \begin{tikzcd} 1081 | $1 1082 | \arrow{r} {$4} 1083 | \arrow[swap]{dr} {$6} & 1084 | $2 1085 | \arrow{d} {$5}\\\\ & 1086 | $3 1087 | \end{tikzcd}$0 1088 | endsnippet 1089 | 1090 | snippet commtrc "Commutative triangle, center aligned" A 1091 | \begin{tikzcd} 1092 | $1 1093 | \arrow{rr} {$4} 1094 | \arrow[swap]{dr} {$6} && 1095 | $2 1096 | \arrow{dl} {$5}\\\\ & 1097 | $3 1098 | \end{tikzcd}$0 1099 | endsnippet 1100 | 1101 | snippet commsq "Commutative square, simple" A 1102 | \begin{tikzcd} 1103 | $1 1104 | \arrow{r} {$5} 1105 | \arrow[swap]{d} {$6} & 1106 | $2 1107 | \arrow{d} {$7}\\\\ 1108 | $3 1109 | \arrow{r} {$8} & 1110 | $4 1111 | \end{tikzcd}$0 1112 | endsnippet 1113 | 1114 | post_expand "vim.eval('timer_start(0, \"MyHandler\")')" 1115 | snippet eqref "Equation Reference" 1116 | \eqref{$0} 1117 | endsnippet 1118 | 1119 | post_expand "vim.eval('timer_start(0, \"MyHandler\")')" 1120 | snippet eqr "Equation Reference" 1121 | \eqref{$0} 1122 | endsnippet 1123 | 1124 | post_expand "vim.eval('timer_start(0, \"MyHandler\")')" 1125 | snippet ref "Reference" 1126 | \ref{$0} 1127 | endsnippet 1128 | post_expand "vim.eval('timer_start(0, \"MyHandler\")')" 1129 | 1130 | snippet cite "Citation" 1131 | \cite{$0} 1132 | endsnippet 1133 | 1134 | snippet / "Fraction" b 1135 | \frac{ ${1:NUMERATOR} } 1136 | { ${0:DENOMINATOR} } 1137 | endsnippet 1138 | 1139 | snippet " /" "Fraction" r 1140 | \frac{ $1 }{ $0 } 1141 | endsnippet 1142 | 1143 | snippet cf "Continued fraction" w 1144 | \cfrac{1} 1145 | {$1 + 1146 | cf$0 1147 | } 1148 | endsnippet 1149 | 1150 | snippet cff "Continued fraction general" w 1151 | \cfrac{${1:1}} 1152 | {$2 + 1153 | cff$0 1154 | } 1155 | endsnippet 1156 | 1157 | snippet "([^ \t\n\r\f\v\$\-]?[^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])/([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])" "frac" ir 1158 | \frac{`!p snip.rv = match.group(1)`}{`!p snip.rv = match.group(2)`} 1159 | endsnippet 1160 | 1161 | snippet mod "Equivalence modulo X" 1162 | $1 \equiv $2 \pmod{$0} 1163 | endsnippet 1164 | 1165 | snippet root "Root" 1166 | \sqrt[$1]{$0} 1167 | endsnippet 1168 | 1169 | snippet "([^ \t\n\r\f\v\$]*[^ \t\n\r\f\v\$\({[])\^rt" "Square root" r 1170 | \sqrt{`!p snip.rv = match.group(1)`} 1171 | endsnippet 1172 | 1173 | snippet __ "Autoindexing" iA 1174 | _{$0} 1175 | endsnippet 1176 | 1177 | snippet ^^ "Autoexponentiation" iA 1178 | ^{$0} 1179 | endsnippet 1180 | 1181 | snippet del "Laplace" w 1182 | \Delta 1183 | endsnippet 1184 | 1185 | snippet grad "Gradient" w 1186 | \nabla 1187 | endsnippet 1188 | 1189 | snippet sqr "Square" w 1190 | \square 1191 | endsnippet 1192 | 1193 | snippet beamer "Beamer presentation" b 1194 | \documentclass[${1:pdf}]{beamer} 1195 | \mode{\usetheme{${2:metropolis}}} 1196 | 1197 | %────────────┤ Environments ├──────────────────────────────────────────────────────────────────────╮ 1198 | %│ 1199 | \newtheorem{${1:theorem}}{${2:Theorem}}[${3:section}] %│ 1200 | \theoremstyle{definition} \newtheorem{definition} [$1] {Definition} %│ 1201 | \theoremstyle{plain} \newtheorem{lemma} [$1] {Lemma} %│ 1202 | \theoremstyle{plain} \newtheorem{proposition} [$1] {Proposition} %│ 1203 | \theoremstyle{remark} \newtheorem{remark} [$1] {Remark} %│ 1204 | \theoremstyle{plain} \newtheorem{corollary} [$1] {Corollary} %│ 1205 | \theoremstyle{remark} \newtheorem{example} [$1] {Example} %│ 1206 | %│ 1207 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1208 | 1209 | %───────────────────────────────┤ Help with Beamer ├───────────────────────────────────────────────╮ 1210 | % %│ 1211 | % \begin{block} for boxes; %│ 1212 | % theorems, propositions, definitions etc. are preloaded and do not need to be declared; %│ 1213 | % \beamerbutton{} : for basic buttons; %│ 1214 | % \hyperlink{} : for jumping to labeled environments %│ 1215 | % : for delayed material %│ 1216 | % \uncover<>{} and \only<>{} : for hiding objects %│ 1217 | % \onslide<> : for revealing parts of table %│ 1218 | % \begin{columns}, \begin{column}{x\textwidth} : for columns %│ 1219 | % In figure environment, %│ 1220 | % \includemovie[poster=FILE,text={text}]{dimx}{dimy}{FILE} %│ 1221 | % %│ 1222 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1223 | 1224 | %────────────┤ Common packages for LaTeX documents ├───────────────────────────────────────────────╮ 1225 | %│ 1226 | \usepackage {amsmath, amssymb, amsfonts, mathrsfs, amsthm, graphicx, hyperref, microtype, tikz, %│ 1227 | tikz-cd} %│ 1228 | %│ 1229 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1230 | 1231 | \title {$9} 1232 | \author {$10} 1233 | 1234 | \begin{document} 1235 | 1236 | \begin{frame} 1237 | \titlepage 1238 | \end{frame} 1239 | 1240 | \begin{frame} 1241 | 1242 | $0 1243 | 1244 | \end{frame} 1245 | 1246 | %\begin{frame}{Bibliography} 1247 | %\nocite{*} 1248 | %\bibliography {${13:`!p snip.rv = snip.basename`}} 1249 | %\bibliographystyle {${14:amsalpha}} 1250 | %\end{frame} 1251 | \end{document} 1252 | endsnippet 1253 | 1254 | snippet bare "Barebones template" b 1255 | \documentclass[10pt]{article} 1256 | 1257 | %────────────┤ Common packages ├───────────────────────────────────────────────────────────────────╮ 1258 | %│ 1259 | \usepackage{ %│ 1260 | amsmath, amssymb, amsfonts, mathrsfs, amsthm, %│ 1261 | graphicx, hyperref, microtype, tikz, tikz-cd, %│ 1262 | } %│ 1263 | %│ 1264 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1265 | 1266 | %────────────┤ Environments ├──────────────────────────────────────────────────────────────────────╮ 1267 | %│ 1268 | \newtheorem{theorem}}{Theorem}[section] %│ 1269 | \theoremstyle{definition} \newtheorem{definition} [theorem] {Definition} %│ 1270 | \theoremstyle{plain} \newtheorem{lemma} [theorem] {Lemma} %│ 1271 | \theoremstyle{plain} \newtheorem{proposition} [theorem] {Proposition} %│ 1272 | \theoremstyle{remark} \newtheorem{remark} [theorem] {Remark} %│ 1273 | \theoremstyle{plain} \newtheorem{corollary} [theorem] {Corollary} %│ 1274 | \theoremstyle{remark} \newtheorem{example} [theorem] {Example} %│ 1275 | %│ 1276 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1277 | 1278 | \author {Author} 1279 | \title {Title} 1280 | 1281 | \begin{document} 1282 | \maketitle 1283 | $0 1284 | \end{document} 1285 | endsnippet 1286 | 1287 | snippet texnote "Tex note template for ./texnotes" b 1288 | \documentclass[10pt]{amsart} 1289 | \input{note.sty} 1290 | \title{Note} 1291 | \date{`!p from datetime import datetime snip.rv=datetime.now().strftime("%Y-%m-%d %H:%M:%S%z")`} 1292 | 1293 | %---Document--- 1294 | \begin{document} 1295 | \maketitle 1296 | $0 1297 | \end{document} 1298 | endsnippet 1299 | 1300 | snippet note "Note template" b 1301 | \documentclass[10pt]{amsart} 1302 | 1303 | \usepackage[T1]{fontenc} 1304 | \usepackage{amsmath,amsthm,amssymb,amsfonts,mathrsfs,kpfonts} 1305 | 1306 | \newtheorem{theorem}{Theorem}[section] 1307 | \theoremstyle{plain} \newtheorem{lemma} [theorem] {Lemma} 1308 | \theoremstyle{plain} \newtheorem{proposition} [theorem] {Proposition} 1309 | \theoremstyle{plain} \newtheorem{corollary} [theorem] {Corollary} 1310 | \theoremstyle{remark} \newtheorem{example} [theorem] {Example} 1311 | \theoremstyle{remark} \newtheorem{remark} [theorem] {Remark} 1312 | \theoremstyle{definition} \newtheorem{definition} [theorem] {Definition} 1313 | 1314 | \title{Note} 1315 | \date{`!p from datetime import datetime snip.rv=datetime.now().strftime("%Y-%m-%d %H:%M:%S%z")`} 1316 | %---Document--- 1317 | \begin{document} 1318 | \maketitle 1319 | $0 1320 | \end{document} 1321 | endsnippet 1322 | 1323 | # Tikz snippets 1324 | snippet tikz "Tikz picture" 1325 | \begin{tikzpicture} 1326 | $0 1327 | \end{tikzpicture} 1328 | endsnippet 1329 | 1330 | snippet draw "Generic draw" 1331 | \draw[$1] ${2:(0,0)} ${3:--} ${4:(5,5)} 1332 | endsnippet 1333 | 1334 | snippet grid "Assist grid" 1335 | \draw[step=${1:1cm},${2:gray},${3:very thin}] ${4:(0,0)} grid ${5:(5,5)}; 1336 | endsnippet 1337 | 1338 | snippet circle "Circle" 1339 | \draw[${1:black},${2:thick}] (0,0) circle (2cm); 1340 | endsnippet 1341 | 1342 | snippet node "Node" 1343 | \node (${1:LABEL}) [${2:STYLE}] \{${3:TEXT}\}; 1344 | endsnippet 1345 | 1346 | snippet flowchart "Flowchart" b 1347 | \begin{tikzpicture}[node distance=${1:2cm}] 1348 | $2 1349 | \end{tikzpicture} 1350 | endsnippet 1351 | 1352 | snippet flowstyles "Flowchart styles" b 1353 | \usetikzlibrary{shapes.geometric, arrows} 1354 | \tikzstyle{boxred} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!10 ] 1355 | \tikzstyle{boxgreen} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=green!10 ] 1356 | \tikzstyle{boxblue} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=blue!10 ] 1357 | \tikzstyle{ellred} = [ellipse, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!10 ] 1358 | \tikzstyle{ellgreen} = [ellipse, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=green!10 ] 1359 | \tikzstyle{ellblue} = [ellipse, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=blue!10 ] 1360 | \tikzstyle{arrow} = [thick, ->, >=stealth] 1361 | endsnippet 1362 | 1363 | snippet fancybox 1364 | %────────────┤ Title ├─────────────────────────────────────────────────────────────────────────────╮ 1365 | %│ 1366 | %│ 1367 | %│ 1368 | %│ 1369 | %│ 1370 | %│ 1371 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1372 | endsnippet 1373 | 1374 | snippet basker "Configure good baskeville font" b 1375 | %────────────┤ Baskerville Fonts ├─────────────────────────────────────────────────────────────────╮ 1376 | %│ 1377 | \usepackage{anyfontsize} %│ 1378 | \usepackage{lmodern} %│ 1379 | \usepackage[scale=0.89]{tgheros} %│ 1380 | \usepackage[osf]{Baskervaldx} %│ 1381 | \usepackage[baskervaldx,cmintegrals,bigdelims,vvarbb]{newtxmath} %│ 1382 | \usepackage[cal=boondoxo]{mathalfa} %│ 1383 | %│ 1384 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1385 | endsnippet 1386 | 1387 | snippet schola "Configure good schoolbook font" b 1388 | %────────────┤ Schoolbook fonts ├──────────────────────────────────────────────────────────────────╮ 1389 | %│ 1390 | \usepackage{unicode-math} %│ 1391 | \usepackage{anyfontsize} %│ 1392 | \setmainfont[Scale=0.90]{TeX Gyre Schola} %│ 1393 | \setmathfont[Scale=0.90]{TeX Gyre Schola Math} %│ 1394 | %│ 1395 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1396 | endsnippet 1397 | 1398 | snippet palat "Configure good palatino font" b 1399 | %────────────┤ Palatino fonts ├────────────────────────────────────────────────────────────────────╮ 1400 | %│ 1401 | \usepackage[T1]{fontenc} %│ 1402 | \usepackage{palatino} %│ 1403 | \usepackage{mathpazo} %│ 1404 | %│ 1405 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1406 | endsnippet 1407 | 1408 | snippet libertine "Configure good libertine font" b 1409 | %────────────┤ Title ├─────────────────────────────────────────────────────────────────────────────╮ 1410 | %│ 1411 | \usepackage[T1]{fontenc} %│ 1412 | \usepackage{fontspec} %│ 1413 | \usepackage{libertine} %│ 1414 | \usepackage[libertine]{newtxmath} %│ 1415 | %│ 1416 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1417 | endsnippet 1418 | 1419 | snippet century "Configure good century font" b 1420 | %────────────┤ Title ├─────────────────────────────────────────────────────────────────────────────╮ 1421 | %│ 1422 | \usepackage[scale=0.89]{tgheros} %│ 1423 | \usepackage{newcent} %│ 1424 | \usepackage[nc,cmintegrals,bigdelims,vvarbb]{newtxmath} %│ 1425 | \usepackage[cal=boondoxo]{mathalfa} %│ 1426 | %│ 1427 | %──────────────────────────────────────────────────────────────────────────────────────────────────╯ 1428 | endsnippet 1429 | 1430 | snippet Re "Real part" 1431 | \Re{$0} 1432 | endsnippet 1433 | 1434 | snippet Im "Imaginary part" 1435 | \Im{$0} 1436 | endsnippet 1437 | 1438 | snippet bx "Box times" 1439 | \boxtimes 1440 | endsnippet 1441 | 1442 | snippet b+ "Box plus" 1443 | \boxplus 1444 | endsnippet 1445 | 1446 | snippet uu "cup" wA 1447 | \cup 1448 | endsnippet 1449 | 1450 | snippet UU "Bic cup" wA 1451 | \bigcup 1452 | endsnippet 1453 | 1454 | snippet cc "cup" wA 1455 | \cap 1456 | endsnippet 1457 | 1458 | snippet CC "Bic cup" wA 1459 | \bigcap 1460 | endsnippet 1461 | 1462 | snippet ii "in" wA 1463 | \in 1464 | endsnippet 1465 | 1466 | snippet "([A-Za-z]+)@@" "Autoformatting common functions" rA 1467 | \\`!p snip.rv = match.group(1)`{$0} 1468 | endsnippet 1469 | 1470 | snippet "(\S+)\)\)" "Autoformatting parens" rA 1471 | (`!p snip.rv = match.group(1)`)$0 1472 | endsnippet 1473 | 1474 | snippet "([A-Za-z]+)@(\w)" "Autoformatting common functions" rA 1475 | \\`!p snip.rv = match.group(1)`{`!p snip.rv = match.group(2)`} 1476 | endsnippet 1477 | 1478 | snippet exact "Exact sequence" b 1479 | 0 \rightarrow $1 1480 | \rightarrow $2 1481 | \rightarrow $3 1482 | \rightarrow 0$0 1483 | endsnippet 1484 | 1485 | snippet M "mathrm" i 1486 | \mathrm{$0} 1487 | endsnippet 1488 | 1489 | snippet newop "Declare math operator" bA 1490 | \DeclareMathOperator{$1}{$0} 1491 | endsnippet 1492 | 1493 | snippet lis "Formatted horizontal array of entries" w 1494 | ( ${1:A1}, \ldots , ${0:AN} ) 1495 | endsnippet 1496 | 1497 | snippet |||| "Inline norm" 1498 | \Vert $0 \Vert 1499 | endsnippet 1500 | 1501 | snippet != "neq" iA 1502 | \neq 1503 | endsnippet 1504 | 1505 | snippet "[ ]+_" "connect subscript" Ar 1506 | _ 1507 | endsnippet 1508 | 1509 | snippet "[ ]+^" "connect superscript" Ar 1510 | ^ 1511 | endsnippet 1512 | 1513 | snippet "([A-Za-z]+)\\" "Make into command" r 1514 | \\`!p snip.rv = match.group(1)` 1515 | endsnippet 1516 | --------------------------------------------------------------------------------