├── bash-support ├── codesnippets │ ├── create-tempfile │ ├── timestamp │ ├── check-for-unsigned-integer │ ├── debugging │ │ ├── _debug_print_pos_param │ │ ├── _debug_assert │ │ ├── _debug_function.noindent │ │ ├── _debug_timestamp.noindent │ │ └── _debug_PS4 │ ├── check-for-signed-integer │ ├── basename+pathname │ ├── check-number-of-command-line-arguments │ ├── use-file-descriptor-write │ ├── use-file-descriptor-read │ ├── free-software-comment │ ├── create-tempfile-with-trap │ ├── _trap_EXIT │ ├── _trap_ERR │ ├── _trap_RETURN │ ├── _trap_DEBUG │ ├── create-tempfile-in-secure-manner │ ├── usage-and-command-line-arguments.noindent │ └── well-behaved-script ├── doc │ ├── bash-hotkeys.pdf │ └── bash-hotkeys.tex ├── rc │ ├── customization.bashrc │ ├── personal.templates │ ├── custom.templates │ ├── customization.gvimrc │ ├── custom_with_personal.templates │ ├── sh.vim │ └── customization.vimrc ├── templates │ ├── set.templates │ ├── specialparams.templates │ ├── builtins.templates │ ├── shelloptions.templates │ ├── regexp.templates │ ├── io-redirection.templates │ ├── patternmatching.templates │ ├── paramsub.templates │ ├── environment.templates │ ├── statements.templates │ ├── tests.templates │ ├── Templates │ └── comments.templates ├── scripts │ └── wrapper.sh ├── wordlists │ └── bash-keywords.list └── README.md ├── syntax ├── bashhelp.vim └── template.vim ├── ftdetect └── template.vim ├── ftplugin ├── bashhelp.vim └── template.vim ├── autoload ├── mmtemplates │ ├── config.vim │ └── wizard.vim └── mmtoolbox │ └── tools.vim ├── doc ├── bashdbintegration.txt └── toolbox.txt ├── project └── release.lua └── README.md /bash-support/codesnippets/create-tempfile: -------------------------------------------------------------------------------- 1 | TMPFILE=$( mktemp /tmp/example.XXXXXXXXXX ) || exit 1 2 | 3 | rm --force $TMPFILE 4 | -------------------------------------------------------------------------------- /bash-support/codesnippets/timestamp: -------------------------------------------------------------------------------- 1 | 2 | timestamp=$(date +"%Y%m%d-%H%M%S") # generate timestamp : YYYYMMDD-hhmmss 3 | 4 | -------------------------------------------------------------------------------- /bash-support/doc/bash-hotkeys.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WolfgangMehner/bash-support/HEAD/bash-support/doc/bash-hotkeys.pdf -------------------------------------------------------------------------------- /bash-support/codesnippets/check-for-unsigned-integer: -------------------------------------------------------------------------------- 1 | if [[ $number =~ ^[0-9]+$ ]] ; then 2 | echo -e "match found : integer\n" 3 | fi 4 | -------------------------------------------------------------------------------- /bash-support/codesnippets/debugging/_debug_print_pos_param: -------------------------------------------------------------------------------- 1 | # print the positional parameters 2 | printf "'%b'\n" "$0" "$@" | nl -v0 -s': ' 3 | 4 | -------------------------------------------------------------------------------- /bash-support/codesnippets/check-for-signed-integer: -------------------------------------------------------------------------------- 1 | if [[ $number =~ ^[+-]?[0-9]+$ ]] ; then 2 | echo -e "match found : (signed) integer\n" 3 | fi 4 | -------------------------------------------------------------------------------- /bash-support/codesnippets/basename+pathname: -------------------------------------------------------------------------------- 1 | basename=${pathname##*/} 2 | dirname=${pathname%/*} 3 | filename=${basename%%.*} 4 | lastextension=${basename##*.} 5 | allextensions=${basename#*.} 6 | -------------------------------------------------------------------------------- /bash-support/codesnippets/check-number-of-command-line-arguments: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------- 2 | # Check number of command line arguments 3 | #----------------------------------------------------------------------- 4 | [ $# -lt 1 ] && { echo -e "\n\tUsage: ${0##/*/} File\n"; exit 1; } 5 | 6 | -------------------------------------------------------------------------------- /bash-support/codesnippets/use-file-descriptor-write: -------------------------------------------------------------------------------- 1 | 2 | outfilename="" # output filename 3 | 4 | exec 4>"$outfilename" 5 | if [ $? -ne 0 ] ; then 6 | echo -e "Could not link file descriptor with file '$outfilename'\n" 7 | exit 1 8 | fi 9 | 10 | echo -e "text" >&4 11 | 12 | exec 4>&- # close file descriptor 13 | 14 | -------------------------------------------------------------------------------- /bash-support/codesnippets/use-file-descriptor-read: -------------------------------------------------------------------------------- 1 | 2 | infilename="" # input filename 3 | 4 | exec 3<"$infilename" 5 | if [ $? -ne 0 ] ; then 6 | echo -e "Could not link file descriptor with file '$infilename'\n" 7 | exit 1 8 | fi 9 | 10 | while read line <&3 ; do 11 | echo -e "$line" 12 | done 13 | 14 | exec 3<&- # close file descriptor 15 | 16 | -------------------------------------------------------------------------------- /bash-support/rc/customization.bashrc: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------- 2 | # set Bash prompts 3 | # PS4 shows the function name when execution is inside a function and 4 | # the xtrace option is set. 5 | #----------------------------------------------------------------------- 6 | export PS2='continue> ' 7 | export PS3='choose: ' 8 | export PS4='|${BASH_SOURCE} ${LINENO}${FUNCNAME[0]:+ ${FUNCNAME[0]}()}| ' 9 | 10 | -------------------------------------------------------------------------------- /bash-support/codesnippets/free-software-comment: -------------------------------------------------------------------------------- 1 | # 2 | #========================================================================== 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | #========================================================================== 8 | # 9 | -------------------------------------------------------------------------------- /bash-support/codesnippets/create-tempfile-with-trap: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------------------------------------------------- 3 | # cleanup temporary file in case of a keyboard interrupt (SIGINT) 4 | # or a termination signal (SIGTERM) 5 | #----------------------------------------------------------------------- 6 | function cleanup_temp 7 | { 8 | [ -e $tmpfile ] && rm --force $tmpfile 9 | exit 0 10 | } 11 | 12 | trap cleanup_temp SIGHUP SIGINT SIGPIPE SIGTERM 13 | 14 | tmpfile=$(mktemp) || { echo "$0: creation of temporary file failed!"; exit 1; } 15 | 16 | # use tmpfile ... 17 | 18 | rm --force $tmpfile 19 | 20 | -------------------------------------------------------------------------------- /bash-support/codesnippets/debugging/_debug_assert: -------------------------------------------------------------------------------- 1 | #=== FUNCTION ================================================================ 2 | # NAME: _assert 3 | # DESCRIPTION: Abort the script if assertion is false. 4 | # PARAMETERS: 1) expression used as test inside brackets 5 | # 2) optional information, e.g. $LINENO 6 | # RETURNS: 0 / 99 assertion is true / false 7 | #=============================================================================== 8 | function _assert () 9 | { 10 | if [ ! $1 ]; then 11 | echo "${0##*/}${2:+:$2}: assertion '$1' failed." 12 | exit 99 13 | fi 14 | return 0 15 | } 16 | 17 | -------------------------------------------------------------------------------- /bash-support/codesnippets/_trap_EXIT: -------------------------------------------------------------------------------- 1 | #=== FUNCTION ================================================================ 2 | # NAME: _trap_EXIT 3 | # DESCRIPTION: Trap code for the pseudo-signal EXIT. Generates an message. 4 | # PARAMETERS: The current line number given by $LINENO . 5 | #=============================================================================== 6 | function _trap_EXIT () 7 | { 8 | echo -e "\nEXIT line ${1}: Script exited with status ${?}" 9 | } # ---------- end of function ---------- 10 | 11 | trap '_trap_EXIT $LINENO' EXIT # trap EXIT 12 | 13 | #trap - EXIT # reset the EXIT trap 14 | 15 | -------------------------------------------------------------------------------- /bash-support/codesnippets/debugging/_debug_function.noindent: -------------------------------------------------------------------------------- 1 | 2 | DEBUG=${DEBUG:-0} # 0 = no debug output, 1 = show debug output, 3 | # or enable debug with: DEBUG=1 script.sh 4 | 5 | #=== FUNCTION ================================================================ 6 | # NAME: _debug 7 | # DESCRIPTION: echo debug output controlled by a global variable 8 | # PARAMETERS: list, e.g.; "$LINENO: x=$x" 9 | # RETURNS: always 0 10 | #=============================================================================== 11 | _debug () 12 | { 13 | [ ${DEBUG} -ne 0 ] && echo -e "${@}" 14 | return 0 15 | } # ---------- end of function _debug ---------- 16 | -------------------------------------------------------------------------------- /syntax/bashhelp.vim: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: bashhelp.vim 4 | " 5 | " Description: Syntax for Bash's built-in help. 6 | " 7 | " Import man page syntax. 8 | " 9 | " VIM Version: 7.4+ 10 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 11 | " Organization: 12 | " Version: 1.0 13 | " Created: 16.11.2017 14 | " Revision: --- 15 | " License: Copyright (c) 2017, Wolfgang Mehner 16 | "=============================================================================== 17 | 18 | runtime! syntax/man.vim 19 | 20 | " nothing noteworthy will happen in Vim 21 | " save in Neovim, because filetype is not "man" 22 | -------------------------------------------------------------------------------- /bash-support/codesnippets/_trap_ERR: -------------------------------------------------------------------------------- 1 | #=== FUNCTION ================================================================ 2 | # NAME: _trap_ERROR 3 | # DESCRIPTION: Trap code for the pseudo-signal ERR (A command returning a 4 | # non-zero exit status). Generates an error message. 5 | # PARAMETERS: The current line number given by $LINENO . 6 | #=============================================================================== 7 | function _trap_ERROR () 8 | { 9 | echo -e "\nERROR line ${1}: Command exited with status ${?}" 10 | } # ---------- end of function _trap_ERROR ---------- 11 | 12 | trap '_trap_ERROR $LINENO' ERR # trap ERR 13 | 14 | #trap - ERR # reset the ERR trap 15 | 16 | -------------------------------------------------------------------------------- /bash-support/templates/set.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Set 3 | § ============================================================= 4 | 5 | == LIST: set == list == 6 | 'allexport', 7 | 'braceexpand', 8 | 'emacs', 9 | 'errexit', 10 | 'errtrace', 11 | 'functrace', 12 | 'hashall', 13 | 'histexpand', 14 | 'history', 15 | 'ignoreeof', 16 | 'keyword', 17 | 'monitor', 18 | 'noclobber', 19 | 'noexec', 20 | 'noglob', 21 | 'notify', 22 | 'nounset', 23 | 'onecmd', 24 | 'physical', 25 | 'pipefail', 26 | 'posix', 27 | 'privileged', 28 | 'verbose', 29 | 'vi', 30 | 'xtrace', 31 | == ENDLIST == 32 | 33 | == Set == expandmenu, map:bse, sc:s == 34 | |PickList( 'set option', 'set' )| 35 | set -o |PICK| 36 | == ENDTEMPLATE == 37 | -------------------------------------------------------------------------------- /bash-support/rc/personal.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Personal Information 3 | § ============================================================= 4 | 5 | SetMacro( 'AUTHOR', 'YOUR NAME' ) 6 | SetMacro( 'AUTHORREF', '' ) 7 | SetMacro( 'EMAIL', '' ) 8 | SetMacro( 'ORGANIZATION', '' ) 9 | SetMacro( 'COMPANY', '' ) 10 | SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) 11 | SetMacro( 'LICENSE', 'GNU General Public License' ) 12 | 13 | § ============================================================= 14 | § Date and Time Format 15 | § ============================================================= 16 | 17 | §SetFormat( 'DATE', '%x' ) 18 | §SetFormat( 'TIME', '%H:%M' ) 19 | §SetFormat( 'YEAR', '%Y' ) 20 | 21 | -------------------------------------------------------------------------------- /ftdetect/template.vim: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: template.vim 4 | " 5 | " Description: Filetype detection for templates. 6 | " 7 | " Straight out of the documentation: 8 | " - do not overwrite the filetype if it has already been set 9 | " 10 | " VIM Version: 7.0+ 11 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 12 | " Organization: 13 | " Version: 1.0 14 | " Created: 07.06.2015 15 | " Revision: --- 16 | " License: Copyright (c) 2015, Wolfgang Mehner 17 | "=============================================================================== 18 | 19 | autocmd BufNewFile,BufRead *.template,*.templates,Templates setfiletype template 20 | -------------------------------------------------------------------------------- /bash-support/codesnippets/_trap_RETURN: -------------------------------------------------------------------------------- 1 | #=== FUNCTION ================================================================ 2 | # NAME: _trap_RETURN 3 | # DESCRIPTION: Trap code for the pseudo-signal RETURN. Generates a message. 4 | # The RETURN trap is not inherited by functions. 5 | # Use 'set -o functrace' 6 | # PARAMETERS: The current line number given by $LINENO . 7 | # variable(s) to be tracked 8 | #=============================================================================== 9 | function _trap_RETURN () 10 | { 11 | echo -e "\nRETURN line ${1}: " 12 | } # ---------- end of functionn _trap_RETURN ---------- 13 | 14 | trap '_trap_RETURN $LINENO' RETURN # trap RETURN 15 | 16 | #trap - RETURN # reset the RETURN trap 17 | 18 | -------------------------------------------------------------------------------- /bash-support/codesnippets/debugging/_debug_timestamp.noindent: -------------------------------------------------------------------------------- 1 | 2 | DEBUG=${DEBUG:-0} # 0 = no debug output, 1 = show debug output, 3 | # or enable debug with: DEBUG=1 script.sh 4 | 5 | #=== FUNCTION ================================================================ 6 | # NAME: _debug_timestamp 7 | # DESCRIPTION: timestamp + optional information 8 | # timestamp: {seconds since 1970-01-01 00:00:00}.{nanoseconds} 9 | # PARAMETERS: identification, e.g. $LINENO (optional) 10 | # RETURNS: always 0 11 | #=============================================================================== 12 | _debug_timestamp () 13 | { 14 | [ ${DEBUG} -ne 0 ] && echo -e "[ $(date "+%s.%N") ]${@:+ -- ${@}}" 15 | return 0 16 | } # ---------- end of function _debug_timestamp ---------- 17 | -------------------------------------------------------------------------------- /bash-support/codesnippets/_trap_DEBUG: -------------------------------------------------------------------------------- 1 | #=== FUNCTION ================================================================ 2 | # NAME: _trap_DEBUG 3 | # DESCRIPTION: Trap code for the pseudo-signal DEBUG. Generate a message. 4 | # The DEBUG trap is not inherited by functions. 5 | # Use 'set -o functrace' 6 | # PARAMETERS: 1) identification (e.g. line number $LINENO) 7 | # 2) variable name(s) to be tracked 8 | #=============================================================================== 9 | function _trap_DEBUG () 10 | { 11 | declare identification=$1; 12 | while [ ${#} -gt 1 ]; do 13 | shift 14 | echo -e "DEBUG [$identification] ${1} = '${!1}'" 15 | done 16 | } # ---------- end of function _trap_DEBUG ---------- 17 | 18 | trap '_trap_DEBUG $LINENO <-variable names->' DEBUG # trap DEBUG 19 | 20 | #trap - DEBUG # reset the DEBUG trap 21 | 22 | -------------------------------------------------------------------------------- /bash-support/codesnippets/debugging/_debug_PS4: -------------------------------------------------------------------------------- 1 | # PS4 : timestamp; the current time in 24-hour HH:MM:SS format 2 | PS4='+[\t] ' 3 | 4 | # PS4 : timestamp; 'seconds.nanoseconds' since 1970-01-01 00:00:00 UT 5 | PS4='+[$(date "+%s.%N")] ' 6 | 7 | # PS4 : position, line number, function name 8 | # The following line avoids error messages due to an unset FUNCNAME[0] : 9 | # set +o nounset # Treat unset variables as an error 10 | # 11 | PS4='+|${BASH_SOURCE##*/} ${LINENO}${FUNCNAME[0]:+ ${FUNCNAME[0]}}| ' 12 | 13 | # PS4 : position, line number, function name, subshell information 14 | # The following line avoids error messages due to an unset FUNCNAME[0] : 15 | # set +o nounset # Treat unset variables as an error 16 | # 17 | PS4='+(${BASH_SOURCE##*/}: ${LINENO}) : ${FUNCNAME[0]} - [level ${SHLVL}, ' 18 | PS4=$PS4'subshell ${BASH_SUBSHELL}, return code $?]\n ' 19 | 20 | # PS4 : default prompt 21 | PS4='+ ' 22 | 23 | -------------------------------------------------------------------------------- /bash-support/templates/specialparams.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Special Parameters 3 | § ============================================================= 4 | 5 | == LIST: SpecialParameters == hash == 6 | 'number of posit. param.' : '#', 7 | 'all posit. param. (quoted spaces)' : '*', 8 | 'all posit. param. (unquoted spaces)' : '@', 9 | 'number of posit. parameters' : '#@', 10 | 'return code of last command' : '?', 11 | 'PID of this shell' : '$', 12 | 'flags set' : '-', 13 | 'last argument of prev. command' : '_', 14 | 'PID of last background command' : '!', 15 | == ENDLIST == 16 | 17 | == SpecParams == expandmenu, insert, sc:p, map:bsp == 18 | |PickList( 'Special Parameters', 'SpecialParameters' )| 19 | ${|VALUE|} 20 | == ENDTEMPLATE == 21 | 22 | SetExpansion ( 'SpecParams', '|KEY|', '$|VALUE|' ) 23 | 24 | -------------------------------------------------------------------------------- /bash-support/codesnippets/create-tempfile-in-secure-manner: -------------------------------------------------------------------------------- 1 | 2 | TMPDIR=${TMPDIR:-/tmp} # defaults to /tmp if unset 3 | 4 | #------------------------------------------------------------------------------- 5 | # Creates a particular temporary directory inside $TMPDIR. 6 | #------------------------------------------------------------------------------- 7 | TEMPORARY_DIR=$(mktemp -d "$TMPDIR/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") || \ 8 | { echo "ERROR creating a temporary file"; exit 1; } 9 | 10 | #------------------------------------------------------------------------------- 11 | # When the program exits, it tries to remove the temporary folder. 12 | # This code is executed even if the process receives a signal 1,2,3 or 15. 13 | #------------------------------------------------------------------------------- 14 | trap '[ "$TEMPORARY_DIR" ] && rm --recursive --force "$TEMPORARY_DIR"' 0 15 | 16 | touch $TEMPORARY_DIR/tempfile # new tempfile inside folder 17 | 18 | -------------------------------------------------------------------------------- /ftplugin/bashhelp.vim: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: bashhelp.vim 4 | " 5 | " Description: Filetype plugin for Bash's built-in help. 6 | " 7 | " Some settings have been taken from Neovim's filetype plug-in 8 | " for 'man'. 9 | " 10 | " VIM Version: 7.4+ 11 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 12 | " Organization: 13 | " Version: 1.0 14 | " Created: 16.11.2017 15 | " Revision: --- 16 | "=============================================================================== 17 | 18 | " only do this when not done yet for this buffer 19 | if exists("b:did_BashHelp_ftplugin") 20 | finish 21 | endif 22 | let b:did_BashHelp_ftplugin = 1 23 | 24 | setlocal noexpandtab 25 | setlocal tabstop=8 26 | setlocal softtabstop=8 27 | setlocal shiftwidth=8 28 | 29 | setlocal nonumber 30 | setlocal norelativenumber 31 | setlocal foldcolumn=0 32 | setlocal colorcolumn=0 33 | setlocal nolist 34 | setlocal nofoldenable 35 | -------------------------------------------------------------------------------- /bash-support/codesnippets/usage-and-command-line-arguments.noindent: -------------------------------------------------------------------------------- 1 | 2 | ScriptVersion="1.0" 3 | 4 | #=== FUNCTION ================================================================ 5 | # NAME: usage 6 | # DESCRIPTION: Display usage information. 7 | #=============================================================================== 8 | function usage () 9 | { 10 | cat <<- EOT 11 | 12 | Usage : ${0##/*/} [options] [--] 13 | 14 | Options: 15 | -h|help Display this message 16 | -v|version Display script version 17 | 18 | EOT 19 | } # ---------- end of function usage ---------- 20 | 21 | #----------------------------------------------------------------------- 22 | # Handle command line arguments 23 | #----------------------------------------------------------------------- 24 | 25 | while getopts ":hv" opt 26 | do 27 | case $opt in 28 | 29 | h|help ) usage; exit 0 ;; 30 | 31 | v|version ) echo "$0 -- Version $ScriptVersion"; exit 0 ;; 32 | 33 | \? ) echo -e "\n Option does not exist : $OPTARG\n" 34 | usage; exit 1 ;; 35 | 36 | esac # --- end of case --- 37 | done 38 | shift $(($OPTIND-1)) 39 | 40 | -------------------------------------------------------------------------------- /bash-support/templates/builtins.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Builtins 3 | § ============================================================= 4 | 5 | § This list is used by the menu entry 'Help->help (Bash builtins)' 6 | § for tab-completion. Please do not change the name. 7 | == LIST: builtins == list == 8 | 'alias', 9 | 'bg', 10 | 'bind', 11 | 'break', 12 | 'builtin', 13 | 'caller', 14 | 'cd', 15 | 'command', 16 | 'compgen', 17 | 'complete', 18 | 'continue', 19 | 'compopt', 20 | 'declare', 21 | 'dirs', 22 | 'disown', 23 | 'echo', 24 | 'enable', 25 | 'eval', 26 | 'exec', 27 | 'exit', 28 | 'export', 29 | 'false', 30 | 'fc', 31 | 'fg', 32 | 'getopts', 33 | 'hash', 34 | 'help', 35 | 'history', 36 | 'jobs', 37 | 'kill', 38 | 'let', 39 | 'local', 40 | 'logout', 41 | 'mapfile', 42 | 'popd', 43 | 'printf', 44 | 'pushd', 45 | 'pwd', 46 | 'read', 47 | 'readarray', 48 | 'readonly', 49 | 'return', 50 | 'set', 51 | 'shift', 52 | 'shopt', 53 | 'source', 54 | 'suspend', 55 | 'test', 56 | 'times', 57 | 'trap', 58 | 'true', 59 | 'type', 60 | 'typeset', 61 | 'ulimit', 62 | 'umask', 63 | 'unalias', 64 | 'unset', 65 | 'wait', 66 | == ENDLIST == 67 | 68 | == Builtins == expandmenu, insert, map:bbu, sc:b == 69 | |PickList( 'Builtins', 'builtins' )| 70 | |PICK| 71 | == ENDTEMPLATE == 72 | 73 | -------------------------------------------------------------------------------- /bash-support/codesnippets/well-behaved-script: -------------------------------------------------------------------------------- 1 | set -o nounset # treat unset variables as errors 2 | 3 | #=============================================================================== 4 | # GLOBAL DECLARATIONS 5 | #=============================================================================== 6 | declare -rx SCRIPT=${0##*/} # the name of this script 7 | declare -rx mkdir='/bin/mkdir' # the mkdir(1) command 8 | 9 | #=============================================================================== 10 | # SANITY CHECKS 11 | #=============================================================================== 12 | if [ -z "$BASH" ] ; then 13 | printf "$SCRIPT:$LINENO: run this script with the BASH shell\n" >&2 14 | exit 192 15 | fi 16 | 17 | if [ ! -x "$mkdir" ] ; then 18 | printf "$SCRIPT:$LINENO: command '$mkdir' not available - aborting\n" >&2 19 | exit 192 20 | fi 21 | 22 | #=============================================================================== 23 | # MAIN SCRIPT 24 | #=============================================================================== 25 | 26 | #=============================================================================== 27 | # STATISTICS / CLEANUP 28 | #=============================================================================== 29 | exit 0 30 | -------------------------------------------------------------------------------- /bash-support/templates/shelloptions.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Shell Options 3 | § ============================================================= 4 | 5 | == LIST: shopt == list == 6 | 'assoc_expand_once', 7 | 'autocd', 8 | 'cdable_vars', 9 | 'cdspell', 10 | 'checkhash', 11 | 'checkjobs', 12 | 'checkwinsize', 13 | 'cmdhist', 14 | 'compat31', 15 | 'compat32', 16 | 'compat40', 17 | 'compat41', 18 | 'compat42', 19 | 'compat43', 20 | 'compat44', 21 | 'complete_fullquote', 22 | 'direxpand', 23 | 'dirspell', 24 | 'dotglob', 25 | 'execfail', 26 | 'expand_aliases', 27 | 'extdebug', 28 | 'extglob', 29 | 'extquote', 30 | 'failglob', 31 | 'force_fignore', 32 | 'globalasciiranges', 33 | 'globstar', 34 | 'gnu_errfmt', 35 | 'histappend', 36 | 'histreedit', 37 | 'histverify', 38 | 'hostcomplete', 39 | 'huponexit', 40 | 'inherit_errexit', 41 | 'interactive_comments', 42 | 'lastpipe', 43 | 'lithist', 44 | 'localvar_inherit', 45 | 'localvar_unset', 46 | 'login_shell', 47 | 'mailwarn', 48 | 'no_empty_cmd_completion', 49 | 'nocaseglob', 50 | 'nocasematch', 51 | 'nullglob', 52 | 'progcomp', 53 | 'progcomp_alias', 54 | 'promptvars', 55 | 'restricted_shell', 56 | 'shift_verbose', 57 | 'sourcepath', 58 | 'xpg_echo', 59 | == ENDLIST == 60 | 61 | == Shopts == expandmenu, insert, map:bso, sc:o == 62 | |PickList( 'Shopts', 'shopt' )| 63 | shopt -s |PICK| 64 | == ENDTEMPLATE == 65 | -------------------------------------------------------------------------------- /bash-support/scripts/wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #=============================================================================== 3 | # FILE: wrapper.sh 4 | # USAGE: ./wrapper.sh scriptname [cmd-line-args] 5 | # DESCRIPTION: Wraps the execution of a programm or script. 6 | # Use with xterm: xterm -e wrapper.sh scriptname cmd-line-args 7 | # This script is used by the Vim plugin bash-support.vim 8 | # OPTIONS: --- 9 | # REQUIREMENTS: --- 10 | # BUGS: --- 11 | # NOTES: --- 12 | # AUTHOR: Dr.-Ing. Fritz Mehner (fgm), mehner.fritz@web.de 13 | # CREATED: 23.11.2004 18:04:01 CET 14 | # REVISION: --- 15 | #=============================================================================== 16 | 17 | scriptname="${1}" # name of the script to execute 18 | returncode=0 # default return code 19 | 20 | if [ ${#} -ge 1 ] ; then 21 | if [ -x "$scriptname" ] ; then # start an executable script? 22 | "${@}" 23 | else 24 | $SHELL "${@}" # start a script which is not executable 25 | fi 26 | returncode=$? 27 | [ $returncode -ne 0 ] && printf "'${@}' returned ${returncode}\n" 28 | else 29 | printf "\n!! ${0} : no argument(s) !!\n" 30 | fi 31 | 32 | read -p "... press return key ... " dummy 33 | exit $returncode 34 | -------------------------------------------------------------------------------- /bash-support/templates/regexp.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § RegExp 3 | § ============================================================= 4 | 5 | == Regexp.zero or one == insert, map:xzo, sc:z == 6 | ?(|) 7 | == Regexp.zero or more == insert, map:xzm, sc:z == 8 | *(|) 9 | == Regexp.one or more == insert, map:xom, sc:o == 10 | +(|) 11 | == Regexp.exactly one == insert, map:xeo, sc:e == 12 | @(|) 13 | == Regexp.anything except == insert, map:xae, sc:a == 14 | !(|) 15 | == ENDTEMPLATE == 16 | 17 | == SEP: Regexp.sep1 == 18 | 19 | == LIST: POSIX_CharClasses == list == 20 | 'alnum', 21 | 'alpha', 22 | 'ascii', 23 | 'blank', 24 | 'cntrl', 25 | 'digit', 26 | 'graph', 27 | 'lower', 28 | 'print', 29 | 'punct', 30 | 'space', 31 | 'upper', 32 | 'word', 33 | 'xdigit', 34 | == ENDLIST == 35 | 36 | == Regexp.POSIX classes == expandmenu, insert, sc:p, map:xpc == 37 | |PickList( 'POSIX char. classes', 'POSIX_CharClasses' )| 38 | [:|PICK|:] 39 | == ENDTEMPLATE == 40 | 41 | == LIST: BashRematch == list == 42 | '${BASH_REMATCH[0]}', 43 | '${BASH_REMATCH[1]}', 44 | '${BASH_REMATCH[2]}', 45 | '${BASH_REMATCH[3]}', 46 | == ENDLIST == 47 | 48 | == Regexp.BASH_REMATCH == expandmenu, insert, sc:b, map:xbr == 49 | |PickList( 'BASH_REMATCH', 'BashRematch' )| 50 | |PICK| 51 | == ENDTEMPLATE == 52 | -------------------------------------------------------------------------------- /bash-support/templates/io-redirection.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § IO Redirection 3 | § ============================================================= 4 | 5 | == LIST: IORedirection == hash == 6 | 'append STDOUT and STDERR' : ' &>> ', 7 | 'close input from file descr n' : ' <&- ', 8 | 'close output from file descr n' : ' >&- ', 9 | 'close STDIN' : ' <&- ', 10 | 'close STDOUT' : ' >&- ', 11 | 'direct file descr n to file, append' : ' >> ', 12 | 'direct file descr n to file' : ' > ', 13 | 'direct STDERR to STDOUT' : ' 2>&1', 14 | 'direct STDOUT and STDERR to file' : ' &> ', 15 | 'direct STDOUT to file, append' : ' >> ', 16 | 'direct STDOUT to file' : ' > ', 17 | 'direct STDOUT to STDERR' : ' >&2', 18 | 'duplicate STDIN from file descr n' : ' <& ', 19 | 'duplicate STDOUT to file descr n' : ' >& ', 20 | 'take file descr n from file' : ' < ', 21 | 'take STDIN from file' : ' < ', 22 | == ENDLIST == 23 | 24 | == IO-Redir.redir == expandmenu, expandright:value-notags, insert, sc:r, map:ior == 25 | |PickList( 'IO-Redir', 'IORedirection' )| 26 | |VALUE| 27 | == ENDTEMPLATE == 28 | 29 | == IO-Redir.here-document == insert, sc:h, map:ioh == 30 | <<-EOF 31 | 32 | EOF 33 | == ENDTEMPLATE == 34 | -------------------------------------------------------------------------------- /bash-support/templates/patternmatching.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § RegExp 3 | § ============================================================= 4 | 5 | == PatternMatching.zero or one == insert, map:pzo, sc:z == 6 | ?(|) 7 | == PatternMatching.zero or more == insert, map:pzm, sc:z == 8 | *(|) 9 | == PatternMatching.one or more == insert, map:pom, sc:o == 10 | +(|) 11 | == PatternMatching.exactly one == insert, map:peo, sc:e == 12 | @(|) 13 | == PatternMatching.anything except == insert, map:pae, sc:a == 14 | !(|) 15 | == ENDTEMPLATE == 16 | 17 | == SEP: PatternMatching.sep1 == 18 | 19 | == LIST: POSIX_CharClasses == list == 20 | 'alnum', 21 | 'alpha', 22 | 'ascii', 23 | 'blank', 24 | 'cntrl', 25 | 'digit', 26 | 'graph', 27 | 'lower', 28 | 'print', 29 | 'punct', 30 | 'space', 31 | 'upper', 32 | 'word', 33 | 'xdigit', 34 | == ENDLIST == 35 | 36 | == PatternMatching.POSIX classes == expandmenu, insert, sc:p, map:ppc == 37 | |PickList( 'POSIX char. classes', 'POSIX_CharClasses' )| 38 | [:|PICK|:] 39 | == ENDTEMPLATE == 40 | 41 | == LIST: BashRematch == list == 42 | '${BASH_REMATCH[0]}', 43 | '${BASH_REMATCH[1]}', 44 | '${BASH_REMATCH[2]}', 45 | '${BASH_REMATCH[3]}', 46 | == ENDLIST == 47 | 48 | == PatternMatching.BASH_REMATCH == expandmenu, insert, sc:b, map:pbr == 49 | |PickList( 'BASH_REMATCH', 'BashRematch' )| 50 | |PICK| 51 | == ENDTEMPLATE == 52 | -------------------------------------------------------------------------------- /bash-support/templates/paramsub.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Parameter Substitution 3 | § ============================================================= 4 | 5 | == LIST: ParameterSubstitution == hash == 6 | 'all lower to upper' : '${^^<+pattern+>}', 7 | 'all upper to lower' : '${,,<+pattern+>}', 8 | 'assign default value' : '${:=<+word+>}', 9 | 'display error' : '${:?<+word+>}', 10 | 'first lower to upper' : '${^<+pattern+>}', 11 | 'first upper to lower' : '${,<+pattern+>}', 12 | 'indirect parameter expansion' : '${!}', 13 | 'names matching prefix' : '${!*}', 14 | 'parameter length' : '${#}', 15 | 'parameter transformation' : '${@<+operator+>}', 16 | 'pattern substitution all' : '${//<+pattern+>/<+string+>}', 17 | 'pattern substitution begin' : '${/#<+pattern+>/<+string+>}', 18 | 'pattern substitution' : '${/<+pattern+>/<+string+>}', 19 | 'pattern substitution end' : '${/%<+pattern+>/<+string+>}', 20 | 'remove all matching prefix pattern' : '${##<+word+>}', 21 | 'remove all matching suffix pattern' : '${%%<+word+>}', 22 | 'remove matching prefix pattern' : '${#<+word+>}', 23 | 'remove matching suffix pattern' : '${%<+word+>}', 24 | 'substitution' : '${}', 25 | 'substring expansion' : '${:<+offset+>:<+length+>}', 26 | 'use alternate value' : '${:+<+word+>}', 27 | 'use default value' : '${:-<+word+>}', 28 | == ENDLIST == 29 | 30 | == ParamSub == expandmenu, expandright:value-whitetags, insert, sc:p, map:bps == 31 | |PickList( 'Parameter Substitution', 'ParameterSubstitution' )| 32 | |VALUE| 33 | == ENDTEMPLATE == 34 | 35 | -------------------------------------------------------------------------------- /ftplugin/template.vim: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: template.vim 4 | " 5 | " Description: Filetype plugin for templates. 6 | " 7 | " VIM Version: 7.0+ 8 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 9 | " Organization: 10 | " Version: 1.0 11 | " Created: 30.08.2011 12 | " Revision: 04.01.2016 13 | " License: Copyright (c) 2012-2016, Wolfgang Mehner 14 | " This program is free software; you can redistribute it and/or 15 | " modify it under the terms of the GNU General Public License as 16 | " published by the Free Software Foundation, version 2 of the 17 | " License. 18 | " This program is distributed in the hope that it will be 19 | " useful, but WITHOUT ANY WARRANTY; without even the implied 20 | " warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 21 | " PURPOSE. 22 | " See the GNU General Public License version 2 for more details. 23 | "=============================================================================== 24 | 25 | " only do this when not done yet for this buffer 26 | if exists("b:did_Template_ftplugin") 27 | finish 28 | endif 29 | let b:did_Template_ftplugin = 1 30 | 31 | "------------------------------------------------------------------------------- 32 | " Editing: repeat comments, ... 33 | "------------------------------------------------------------------------------- 34 | 35 | " default: -something- 36 | setlocal comments=sO:§\ -,mO:§\ \ ,eO:§§,:§ 37 | " default: tcq 38 | " - remove auto-wrap text 39 | " - keep autowrap comments 40 | " - add insertion of comment leader after hitting , o, O 41 | " - add do not break lines which were already to long 42 | setlocal formatoptions-=t 43 | setlocal formatoptions+=rol 44 | 45 | -------------------------------------------------------------------------------- /bash-support/templates/environment.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Environment 3 | § ============================================================= 4 | 5 | == LIST: environment == list == 6 | 'BASH', 7 | 'BASH_ALIASES', 8 | 'BASH_ARGC', 9 | 'BASH_ARGV', 10 | 'BASH_ARGV0', 11 | 'BASH_CMDS', 12 | 'BASH_COMMAND', 13 | 'BASH_COMPAT', 14 | 'BASH_ENV', 15 | 'BASH_EXECUTION_STRING', 16 | 'BASH_LINENO', 17 | 'BASH_LOADABLES_PATH', 18 | 'BASHOPTS', 19 | 'BASHPID', 20 | 'BASH_REMATCH', 21 | 'BASH_SOURCE', 22 | 'BASH_SUBSHELL', 23 | 'BASH_VERSINFO', 24 | 'BASH_VERSION', 25 | 'BASH_XTRACEFD', 26 | 'CDPATH', 27 | 'CHILD_MAX', 28 | 'COLUMNS', 29 | 'COMP_CWORD', 30 | 'COMP_KEY', 31 | 'COMP_LINE', 32 | 'COMP_POINT', 33 | 'COMPREPLY', 34 | 'COMP_TYPE', 35 | 'COMP_WORDBREAKS', 36 | 'COMP_WORDS', 37 | 'COPROC', 38 | 'DIRSTACK', 39 | 'EMACS', 40 | 'ENV', 41 | 'EPOCHREALTIME', 42 | 'EPOCHSECONDS', 43 | 'EUID', 44 | 'EXECIGNORE', 45 | 'FCEDIT', 46 | 'FIGNORE', 47 | 'FUNCNAME', 48 | 'FUNCNEST', 49 | 'GLOBIGNORE', 50 | 'GROUPS', 51 | 'HISTCMD', 52 | 'HISTCONTROL', 53 | 'HISTFILE', 54 | 'HISTFILESIZE', 55 | 'HISTIGNORE', 56 | 'HISTSIZE', 57 | 'HISTTIMEFORMAT', 58 | 'HOME', 59 | 'HOSTFILE', 60 | 'HOSTNAME', 61 | 'HOSTTYPE', 62 | 'IFS', 63 | 'IGNOREEOF', 64 | 'INPUTRC', 65 | 'INSIDE_EMACS', 66 | 'LANG', 67 | 'LC_ALL', 68 | 'LC_COLLATE', 69 | 'LC_CTYPE', 70 | 'LC_MESSAGES', 71 | 'LC_NUMERIC', 72 | 'LC_TIME', 73 | 'LINENO', 74 | 'LINES', 75 | 'MACHTYPE', 76 | 'MAIL', 77 | 'MAILCHECK', 78 | 'MAILPATH', 79 | 'MAPFILE', 80 | 'OLDPWD', 81 | 'OPTARG', 82 | 'OPTERR', 83 | 'OPTIND', 84 | 'OSTYPE', 85 | 'PATH', 86 | 'PIPESTATUS', 87 | 'POSIXLY_CORRECT', 88 | 'PPID', 89 | 'PROMPT_COMMAND', 90 | 'PROMPT_DIRTRIM', 91 | 'PS0', 92 | 'PS1', 93 | 'PS2', 94 | 'PS3', 95 | 'PS4', 96 | 'PWD', 97 | 'RANDOM', 98 | 'READLINE_LINE', 99 | 'READLINE_POINT', 100 | 'REPLY', 101 | 'SECONDS', 102 | 'SHELL', 103 | 'SHELLOPTS', 104 | 'SHLVL', 105 | 'TIMEFORMAT', 106 | 'TMOUT', 107 | 'TMPDIR', 108 | 'UID', 109 | == ENDLIST == 110 | 111 | == Environment == expandmenu, insert, map:ben, sc:e == 112 | |PickList( 'Environment', 'environment' )| 113 | |PICK| 114 | == ENDTEMPLATE == 115 | 116 | -------------------------------------------------------------------------------- /bash-support/rc/custom.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Custom Templates 3 | § ============================================================= 4 | 5 | § set the template style used after loading the library 6 | SetStyle( 'default' ) 7 | 8 | § used by the template "Comments.shebang": 9 | SetMacro( 'BASH_INTERPRETER', '/bin/bash' ) 10 | 11 | § templates automatically included into new files 12 | § set the property to an empty string to disable the insertion 13 | §SetProperty ( 'Bash::FileSkeleton::Script', 'Comments.shebang;Comments.file header; ;Skeleton.script-set' ) 14 | 15 | § ------------------------------------------------------------- 16 | § A template definition is build like this: 17 | § == Menu.some name == == 18 | § 19 | § == Menu.other name == == 20 | § 21 | § == ENDTEMPLATE == 22 | § A template ends with the line "== ENDTEMPLATE ==" or with 23 | § the start of a new template. 24 | § ------------------------------------------------------------- 25 | 26 | § ------------------------------------------------------------- 27 | § Inserted when creating a new script. 28 | § See configuration variable 'g:BASH_InsertFileHeader' 29 | § and template property 'Bash::FileSkeleton::Script'. 30 | § 31 | § - option 'nomenu': this will not create a menu entry 32 | § ------------------------------------------------------------- 33 | 34 | § uncomment and edit to customize 35 | 36 | §== Skeleton.script-set == nomenu, below == 37 | §set -o nounset # Treat unset variables as an error 38 | §shopt -s extglob # Extended pattern matching 39 | §== ENDTEMPLATE == 40 | 41 | § ------------------------------------------------------------- 42 | § Statements 43 | § ------------------------------------------------------------- 44 | 45 | § uncomment and edit to customize 46 | 47 | §== Statements.case == map:sc, shortcut:c == 48 | §case in 49 | § ) 50 | § ;; 51 | § 52 | § ) 53 | § ;; 54 | § 55 | § *) 56 | § ;; 57 | § 58 | §esac # --- end of case --- 59 | §== ENDTEMPLATE == 60 | 61 | §== Statements.function == map:sfu, shortcut:f == 62 | §|?FUNCTION_NAME| () 63 | §{ 64 | § 65 | §} # ---------- end of function |FUNCTION_NAME| ---------- 66 | §== ENDTEMPLATE == 67 | 68 | -------------------------------------------------------------------------------- /bash-support/templates/statements.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Statements 3 | § ============================================================= 4 | 5 | == Statements.case == map:sc, shortcut:c == 6 | case in 7 | ) 8 | ;; 9 | 10 | ) 11 | ;; 12 | 13 | *) 14 | ;; 15 | 16 | esac # --- end of case --- 17 | == Statements.elif == map:sei, shortcut:e == 18 | elif ; then 19 | == Statements.for-in == map:sf, shortcut:f == 20 | for in ; do 21 | <-LOOP_BODY-> 22 | done 23 | == Statements.for == map:sfo, shortcut:f == 24 | for (( CNTR=0; CNTR<0; CNTR+=1 )); do 25 | <-LOOP_BODY-> 26 | done 27 | == Statements.if == map:si, shortcut:i == 28 | if ; then 29 | <-IF_PART-> 30 | fi 31 | == Statements.if-else == map:sie, shortcut:i == 32 | if ; then 33 | <-IF_PART-> 34 | else 35 | <+ELSE_PART+> 36 | fi 37 | == Statements.select == map:ss, shortcut:s == 38 | select in ; do 39 | done 40 | == Statements.until == map:su, shortcut:u == 41 | until ; do 42 | done 43 | == Statements.while == map:sw, shortcut:w == 44 | while ; do 45 | done 46 | == Statements.function == map:sfu, shortcut:f == 47 | |?FUNCTION_NAME| () 48 | { 49 | 50 | } # ---------- end of function |FUNCTION_NAME| ---------- 51 | == ENDTEMPLATE == 52 | 53 | § ------------------------------------------------------------- 54 | 55 | == SEP: Statements.sep-print == 56 | 57 | == Statements.echo == insert, map:se, shortcut:e == 58 | echo -e "" 59 | == Statements.printf == insert, map:sp, shortcut:p == 60 | printf "%s\n" 61 | == ENDTEMPLATE == 62 | 63 | § ------------------------------------------------------------- 64 | 65 | == SEP: Statements.sep-array == 66 | 67 | == Statements.array element == insert, map:sae, shortcut:a == 68 | ${[]} 69 | == Statements.array elements, all == insert, map:saa, shortcut:a == 70 | ${[@]} 71 | == Statements.array elements, string == insert, map:sas, shortcut:s == 72 | ${[*]} 73 | == Statements.subarray == insert, map:ssa, shortcut:s == 74 | ${[@]::} 75 | == Statements.no of element == insert, map:san, shortcut:n == 76 | ${#[@]} 77 | == Statements.array indices== insert, map:sai, shortcut:i == 78 | ${![@]} 79 | == ENDTEMPLATE == 80 | 81 | -------------------------------------------------------------------------------- /bash-support/rc/customization.gvimrc: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: customization.gvimrc 4 | " 5 | " Description: suggestion for a personal configuration file ~/.vimrc 6 | " 7 | " VIM Version: 7.4+ 8 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 9 | " Dr. Fritz Mehner (fgm), mehner.fritz@web.de 10 | " Revision: 16.04.2019 11 | " License: Copyright (c) 2009-2018, Dr. Fritz Mehner 12 | " Copyright (c) 2019-2020, Wolfgang Mehner 13 | "=============================================================================== 14 | 15 | "=============================================================================== 16 | " GENERAL SETTINGS 17 | "=============================================================================== 18 | 19 | set cmdheight=2 " Make command line two lines high 20 | set mousehide " Hide the mouse when typing text 21 | 22 | highlight Normal guibg=grey90 23 | highlight Cursor guibg=Blue guifg=NONE 24 | highlight lCursor guibg=Cyan guifg=NONE 25 | highlight NonText guibg=grey80 26 | highlight Constant gui=NONE guibg=grey95 27 | highlight Special gui=NONE guibg=grey95 28 | 29 | let c_comment_strings=1 " highlight strings inside C comments 30 | 31 | "------------------------------------------------------------------------------- 32 | " Moving cursor to other windows 33 | " 34 | " shift-down : change window focus to lower one (cyclic) 35 | " shift-up : change window focus to upper one (cyclic) 36 | " shift-left : change window focus to one on left 37 | " shift-right : change window focus to one on right 38 | "------------------------------------------------------------------------------- 39 | nnoremap w 40 | nnoremap W 41 | nnoremap h 42 | nnoremap l 43 | 44 | "------------------------------------------------------------------------------- 45 | " Some additional hot keys 46 | " 47 | " shift-F3 : call gvim file browser 48 | "------------------------------------------------------------------------------- 49 | noremap :silent browse confirm e 50 | inoremap :silent browse confirm e 51 | 52 | "------------------------------------------------------------------------------- 53 | " toggle insert mode <--> normal mode with the -key 54 | "------------------------------------------------------------------------------- 55 | 56 | nnoremap 57 | inoremap 58 | 59 | "------------------------------------------------------------------------------- 60 | " use font with clearly distinguishable brackets: ()[]{} 61 | "------------------------------------------------------------------------------- 62 | "set guifont=Luxi\ Mono\ 14 63 | -------------------------------------------------------------------------------- /bash-support/templates/tests.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Tests 3 | § ============================================================= 4 | 5 | == LIST: TestsArithmetic == hash == 6 | 'arg1 is equal to arg2' : '-eq', 7 | 'arg1 not equal to arg2' : '-ne', 8 | 'arg1 less than arg2' : '-lt', 9 | 'arg1 less than or equal to arg2' : '-le', 10 | 'arg1 greater than arg2' : '-gt', 11 | 'arg1 greater than or equal to arg2' : '-ge', 12 | == ENDLIST == 13 | 14 | == Tests.arithmetic tests == expandmenu, expandright:value, insert, sc:a, map:ta == 15 | |PickList( 'arithmetic tests', 'TestsArithmetic' )| 16 | [ |VALUE| ] 17 | == ENDTEMPLATE == 18 | 19 | == LIST: TestsFilePermission == hash == 20 | 'readable' : '-r', 21 | 'writable' : '-w', 22 | 'executable' : '-x', 23 | 'SUID-bit is set' : '-u', 24 | 'SGID-bit is set' : '-g', 25 | 'sticky bit is set' : '-k', 26 | == ENDLIST == 27 | 28 | == Tests.file permissions == expandmenu, expandright:value, insert, sc:p, map:tfp == 29 | |PickList( 'file permission', 'TestsFilePermission' )| 30 | [ |VALUE| ] 31 | == ENDTEMPLATE == 32 | 33 | == LIST: TestsFileTypes == hash == 34 | 'block special file' : '-b', 35 | 'character special file' : '-c', 36 | 'directory' : '-d', 37 | 'named pipe (FIFO)' : '-p', 38 | 'regular file' : '-f', 39 | 'socket' : '-S', 40 | 'symbolic link (-h)' : '-h', 41 | 'symbolic link (-L)' : '-L', 42 | == ENDLIST == 43 | 44 | == Tests.file types == expandmenu, expandright:value, insert, sc:t, map:tft == 45 | |PickList( 'file type', 'TestsFileTypes' )| 46 | [ |VALUE| ] 47 | == ENDTEMPLATE == 48 | 49 | == LIST: TestsFileCharacteristics == hash == 50 | 'file exists' : '-e', 51 | 'file exists, size greater zero' : '-s', 52 | 'file exists, owned by eff UID' : '-O', 53 | 'file exists, owned by eff GID' : '-G', 54 | 'file exists, modified since last read' : '-N', 55 | 'file1 newer than file2' : '-nt', 56 | 'file1 older than file2' : '-ot', 57 | 'files have same device and inode numbers ' : '-ef', 58 | == ENDLIST == 59 | 60 | == Tests.file characteristics == expandmenu, expandright:value, insert, sc:c, map:tfc == 61 | |PickList( 'file characteristics', 'TestsFileCharacteristics' )| 62 | [ |VALUE| ] 63 | == ENDTEMPLATE == 64 | 65 | == LIST: TestsStrings == hash == 66 | 'length is zero' : '-z', 67 | 'length is non-zero' : '-n', 68 | 'strings are equal' : '==', 69 | 'strings are not equal' : '!=', 70 | 'sorts before' : '<', 71 | 'sorts after' : '>', 72 | == ENDLIST == 73 | 74 | == Tests.string comparison == expandmenu, expandright:value, insert, sc:s, map:ts == 75 | |PickList( 'string comparisons', 'TestsStrings' )| 76 | [ |VALUE| ] 77 | == ENDTEMPLATE == 78 | 79 | == Tests.option is enabled, -o == insert, map:toe, sc:o == 80 | [ -o ] 81 | == Tests.variable has been set, -v == insert, map:tvs, sc:v == 82 | [ -v ] 83 | == Tests.file descriptor is open, refers to a terminal, -t == insert, map:tfd, sc:d == 84 | [ -t ] 85 | == Tests.string matches regexp == insert, map:tm, sc:m == 86 | [[ =~ ]] 87 | == ENDTEMPLATE == 88 | -------------------------------------------------------------------------------- /bash-support/rc/custom_with_personal.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Template Customization 3 | § ============================================================= 4 | 5 | § ============================================================= 6 | § Personal Information 7 | § 8 | § - overwrites the information in the template personalization 9 | § file, because these commands are read later 10 | § ============================================================= 11 | 12 | SetMacro( 'AUTHOR', 'YOUR NAME' ) 13 | SetMacro( 'AUTHORREF', '' ) 14 | SetMacro( 'EMAIL', '' ) 15 | SetMacro( 'ORGANIZATION', '' ) 16 | SetMacro( 'COMPANY', '' ) 17 | SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) 18 | SetMacro( 'LICENSE', 'GNU General Public License' ) 19 | 20 | § ============================================================= 21 | § Date and Time Format 22 | § ============================================================= 23 | 24 | §SetFormat( 'DATE', '%x' ) 25 | §SetFormat( 'TIME', '%H:%M' ) 26 | §SetFormat( 'YEAR', '%Y' ) 27 | 28 | § ============================================================= 29 | § Custom Templates 30 | § ============================================================= 31 | 32 | § set the template style used after loading the library 33 | SetStyle( 'default' ) 34 | 35 | § used by the template "Comments.shebang": 36 | SetMacro( 'BASH_INTERPRETER', '/bin/bash' ) 37 | 38 | § templates automatically included into new files 39 | § set the property to an empty string to disable the insertion 40 | §SetProperty ( 'Bash::FileSkeleton::Script', 'Comments.shebang;Comments.file header; ;Skeleton.script-set' ) 41 | 42 | § ------------------------------------------------------------- 43 | § A template definition is build like this: 44 | § == Menu.some name == == 45 | § 46 | § == Menu.other name == == 47 | § 48 | § == ENDTEMPLATE == 49 | § A template ends with the line "== ENDTEMPLATE ==" or with 50 | § the start of a new template. 51 | § ------------------------------------------------------------- 52 | 53 | § ------------------------------------------------------------- 54 | § Inserted when creating a new script. 55 | § See configuration variable 'g:BASH_InsertFileHeader' 56 | § and template property 'Bash::FileSkeleton::Script'. 57 | § 58 | § - option 'nomenu': this will not create a menu entry 59 | § ------------------------------------------------------------- 60 | 61 | § uncomment and edit to customize 62 | 63 | §== Skeleton.script-set == nomenu, below == 64 | §set -o nounset # Treat unset variables as an error 65 | §shopt -s extglob # Extended pattern matching 66 | §== ENDTEMPLATE == 67 | 68 | § ------------------------------------------------------------- 69 | § Statements 70 | § ------------------------------------------------------------- 71 | 72 | § uncomment and edit to customize 73 | 74 | §== Statements.case == map:sc, shortcut:c == 75 | §case in 76 | § ) 77 | § ;; 78 | § 79 | § ) 80 | § ;; 81 | § 82 | § *) 83 | § ;; 84 | § 85 | §esac # --- end of case --- 86 | §== ENDTEMPLATE == 87 | 88 | §== Statements.function == map:sfu, shortcut:f == 89 | §|?FUNCTION_NAME| () 90 | §{ 91 | § 92 | §} # ---------- end of function |FUNCTION_NAME| ---------- 93 | §== ENDTEMPLATE == 94 | 95 | -------------------------------------------------------------------------------- /bash-support/templates/Templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Interface Version 3 | § 4 | § enable advanced features 5 | § ============================================================= 6 | 7 | InterfaceVersion ( "1.0" ) 8 | 9 | § ============================================================= 10 | § Settings 11 | § ============================================================= 12 | 13 | SetMacro( 'AUTHOR', 'YOUR NAME' ) 14 | SetMacro( 'AUTHORREF', '' ) 15 | SetMacro( 'EMAIL', '' ) 16 | SetMacro( 'ORGANIZATION', '' ) 17 | SetMacro( 'COMPANY', '' ) 18 | SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) 19 | SetMacro( 'LICENSE', 'GNU General Public License' ) 20 | 21 | SetFormat( 'DATE', '%x' ) 22 | SetFormat( 'TIME', '%X' ) 23 | SetFormat( 'YEAR', '%Y' ) 24 | 25 | SetStyle( 'default' ) 26 | 27 | § used by the template "Comments.shebang": 28 | SetMacro( 'BASH_INTERPRETER', '/bin/bash' ) 29 | 30 | § templates automatically included into new files 31 | § set the property to an empty string to disable the insertion 32 | SetProperty ( 'Bash::FileSkeleton::Script', 'Comments.shebang;Comments.file header; ;Skeleton.script-set' ) 33 | 34 | § ============================================================= 35 | § File Includes and Shortcuts 36 | § ============================================================= 37 | 38 | § :TODO:14.07.13 12:50:WM: files "paramsub.templates" and "io-redirection.templates": maps, shortcuts? sort alphabetically? 39 | 40 | MenuShortcut( 'Comments', 'c' ) 41 | MenuShortcut( 'Statements', 's' ) 42 | MenuShortcut( 'Tests', 't' ) 43 | MenuShortcut( 'ParamSub', 'p' ) 44 | MenuShortcut( 'PatternMatching', 'p' ) 45 | MenuShortcut( 'IO-Redir', 'i' ) 46 | 47 | IncludeFile( 'comments.templates' ) 48 | IncludeFile( 'statements.templates' ) 49 | IncludeFile( 'tests.templates' ) 50 | IncludeFile( 'paramsub.templates' ) 51 | IncludeFile( 'specialparams.templates' ) 52 | IncludeFile( 'environment.templates' ) 53 | IncludeFile( 'builtins.templates' ) 54 | IncludeFile( 'set.templates' ) 55 | IncludeFile( 'shelloptions.templates' ) 56 | IncludeFile( 'io-redirection.templates' ) 57 | IncludeFile( 'patternmatching.templates' ) 58 | 59 | § ============================================================= 60 | § Inserted when creating a new script. 61 | § See configuration variable 'g:BASH_InsertFileHeader' 62 | § and template property 'Bash::FileSkeleton::Script'. 63 | § 64 | § - option 'nomenu': this will not create a menu entry 65 | § ============================================================= 66 | 67 | == Skeleton.script-set == nomenu, below == 68 | set -o nounset # Treat unset variables as an error 69 | == ENDTEMPLATE == 70 | 71 | § ============================================================= 72 | § Help 73 | § 74 | § help English: 75 | § - pick up the word under the cursor 76 | § - delete non-word characters before calling the help 77 | § - the word is always included in the URL in lowercase, 78 | § which seems to work better 79 | § ============================================================= 80 | 81 | SetMacro( 'HelpPathEnglish', 'http://en.wiktionary.org/wiki/' ) 82 | 83 | == HELP: Help.English == map:he, sc:e == 84 | |Word( '' )| 85 | |Substitute( '\W', '', 'g' )| 86 | |Browser( '|HelpPathEnglish||PICK:l|' )| 87 | == ENDTEMPLATE == 88 | -------------------------------------------------------------------------------- /bash-support/rc/sh.vim: -------------------------------------------------------------------------------- 1 | " ------------------------------------------------------------------------------ 2 | " 3 | " Vim filetype plugin file 4 | " 5 | " Language : Bash 6 | " Plugin : bash-support.vim 7 | " Revision : 08.10.2017 8 | " Maintainer : Wolfgang Mehner 9 | " (formerly Fritz Mehner ) 10 | " 11 | " ------------------------------------------------------------------------------ 12 | 13 | " Only do this when not done yet for this buffer 14 | if exists("b:did_bash_support_ftplugin") 15 | finish 16 | endif 17 | let b:did_bash_support_ftplugin = 1 18 | 19 | " ---------- Avoid a wrong syntax highlighting for $(..) and $((..)) --------- 20 | let b:is_bash = 1 21 | 22 | " ---------- Key mappings - Quotes ------------------------------------------- 23 | " single quotes around a Word (non-whitespaces) 24 | " masks the normal mode command '' (jump to the position before the latest jump) 25 | " double quotes around a Word (non-whitespaces) 26 | "nnoremap '' ciW''P 27 | "nnoremap "" ciW""P 28 | 29 | " ---------- Key mappings - Tests -------------------------------------------- 30 | " additional mapping : \t1 expands to [ - ] 31 | " additional mapping : \t2 expands to [ - ] 32 | "nnoremap t1 a[ - ] 33 | "inoremap t1 [ - ] 34 | 35 | "nnoremap t2 a[ - ] 36 | "inoremap t2 [ - ] 37 | 38 | " ---------- Set "maplocalleader" as configured using "g:BASH_MapLeader" ----- 39 | call Bash_SetMapLeader () 40 | 41 | " maps defined here will use "g:BASH_MapLeader" as 42 | " example: 43 | "map eg :echo "Example Map :)" 44 | 45 | " ---------- Run, compile, code checker -------------------------------------- 46 | nnoremap :Bash 47 | inoremap :Bash 48 | vnoremap :Bash 49 | " the ex-command :Bash handles the range in visual mode, do not escape via 50 | 51 | nnoremap :BashScriptArguments 52 | inoremap :BashScriptArguments 53 | 54 | nnoremap :BashCheck 55 | inoremap :BashCheck 56 | 57 | " ---------- Debugger -------------------------------------------------------- 58 | 59 | " use F9 to start the debugger 60 | "nnoremap :BashDB 61 | "inoremap :BashDB 62 | "vnoremap :BashDB 63 | 64 | " map (D)ebugger (R)un 65 | "nnoremap dr :BashDB 66 | "inoremap dr :BashDB 67 | "vnoremap dr :BashDB 68 | " map (D)ebugger (C)hoose method 69 | "nnoremap dc :BashDBDebugger 70 | "inoremap dc :BashDBDebugger 71 | "vnoremap dc :BashDBDebugger 72 | 73 | " ---------- Reset "maplocalleader" ------------------------------------------ 74 | call Bash_ResetMapLeader () 75 | 76 | -------------------------------------------------------------------------------- /bash-support/wordlists/bash-keywords.list: -------------------------------------------------------------------------------- 1 | BASH 2 | BASHPID 3 | BASH_ALIASES 4 | BASH_ARGC 5 | BASH_ARGV 6 | BASH_CMDS 7 | BASH_COMMAND 8 | BASH_ENV 9 | BASH_EXECUTION_STRING 10 | BASH_LINENO 11 | BASHOPTS 12 | BASH_REMATCH 13 | BASH_SOURCE 14 | BASH_SUBSHELL 15 | BASH_VERSINFO 16 | BASH_VERSION 17 | BASH_XTRACEFD 18 | CDPATH 19 | COLUMNS 20 | COMPREPLY 21 | COMP_CWORD 22 | COMP_KEY 23 | COMP_LINE 24 | COMP_POINT 25 | COMP_TYPE 26 | COMP_WORDBREAKS 27 | COMP_WORDS 28 | DIRSTACK 29 | EMACS 30 | EUID 31 | FCEDIT 32 | FIGNORE 33 | FUNCNAME 34 | FUNCNEST 35 | GLOBIGNORE 36 | GROUPS 37 | HISTCMD 38 | HISTCONTROL 39 | HISTFILE 40 | HISTFILESIZE 41 | HISTIGNORE 42 | HISTSIZE 43 | HISTTIMEFORMAT 44 | HOME 45 | HOSTFILE 46 | HOSTNAME 47 | HOSTTYPE 48 | IFS 49 | IGNOREEOF 50 | INPUTRC 51 | LANG 52 | LC_ALL 53 | LC_COLLATE 54 | LC_CTYPE 55 | LC_MESSAGES 56 | LC_NUMERIC 57 | LINENO 58 | LINES 59 | MACHTYPE 60 | MAIL 61 | MAILCHECK 62 | MAILPATH 63 | OLDPWD 64 | OPTARG 65 | OPTERR 66 | OPTIND 67 | OSTYPE 68 | PATH 69 | PIPESTATUS 70 | POSIXLY_CORRECT 71 | PPID 72 | PROMPT_COMMAND 73 | PROMPT_DIRTRIM 74 | PS1 75 | PS2 76 | PS3 77 | PS4 78 | PWD 79 | RANDOM 80 | REPLY 81 | SECONDS 82 | SHELL 83 | SHELLOPTS 84 | SHLVL 85 | TIMEFORMAT 86 | TMOUT 87 | TMPDIR 88 | UID 89 | auto_resume 90 | histchars 91 | 92 | alias 93 | bg 94 | bind 95 | break 96 | builtin 97 | caller 98 | cd 99 | command 100 | compgen 101 | complete 102 | compopt 103 | continue 104 | declare 105 | dirs 106 | disown 107 | echo 108 | enable 109 | eval 110 | exec 111 | exit 112 | export 113 | false 114 | fc 115 | fg 116 | getopts 117 | hash 118 | help 119 | history 120 | jobs 121 | kill 122 | let 123 | local 124 | logout 125 | mapfile 126 | popd 127 | printf 128 | pushd 129 | pwd 130 | read 131 | readarray 132 | readonly 133 | return 134 | set 135 | shift 136 | shopt 137 | source 138 | suspend 139 | test 140 | times 141 | trap 142 | true 143 | type 144 | typeset 145 | ulimit 146 | umask 147 | unalias 148 | unset 149 | wait 150 | 151 | case 152 | done 153 | elif 154 | else 155 | esac 156 | for 157 | function 158 | select 159 | then 160 | time 161 | until 162 | while 163 | 164 | allexport 165 | braceexpand 166 | emacs 167 | errexit 168 | errtrace 169 | functrace 170 | hashall 171 | histexpand 172 | history 173 | ignoreeof 174 | keyword 175 | monitor 176 | noclobber 177 | noexec 178 | noglob 179 | notify 180 | nounset 181 | onecmd 182 | physical 183 | pipefail 184 | posix 185 | privileged 186 | verbose 187 | xtrace 188 | 189 | autocd 190 | cdable_vars 191 | cdspell 192 | checkhash 193 | checkjobs 194 | checkwinsize 195 | cmdhist 196 | compat31 197 | compat32 198 | compat40 199 | compat41 200 | dirspell 201 | dotglob 202 | execfail 203 | expand_aliases 204 | extdebug 205 | extglob 206 | extquote 207 | failglob 208 | force_fignore 209 | globstar 210 | gnu_errfmt 211 | histappend 212 | histreedit 213 | histverify 214 | hostcomplete 215 | huponexit 216 | interactive_comments 217 | lastpipe 218 | lithist 219 | login_shell 220 | mailwarn 221 | no_empty_cmd_completion 222 | nocaseglob 223 | nocasematch 224 | nullglob 225 | progcomp 226 | promptvars 227 | restricted_shell 228 | shift_verbose 229 | sourcepath 230 | xpg_echo 231 | 232 | SIGABRT 233 | SIGALRM 234 | SIGBUS 235 | SIGCHLD 236 | SIGCONT 237 | SIGFPE 238 | SIGHUP 239 | SIGILL 240 | SIGINT 241 | SIGIO 242 | SIGKILL 243 | SIGPIPE 244 | SIGPROF 245 | SIGPWR 246 | SIGQUIT 247 | SIGRTMAX 248 | SIGRTMIN 249 | SIGSEGV 250 | SIGSTKFLT 251 | SIGSTOP 252 | SIGSYS 253 | SIGTERM 254 | SIGTRAP 255 | SIGTSTP 256 | SIGTTIN 257 | SIGTTOU 258 | SIGURG 259 | SIGUSR1 260 | SIGUSR2 261 | SIGVTALRM 262 | SIGWINCH 263 | SIGXCPU 264 | SIGXFSZ 265 | -------------------------------------------------------------------------------- /bash-support/templates/comments.templates: -------------------------------------------------------------------------------- 1 | § ============================================================= 2 | § Comments 3 | § ============================================================= 4 | 5 | == Comments.end-of-line comment == nomenu, append == 6 | # 7 | == Comments.frame == map:cfr, sc:r == 8 | #------------------------------------------------------------------------------- 9 | # 10 | #------------------------------------------------------------------------------- 11 | == Comments.function == map:cfu, sc:f == 12 | #--- FUNCTION ---------------------------------------------------------------- 13 | # NAME: |?FUNCTION_NAME| 14 | # DESCRIPTION: 15 | # PARAMETERS: 16 | # RETURNS: 17 | #------------------------------------------------------------------------------- 18 | == Comments.file header == start, map:ch == 19 | #=============================================================================== 20 | # 21 | # FILE: |FILENAME| 22 | # 23 | # USAGE: ./|FILENAME| 24 | # 25 | # DESCRIPTION: 26 | # 27 | # OPTIONS: --- 28 | # REQUIREMENTS: --- 29 | # BUGS: --- 30 | # NOTES: --- 31 | # AUTHOR: |AUTHOR| (|AUTHORREF|), |EMAIL| 32 | # ORGANIZATION: |ORGANIZATION| 33 | # CREATED: |DATE| |TIME| 34 | # REVISION: --- 35 | #=============================================================================== 36 | == Comments.shebang == start, map:csh == 37 | #!|BASH_INTERPRETER| - 38 | == ENDTEMPLATE == 39 | 40 | § ------------------------------------------------------------- 41 | 42 | == SEP: Comments.sep-date-time == 43 | 44 | == Comments.date == insert, map:cd, sc:d == 45 | |DATE| 46 | == Comments.date+time == insert, map:ct, sc:t == 47 | |DATE| |TIME| 48 | == ENDTEMPLATE == 49 | 50 | § ------------------------------------------------------------- 51 | § Keywords, Special and Macros 52 | § ------------------------------------------------------------- 53 | 54 | == LIST: comments_sections == hash == 55 | 'GLOBAL DECLARATIONS' : 'GLOBAL DECLARATIONS', 56 | 'COMMAND LINE PROCESSING' : 'COMMAND LINE PROCESSING', 57 | 'SANITY CHECKS' : 'SANITY CHECKS', 58 | 'FUNCTION DEFINITIONS' : 'FUNCTION DEFINITIONS', 59 | 'TRAPS' : 'TRAPS', 60 | 'MAIN SCRIPT' : 'MAIN SCRIPT', 61 | 'STATISTICS AND CLEAN-UP' : 'STATISTICS AND CLEAN-UP', 62 | == LIST: comments_keywords == hash == 63 | 'bug' : ':BUG:|DATE| |TIME|:|AUTHORREF|: ', 64 | 'todo' : ':TODO:|DATE| |TIME|:|AUTHORREF|: ', 65 | 'tricky' : ':TRICKY:|DATE| |TIME|:|AUTHORREF|: ', 66 | 'warning' : ':WARNING:|DATE| |TIME|:|AUTHORREF|: ', 67 | 'workaround' : ':WORKAROUND:|DATE| |TIME|:|AUTHORREF|: ', 68 | 'new keyword' : '::|DATE| |TIME|:|AUTHORREF|: {+COMMENT+}', 69 | == LIST: comments_macros == hash == 70 | 'AUTHOR' : '|AUTHOR|', 71 | 'AUTHORREF' : '|AUTHORREF|', 72 | 'COMPANY' : '|COMPANY|', 73 | 'COPYRIGHT' : '|COPYRIGHT|', 74 | 'EMAIL' : '|EMAIL|', 75 | 'ORGANIZATION' : '|ORGANIZATION|', 76 | == ENDLIST == 77 | 78 | § ------------------------------------------------------------- 79 | 80 | == Comments.script sections == expandmenu, map:css, sc:s == 81 | |PickList( 'script sections', 'comments_sections' )| 82 | #=============================================================================== 83 | # |PICK| 84 | #=============================================================================== 85 | == Comments.keyword comments == expandmenu, append, map:ckc, sc:k == 86 | |PickList( 'keyword comment', 'comments_keywords' )| 87 | # |PICK| 88 | == Comments.macros == expandmenu, insert, map:cma, sc:m == 89 | |PickList( 'macro', 'comments_macros' )| 90 | |PICK| 91 | == ENDTEMPLATE == 92 | 93 | == SEP: Comments.sep1 == 94 | -------------------------------------------------------------------------------- /syntax/template.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: mm template engine : template library 3 | " Maintainer: Wolfgang Mehner 4 | " Last Change: 27.03.2016 5 | " Version: 1.0 6 | 7 | if version < 600 8 | syntax clear 9 | elseif exists("b:current_syntax") 10 | finish 11 | endif 12 | 13 | "------------------------------------------------------------------------------- 14 | " Syntax 15 | "------------------------------------------------------------------------------- 16 | 17 | " comment 18 | syn match Comment "^§.*$" 19 | syn match Comment "\%(==\)\@<=[^=]*$" 20 | 21 | " templates, lists, ... 22 | syn match Structure "^==\s*\%(TEMPLATE:\)\?[a-zA-Z0-9\-+.,_ ]\+==\%(.\+==\)\?" 23 | syn match Structure "^==\s*ENDTEMPLATE\s*==" 24 | 25 | syn match Structure "^==\s*HELP:[a-zA-Z0-9\-+.,_ ]\+==\%(.\+==\)\?" 26 | 27 | syn match Structure "^==\s*SEP:[a-zA-Z0-9\-+.,_ ]\+==" 28 | 29 | syn match Structure "^==\s*LIST:\s*[a-zA-Z0-9_]\+\s*==\%(.\+==\)\?" 30 | syn match Structure "^==\s*ENDLIST\s*==" 31 | 32 | " style sections 33 | syn match Statement "^==\s*IF\s\+|STYLE|\s\+IS\s\+[a-zA-Z0-9_]\+\s*==" 34 | syn match Statement "^==\s*ENDIF\s*==" 35 | 36 | syn match Statement "^==\s*USE\s\+STYLES\s*:[a-zA-Z0-9_, ]\+==" 37 | syn match Statement "^==\s*ENDSTYLES\s*==" 38 | 39 | syn match Statement "^==\s*USE\s\+FILETYPES\s*:[a-zA-Z0-9_, ]\+==" 40 | syn match Statement "^==\s*ENDFILETYPES\s*==" 41 | 42 | " functions: command mode 43 | syn match Function "InterfaceVersion\ze\s*(" 44 | 45 | syn match Function "IncludeFile\ze\s*(" 46 | syn match Function "SetFormat\ze\s*(" 47 | syn match Function "SetMacro\ze\s*(" 48 | syn match Function "SetStyle\ze\s*(" 49 | syn match Function "SetSyntax\ze\s*(" 50 | syn match Function "SetPath\ze\s*(" 51 | 52 | syn match Function "MenuShortcut\ze\s*(" 53 | syn match Function "SetProperty\ze\s*(" 54 | syn match Function "SetMap\ze\s*(" 55 | syn match Function "SetShortcut\ze\s*(" 56 | syn match Function "SetMenuEntry\ze\s*(" 57 | syn match Function "SetExpansion\ze\s*(" 58 | 59 | " functions: standard template 60 | syn match Function "|\zsDefaultMacro\ze(" 61 | syn match Function "|\zsPrompt\ze(" 62 | syn match Function "|\zsPickFile\ze(" 63 | syn match Function "|\zsPickList\ze(" 64 | syn match Function "|\zsSurroundWith\ze(" 65 | syn match Function "|\zsInsert\ze(" 66 | syn match Function "|\zsInsertLine\ze(" 67 | 68 | syn match Comment "|C(.\{-})|" 69 | syn match Comment "|Comment(.\{-})|" 70 | 71 | " functions: help 72 | syn match Function "|\zsWord\ze(" 73 | syn match Function "|\zsPattern\ze(" 74 | syn match Function "|\zsDefault\ze(" 75 | syn match Function "|\zsSubstitute\ze(" 76 | syn match Function "|\zsLiteralSub\ze(" 77 | syn match Function "|\zsBrowser\ze(" 78 | syn match Function "|\zsSystem\ze(" 79 | syn match Function "|\zsVim\ze(" 80 | 81 | " strings, macros, tags, jump targets 82 | syn match TemplString "'\%([^']\|''\)*'" contains=TemplMacro,TemplTag,TemplJump 83 | syn match TemplString "\"\%([^"\\]\|\\.\)*\"" contains=TemplMacro,TemplTag,TemplJump 84 | 85 | syn match TemplMacro "|?\?[a-zA-Z][a-zA-Z0-9_]*\%(:\a\)\?\%(%\%([-+*]\+\|[-+*]\?\d\+\)[lrc]\?\)\?|" 86 | syn match TemplTag "|<\+>\+|" 87 | syn match TemplTag "\|{CURSOR}" 88 | syn match TemplTag "\|{RCURSOR}" 89 | syn match TemplTag "" 90 | syn match TemplTag "" 91 | syn match TemplTag "" 92 | 93 | syn match TemplJump "<\([+-]\)\w*\1>" 94 | syn match TemplJump "{\([+-]\)\w*\1}" 95 | syn match TemplJump "\[\([+-]\)\w*\1]" 96 | 97 | "------------------------------------------------------------------------------- 98 | " Highlight 99 | "------------------------------------------------------------------------------- 100 | 101 | highlight default link TemplString String 102 | highlight default link TemplMacro Tag 103 | highlight default link TemplTag Tag 104 | highlight default link TemplJump Search 105 | 106 | let b:current_syntax = "template" 107 | -------------------------------------------------------------------------------- /autoload/mmtemplates/config.vim: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: config.vim 4 | " 5 | " Description: Template engine: Config. 6 | " 7 | " Maps & Menus - Template Engine 8 | " 9 | " VIM Version: 7.0+ 10 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 11 | " Organization: 12 | " Version: 1.0 13 | " Created: 27.12.2015 14 | " Revision: --- 15 | " License: Copyright (c) 2015-2016, Wolfgang Mehner 16 | " This program is free software; you can redistribute it and/or 17 | " modify it under the terms of the GNU General Public License as 18 | " published by the Free Software Foundation, version 2 of the 19 | " License. 20 | " This program is distributed in the hope that it will be 21 | " useful, but WITHOUT ANY WARRANTY; without even the implied 22 | " warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 23 | " PURPOSE. 24 | " See the GNU General Public License version 2 for more details. 25 | "=============================================================================== 26 | 27 | "------------------------------------------------------------------------------- 28 | " === Basic Checks === {{{1 29 | "------------------------------------------------------------------------------- 30 | 31 | " need at least 7.0 32 | if v:version < 700 33 | echohl WarningMsg 34 | echo 'The plugin templates.vim needs Vim version >= 7.' 35 | echohl None 36 | finish 37 | endif 38 | 39 | " prevent duplicate loading 40 | " need compatible 41 | if &cp || ( exists('g:TemplatesConfig_Version') && g:TemplatesConfig_Version != 'searching' && ! exists('g:TemplatesConfig_DevelopmentOverwrite') ) 42 | finish 43 | endif 44 | 45 | let s:TemplatesConfig_Version = '1.0' " version number of this script; do not change 46 | 47 | "------------------------------------------------------------------------------- 48 | " --- Find Newest Version --- {{{2 49 | "------------------------------------------------------------------------------- 50 | 51 | if exists('g:TemplatesConfig_DevelopmentOverwrite') 52 | " skip ahead 53 | elseif exists('g:TemplatesConfig_VersionUse') 54 | 55 | " not the newest one: abort 56 | if s:TemplatesConfig_Version != g:TemplatesConfig_VersionUse 57 | finish 58 | endif 59 | 60 | " otherwise: skip ahead 61 | 62 | elseif exists('g:TemplatesConfig_VersionSearch') 63 | 64 | " add own version number to the list 65 | call add ( g:TemplatesConfig_VersionSearch, s:TemplatesConfig_Version ) 66 | 67 | finish 68 | 69 | else 70 | 71 | "------------------------------------------------------------------------------- 72 | " s:VersionComp : Compare two version numbers. {{{3 73 | " 74 | " Parameters: 75 | " op1 - first version number (string) 76 | " op2 - second version number (string) 77 | " Returns: 78 | " result - -1, 0 or 1, to the specifications of sort() (integer) 79 | "------------------------------------------------------------------------------- 80 | function! s:VersionComp ( op1, op2 ) 81 | 82 | let l1 = split ( a:op1, '[.-]' ) 83 | let l2 = split ( a:op2, '[.-]' ) 84 | 85 | for i in range( 0, max( [ len( l1 ), len( l2 ) ] ) - 1 ) 86 | " until now, all fields where equal 87 | if len ( l2 ) <= i 88 | return -1 " op1 has more fields -> sorts first 89 | elseif len( l1 ) <= i 90 | return 1 " op2 has more fields -> sorts first 91 | elseif str2nr ( l1[i] ) > str2nr ( l2[i] ) 92 | return -1 " op1 is larger here -> sorts first 93 | elseif str2nr ( l2[i] ) > str2nr ( l1[i] ) 94 | return 1 " op2 is larger here -> sorts first 95 | endif 96 | endfor 97 | 98 | return 0 " same amount of fields, all equal 99 | endfunction " ---------- end of function s:VersionComp ---------- 100 | " }}}3 101 | "------------------------------------------------------------------------------- 102 | 103 | try 104 | 105 | " collect all available version 106 | let g:TemplatesConfig_Version = 'searching' 107 | let g:TemplatesConfig_VersionSearch = [] 108 | 109 | runtime! autoload/mmtemplates/config.vim 110 | 111 | " select the newest one 112 | call sort ( g:TemplatesConfig_VersionSearch, 's:VersionComp' ) 113 | 114 | let g:TemplatesConfig_VersionUse = g:TemplatesConfig_VersionSearch[ 0 ] 115 | 116 | " run all scripts again, the newest one will be used 117 | runtime! autoload/mmtemplates/config.vim 118 | 119 | unlet g:TemplatesConfig_VersionSearch 120 | unlet g:TemplatesConfig_VersionUse 121 | 122 | finish 123 | 124 | catch /.*/ 125 | 126 | " an error occurred, skip ahead 127 | echohl WarningMsg 128 | echomsg 'Search for the newest version number failed.' 129 | echomsg 'Using this version ('.s:TemplatesConfig_Version.').' 130 | echohl None 131 | endtry 132 | 133 | endif 134 | " }}}2 135 | "------------------------------------------------------------------------------- 136 | 137 | let g:TemplatesConfig_Version = s:TemplatesConfig_Version " version number of this script; do not change 138 | 139 | "---------------------------------------------------------------------- 140 | " === Modul Setup === {{{1 141 | "---------------------------------------------------------------------- 142 | 143 | " platform specifics 144 | let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") 145 | let s:UNIX = has("unix") || has("macunix") || has("win32unix") 146 | 147 | " list of template files 148 | let s:filetype_list = {} 149 | 150 | "------------------------------------------------------------------------------- 151 | " === Script: Auxiliary Functions === {{{1 152 | "------------------------------------------------------------------------------- 153 | 154 | "------------------------------------------------------------------------------- 155 | " s:UserInput : Input using a highlighting prompt. {{{2 156 | " 157 | " Parameters: 158 | " prompt - prompt, shown to the user (string) 159 | " text - default reply (string) 160 | " compl - type of completion, see :help command-completion (string, optional) 161 | " Returns: 162 | " retval - the user input (string) 163 | " 164 | " Returns an empty string if the input procedure was aborted by the user. 165 | "------------------------------------------------------------------------------- 166 | function! s:UserInput ( prompt, text, ... ) 167 | echohl Search " highlight prompt 168 | call inputsave() " preserve typeahead 169 | if a:0 == 0 || a:1 == '' 170 | let retval = input( a:prompt, a:text ) " read input 171 | else 172 | let retval = input( a:prompt, a:text, a:1 ) " read input (with completion) 173 | end 174 | call inputrestore() " restore typeahead 175 | echohl None " reset highlighting 176 | let retval = substitute( retval, '^\s\+', '', '' ) " remove leading whitespaces 177 | let retval = substitute( retval, '\s\+$', '', '' ) " remove trailing whitespaces 178 | return retval 179 | endfunction " ---------- end of function s:UserInput ---------- 180 | " }}}2 181 | "------------------------------------------------------------------------------- 182 | 183 | " }}}1 184 | "------------------------------------------------------------------------------- 185 | 186 | function! mmtemplates#config#Add ( ft, path, ... ) 187 | 188 | let ft = tolower ( a:ft ) 189 | let entry = [ a:path ] 190 | 191 | if a:0 >= 1 192 | call add ( entry, a:1 ) 193 | endif 194 | if a:0 >= 2 195 | call add ( entry, a:2 ) 196 | endif 197 | 198 | if has_key ( s:filetype_list, ft ) 199 | call add ( s:filetype_list[ft], entry ) 200 | else 201 | let s:filetype_list[ft] = [ entry ] 202 | endif 203 | 204 | endfunction " ---------- end of function mmtemplates#config#Add ---------- 205 | 206 | function! mmtemplates#config#GetAll () 207 | 208 | return s:filetype_list 209 | 210 | endfunction " ---------- end of function mmtemplates#config#GetAll ---------- 211 | 212 | function! mmtemplates#config#GetFt ( ft ) 213 | 214 | let ft = tolower ( a:ft ) 215 | 216 | if has_key ( s:filetype_list, ft ) 217 | return s:filetype_list[ft] 218 | else 219 | return [] 220 | endif 221 | 222 | endfunction " ---------- end of function mmtemplates#config#GetFt ---------- 223 | 224 | function! mmtemplates#config#Print () 225 | 226 | let ft_names = keys ( s:filetype_list ) 227 | call sort ( ft_names ) 228 | 229 | for ft in ft_names 230 | echo 'Filetype "'.ft.'":' 231 | for entry in s:filetype_list[ft] 232 | echo "\t- ".entry[0] 233 | endfor 234 | endfor 235 | 236 | endfunction " ---------- end of function mmtemplates#config#Print ---------- 237 | 238 | "------------------------------------------------------------------------------- 239 | " vim: foldmethod=marker 240 | -------------------------------------------------------------------------------- /bash-support/rc/customization.vimrc: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: customization.vimrc 4 | " 5 | " Description: suggestion for a personal configuration file ~/.vimrc 6 | " 7 | " VIM Version: 7.4+ 8 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 9 | " Dr. Fritz Mehner (fgm), mehner.fritz@web.de 10 | " Revision: 15.04.2019 11 | " License: Copyright (c) 2009-2018, Dr. Fritz Mehner 12 | " Copyright (c) 2019-2020, Wolfgang Mehner 13 | "=============================================================================== 14 | 15 | "=============================================================================== 16 | " GENERAL SETTINGS 17 | "=============================================================================== 18 | 19 | "------------------------------------------------------------------------------- 20 | " Use Vim settings, rather then Vi settings. 21 | " This must be first, because it changes other options as a side effect. 22 | "------------------------------------------------------------------------------- 23 | set nocompatible 24 | 25 | "------------------------------------------------------------------------------- 26 | " Enable file type detection. Use the default filetype settings. 27 | " Also load indent files, to automatically do language-dependent indenting. 28 | "------------------------------------------------------------------------------- 29 | filetype plugin on 30 | filetype indent on 31 | 32 | "------------------------------------------------------------------------------- 33 | " Switch syntax highlighting on. 34 | "------------------------------------------------------------------------------- 35 | syntax on 36 | 37 | "------------------------------------------------------------------------------- 38 | " Platform specific items: 39 | " - central backup directory (has to be created) 40 | " - default dictionary 41 | " Uncomment your choice. 42 | " 43 | " Using a backupdir under UNIX/Linux: you may want to include a line similar to: 44 | " find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; 45 | " in one of your shell startup files (e.g. $HOME/.profile). 46 | "------------------------------------------------------------------------------- 47 | if has("win16") || has("win32") || has("win64") || 48 | \ has("win95") || has("win32unix") 49 | " runtime mswin.vim 50 | " set backupdir =$VIM\vimfiles\backupdir 51 | " set dictionary=$VIM\vimfiles\wordlists/german.list 52 | else 53 | " set backupdir =$HOME/.vim.backupdir 54 | " set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list 55 | endif 56 | 57 | "------------------------------------------------------------------------------- 58 | " Various settings 59 | "------------------------------------------------------------------------------- 60 | set autoindent " copy indent from current line 61 | set autoread " read open files again when changed outside Vim 62 | set autowrite " write a modified buffer on each :next , ... 63 | set backspace=indent,eol,start " backspacing over everything in insert mode 64 | set backup " keep a backup file 65 | set browsedir=current " which directory to use for the file browser 66 | set complete+=k " scan the files given with the 'dictionary' option 67 | set formatoptions+=j " remove comment leader when joining lines 68 | set history=50 " keep 50 lines of command line history 69 | set hlsearch " highlight the last used search pattern 70 | set incsearch " do incremental searching 71 | set listchars=tab:>.,eol:\$ " strings to use in 'list' mode 72 | set mouse=a " enable the use of the mouse 73 | set popt=left:8pc,right:3pc " print options 74 | set ruler " show the cursor position all the time 75 | set shiftwidth=2 " number of spaces to use for each step of indent 76 | set showcmd " display incomplete commands 77 | set smartindent " smart autoindenting when starting a new line 78 | set tabstop=2 " number of spaces that a counts for 79 | set visualbell " visual bell instead of beeping 80 | set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions 81 | set wildmenu " command-line completion in an enhanced mode 82 | set nowrap " do not wrap lines 83 | 84 | "------------------------------------------------------------------------------- 85 | " Highlight paired brackets 86 | "------------------------------------------------------------------------------- 87 | "highlight MatchParen ctermbg=blue guibg=lightyellow 88 | 89 | "=============================================================================== 90 | " BUFFERS, WINDOWS 91 | "=============================================================================== 92 | 93 | "------------------------------------------------------------------------------- 94 | " When editing a file, always jump to the last known cursor position. 95 | " Don't do it when the position is invalid or when inside an event handler 96 | " (happens when dropping a file on gvim). 97 | "------------------------------------------------------------------------------- 98 | if has("autocmd") 99 | augroup MyResetCursor 100 | autocmd BufReadPost * 101 | \ if line("'\"") > 0 && line("'\"") <= line("$") | 102 | \ exe "normal! g`\"" | 103 | \ endif 104 | augroup END 105 | endif 106 | 107 | "------------------------------------------------------------------------------- 108 | " Change the working directory to the directory containing the current file 109 | "------------------------------------------------------------------------------- 110 | if has("autocmd") 111 | augroup MySetLocalDir 112 | autocmd BufEnter * :lchdir %:p:h 113 | augroup END 114 | endif 115 | 116 | "------------------------------------------------------------------------------- 117 | " Fast switching between buffers 118 | " The current buffer will be saved before switching to the next one. 119 | " Choose :bprevious or :bnext 120 | "------------------------------------------------------------------------------- 121 | "nnoremap :if !&readonly && &modifiable && &modified 122 | " \ :write :endif :bprevious 123 | "inoremap :if !&readonly && &modifiable && &modified 124 | " \ :write :endif :bprevious 125 | 126 | "------------------------------------------------------------------------------- 127 | " Leave the editor with Ctrl-q: Write all changed buffers and exit Vim 128 | "------------------------------------------------------------------------------- 129 | nnoremap :wqall 130 | 131 | "------------------------------------------------------------------------------- 132 | " Some additional hot keys 133 | " 134 | " F2 - write file without confirmation 135 | " F3 - call file explorer Ex 136 | " F4 - show tag under cursor in the preview window (tagfile must exist!) 137 | " F5 - open quickfix error window 138 | " F6 - close quickfix error window 139 | " F7 - display previous error 140 | " F8 - display next error 141 | " F12 - list buffers and prompt for a buffer name 142 | "------------------------------------------------------------------------------- 143 | 144 | noremap :write 145 | noremap :Explore 146 | nnoremap :execute ":ptag ".expand("") 147 | noremap :copen 148 | noremap :cclose 149 | noremap :cprevious 150 | noremap :cnext 151 | noremap :buffer 152 | noremap :sbuffer 153 | 154 | inoremap :write 155 | inoremap :Explore 156 | inoremap :execute ":ptag ".expand("") 157 | inoremap :copen 158 | inoremap :cclose 159 | inoremap :cprevious 160 | inoremap :cnext 161 | inoremap :buffer 162 | inoremap :sbuffer 163 | 164 | "------------------------------------------------------------------------------- 165 | " Always wrap lines in the quickfix buffer 166 | "------------------------------------------------------------------------------- 167 | "autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak 168 | 169 | "=============================================================================== 170 | " AUTOCOMPLETE BRACKETS, QUOTES 171 | "=============================================================================== 172 | 173 | "------------------------------------------------------------------------------- 174 | " Autocomplete parenthesis, brackets and braces 175 | "------------------------------------------------------------------------------- 176 | 177 | inoremap ( () 178 | inoremap [ [] 179 | inoremap { {} 180 | 181 | " surround content 182 | vnoremap ( s()P% 183 | vnoremap [ s[]P% 184 | vnoremap { s{}P% 185 | 186 | " surround content with additional spaces 187 | vnoremap ) s()P% 188 | vnoremap ] s[]P% 189 | vnoremap } s{}P% 190 | 191 | "------------------------------------------------------------------------------- 192 | " Autocomplete quotes 193 | "------------------------------------------------------------------------------- 194 | 195 | " surround content (visual and select mode) 196 | vnoremap ' s''P 197 | vnoremap " s""P 198 | vnoremap ` s``P 199 | 200 | "=============================================================================== 201 | " VARIOUS PLUGIN CONFIGURATIONS 202 | "=============================================================================== 203 | 204 | "------------------------------------------------------------------------------- 205 | " Bash-Support 206 | " 207 | " the settings are documented here: 208 | " :help bashsupport-custom-variables 209 | "------------------------------------------------------------------------------- 210 | 211 | "let g:BASH_LoadMenus = 'yes' 212 | "let g:BASH_CreateMenusDelayed = 'no' 213 | "let g:BASH_RootMenu = '&Bash' 214 | "let g:BASH_MapLeader = '\' 215 | 216 | "let g:BASH_InsertFileHeader = 'no' 217 | 218 | "let g:BASH_OutputMethod = 'terminal' 219 | "let g:BASH_DirectRun = 'yes' 220 | 221 | "let g:BASH_AlsoBash = [ '*.SlackBuild' , 'rc.*' ] 222 | 223 | "------------------------------------------------------------------------------- 224 | " taglist.vim : toggle the taglist window 225 | "------------------------------------------------------------------------------- 226 | noremap :TlistToggle 227 | inoremap :TlistToggle 228 | 229 | let Tlist_GainFocus_On_ToggleOpen = 1 230 | let Tlist_Close_On_Select = 1 231 | -------------------------------------------------------------------------------- /doc/bashdbintegration.txt: -------------------------------------------------------------------------------- 1 | *bashdbintegration.txt* BashDB Integration Oct 08 2017 2 | 3 | BashDB Integration *bashdb-integration* 4 | 5 | Plug-in version 0.5 6 | for Vim version 7.0 and above 7 | Wolfgang Mehner 8 | 9 | The BashDB integration can run bashdb inside Vim/gVim. It is modelled after 10 | the GDB integration |:Termdebug|. 11 | 12 | ============================================================================== 13 | 0. TABLE OF CONTENTS *bashdb-integration-contents* 14 | ============================================================================== 15 | 16 | 1. Introduction |bashdb-integration-intro| 17 | 2. Commands |bashdb-integration-commands| 18 | 2.1 Debugger Integration |bashdb-integration-db-control| 19 | 3. Configuration |bashdb-integration-config| 20 | 21 | A. Change Log |bashdb-integration-change-log| 22 | 23 | ============================================================================== 24 | 1. INTRODUCTION *bashdb-integration-intro* 25 | ============================================================================== 26 | 27 | This tool starts the debugger 'bashdb' or the frontend 'ddd'. Your version of 28 | the bash must be prepared for debugging and the debugger must be installed 29 | (see http://bashdb.sourceforge.net/). When Vim is compiled with the |+terminal| 30 | feature, the debugger can be run inside the editor. 31 | 32 | The debugger can be run right inside Vim (requires |+terminal|), by setting > 33 | :BashDBDebugger integrated 34 | and then starting the debugging for the script in the current buffer via > 35 | :BashDB [] 36 | The optional arguments are passed on the debugged script. 37 | 38 | The output is split into two terminal windows. The debugging can be controlled 39 | from the buffer containing the script. E.g. breakpoints can be set for the 40 | line under the cursor. 41 | 42 | Furthermore, the debugger can be run in a terminal window, but without further 43 | integration > 44 | :BashDBDebugger terminal 45 | or in a separate xterm > 46 | :BashDBDebugger xterm 47 | or in the frontend ddd > 48 | :BashDBDebugger ddd 49 | < 50 | The debugger integration is controlled via a number of ex-commands, see below. 51 | 52 | Command Short Description 53 | ---------------------------------------------------------------------------- 54 | |:BashDB| [] run the debugger 55 | |:BashDBCommand| [] send a command to the debugger 56 | (only with the method "integrated") 57 | 58 | |:BashDBDebugger| set the debugging method: 59 | ddd, terminal, xterm, or integrated 60 | |:BashDBExecutable| set the debugger executable: 61 | bashdb, zshdb, ... 62 | 63 | |:BashDBSettings| shows the plug-in settings 64 | |:BashDBHelp| help for the BashDB integration 65 | ---------------------------------------------------------------------------- 66 | 67 | Detailed explanations are given in the section |bashdb-integration-commands|. 68 | 69 | ============================================================================== 70 | 2. COMMANDS *bashdb-integration-commands* 71 | ============================================================================== 72 | 73 | This chapter provides detailed explanations of all the commands. 74 | 75 | ------------------------------------------------------------------------------ 76 | *:BashDB* 77 | :BashDB [] ~ 78 | 79 | Run the debugger for the script in the current buffer. The arguments are 80 | passed to the script. 81 | 82 | Cooperates with |bash-support|. When arguments are set for the current buffer 83 | via |:BashScriptArguments| and none are given on the command line, then the 84 | arguments set with Bash Support are passed to the script. 85 | 86 | ------------------------------------------------------------------------------ 87 | *:BashDBDebugger* 88 | :BashDBDebugger ~ 89 | :BashDBDebugger! ~ 90 | 91 | Set the debugging method. The 2nd version echoes the current method. 92 | 93 | The method "integrated" runs the debugger inside Vim. This enables further 94 | commands to control the compiler, see |bashdb-integration-db-control|. 95 | 96 | The method "terminal" runs the debugger in a terminal window, but without 97 | further integration. 98 | 99 | The other two methods are mostly for backwards compatibility with the old 100 | debugger features of |bash-support| (before version 4.4). 101 | 102 | Method Short Description 103 | ---------------------------------------------------------------------------- 104 | integrated Run in integrated mode. 105 | terminal Run in a |terminal| window. 106 | xterm Run bashdb in an external xterm. 107 | ddd Run in DDD. 108 | ---------------------------------------------------------------------------- 109 | 110 | Set the default using |g:BashDB_Debugger|. 111 | 112 | ------------------------------------------------------------------------------ 113 | *:BashDBExecutable* 114 | :BashDBExecutable ~ 115 | :BashDBExecutable! ~ 116 | 117 | Set the debugger executable. The 2nd version echoes the current executable. 118 | 119 | This look peculiar, but sort of works: > 120 | :BashDBExecutable zshdb 121 | Use bashdb again: > 122 | :BashDBExecutable bashdb 123 | < 124 | Set the default using |g:BashDB_Executable|. 125 | 126 | ------------------------------------------------------------------------------ 127 | *:BashDBHelp* 128 | :BashDBHelp ~ 129 | 130 | Open the help for the BashDB integration. 131 | 132 | ------------------------------------------------------------------------------ 133 | *:BashDBSettings* 134 | :BashDBSettings ~ 135 | :BashDBSettings! ~ 136 | 137 | Show the plug-in settings. The second version is verbose. 138 | 139 | ------------------------------------------------------------------------------ 140 | 2.1 DEBUGGER INTEGRATION *bashdb-integration-db-control* 141 | ------------------------------------------------------------------------------ 142 | 143 | When running the integrated debugger, various commands can be used to send 144 | control commands to it. 145 | 146 | ------------------------------------------------------------------------------ 147 | *:BashDBCommand* 148 | :BashDBCommand [] ~ 149 | 150 | Send the command to the debugger. Since you can enter commands in the debugger 151 | buffer itself, this is mainly for creating mappings, e.g.: 152 | 153 | Use CTRL-d t to display a backtrace, and CTRL-d ib to list the breakpoints: > 154 | :nnoremap t :BashDBCommand backtrace 155 | :nnoremap ib :BashDBCommand info breakpoints 156 | These maps should be placed in the shell filetype plug-in "ftplugin/sh.vim". 157 | 158 | ------------------------------------------------------------------------------ 159 | 160 | These commands are only available while running the debugger, and only in the 161 | buffer from which the debugger was started. 162 | 163 | Sends the "continue" and "step" commands: 164 | :Continue ~ 165 | :Step ~ 166 | 167 | Set a breakpoint for the line under the cursor ("!" for a one-time breakpoint): 168 | :Break ~ 169 | :Break! ~ 170 | Add the variable under the cursor to the "display" list: 171 | :Display ~ 172 | 173 | These commands can also be used to create custom mappings, e.g.: 174 | 175 | Use CTRL-d s to step, CTRL-d c to continue, and CTRL-d b to set a breakpoints: > 176 | :nnoremap s :Step 177 | :nnoremap c :Continue 178 | :nnoremap b :Break 179 | These maps should be placed in the shell filetype plug-in "ftplugin/sh.vim". 180 | 181 | ============================================================================== 182 | 3. CONFIGURATION *bashdb-integration-config* 183 | ============================================================================== 184 | 185 | The tool is configured via a number of global variables, which can be set in 186 | the .vimrc file. 187 | 188 | Variable Default Description and further information 189 | ---------------------------------------------------------------------------- 190 | |g:BashDB_Debugger| 'xterm' the debugging method 191 | |g:BashDB_Executable| 'bashdb' the debugger executable 192 | |g:BashDB_DDD_Exec| 'ddd' the DDD executable 193 | 194 | g:Xterm_Executable 'xterm' the xterm executable (^1) 195 | g:Xterm_Options '...' the xterm default settings (^1) 196 | 197 | g:BASH_Debugger n/a the method, deprecated (^2) 198 | g:BASH_bashdb n/a the executable, deprecated (^2) 199 | ---------------------------------------------------------------------------- 200 | 201 | (^1) UNIX only, see |bashdb-integration-xterm| 202 | (^2) *g:BASH_Debugger* and *g:BASH_bashdb* are deprecated, and only included 203 | for backwards compatibility with the old debugger features of |bash-support| 204 | (before version 4.4) 205 | 206 | ------------------------------------------------------------------------------ 207 | *g:BashDB_Debugger* 208 | The default debugging method is set by g:BashDB_Debugger: > 209 | let g:BashDB_Debugger = 'integrated' 210 | < 211 | The possible settings are listed below: 212 | 213 | Value Short Description 214 | ---------------------------------------------------------------------------- 215 | integrated Run in integrated mode. 216 | terminal Run in a |terminal| window. 217 | xterm Run bashdb in an external xterm. 218 | ddd Run in DDD. 219 | ---------------------------------------------------------------------------- 220 | 221 | ------------------------------------------------------------------------------ 222 | *g:BashDB_Executable* *g:BashDB_DDD_Exec* 223 | The debugger executable is set by g:BashDB_Executable: > 224 | let g:BashDB_Executable = 'zshdb' 225 | < 226 | The debugger executable is set by g:BashDB_DDD_Exec: > 227 | let g:BashDB_DDD_Exec = '/usr/local/bin/ddd' 228 | < 229 | ------------------------------------------------------------------------------ 230 | *bashdb-integration-xterm* 231 | The xterm related functionality is only available under UNIX. It is used to 232 | run interactive commands. 233 | 234 | g:Xterm_Executable 235 | The xterm executable is set by g:Xterm_Executable, for example: > 236 | let g:Xterm_Executable = '/usr/local/bin/xterm' 237 | < 238 | g:Xterm_Options 239 | Set additional options for xterm. The default is: > 240 | let g:Xterm_Options = '-fa courier -fs 12 -geometry 80x24' 241 | < 242 | For example, use these arguments for black letters on a white background: > 243 | let g:Xterm_Options = '-fg black -bg white -fs 12 -geometry 80x24' 244 | < 245 | See the man-page of xterm for the possible options. 246 | 247 | The behavior can be changed on the fly by settings the variable to a different 248 | value on the command line. 249 | 250 | ============================================================================== 251 | A. CHANGE LOG *bashdb-integration-change-log* 252 | ============================================================================== 253 | 254 | ------------------------------------------------------------------------------ 255 | RELEASE NOTES FOR VERSION 0.5 256 | ------------------------------------------------------------------------------ 257 | 258 | - Initial upload. 259 | 260 | ============================================================================== 261 | vim:filetype=help:textwidth=78:expandtab:tabstop=2:norl: 262 | -------------------------------------------------------------------------------- /bash-support/README.md: -------------------------------------------------------------------------------- 1 | README for bash-support.vim (Version 5.0beta) / November 22 2020 2 | ================================================================================ 3 | 4 | * INSTALLATION 5 | * RELEASE NOTES 6 | * FILES 7 | * ADDITIONAL TIPS 8 | * CREDITS 9 | 10 | Bash Support implements a Bash-IDE for Vim/gVim. It is written to considerably 11 | speed up writing code in a consistent style. This is done by inserting complete 12 | statements, comments, idioms, and code snippets. Syntax checking, running a 13 | script, starting a debugger can be done with a keystroke. There are many 14 | additional hints and options which can improve speed and comfort when writing 15 | shell scripts. 16 | 17 | This plug-in can be used with Vim version 7.4+ and Neovim 0.2.1+. 18 | 19 | 20 | -------------------------------------------------------------------------------- 21 | 22 | INSTALLATION 23 | ================================================================================ 24 | 25 | A system-wide installation for all users can also be done. This will have 26 | further effects on how the plug-in works. For a step-by-step instruction, as 27 | well as an explanation of the other consequences, please see the help file 28 | `doc/bashsupport.txt` or look up the documentation via: 29 | 30 | :help bashsupport-system-wide 31 | 32 | 33 | (1) LINUX 34 | ---------------------------------------------------------------------- 35 | 36 | The subdirectories in the zip archive `bash-support.zip` mirror the directory 37 | structure which is needed below the local installation directory `$HOME/.vim/` 38 | (find the value of `$HOME` with `:echo $HOME` from inside Vim). 39 | 40 | (1.0) Save the template files in `$HOME/.vim/bash-support/templates/Templates` 41 | if you have changed any of them. 42 | 43 | (1.1) Copy the zip archive `bash-support.zip` to `$HOME/.vim` and run 44 | 45 | unzip bash-support.zip 46 | 47 | Afterwards, these files should exist: 48 | 49 | $HOME/.vim/autoload/mmtemplates/... 50 | $HOME/.vim/doc/... 51 | $HOME/.vim/plugin/bash-support.vim 52 | 53 | (1.2) Loading of plug-in files must be enabled. If not use 54 | 55 | :filetype plugin on 56 | 57 | This is the minimal content of the file `$HOME/.vimrc`. Create one if there 58 | is none or use the files in `$HOME/.vim/bash-support/rc` as a starting point. 59 | 60 | (1.3) Make the plug-in help accessible by typing the following command on the 61 | Vim command line: 62 | 63 | :helptags $HOME/.vim/doc/ 64 | 65 | (1.4) Set at least some personal details. Use the map `\ntw` inside a Bash buffer 66 | or the menu entry: 67 | 68 | Bash -> Snippets -> template setup wizard 69 | 70 | It will help you set up the file `_runtimepath_/templates/personal.templates`. 71 | The file is read by all plug-ins supporting this feature to get your personal 72 | details. Here is the minimal personalization (my settings as an example): 73 | 74 | SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) 75 | SetMacro( 'AUTHORREF', 'wm' ) 76 | SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) 77 | SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) 78 | 79 | Use the file `$HOME/.vim/templates/bash.templates` to customize or add to your 80 | Bash template library. It can also be set up via the wizard. 81 | 82 | (Read more about the template system in the plug-in documentation.) 83 | 84 | (1.5) Consider additional settings in the file `$HOME/.vimrc`. The files 85 | `customization.vimrc` and `customization.gvimrc` are replacements or extensions 86 | for your `.vimrc` and `.gvimrc`. You may want to use parts of them. The files 87 | are documented. 88 | 89 | 90 | (2) WINDOWS 91 | ---------------------------------------------------------------------- 92 | 93 | The subdirectories in the zip archive `bash-support.zip` mirror the directory 94 | structure which is needed below the local installation directory 95 | `$HOME/vimfiles/` (find the value of `$HOME` with `:echo $HOME` from inside Vim). 96 | 97 | (2.0) Save the template files in `$HOME/vimfiles/bash-support/templates/Templates` 98 | if you have changed any of them. 99 | 100 | (2.1) Copy the zip archive bash-support.zip to `$HOME/vimfiles` and run 101 | 102 | unzip bash-support.zip 103 | 104 | Afterwards, these files should exist: 105 | 106 | $HOME/vimfiles/autoload/mmtemplates/... 107 | $HOME/vimfiles/doc/... 108 | $HOME/vimfiles/plugin/bash-support.vim 109 | 110 | (2.2) Loading of plug-in files must be enabled. If not use 111 | 112 | :filetype plugin on 113 | 114 | This is the minimal content of the file `$HOME/_vimrc`. Create one if there 115 | is none or use the files in `$HOME/vimfiles/bash-support/rc` as a starting point. 116 | 117 | (2.3) Make the plug-in help accessible by typing the following command on the 118 | Vim command line: 119 | 120 | :helptags $HOME\vimfiles\doc\ 121 | 122 | (2.4) Set at least some personal details. Use the map `\ntw` inside a Bash buffer 123 | or the menu entry: 124 | 125 | Bash -> Snippets -> template setup wizard 126 | 127 | It will help you set up the file `_runtimepath_/templates/personal.templates`. 128 | The file is read by all plug-ins supporting this feature to get your personal 129 | details. Here is the minimal personalization (my settings as an example): 130 | 131 | SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) 132 | SetMacro( 'AUTHORREF', 'wm' ) 133 | SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) 134 | SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) 135 | 136 | Use the file `$HOME/vimfiles/templates/bash.templates` to customize or add to 137 | your Bash template library. It can also be set up via the wizard. 138 | 139 | (Read more about the template system in the plug-in documentation.) 140 | 141 | (2.5) Consider additional settings in the file `$HOME/_vimrc`. The files 142 | `customization.vimrc` and `customization.gvimrc` are replacements or extensions 143 | for your `_vimrc` and `_gvimrc`. You may want to use parts of them. The files 144 | are documented. 145 | 146 | 147 | (3) ADDITIONAL REMARKS 148 | ---------------------------------------------------------------------- 149 | 150 | There are a lot of features and options which can be used and influenced: 151 | 152 | * use of template files and macros 153 | * using and managing personal code snippets 154 | * bash dictionary for keyword completion 155 | * removing the root menu 156 | * using additional plug-ins 157 | 158 | Actions differ for different modes. Please read the documentation: 159 | 160 | :help bashsupport 161 | 162 | Any problems? See the TROUBLESHOOTING section at the end of the help file 163 | `doc/bashsupport.txt`. 164 | 165 | 166 | -------------------------------------------------------------------------------- 167 | 168 | RELEASE NOTES 169 | ================================================================================ 170 | 171 | RELEASE NOTES FOR VERSION 5.0beta 172 | ---------------------------------------------------------------------- 173 | - Adapt for running under Neovim more smoothly. 174 | - Add command `:Bash []` to run the interpreter with arguments. 175 | - Add command `:BashCheck.` the run the syntax checker. 176 | - Add command `:BashDirectRun` to run executable scripts without `g:BASH_Executable`. 177 | - Add command `:BashOutputMethod` to set the output destination for `:Bash`. 178 | - Add command `:BashExecutable` to set the executable during runtime. 179 | - Add output method 'terminal' for running scripts in a terminal window 180 | (requires +terminal). 181 | - The templates which are inserted into new files as file skeletons can be 182 | specified in the templates library, via the property: 183 | `Bash::FileSkeleton::Script` 184 | - Use `g:Xterm_Executable`. 185 | - Use `g:Xterm_Options` instead of `g:BASH_XtermDefaults`. The setting 186 | `g:BASH_XtermDefaults` still works for backwards compatibility. 187 | - Add configuration variables `g:BASH_Ctrl_j` and `g:BASH_Ctrl_d` to control the 188 | creation of the `CTRL+J` and `CTRL+D` maps. 189 | - Remove the definition of the maps `CTRL+F9`, `SHIFT+F9`, and `ALT+F9`. 190 | Add them to your filetype plug-in if you want to use them. 191 | - Integration of BashDB moved into the toolbox. 192 | - Add shell options and variables for BASH Version 4.4 and 5.0. 193 | - Minor corrections and improvements. 194 | 195 | Note: The filetype plug-in has been moved, and is thus not loaded automatically 196 | anymore. Copy it from `bash-support/rc` to `ftplugin`, or add the commands there 197 | to your own filetype plug-in. 198 | 199 | 200 | RELEASE NOTES FOR OLDER VERSIONS 201 | ---------------------------------------------------------------------- 202 | -> see file `bash-support/doc/ChangeLog` 203 | 204 | 205 | -------------------------------------------------------------------------------- 206 | 207 | FILES 208 | ================================================================================ 209 | 210 | README.md 211 | This file. 212 | 213 | autoload/mmtemplates/* 214 | The template system. 215 | 216 | doc/bashsupport.txt 217 | The help file for Bash Support. 218 | doc/templatesupport.txt 219 | The help file for the template system. 220 | 221 | plugin/bash-support.vim 222 | The Bash plugin for Vim/gVim. 223 | 224 | bash-support/codesnippets/* 225 | Some Bash code snippets as a starting point. 226 | 227 | bash-support/scripts/* 228 | Several helper scripts. 229 | 230 | bash-support/templates/Templates 231 | Bash main template file. 232 | bash-support/templates/*.templates 233 | Several dependent template files. 234 | 235 | bash-support/wordlists/bash-keywords.list 236 | A file used as dictionary for automatic word completion. 237 | This file is referenced in the file customization.vimrc. 238 | 239 | ___The following files and extensions are for convenience only.___ 240 | ___bash-support.vim will work without them.___ 241 | ___The settings are explained in the files themselves.___ 242 | 243 | ftdetect/template.vim 244 | ftplugin/template.vim 245 | syntax/template.vim 246 | Additional files for working with templates. 247 | 248 | bash-support/doc/bash-hotkeys.pdf 249 | Reference card for the key mappings. The mappings can 250 | also be used with the non-GUI Vim, where the menus are 251 | not available. 252 | bash-support/doc/ChangeLog 253 | The change log. 254 | 255 | bash-support/rc/customization.bashrc 256 | Additional settings for use in .bashrc: 257 | set the prompt P2, P3, P4 (for debugging) 258 | bash-support/rc/customization.gvimrc 259 | Additional settings for use in .gvimrc: 260 | hot keys, mouse settings, ... 261 | The file is commented. Append it to your .gvimrc if you 262 | like. 263 | bash-support/rc/customization.vimrc 264 | Additional settings for use in .vimrc: 265 | incremental search, tabstop, hot keys, 266 | font, use of dictionaries, ... 267 | The file is commented. Append it to your .vimrc if you 268 | like. 269 | 270 | bash-support/rc/sh.vim 271 | Example filetype plug-ins for Bash: 272 | defines additional maps 273 | 274 | bash-support/rc/*.templates 275 | Sample template files for customization. Used by the 276 | template setup wizard. 277 | 278 | 279 | -------------------------------------------------------------------------------- 280 | 281 | ADDITIONAL TIPS 282 | ================================================================================ 283 | 284 | (1) gvim. Toggle 'insert mode' <--> 'normal mode' with the right mouse button 285 | (see mapping in file `customization.gvimrc`). 286 | 287 | (2) gvim. Use tear off menus and 288 | 289 | (3) try 'Focus under mouse' as window behavior (No mouse click when the mouse 290 | pointer is back from the menu entry). 291 | 292 | (4) Use Emulate3Buttons "on" (X11) even for a 3-button mouse. Pressing left and 293 | right button simultaneously without moving your fingers is faster then moving 294 | a finger to the middle button (often a wheel). 295 | 296 | 297 | -------------------------------------------------------------------------------- 298 | 299 | CREDITS 300 | ================================================================================ 301 | 302 | Fritz Mehner thanks: 303 | ---------------------------------------------------------------------- 304 | 305 | Wolfgang Mehner (wolfgang-mehner AT web.de) for the implementation of the 306 | powerful template system templatesupport. 307 | 308 | Wolfgang Mehner thanks: 309 | ---------------------------------------------------------------------- 310 | 311 | This plug-in has been developed by Fritz Mehner, who maintained it until 2015. 312 | 313 | -------------------------------------------------------------------------------- /project/release.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | -- 3 | -------------------------------------------------------------------------------- 4 | -- FILE: release.lua 5 | -- 6 | -- USAGE: lua project/release.lua [] 7 | -- 8 | -- DESCRIPTION: Run from the project's top-level directory. 9 | -- 10 | -- OPTIONS: The plug-in is one of: 11 | -- - awk 12 | -- - bash 13 | -- - c 14 | -- - latex 15 | -- - lua 16 | -- - perl 17 | -- - vim 18 | -- 19 | -- The mode is one of: 20 | -- - list 21 | -- - check 22 | -- - zip 23 | -- - archive 24 | -- - cp-repo 25 | -- - help 26 | -- 27 | -- REQUIREMENTS: --- 28 | -- BUGS: --- 29 | -- NOTES: --- 30 | -- AUTHOR: Wolfgang Mehner, 31 | -- COMPANY: 32 | -- VERSION: 1.0 33 | -- CREATED: 05.01.2016 34 | -- REVISION: --- 35 | -------------------------------------------------------------------------------- 36 | -- 37 | 38 | ------------------------------------------------------------------------ 39 | -- Auxiliary Functions {{{1 40 | ------------------------------------------------------------------------ 41 | 42 | local function escape_shell ( text ) 43 | return string.gsub ( text, '[%(%);&=\' ]', function ( m ) return '\\' .. m end ) 44 | end ---------- end of function escape_shell ---------- 45 | 46 | -- }}}1 47 | ------------------------------------------------------------------------ 48 | 49 | 50 | ------------------------------------------------------------------------ 51 | -- Arguments and Lists {{{1 52 | ------------------------------------------------------------------------ 53 | 54 | local print_help = false 55 | 56 | local args = { ... } 57 | 58 | -- files for the zip-archive 59 | local filelists = {} 60 | 61 | -- additional files for the stand-alone repository 62 | local filelists_repo = {} 63 | 64 | -- }}}1 65 | ------------------------------------------------------------------------ 66 | 67 | 68 | ------------------------------------------------------------------------ 69 | -- Awk {{{1 70 | ------------------------------------------------------------------------ 71 | 72 | filelists.awk = { 73 | 'autoload/mmtemplates/', 74 | 'doc/awksupport.txt', 75 | 'doc/templatesupport.txt', 76 | 'ftdetect/template.vim', 77 | 'ftplugin/template.vim', 78 | 'plugin/awk-support.vim', 79 | 'syntax/template.vim', 80 | 'awk-support/codesnippets/', 81 | 'awk-support/doc/ChangeLog', 82 | 'awk-support/doc/awk-hotkeys.pdf', 83 | 'awk-support/doc/awk-hotkeys.tex', 84 | 'awk-support/rc/', 85 | 'awk-support/scripts/', 86 | 'awk-support/templates/', 87 | 'awk-support/wordlists/', 88 | 'awk-support/README.md', 89 | } 90 | 91 | filelists_repo.awk = { 92 | 'project/release.lua', 93 | } 94 | 95 | ------------------------------------------------------------------------ 96 | -- Bash {{{1 97 | ------------------------------------------------------------------------ 98 | 99 | filelists.bash = { 100 | 'autoload/mmtemplates/', 101 | 'autoload/mmtoolbox/tools.vim', 102 | 'autoload/mmtoolbox/bash/bashdb.vim', 103 | 'doc/bashsupport.txt', 104 | 'doc/templatesupport.txt', 105 | 'doc/toolbox.txt', 106 | 'doc/bashdbintegration.txt', 107 | 'ftdetect/template.vim', 108 | 'ftplugin/bashhelp.vim', 109 | 'ftplugin/template.vim', 110 | 'plugin/bash-support.vim', 111 | 'syntax/bashhelp.vim', 112 | 'syntax/template.vim', 113 | 'bash-support/codesnippets/', 114 | 'bash-support/doc/ChangeLog', 115 | 'bash-support/doc/bash-hotkeys.pdf', 116 | 'bash-support/doc/bash-hotkeys.tex', 117 | 'bash-support/rc/', 118 | 'bash-support/scripts/', 119 | 'bash-support/templates/', 120 | 'bash-support/wordlists/', 121 | 'bash-support/README.md', 122 | } 123 | 124 | filelists_repo.bash = { 125 | 'project/release.lua', 126 | } 127 | 128 | ------------------------------------------------------------------------ 129 | -- C/C++ {{{1 130 | ------------------------------------------------------------------------ 131 | 132 | filelists.c = { 133 | 'autoload/mmtemplates/', 134 | 'autoload/mmtoolbox/cmake.vim', 135 | 'autoload/mmtoolbox/doxygen.vim', 136 | 'autoload/mmtoolbox/make.vim', 137 | 'autoload/mmtoolbox/tools.vim', 138 | 'doc/csupport.txt', 139 | 'doc/templatesupport.txt', 140 | 'doc/toolbox.txt', 141 | 'doc/toolboxcmake.txt', 142 | 'doc/toolboxdoxygen.txt', 143 | 'doc/toolboxmake.txt', 144 | 'ftdetect/template.vim', 145 | 'ftplugin/template.vim', 146 | 'plugin/c.vim', 147 | 'syntax/template.vim', 148 | 'c-support/codesnippets/', 149 | 'c-support/doc/ChangeLog', 150 | 'c-support/doc/c-hotkeys.pdf', 151 | 'c-support/doc/c-hotkeys.tex', 152 | 'c-support/rc/', 153 | 'c-support/scripts/', 154 | 'c-support/templates/', 155 | 'c-support/wordlists/', 156 | 'c-support/README.md', 157 | } 158 | 159 | filelists_repo.c = { 160 | 'project/release.lua', 161 | } 162 | 163 | ------------------------------------------------------------------------ 164 | -- LaTeX {{{1 165 | ------------------------------------------------------------------------ 166 | 167 | filelists.latex = { 168 | 'autoload/mmtemplates/', 169 | 'autoload/mmtoolbox/make.vim', 170 | 'autoload/mmtoolbox/tools.vim', 171 | 'doc/latexsupport.txt', 172 | 'doc/templatesupport.txt', 173 | 'doc/toolbox.txt', 174 | 'doc/toolboxmake.txt', 175 | 'ftdetect/template.vim', 176 | 'ftplugin/template.vim', 177 | 'plugin/latex-support.vim', 178 | 'syntax/template.vim', 179 | 'latex-support/codesnippets/', 180 | 'latex-support/doc/ChangeLog', 181 | 'latex-support/doc/latex-hotkeys.pdf', 182 | 'latex-support/doc/latex-hotkeys.tex', 183 | 'latex-support/rc/', 184 | 'latex-support/templates/', 185 | 'latex-support/wordlists/', 186 | 'latex-support/README.md', 187 | } 188 | 189 | filelists_repo.latex = { 190 | 'project/release.lua', 191 | } 192 | 193 | ------------------------------------------------------------------------ 194 | -- Lua {{{1 195 | ------------------------------------------------------------------------ 196 | 197 | filelists.lua = { 198 | 'autoload/mmtemplates/', 199 | 'autoload/mmtoolbox/make.vim', 200 | 'autoload/mmtoolbox/tools.vim', 201 | 'doc/luaref*.txt', 202 | 'doc/luasupport.txt', 203 | 'doc/templatesupport.txt', 204 | 'doc/toolbox.txt', 205 | 'doc/toolboxmake.txt', 206 | 'ftdetect/template.vim', 207 | 'ftplugin/template.vim', 208 | 'plugin/lua-support.vim', 209 | 'syntax/template.vim', 210 | 'lua-support/codesnippets/', 211 | 'lua-support/doc/', 212 | 'lua-support/rc/', 213 | 'lua-support/templates/', 214 | 'lua-support/templates-c-api/', 215 | 'lua-support/README.md', 216 | } 217 | 218 | filelists_repo.lua = { 219 | 'lua-support/html2doc/', 220 | 'lua-support/lua-doc/', 221 | 'project/release.lua', 222 | } 223 | 224 | ------------------------------------------------------------------------ 225 | -- Perl {{{1 226 | ------------------------------------------------------------------------ 227 | 228 | filelists.perl = { 229 | 'autoload/mmtemplates/', 230 | 'autoload/mmtoolbox/make.vim', 231 | 'autoload/mmtoolbox/tools.vim', 232 | 'autoload/perlsupportprofiling.vim', 233 | 'autoload/perlsupportregex.vim', 234 | 'doc/perlsupport.txt', 235 | 'doc/templatesupport.txt', 236 | 'doc/toolbox.txt', 237 | 'doc/toolboxmake.txt', 238 | 'ftdetect/template.vim', 239 | 'ftplugin/template.vim', 240 | 'plugin/perl-support.vim', 241 | 'syntax/template.vim', 242 | 'perl-support/codesnippets/', 243 | 'perl-support/doc/ChangeLog', 244 | 'perl-support/doc/perl-hot-keys.pdf', 245 | 'perl-support/doc/perl-hot-keys.tex', 246 | 'perl-support/doc/pmdesc3.text', 247 | 'perl-support/modules/', 248 | 'perl-support/rc/', 249 | 'perl-support/scripts/', 250 | 'perl-support/templates/', 251 | 'perl-support/wordlists/', 252 | 'perl-support/README.md', 253 | } 254 | 255 | filelists_repo.perl = { 256 | 'project/release.lua', 257 | } 258 | 259 | ------------------------------------------------------------------------ 260 | -- VimL {{{1 261 | ------------------------------------------------------------------------ 262 | 263 | filelists.vim = { 264 | 'autoload/mmtemplates/', 265 | 'doc/templatesupport.txt', 266 | 'doc/vimsupport.txt', 267 | 'ftdetect/template.vim', 268 | 'ftplugin/template.vim', 269 | 'plugin/vim-support.vim', 270 | 'syntax/template.vim', 271 | 'vim-support/codesnippets/', 272 | 'vim-support/doc/ChangeLog', 273 | 'vim-support/doc/vim-hotkeys.pdf', 274 | 'vim-support/doc/vim-hotkeys.tex', 275 | 'vim-support/rc/', 276 | 'vim-support/templates/', 277 | 'vim-support/README.md', 278 | } 279 | 280 | filelists_repo.vim = { 281 | 'project/release.lua', 282 | } 283 | 284 | ------------------------------------------------------------------------ 285 | -- TODO {{{1 286 | ------------------------------------------------------------------------ 287 | 288 | filelists.TODO = { 289 | } 290 | 291 | filelists_repo.TODO = { 292 | 'project/release.lua', 293 | } 294 | 295 | -- }}}1 296 | ------------------------------------------------------------------------ 297 | 298 | 299 | ------------------------------------------------------------------------ 300 | -- Processing ... 301 | ------------------------------------------------------------------------ 302 | 303 | local plugin_name = args[1] or 'FAILED' 304 | local filelist 305 | local filelist_repo 306 | 307 | if #args == 0 then 308 | 309 | print ( '\n=== failed: plug-in missing ===\n' ) 310 | 311 | print_help = true 312 | 313 | elseif filelists[plugin_name] then 314 | 315 | filelist = filelists[plugin_name] 316 | filelist_repo = filelists_repo[plugin_name] 317 | 318 | elseif args[1] == 'help' then 319 | 320 | print_help = true 321 | 322 | else 323 | 324 | print ( '\n=== failed: unknown plug-in "'..args[1]..'" ===\n' ) 325 | 326 | print_help = true 327 | 328 | end 329 | 330 | local outfile = escape_shell ( plugin_name..'-support.zip' ) 331 | 332 | for idx, val in ipairs ( filelist or {} ) do 333 | filelist[ idx ] = escape_shell ( val ) 334 | end 335 | 336 | if #args == 1 and args[1] ~= 'help' then 337 | 338 | print ( '\n=== failed: mode missing ===\n' ) 339 | 340 | print_help = true 341 | 342 | elseif args[2] == 'list' then 343 | 344 | local cmd = 'ls -1 '..table.concat ( filelist, ' ' ) 345 | 346 | print ( '\n=== listing ===\n' ) 347 | 348 | local success, res_reason, res_status = os.execute ( cmd ) 349 | 350 | if success then 351 | print ( '\n=== done ===\n' ) 352 | else 353 | print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' ) 354 | end 355 | 356 | elseif args[2] == 'check' then 357 | 358 | local flag_dir = '--directories recurse' 359 | local flag_excl = '--exclude "*.pdf"' 360 | local cmd = 'grep '..flag_dir..' '..flag_excl..' -nH ":[[:upper:]]\\+:\\|[Tt][Oo][Dd][Oo]" '..table.concat ( filelist, ' ' ) 361 | 362 | print ( '\n=== checking ===\n' ) 363 | 364 | local success, res_reason, res_status = os.execute ( cmd ) 365 | 366 | if success then 367 | print ( '\n=== done ===\n' ) 368 | else 369 | print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' ) 370 | end 371 | 372 | elseif args[2] == 'zip' then 373 | 374 | local cmd = 'zip -r '..outfile..' '..table.concat ( filelist, ' ' ) 375 | 376 | print ( '\n=== executing: '..outfile..' ===\n' ) 377 | 378 | local success, res_reason, res_status = os.execute ( cmd ) 379 | 380 | if success then 381 | print ( '\n=== successful ===\n' ) 382 | else 383 | print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' ) 384 | end 385 | 386 | elseif args[2] == 'archive' then 387 | 388 | local cmd = 'git archive --prefix='..plugin_name..'-support/'..' --output='..outfile..' HEAD' 389 | 390 | print ( '\n=== executing: '..outfile..' ===\n' ) 391 | 392 | local success, res_reason, res_status = os.execute ( cmd ) 393 | 394 | if success then 395 | print ( '\n=== successful ===\n' ) 396 | else 397 | print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' ) 398 | end 399 | 400 | elseif args[2] == 'cp-repo' then 401 | 402 | if #args >= 3 then 403 | 404 | local dest_dir = args[3] 405 | local filelist_compl = {} 406 | 407 | for key, val in pairs ( filelist ) do 408 | table.insert ( filelist_compl, val ) 409 | end 410 | 411 | for key, val in pairs ( filelist_repo ) do 412 | table.insert ( filelist_compl, val ) 413 | end 414 | 415 | os.execute ( 'mkdir -p '..dest_dir ) 416 | os.execute ( 'mkdir -p '..dest_dir..'/project' ) 417 | 418 | local cmd = 'cp --parents -r '..table.concat ( filelist_compl, ' ' )..' '..dest_dir 419 | 420 | print ( '\n=== copying: '..dest_dir..' ===\n' ) 421 | 422 | local success, res_reason, res_status = os.execute ( cmd ) 423 | 424 | if success then 425 | cmd = 'cat '..plugin_name..'-support/README.standalone.md '..plugin_name..'-support/README.md > '..dest_dir..'/README.md' 426 | 427 | success, res_reason, res_status = os.execute ( cmd ) 428 | end 429 | 430 | if success then 431 | cmd = 'echo "\\ntaken from WolfgangMehner/vim-plugins, revision\\nhttps://github.com/WolfgangMehner/vim-plugins/commit/$(git rev-parse HEAD)" >> '..dest_dir..'/project/commit.txt' 432 | 433 | success, res_reason, res_status = os.execute ( cmd ) 434 | end 435 | 436 | if success then 437 | print ( '\n=== successful ===\n' ) 438 | else 439 | print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' ) 440 | end 441 | 442 | else 443 | 444 | print ( '\n=== failed: no destination given: release.lua cp-repo ===\n' ) 445 | 446 | end 447 | 448 | elseif args[2] == 'help' then 449 | 450 | print_help = true 451 | 452 | elseif #args >= 2 then 453 | 454 | print ( '\n=== failed: unknown mode "'..args[2]..'" ===\n' ) 455 | 456 | print_help = true 457 | 458 | end 459 | 460 | if print_help then 461 | 462 | print ( '' ) 463 | print ( 'release ' ) 464 | print ( '' ) 465 | print ( 'Plug-Ins:' ) 466 | print ( '\tawk' ) 467 | print ( '\tbash' ) 468 | print ( '\tc' ) 469 | print ( '\tlatex' ) 470 | print ( '\tlua' ) 471 | print ( '\tperl' ) 472 | print ( '\tvim' ) 473 | print ( '' ) 474 | print ( 'Modes:' ) 475 | print ( '\tlist - list all files' ) 476 | print ( '\tcheck - check the release' ) 477 | print ( '\tzip - create archive via "zip"' ) 478 | print ( '\tarchive - create archive via "git archive"' ) 479 | print ( '\tcp-repo - copy the repository' ) 480 | print ( '\thelp - print help' ) 481 | print ( '' ) 482 | 483 | end 484 | 485 | ------------------------------------------------------------------------ 486 | -- vim: foldmethod=marker 487 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Preface 2 | ================================================================================ 3 | 4 | This repository is mainly for the use with plug-in managers. 5 | 6 | Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/bashsupport.html). 7 | 8 | The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins). 9 | 10 | 11 | Preview Version 12 | ================================================================================ 13 | 14 | ___This is a preview version!___ 15 | 16 | Notable new features: 17 | 18 | - Call the Bash interpreter via the command-line: `:Bash `. You can use it 19 | to pass arguments to the script. 20 | - Run Bash in a terminal window directly inside the editor. 21 | - The template library now has shell options and variables for BASH Version 4.4. 22 | - The debugger integration has been move into the toolbox, and comes with 23 | extended functionality. 24 | 25 | The terminal window relies on the new `+terminal` feature, which becomes 26 | available with a patch level of approx. `8.0.1000`. 27 | 28 | _Please read the release notes below._ 29 | 30 | 31 | -------------------------------------------------------------------------------- 32 | 33 | README for bash-support.vim (Version 5.0beta) / November 22 2020 34 | ================================================================================ 35 | 36 | * INSTALLATION 37 | * RELEASE NOTES 38 | * FILES 39 | * ADDITIONAL TIPS 40 | * CREDITS 41 | 42 | Bash Support implements a Bash-IDE for Vim/gVim. It is written to considerably 43 | speed up writing code in a consistent style. This is done by inserting complete 44 | statements, comments, idioms, and code snippets. Syntax checking, running a 45 | script, starting a debugger can be done with a keystroke. There are many 46 | additional hints and options which can improve speed and comfort when writing 47 | shell scripts. 48 | 49 | This plug-in can be used with Vim version 7.4+ and Neovim 0.2.1+. 50 | 51 | 52 | -------------------------------------------------------------------------------- 53 | 54 | INSTALLATION 55 | ================================================================================ 56 | 57 | A system-wide installation for all users can also be done. This will have 58 | further effects on how the plug-in works. For a step-by-step instruction, as 59 | well as an explanation of the other consequences, please see the help file 60 | `doc/bashsupport.txt` or look up the documentation via: 61 | 62 | :help bashsupport-system-wide 63 | 64 | 65 | (1) LINUX 66 | ---------------------------------------------------------------------- 67 | 68 | The subdirectories in the zip archive `bash-support.zip` mirror the directory 69 | structure which is needed below the local installation directory `$HOME/.vim/` 70 | (find the value of `$HOME` with `:echo $HOME` from inside Vim). 71 | 72 | (1.0) Save the template files in `$HOME/.vim/bash-support/templates/Templates` 73 | if you have changed any of them. 74 | 75 | (1.1) Copy the zip archive `bash-support.zip` to `$HOME/.vim` and run 76 | 77 | unzip bash-support.zip 78 | 79 | Afterwards, these files should exist: 80 | 81 | $HOME/.vim/autoload/mmtemplates/... 82 | $HOME/.vim/doc/... 83 | $HOME/.vim/plugin/bash-support.vim 84 | 85 | (1.2) Loading of plug-in files must be enabled. If not use 86 | 87 | :filetype plugin on 88 | 89 | This is the minimal content of the file `$HOME/.vimrc`. Create one if there 90 | is none or use the files in `$HOME/.vim/bash-support/rc` as a starting point. 91 | 92 | (1.3) Make the plug-in help accessible by typing the following command on the 93 | Vim command line: 94 | 95 | :helptags $HOME/.vim/doc/ 96 | 97 | (1.4) Set at least some personal details. Use the map `\ntw` inside a Bash buffer 98 | or the menu entry: 99 | 100 | Bash -> Snippets -> template setup wizard 101 | 102 | It will help you set up the file `_runtimepath_/templates/personal.templates`. 103 | The file is read by all plug-ins supporting this feature to get your personal 104 | details. Here is the minimal personalization (my settings as an example): 105 | 106 | SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) 107 | SetMacro( 'AUTHORREF', 'wm' ) 108 | SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) 109 | SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) 110 | 111 | Use the file `$HOME/.vim/templates/bash.templates` to customize or add to your 112 | Bash template library. It can also be set up via the wizard. 113 | 114 | (Read more about the template system in the plug-in documentation.) 115 | 116 | (1.5) Consider additional settings in the file `$HOME/.vimrc`. The files 117 | `customization.vimrc` and `customization.gvimrc` are replacements or extensions 118 | for your `.vimrc` and `.gvimrc`. You may want to use parts of them. The files 119 | are documented. 120 | 121 | 122 | (2) WINDOWS 123 | ---------------------------------------------------------------------- 124 | 125 | The subdirectories in the zip archive `bash-support.zip` mirror the directory 126 | structure which is needed below the local installation directory 127 | `$HOME/vimfiles/` (find the value of `$HOME` with `:echo $HOME` from inside Vim). 128 | 129 | (2.0) Save the template files in `$HOME/vimfiles/bash-support/templates/Templates` 130 | if you have changed any of them. 131 | 132 | (2.1) Copy the zip archive bash-support.zip to `$HOME/vimfiles` and run 133 | 134 | unzip bash-support.zip 135 | 136 | Afterwards, these files should exist: 137 | 138 | $HOME/vimfiles/autoload/mmtemplates/... 139 | $HOME/vimfiles/doc/... 140 | $HOME/vimfiles/plugin/bash-support.vim 141 | 142 | (2.2) Loading of plug-in files must be enabled. If not use 143 | 144 | :filetype plugin on 145 | 146 | This is the minimal content of the file `$HOME/_vimrc`. Create one if there 147 | is none or use the files in `$HOME/vimfiles/bash-support/rc` as a starting point. 148 | 149 | (2.3) Make the plug-in help accessible by typing the following command on the 150 | Vim command line: 151 | 152 | :helptags $HOME\vimfiles\doc\ 153 | 154 | (2.4) Set at least some personal details. Use the map `\ntw` inside a Bash buffer 155 | or the menu entry: 156 | 157 | Bash -> Snippets -> template setup wizard 158 | 159 | It will help you set up the file `_runtimepath_/templates/personal.templates`. 160 | The file is read by all plug-ins supporting this feature to get your personal 161 | details. Here is the minimal personalization (my settings as an example): 162 | 163 | SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) 164 | SetMacro( 'AUTHORREF', 'wm' ) 165 | SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) 166 | SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) 167 | 168 | Use the file `$HOME/vimfiles/templates/bash.templates` to customize or add to 169 | your Bash template library. It can also be set up via the wizard. 170 | 171 | (Read more about the template system in the plug-in documentation.) 172 | 173 | (2.5) Consider additional settings in the file `$HOME/_vimrc`. The files 174 | `customization.vimrc` and `customization.gvimrc` are replacements or extensions 175 | for your `_vimrc` and `_gvimrc`. You may want to use parts of them. The files 176 | are documented. 177 | 178 | 179 | (3) ADDITIONAL REMARKS 180 | ---------------------------------------------------------------------- 181 | 182 | There are a lot of features and options which can be used and influenced: 183 | 184 | * use of template files and macros 185 | * using and managing personal code snippets 186 | * bash dictionary for keyword completion 187 | * removing the root menu 188 | * using additional plug-ins 189 | 190 | Actions differ for different modes. Please read the documentation: 191 | 192 | :help bashsupport 193 | 194 | Any problems? See the TROUBLESHOOTING section at the end of the help file 195 | `doc/bashsupport.txt`. 196 | 197 | 198 | -------------------------------------------------------------------------------- 199 | 200 | RELEASE NOTES 201 | ================================================================================ 202 | 203 | RELEASE NOTES FOR VERSION 5.0beta 204 | ---------------------------------------------------------------------- 205 | - Adapt for running under Neovim more smoothly. 206 | - Add command `:Bash []` to run the interpreter with arguments. 207 | - Add command `:BashCheck.` the run the syntax checker. 208 | - Add command `:BashDirectRun` to run executable scripts without `g:BASH_Executable`. 209 | - Add command `:BashOutputMethod` to set the output destination for `:Bash`. 210 | - Add command `:BashExecutable` to set the executable during runtime. 211 | - Add output method 'terminal' for running scripts in a terminal window 212 | (requires +terminal). 213 | - The templates which are inserted into new files as file skeletons can be 214 | specified in the templates library, via the property: 215 | `Bash::FileSkeleton::Script` 216 | - Use `g:Xterm_Executable`. 217 | - Use `g:Xterm_Options` instead of `g:BASH_XtermDefaults`. The setting 218 | `g:BASH_XtermDefaults` still works for backwards compatibility. 219 | - Add configuration variables `g:BASH_Ctrl_j` and `g:BASH_Ctrl_d` to control the 220 | creation of the `CTRL+J` and `CTRL+D` maps. 221 | - Remove the definition of the maps `CTRL+F9`, `SHIFT+F9`, and `ALT+F9`. 222 | Add them to your filetype plug-in if you want to use them. 223 | - Integration of BashDB moved into the toolbox. 224 | - Add shell options and variables for BASH Version 4.4 and 5.0. 225 | - Minor corrections and improvements. 226 | 227 | Note: The filetype plug-in has been moved, and is thus not loaded automatically 228 | anymore. Copy it from `bash-support/rc` to `ftplugin`, or add the commands there 229 | to your own filetype plug-in. 230 | 231 | 232 | RELEASE NOTES FOR OLDER VERSIONS 233 | ---------------------------------------------------------------------- 234 | -> see file `bash-support/doc/ChangeLog` 235 | 236 | 237 | -------------------------------------------------------------------------------- 238 | 239 | FILES 240 | ================================================================================ 241 | 242 | README.md 243 | This file. 244 | 245 | autoload/mmtemplates/* 246 | The template system. 247 | 248 | doc/bashsupport.txt 249 | The help file for Bash Support. 250 | doc/templatesupport.txt 251 | The help file for the template system. 252 | 253 | plugin/bash-support.vim 254 | The Bash plugin for Vim/gVim. 255 | 256 | bash-support/codesnippets/* 257 | Some Bash code snippets as a starting point. 258 | 259 | bash-support/scripts/* 260 | Several helper scripts. 261 | 262 | bash-support/templates/Templates 263 | Bash main template file. 264 | bash-support/templates/*.templates 265 | Several dependent template files. 266 | 267 | bash-support/wordlists/bash-keywords.list 268 | A file used as dictionary for automatic word completion. 269 | This file is referenced in the file customization.vimrc. 270 | 271 | ___The following files and extensions are for convenience only.___ 272 | ___bash-support.vim will work without them.___ 273 | ___The settings are explained in the files themselves.___ 274 | 275 | ftdetect/template.vim 276 | ftplugin/template.vim 277 | syntax/template.vim 278 | Additional files for working with templates. 279 | 280 | bash-support/doc/bash-hotkeys.pdf 281 | Reference card for the key mappings. The mappings can 282 | also be used with the non-GUI Vim, where the menus are 283 | not available. 284 | bash-support/doc/ChangeLog 285 | The change log. 286 | 287 | bash-support/rc/customization.bashrc 288 | Additional settings for use in .bashrc: 289 | set the prompt P2, P3, P4 (for debugging) 290 | bash-support/rc/customization.gvimrc 291 | Additional settings for use in .gvimrc: 292 | hot keys, mouse settings, ... 293 | The file is commented. Append it to your .gvimrc if you 294 | like. 295 | bash-support/rc/customization.vimrc 296 | Additional settings for use in .vimrc: 297 | incremental search, tabstop, hot keys, 298 | font, use of dictionaries, ... 299 | The file is commented. Append it to your .vimrc if you 300 | like. 301 | 302 | bash-support/rc/sh.vim 303 | Example filetype plug-ins for Bash: 304 | defines additional maps 305 | 306 | bash-support/rc/*.templates 307 | Sample template files for customization. Used by the 308 | template setup wizard. 309 | 310 | 311 | -------------------------------------------------------------------------------- 312 | 313 | ADDITIONAL TIPS 314 | ================================================================================ 315 | 316 | (1) gvim. Toggle 'insert mode' <--> 'normal mode' with the right mouse button 317 | (see mapping in file `customization.gvimrc`). 318 | 319 | (2) gvim. Use tear off menus and 320 | 321 | (3) try 'Focus under mouse' as window behavior (No mouse click when the mouse 322 | pointer is back from the menu entry). 323 | 324 | (4) Use Emulate3Buttons "on" (X11) even for a 3-button mouse. Pressing left and 325 | right button simultaneously without moving your fingers is faster then moving 326 | a finger to the middle button (often a wheel). 327 | 328 | 329 | -------------------------------------------------------------------------------- 330 | 331 | CREDITS 332 | ================================================================================ 333 | 334 | Fritz Mehner thanks: 335 | ---------------------------------------------------------------------- 336 | 337 | Wolfgang Mehner (wolfgang-mehner AT web.de) for the implementation of the 338 | powerful template system templatesupport. 339 | 340 | Wolfgang Mehner thanks: 341 | ---------------------------------------------------------------------- 342 | 343 | This plug-in has been developed by Fritz Mehner, who maintained it until 2015. 344 | 345 | -------------------------------------------------------------------------------- /bash-support/doc/bash-hotkeys.tex: -------------------------------------------------------------------------------- 1 | %%===================================================================================== 2 | %% 3 | %% File: bash-hotkeys.tex 4 | %% 5 | %% Description: bash-support.vim : Key mappings for Bash with/without GUI. 6 | %% 7 | %% Version: see \Pluginversion 8 | %% Created: 20.05.2013 9 | %% Revision: 17.02.2018 10 | %% 11 | %% Author: Wolfgang Mehner, wolfgang-mehner@web.de 12 | %% (formerly Dr. Fritz Mehner (fgm), mehner.fritz@web.de) 13 | %% Copyright: Copyright (c) 2013-2018, Wolfgang Mehner 14 | %% 15 | %%===================================================================================== 16 | 17 | %%====================================================================== 18 | %% LaTeX settings [[[1 19 | %%====================================================================== 20 | 21 | \documentclass[oneside,11pt,landscape,DIV16]{scrartcl} 22 | 23 | \usepackage[english]{babel} 24 | \usepackage[utf8]{inputenc} 25 | \usepackage[T1]{fontenc} 26 | \usepackage{times} 27 | \usepackage{lastpage} 28 | \usepackage{multicol} 29 | \usepackage{fancyhdr} 30 | 31 | \setlength\parindent{0pt} 32 | 33 | \newcommand{\Pluginversion}{5.0alpha} 34 | \newcommand{\ReleaseDate}{\today} 35 | \newcommand{\Rep}{{\scriptsize{[n]}}} 36 | 37 | %%---------------------------------------------------------------------- 38 | %% fancyhdr 39 | %%---------------------------------------------------------------------- 40 | \pagestyle{fancyplain} 41 | \fancyhf{} 42 | \fancyfoot[L]{\small \ReleaseDate} 43 | \fancyfoot[C]{\small bash-support.vim} 44 | \fancyfoot[R]{\small \textbf{Page \thepage{} / \pageref{LastPage}}} 45 | \renewcommand{\headrulewidth}{0.0pt} 46 | 47 | %%---------------------------------------------------------------------- 48 | %% luximono : Type1-font 49 | %% Makes keyword stand out by using semibold letters. 50 | %%---------------------------------------------------------------------- 51 | \usepackage[scaled]{luximono} 52 | 53 | %%---------------------------------------------------------------------- 54 | %% hyperref 55 | %%---------------------------------------------------------------------- 56 | \usepackage{hyperref} 57 | \hypersetup{pdfauthor={Wolfgang Mehner, Germany, wolfgang-mehner@web.de}} 58 | \hypersetup{pdfkeywords={Vim, Perl}} 59 | \hypersetup{pdfsubject={Vim-plug-in, bash-support.vim, hot keys}} 60 | \hypersetup{pdftitle={Vim-plug-in, bash-support.vim, hot keys}} 61 | 62 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 63 | %% START OF DOCUMENT 64 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 65 | \begin{document}% 66 | 67 | \begin{multicols}{3} 68 | % 69 | \begin{center} 70 | % 71 | %%====================================================================== 72 | %% title [[[1 73 | %%====================================================================== 74 | \textbf{\textsc{\small{Vim-Plug-in}}}\\ 75 | \textbf{\LARGE{bash-support.vim}}\\ 76 | \textbf{\textsc{\small{Version \Pluginversion}}}\\ 77 | \vspace{1mm}% 78 | \textbf{\textsc{\Huge{Hot keys}}}\\ 79 | \vspace{1mm}% 80 | Key mappings for Vim/gVim/Neovim.\\ 81 | {\tiny \texttt{https://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ 82 | \vspace{1.0mm} 83 | % 84 | %%====================================================================== 85 | %% page 1 / table, left part [[[1 86 | %%====================================================================== 87 | %%~~~~~ TABULAR : begin ~~~~~~~~~~ 88 | \begin{tabular}[]{|p{11mm}|p{60mm}|} 89 | %%---------------------------------------------------------------------- 90 | %% menu Help [[[2 91 | %%---------------------------------------------------------------------- 92 | \hline 93 | \multicolumn{2}{|r|}{\textsl{\textbf{H}elp}}\\[1.0ex] 94 | \hline \verb'\he' & English dictionary \\ 95 | \hline \verb'\hb' & display the Bash manual \\ 96 | \hline \verb'\hh' & help (Bash builtins) \hfill (T)\\ 97 | \hline \verb'\hm' & show manual (cmd. line utilities) \\ 98 | \hline \verb'\hp' & help (plug-in) \\ 99 | \hline 100 | %%---------------------------------------------------------------------- 101 | %% main menu [[[2 102 | %%---------------------------------------------------------------------- 103 | \hline 104 | \multicolumn{2}{|r|}{\textsl{\textbf{B}ash}}\\[1.0ex] 105 | \hline \verb'\bps' & \textbf{p}arameter \textbf{s}ubstitution (list) \hfill (T)\\ 106 | \hline \verb'\bsp' & \textbf{s}pecial \textbf{p}arameters (list) \hfill (T)\\ 107 | \hline \verb'\ben' & \textbf{en}vironment (list) \hfill (T)\\ 108 | \hline \verb'\bbu' & \textbf{bu}iltins (list) \hfill (T)\\ 109 | \hline \verb'\bse' & \textbf{se}t options (list) \hfill (T)\\ 110 | \hline \verb'\bso' & \textbf{s}h\textbf{o}pts (list) \hfill (T)\\ 111 | \hline 112 | %%---------------------------------------------------------------------- 113 | %% menu Comments [[[2 114 | %%---------------------------------------------------------------------- 115 | \hline 116 | \multicolumn{2}{|r|}{\textsl{\textbf{C}omments}} \\[1.0ex] 117 | \hline \Rep\verb'\cl' & end-of-line comment \hfill (v)\\ 118 | \hline \Rep\verb'\cj' & adjust end-of-line comments \hfill (v)\\ 119 | \hline \verb'\cs' & set end-of-line comment col. \\ 120 | % 121 | \hline \Rep\verb'\cc' & code $\rightarrow$ comment \hfill (v)\\ 122 | \hline \Rep\verb'\co' & uncomment code \hfill (v)\\ 123 | % 124 | \hline \verb'\cfr' & frame comment \\ 125 | \hline \verb'\cfu' & function description \\ 126 | \hline \verb'\ch' & file header \\ 127 | \hline \verb'\csh' & shebang \\ 128 | \hline \verb'\cd' & date \\ 129 | \hline \verb'\ct' & date \& time \\ 130 | \hline 131 | \end{tabular}\\ 132 | %%~~~~~ TABULAR : end ~~~~~~~~~~ 133 | % ]]]2 134 | % 135 | %%====================================================================== 136 | %% page 1 / table, middle part [[[1 137 | %%====================================================================== 138 | %%~~~~~ TABULAR : begin ~~~~~~~~~~ 139 | \begin{tabular}[]{|p{11mm}|p{60mm}|} 140 | %%---------------------------------------------------------------------- 141 | %% menu Comments [[[2 142 | %%---------------------------------------------------------------------- 143 | \hline 144 | \multicolumn{2}{|r|}{\textsl{\textbf{C}omments (cont)}} \\[1.0ex] 145 | \hline \verb'\css' & script sections \hfill (T)\\ 146 | \hline \verb'\ckc' & keyword comments \hfill (T)\\ 147 | \hline \verb'\cma' & plug-in macros \hfill (T)\\ 148 | % 149 | \hline \verb'\ce' & \texttt{echo} "\textsl{actual line}" \hfill (v)\\ 150 | \hline \verb'\cr' & remove \texttt{echo} from actual line \hfill (v)\\ 151 | \hline 152 | %%---------------------------------------------------------------------- 153 | %% menu Statements [[[2 154 | %%---------------------------------------------------------------------- 155 | \hline 156 | \multicolumn{2}{|r|}{\textsl{\textbf{S}tatements}} \\[1.0ex] 157 | \hline \verb'\sc' & \verb'case in ... esac' \\ 158 | \hline \verb'\sei' & \verb'elif then' \\ 159 | \hline \verb'\sf' & \verb'for in do done' \hfill (s)\\ 160 | \hline \verb'\sfo' & \verb'for ((...)) do done' \hfill (s)\\ 161 | \hline \verb'\si' & \verb'if then fi' \hfill (s)\\ 162 | \hline \verb'\sie' & \verb'if then else fi' \hfill (s)\\ 163 | \hline \verb'\ss' & \verb'select in do done' \hfill (s)\\ 164 | \hline \verb'\su' & \verb'until do done' \hfill (s)\\ 165 | \hline \verb'\sw' & \verb'while do done' \hfill (s)\\ 166 | \hline \verb'\sfu' & \verb'function' \hfill (s)\\ 167 | % 168 | \hline \verb'\se' & \verb'echo -e ""' \hfill (s)\\ 169 | \hline \verb'\sp' & \verb'printf "%s"' \hfill (s)\\ 170 | % 171 | \hline \verb'\sae' & array element\ \ \ \verb'${.[.]}' \hfill (s)\\ 172 | \hline \verb'\saa' & arr. elem.s (all) \ \verb'${.[@]}' \hfill (s)\\ 173 | \hline \verb'\sas' & arr. elem.s (1 word) \ \verb'${.[*]}' \hfill (s)\\ 174 | \hline \verb'\ssa' & subarray \ \verb'${.[@]::}' \hfill (s)\\ 175 | \hline \verb'\san' & no. of arr. elem.s \ \verb'${.[@]}' \hfill (s)\\ 176 | \hline \verb'\sai' & list of indices \ \verb'${.[*]}' \hfill (s)\\ 177 | \hline 178 | %% 179 | %%---------------------------------------------------------------------- 180 | %% menu Tests [[[2 181 | %%---------------------------------------------------------------------- 182 | \hline 183 | \multicolumn{2}{|r|}{\textsl{\textbf{T}ests}} \\[1.0ex] 184 | \hline \verb'\ta' & arithmetic tests \hfill (T)\\ 185 | \hline \verb'\tfp' & file permissions \hfill (T)\\ 186 | \hline \verb'\tft' & file types \hfill (T)\\ 187 | \hline \verb'\tfc' & file characteristics \hfill (T)\\ 188 | \hline \verb'\ts' & string comparisons \hfill (T)\\ 189 | \hline \verb'\toe' & option is enabled \\ 190 | \hline \verb'\tvs' & variables has been set \\ 191 | \hline \verb'\tfd' & file descr. refers to a terminal \\ 192 | \hline \verb'\tm' & string matches regexp \\ 193 | \hline 194 | %% 195 | \end{tabular}\\ 196 | %%~~~~~ TABULAR : end ~~~~~~~~~~ 197 | % ]]]2 198 | % 199 | %%====================================================================== 200 | %% page 1 / table, right part [[[1 201 | %%====================================================================== 202 | %%~~~~~ TABULAR : begin ~~~~~~~~~~ 203 | \begin{tabular}[]{|p{11mm}|p{60mm}|} 204 | %%---------------------------------------------------------------------- 205 | %% menu IO-Redirection [[[2 206 | %%---------------------------------------------------------------------- 207 | \hline 208 | \multicolumn{2}{|r|}{\textsl{\textbf{I}O-Redirection}} \\[1.0ex] 209 | \hline \verb'\ior' & IO-redirections (list) \hfill (T)\\ 210 | \hline \verb'\ioh' & here-document \hfill (s)\\ 211 | \hline 212 | % 213 | %%---------------------------------------------------------------------- 214 | %% menu Pattern Matching [[[2 215 | %%---------------------------------------------------------------------- 216 | \hline 217 | \multicolumn{2}{|r|}{\textsl{\textbf{P}attern Matching}} \\[1.0ex] 218 | \hline \verb'\pzo' & zero or one, \verb' ?( | )' \hfill (s)\\ 219 | \hline \verb'\pzm' & zero or more, \verb' *( | )' \hfill (s)\\ 220 | \hline \verb'\pom' & one or more, \verb' +( | )' \hfill (s)\\ 221 | \hline \verb'\peo' & exactly one, \verb' @( | )' \hfill (s)\\ 222 | \hline \verb'\pae' & anything except, \verb' !( | )' \hfill (s)\\ 223 | \hline \verb'\ppc' & POSIX classes \hfill (T)\\ 224 | \hline \verb'\pbr' & \verb'${BASH_REMATCH[0'$\ldots$\verb'3]}' \hfill (T)\\ 225 | \hline 226 | % 227 | %%---------------------------------------------------------------------- 228 | %% menu Snippet [[[2 229 | %%---------------------------------------------------------------------- 230 | \hline 231 | \multicolumn{2}{|r|}{\textsl{S\textbf{n}ippets}} \\[1.0ex] 232 | \hline \verb'\nr' & read code snippet \\ 233 | \hline \verb'\nv' & view code snippet \\ 234 | \hline \verb'\nw' & write code snippet \hfill (v)\\ 235 | \hline \verb'\ne' & edit code snippet \\ 236 | % 237 | \hline \verb'\ntl' & edit local templates \\ 238 | \hline \verb'\ntc' & edit custom templates \\ 239 | \hline \verb'\ntp' & edit personal templates \\ 240 | \hline \verb'\ntr' & reread the templates \\ 241 | \hline \verb'\ntw' & template setup wizard \\ 242 | \hline \verb'\nts' & choose style \hfill (T)\\ 243 | \hline 244 | \end{tabular}\\[1.0ex] 245 | %%~~~~~ TABULAR : end ~~~~~~~~~~ 246 | % 247 | %%---------------------------------------------------------------------- 248 | %% box Footnotes [[[2 249 | %%---------------------------------------------------------------------- 250 | \begin{minipage}[b]{72mm}% 251 | \scriptsize{% 252 | all hotkeys work in normal and insert mode \\ 253 | visual mode: {\normalsize (v)} use the range, 254 | {\normalsize (s)} surround range \\ 255 | tab-completion: {\normalsize (T)} specialized, 256 | {\normalsize (F)} filenames 257 | }% 258 | \end{minipage} 259 | % ]]]2 260 | % 261 | \newpage 262 | % 263 | %%====================================================================== 264 | %% page 2 / table, left part [[[1 265 | %%====================================================================== 266 | % 267 | %%~~~~~ TABULAR : begin ~~~~~~~~~~ 268 | \begin{tabular}[]{|p{11mm}|p{60mm}|} 269 | %%---------------------------------------------------------------------- 270 | %% menu Run [[[2 271 | %%---------------------------------------------------------------------- 272 | \hline 273 | \multicolumn{2}{|r|}{\textsl{\textbf{R}un}} \\[1.0ex] 274 | \hline \verb'\rr' & run script \hfill (v)\\ 275 | \hline \verb'\rsa' & set script cmd. line arguments \hfill (F)\\ 276 | \hline \verb'\ria' & set interp. cmd. line arguments \hfill (F)\\ 277 | \hline \verb'\rk' & check syntax \\ 278 | \hline \verb'\rso' & syntax check options \\ 279 | \hline \verb'\ro' & change output destination \hfill (T)\\ 280 | \hline \verb'\rd' & set ``direct run'' \hfill (T)\\ 281 | \hline \verb'\rse' & set shell executable \hfill (T)\\ 282 | \hline \verb'\rx' & set xterm size \\ 283 | \hline \verb'\re' & make script executable/not exec. \\ 284 | \hline \verb'\rh' & hardcopy buffer \hfill (v)\\ 285 | \hline \verb'\rs' & plug-in settings \\ 286 | \hline 287 | \hline \verb'\ra' & set script cmd. line arguments \hfill {(\textit{d})}\\ 288 | \hline \verb'\rba' & set interp. cmd. line arguments \hfill {(\textit{d})}\\ 289 | \hline \verb'\rc' & check syntax \hfill {(\textit{d})}\\ 290 | \hline \verb'\rco' & syntax check options \hfill {(\textit{d})}\\ 291 | \hline 292 | %%---------------------------------------------------------------------- 293 | %% buffer "Bash Output" [[[2 294 | %%---------------------------------------------------------------------- 295 | \hline 296 | \multicolumn{2}{|r|}{\textsl{Buffer ``Bash Output''}} \\[1.0ex] 297 | \hline \verb'\qf' & load errors into quickfix \\ 298 | \hline \verb'\qj' & load into qf.~and jump to first error \\ 299 | \hline 300 | \end{tabular}\\[1.0ex] 301 | %%~~~~~ TABULAR : end ~~~~~~~~~~ 302 | % 303 | %%---------------------------------------------------------------------- 304 | %% box Footnotes [[[2 305 | %%---------------------------------------------------------------------- 306 | \begin{minipage}[b]{72mm}% 307 | \scriptsize{% 308 | {\normalsize (\textit{d})} deprecated, will be removed in next version 309 | }% 310 | \end{minipage} 311 | % ]]]2 312 | \columnbreak 313 | % 314 | %%====================================================================== 315 | %% page 2 / table, middle part [[[1 316 | %%====================================================================== 317 | % 318 | %%---------------------------------------------------------------------- 319 | %% Run Bash [[[2 320 | %%---------------------------------------------------------------------- 321 | \begin{minipage}[b]{72mm}% 322 | \large{\textbf{Run}}\\[1.0ex] 323 | Run \textit{bash} with optional arguments: \\[0.5ex] 324 | \texttt{:Bash []} \\[1.0ex] 325 | Memorize script arguments: \\[0.5ex] 326 | \texttt{:BashScriptArguments []} \\[0.5ex] 327 | The memorize arguments are used if \texttt{:Bash} is invoked without arguments. \\[1.0ex] 328 | Set interpreter arguments: \\[0.5ex] 329 | \texttt{:BashInterpArguments []} 330 | \end{minipage} 331 | \\[2.5ex] 332 | % 333 | %%---------------------------------------------------------------------- 334 | %% Check Syntax [[[2 335 | %%---------------------------------------------------------------------- 336 | \begin{minipage}[b]{72mm}% 337 | \large{\textbf{Syntax}}\\[1.0ex] 338 | Run syntax checking: \\[0.5ex] 339 | \texttt{:BashCheck} \\[1.0ex] 340 | Set syntax checking options: \\[0.5ex] 341 | \texttt{:BashSyntaxCheckOptions } 342 | \end{minipage} 343 | \\[2.5ex] 344 | % 345 | %%---------------------------------------------------------------------- 346 | %% Options [[[2 347 | %%---------------------------------------------------------------------- 348 | \begin{minipage}[b]{72mm}% 349 | \large{\textbf{Options}}\\[1.0ex] 350 | Set the output method: \\[0.5ex] 351 | \texttt{:BashOutputMethod []} \\[1.0ex] 352 | Set the shell executable: \\[0.5ex] 353 | \texttt{:BashExecutable []} \\[1.0ex] 354 | Set ``direct run'': \\[0.5ex] 355 | \texttt{:BashDirectRun [ yes | no ]} \\[0.5ex] 356 | When set to \texttt{yes}, executable scripts will be run as the executable, instead of using \texttt{:BashExecutable}. 357 | \end{minipage} 358 | \\[2.5ex] 359 | % 360 | %%---------------------------------------------------------------------- 361 | %% Debugger [[[2 362 | %%---------------------------------------------------------------------- 363 | \begin{minipage}[b]{72mm}% 364 | \large{\textbf{BashDB}}\\[1.0ex] 365 | Run the debugger \texttt{bashdb}: \\[0.5ex] 366 | \texttt{:BashDB} \\[1.0ex] 367 | \dots 368 | % TODO 369 | \end{minipage} 370 | % ]]]2 371 | % 372 | \end{center}% 373 | \end{multicols}% 374 | % 375 | %%----- TABBING : end ---------- 376 | \end{document} 377 | % vim: foldmethod=marker foldmarker=[[[,]]] 378 | -------------------------------------------------------------------------------- /doc/toolbox.txt: -------------------------------------------------------------------------------- 1 | *toolbox.txt* MM Toolbox Support Sep 30 2017 2 | 3 | MM Toolbox Support *toolbox* 4 | 5 | Plug-in version 1.3 6 | for Vim version 7.0 and above 7 | Wolfgang Mehner 8 | 9 | --- The Maps & Menus Toolbox Support --- 10 | 11 | Toolboxes are selection of tools, which are made available to a plug-in. Tools 12 | mostly stand on their own. The purpose of the toolbox is to provide an easy 13 | interface between a plug-in and the tools, switching tool on and off and 14 | triggering the creation of maps and menus. The plug-in does not need any prior 15 | knowledge of what tools are available. 16 | 17 | The toolbox support is controlled by an API and thus can be integrated into 18 | another plug-in. A toolbox is essentially an object, several of which can 19 | exist in parallel. This makes it easy to integrate a toolbox into your 20 | plug-in. 21 | 22 | Here is a list of high profile plug-ins which use the toolbox support: 23 | - C-Support (https://www.vim.org/scripts/script.php?script_id=213) 24 | - Perl-Support (https://www.vim.org/scripts/script.php?script_id=556) 25 | 26 | ============================================================================== 27 | 0. TABLE OF CONTENTS *toolbox-support-contents* 28 | ============================================================================== 29 | 30 | 1. Introduction |toolbox-support-intro| 31 | 2. Integration |toolbox-support-integration| 32 | 3. Tool Development |toolbox-support-tools| 33 | 3.1 Minimal Tool API |toolbox-support-tools-api| 34 | 3.2 Common Tool Functionality |toolbox-support-tools-common| 35 | 4. API |toolbox-support-api| 36 | 37 | A. Change Log |toolbox-support-change-log| 38 | 39 | ============================================================================== 40 | 1. INTRODUCTION *toolbox-support-intro* 41 | ============================================================================== 42 | 43 | The manual at hand documents the Maps & Menus Toolbox Support. If your are not 44 | a plug-In developer, this will not be interesting, tools should come with a 45 | separate documentation. 46 | 47 | The next chapter |toolbox-support-integration| describes how to integrate the 48 | toolbox support into a plug-in. Then the tool development is addressed in 49 | |toolbox-support-tools|. The whole API of the toolbox support is documented in 50 | |toolbox-support-api|. 51 | 52 | ============================================================================== 53 | 2. INTEGRATION *toolbox-support-integration* 54 | ============================================================================== 55 | 56 | This chapter explains the basic steps for integrating the toolbox into a 57 | plug-in. A complete description of all the commands can be found in 58 | |toolbox-support-api|. 59 | 60 | ------------------------------------------------------------------------------ 61 | 62 | Firstly, the toolbox needs to be created using |mmtoolbox#tools#NewToolbox()| 63 | and then loading via |mmtoolbox#tools#Load()|. 64 | > 65 | let s:ToolID = 'MyPlugin' " the toolboxes ID 66 | let s:MapLeader = '\' " configurable mapl. 67 | let s:ToolboxDir = [ vim_dir.'/autoload/mmtoolbox/' ] " list of directories 68 | 69 | let s:Toolbox = mmtoolbox#tools#NewToolbox ( s:ToolID ) 70 | call mmtoolbox#tools#Property ( s:Toolbox, 'mapleader', s:MapLeader ) 71 | 72 | call mmtoolbox#tools#Load ( s:Toolbox, s:ToolboxDir ) 73 | 74 | " debugging only: 75 | "call mmtoolbox#tools#Info ( s:Toolbox ) 76 | < 77 | The function |mmtoolbox#tools#Property()| is used for basic configuration. 78 | During development |mmtoolbox#tools#Info()| helps with some debug output. 79 | 80 | Each tool is only loaded if the following condition holds: > 81 | g:_UseTool_ == "yes" 82 | The ID is the ID set by the call to |mmtoolbox#tools#NewToolbox()|. 83 | If the above toolbox "MyPlugin" should load a tool called "align", then the 84 | following variable assignment must be made: > 85 | let g:MyPlugin_UseTool_align == "yes" 86 | < 87 | ------------------------------------------------------------------------------ 88 | 89 | Menu creation is done using |mmtoolbox#tools#AddMenus()|: 90 | > 91 | if mmtoolbox#tools#Property ( s:Toolbox, 'empty-menu' ) == 0 92 | " create menu header 93 | " ... 94 | 95 | call mmtoolbox#tools#AddMenus ( s:Toolbox, 'My\ PlugIn.&Tool\ Box' ) 96 | endif 97 | < 98 | ------------------------------------------------------------------------------ 99 | > 100 | For each appropriate buffer, map creation is triggered via 101 | |mmtoolbox#tools#AddMaps()|: 102 | > 103 | call mmtoolbox#tools#AddMaps ( s:Toolbox ) 104 | < 105 | ============================================================================== 106 | 3. TOOL DEVELOPMENT *toolbox-support-tools* 107 | ============================================================================== 108 | 109 | This chapter shows the basic steps to implementing a tool. The tool has to 110 | fulfill some minimal requirements to work with the toolbox. Other requirements 111 | are suggestions to provide a common user experience. 112 | 113 | ------------------------------------------------------------------------------ 114 | 3.1 MINIMAL TOOL API *toolbox-support-tools-api* 115 | ------------------------------------------------------------------------------ 116 | 117 | Tools must implement a minimal API in order to work with the toolbox support. 118 | Initially, the GetInfo() function is called to obtain some basic information 119 | about the tool. For map creation, AddMaps(...) is called and for menus 120 | AddMenu(). 121 | 122 | Function Call Further Information 123 | ---------------------------------------------------------------------------- 124 | ret_list = mmtoolbox##GetInfo() |toolbox-support-GetInfo()| 125 | mmtoolbox##AddMaps() |toolbox-support-AddMaps()| 126 | mmtoolbox##AddMenu( menu_sub, mleader ) |toolbox-support-AddMenu()| 127 | ---------------------------------------------------------------------------- 128 | 129 | ------------------------------------------------------------------------------ 130 | *toolbox-support-GetInfo()* 131 | ret_list = mmtoolbox##GetInfo () ~ 132 | 133 | No parameters. 134 | Returns: 135 | ret_list - information about the tool, see below (list) 136 | 137 | To initialize a tool , the 'GetInfo' function is called: > 138 | let ret_list = mmtoolbox##GetInfo() 139 | The tool must provide some basic information in the return argument: 140 | ret_list = [ , , , , ... ] 141 | With the first two entries: 142 | prettyname - the name of the tool, can be different from (string), 143 | for example the pretty name of cmake is "CMake" 144 | version - the version of the tool (string), 145 | for debugging purposes 146 | Followed by a list of optional flags: 147 | "nomenu" - the tool does not have an own menu 148 | "disabled" - the tool is disabled, no maps or menus are created 149 | 150 | ------------------------------------------------------------------------------ 151 | *toolbox-support-AddMaps()* 152 | mmtoolbox##AddMaps ( toolbox ) ~ 153 | 154 | No parameters: 155 | No returns. 156 | 157 | Creates maps for the tool. A tool should only create buffer-local mappings. 158 | The function will be called for each appropriate buffer. The settings for 159 | are handled before calling 'mmtoolbox##AddMaps'. 160 | 161 | ------------------------------------------------------------------------------ 162 | *toolbox-support-AddMenu()* 163 | mmtoolbox##AddMenu ( menu_sub, mapl ) ~ 164 | 165 | Parameters: 166 | menu_sub - the submenu set up for the toolbox (string) 167 | mapl - the mapleader configured for the toolbox (string) 168 | No returns. 169 | 170 | Creates a menu for the tool. The arguments 'menu_sub' and 'mapl' are provided 171 | correctly escaped for menu creation, so they can be used for |amenu| commands 172 | without further preparation: 173 | > 174 | function! mmtoolbox#cmake#AddMenu ( menu_sub, mapl ) 175 | 176 | exe 'amenu '.a:menu_sub.'.&run\ make'.a:mapl.'rm :CMake ' 177 | 178 | " ... 179 | endfunction 180 | < 181 | Before calling AddMenu, a menu header is created for the tool's submenu, 182 | showing the pretty name of the tool. 183 | 184 | ------------------------------------------------------------------------------ 185 | 3.2 COMMON TOOL FUNCTIONALITY *toolbox-support-tools-common* 186 | ------------------------------------------------------------------------------ 187 | 188 | In order to achieve a consistent user experience, it is recommended that tools 189 | provide a set of common features. It is not strictly necessary to implement 190 | all of them, but it will help users who already use other tools. 191 | 192 | The call: > 193 | mmtoolbox##Property( 'get', 'enabled' ) 194 | should return a non-zero integer if the tool is working correctly. This also 195 | means that |mmtoolbox#tools#ToolEnabled()| will work correctly with the tool. 196 | 197 | A tool might not be enabled because some resources are missing. For example, 198 | the CMake tool will be disabled, if the "cmake" executable is missing. In this 199 | case the ex-command like > 200 | :ToolnameHelp 201 | should show the reason while the tool is not working (see |:MakeHelp|). 202 | Otherwise, :ToolnameHelp should open the documentation of the tool. 203 | 204 | Settings which might change during runtime, like the Makefile used for a 205 | build, should also be set by a call to: > 206 | mmtoolbox##Property( 'set', 'some-setting', 'new-value' ) 207 | This enabled users to change these settings using scripts (see 208 | |mmtoolbox#make#Property()|). 209 | 210 | ============================================================================== 211 | 4. API *toolbox-support-api* 212 | ============================================================================== 213 | 214 | This describes the usage of the toolbox support from the view of a plug-in 215 | using it. For a discussion of all the necessary step see the chapter 216 | |toolbox-support-integration|. 217 | 218 | ------------------------------------------------------------------------------ 219 | *mmtoolbox#tools#NewToolbox()* 220 | 221 | toolbox = mmtoolbox#tools#NewToolbox ( plugin ) ~ 222 | 223 | Parameters: 224 | plugin - the "id" of the plug-in (string) 225 | Returns: 226 | toolbox - the new toolbox (dict) 227 | 228 | Creates a new toolbox object. The plug-in ID is important for the user's 229 | configuration of the toolbox. 230 | 231 | ------------------------------------------------------------------------------ 232 | *mmtoolbox#tools#Load()* 233 | mmtoolbox#tools#Load ( toolbox, directories ) ~ 234 | 235 | Parameters: 236 | toolbox - the toolbox (dict) 237 | directories - list of directories containing the tools (list of string) 238 | No returns. 239 | 240 | Loads the tools in the given directories. A tool is only loaded if the 241 | following condition holds: > 242 | g:_UseTool_ == "yes" 243 | Here, is the ID set by |mmtoolbox#tools#NewToolbox()|. 244 | 245 | For each tool, the 'GetInfo' function is called: > 246 | let ret_list = mmtoolbox##GetInfo() 247 | For a description of the interface, see |toolbox-support-GetInfo()|. 248 | 249 | ------------------------------------------------------------------------------ 250 | *mmtoolbox#tools#ToolEnabled()* 251 | enabled = mmtoolbox#tools#ToolEnabled ( toolbox, name ) ~ 252 | 253 | Parameters: 254 | toolbox - the toolbox (dict) 255 | name - the name of the tool (dict) 256 | Returns: 257 | enabled - non-zero if the tool is enabled (integer) 258 | 259 | This function can be used to check whether a tool is enabled, regardless of 260 | whether it exists or is loaded. 261 | 262 | ------------------------------------------------------------------------------ 263 | *mmtoolbox#tools#Property()* 264 | [ value = ] mmtoolbox#tools#Property ( toolbox, property [, value] ) ~ 265 | 266 | Parameters: 267 | toolbox - the toolbox (dict) 268 | property - the name of the property (string) 269 | value - the new value of the property (optional, type depends on 270 | 'property') 271 | Returns: 272 | value - the value of the property, only if called with two arguments 273 | (type depends on 'property') 274 | 275 | Gets (two arguments) or sets (three arguments) a property. 276 | 277 | The following properties exists: 278 | mapleader - the map leader used for menu creation (string) 279 | empty-menu - non-zero, if no tool that creates a menu is loaded (integer) 280 | 281 | Note: The property 'mapleader' is only used for menu creation, see 282 | |mmtoolbox#tools#AddMenus()|. 283 | 284 | Examples: 285 | 286 | Set a mapleader: 287 | > 288 | call mmtoolbox#tools#Property ( My_Toolbox, "mapleader", "#" ) 289 | < 290 | 291 | Check whether any tool creates a menu: 292 | > 293 | if mmtoolbox#tools#Property ( My_Toolbox, "empty-menu" ) == 0 294 | " ... create a sub menu for the toolbox, then 295 | call mmtoolbox#tools#AddMenus ( My_Toolbox, "C/C++.Toolbox." ) 296 | endif 297 | < 298 | ------------------------------------------------------------------------------ 299 | *mmtoolbox#tools#GetList()* 300 | list = mmtoolbox#tools#GetList ( toolbox ) ~ 301 | 302 | Parameters: 303 | toolbox - the toolbox (dict) 304 | Returns: 305 | list - information about each tool (list of strings) 306 | 307 | Produces a list of strings containing some information about each tool. It can 308 | be used to create nice debug information. The output looks something like 309 | this: > 310 | [ 'CMake (1.2)', 311 | \ 'Doxygen (2.0, disabled)', 312 | \ 'Make (1.1)' ] 313 | < 314 | ------------------------------------------------------------------------------ 315 | *mmtoolbox#tools#Info()* 316 | mmtoolbox#tools#Info ( toolbox ) ~ 317 | 318 | Parameters: 319 | toolbox - the toolbox (dict) 320 | No returns. 321 | 322 | Echoes debug information about the loaded tools. 323 | 324 | ------------------------------------------------------------------------------ 325 | *mmtoolbox#tools#AddMaps()* 326 | mmtoolbox#tools#AddMaps ( toolbox ) ~ 327 | 328 | Parameters: 329 | toolbox - the toolbox (dict) 330 | No returns. 331 | 332 | Creates maps. For each tool the 'AddMaps' function is called: > 333 | call mmtoolbox##AddMaps() 334 | A tool should only create buffer-local mappings. 335 | 336 | Plug-ins should call mmtoolbox#tools#AddMaps for each appropriate buffer. The 337 | settings for should also be handled by the plug-in, before 338 | calling 'mmtoolbox#tools#AddMaps'. 339 | 340 | See also |toolbox-support-AddMaps()|. 341 | 342 | ------------------------------------------------------------------------------ 343 | *mmtoolbox#tools#AddMenus()* 344 | mmtoolbox#tools#AddMenus ( toolbox, root ) ~ 345 | 346 | Parameters: 347 | toolbox - the toolbox (dict) 348 | root - the root menu used by the toolbox (string) 349 | No returns. 350 | 351 | Creates menus. For each tool the 'AddMenus' function is called: > 352 | call mmtoolbox##AddMenus( menu_sub, mapleader ) 353 | The arguments 'menu_sub' and 'mapleader' are provided correctly escaped for 354 | menu creation. 355 | The name of the tool's sub menu 'menu_sub' is different for each tool and 356 | computed using 'root' and the pretty name: > 357 | let menu_sub = root.".".prettyname 358 | Before calling AddMenus, a menu header is created for each sub menu, showing 359 | the name of the tool. 360 | 361 | The mapleader is supposed to be the local mapleader the plug-in also uses for 362 | |mmtoolbox#tools#AddMaps()|. 363 | 364 | See also |toolbox-support-AddMenu()|. 365 | 366 | 367 | 368 | -------------------------------------------------------------------------- ~ 369 | 370 | -------------------------------------------------------------------------- ~ 371 | 372 | -------------------------------------------------------------------------- ~ 373 | 374 | 375 | 376 | ============================================================================== 377 | A. CHANGE LOG *toolbox-support-change-log* 378 | ============================================================================== 379 | 380 | ------------------------------------------------------------------------------ 381 | RELEASE NOTES FOR VERSION 1.3 382 | ------------------------------------------------------------------------------ 383 | 384 | - Change path handling to be more flexible with regards to file locations. 385 | - Minor changes. 386 | 387 | ------------------------------------------------------------------------------ 388 | RELEASE NOTES FOR VERSION 1.2 389 | ------------------------------------------------------------------------------ 390 | 391 | - Added sub-menu "load additional tools" to load tools during a session. 392 | - Minor changes. 393 | 394 | ------------------------------------------------------------------------------ 395 | RELEASE NOTES FOR VERSION 1.1 396 | ------------------------------------------------------------------------------ 397 | 398 | - Change: In case several version of autoload/mmtoolbox/tools.vim are 399 | available on 'runtimepath', pick out the newest one to load. 400 | - Minor changes. 401 | 402 | ------------------------------------------------------------------------------ 403 | RELEASE NOTES FOR VERSION 1.0.1 404 | ------------------------------------------------------------------------------ 405 | 406 | - Change: Do not load a tool multiple times. 407 | 408 | ------------------------------------------------------------------------------ 409 | RELEASE NOTES FOR VERSION 1.0 410 | ------------------------------------------------------------------------------ 411 | 412 | - Added: Extended the API with 'mmtoolbox#tools#ToolEnabled'. 413 | - Added the documentation. 414 | - Internal changes. 415 | 416 | ------------------------------------------------------------------------------ 417 | RELEASE NOTES FOR VERSION 1.0pre 418 | ------------------------------------------------------------------------------ 419 | 420 | - Initial upload. 421 | 422 | ============================================================================== 423 | vim:tw=78:expandtab:ts=2:ft=help:norl: 424 | -------------------------------------------------------------------------------- /autoload/mmtemplates/wizard.vim: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: mmtemplates#wizard.vim 4 | " 5 | " Description: Template engine: Wizard. 6 | " 7 | " Maps & Menus - Template Engine 8 | " 9 | " VIM Version: 7.0+ 10 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 11 | " Organization: 12 | " Version: 1.0 13 | " Created: 01.12.2014 14 | " Revision: --- 15 | " License: Copyright (c) 2014-2015, Wolfgang Mehner 16 | " This program is free software; you can redistribute it and/or 17 | " modify it under the terms of the GNU General Public License as 18 | " published by the Free Software Foundation, version 2 of the 19 | " License. 20 | " This program is distributed in the hope that it will be 21 | " useful, but WITHOUT ANY WARRANTY; without even the implied 22 | " warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 23 | " PURPOSE. 24 | " See the GNU General Public License version 2 for more details. 25 | "=============================================================================== 26 | " 27 | "------------------------------------------------------------------------------- 28 | " === Basic Checks === {{{1 29 | "------------------------------------------------------------------------------- 30 | " 31 | " need at least 7.0 32 | if v:version < 700 33 | echohl WarningMsg 34 | echo 'The plugin templates.vim needs Vim version >= 7.' 35 | echohl None 36 | finish 37 | endif 38 | " 39 | " prevent duplicate loading 40 | " need compatible 41 | if &cp || ( exists('g:TemplatesWizard_Version') && g:TemplatesWizard_Version != 'searching' && ! exists('g:TemplatesWizard_DevelopmentOverwrite') ) 42 | finish 43 | endif 44 | " 45 | let s:TemplatesWizard_Version = '1.0alpha' " version number of this script; do not change 46 | " 47 | "------------------------------------------------------------------------------- 48 | " --- Find Newest Version --- {{{2 49 | "------------------------------------------------------------------------------- 50 | " 51 | if exists('g:TemplatesWizard_DevelopmentOverwrite') 52 | " skip ahead 53 | elseif exists('g:TemplatesWizard_VersionUse') 54 | " 55 | " not the newest one: abort 56 | if s:TemplatesWizard_Version != g:TemplatesWizard_VersionUse 57 | finish 58 | endif 59 | " 60 | " otherwise: skip ahead 61 | " 62 | elseif exists('g:TemplatesWizard_VersionSearch') 63 | " 64 | " add own version number to the list 65 | call add ( g:TemplatesWizard_VersionSearch, s:TemplatesWizard_Version ) 66 | " 67 | finish 68 | " 69 | else 70 | " 71 | "------------------------------------------------------------------------------- 72 | " s:VersionComp : Compare two version numbers. {{{3 73 | " 74 | " Parameters: 75 | " op1 - first version number (string) 76 | " op2 - second version number (string) 77 | " Returns: 78 | " result - -1, 0 or 1, to the specifications of sort() (integer) 79 | "------------------------------------------------------------------------------- 80 | function! s:VersionComp ( op1, op2 ) 81 | " 82 | let l1 = split ( a:op1, '[.-]' ) 83 | let l2 = split ( a:op2, '[.-]' ) 84 | " 85 | for i in range( 0, max( [ len( l1 ), len( l2 ) ] ) - 1 ) 86 | " until now, all fields where equal 87 | if len ( l2 ) <= i 88 | return -1 " op1 has more fields -> sorts first 89 | elseif len( l1 ) <= i 90 | return 1 " op2 has more fields -> sorts first 91 | elseif str2nr ( l1[i] ) > str2nr ( l2[i] ) 92 | return -1 " op1 is larger here -> sorts first 93 | elseif str2nr ( l2[i] ) > str2nr ( l1[i] ) 94 | return 1 " op2 is larger here -> sorts first 95 | endif 96 | endfor 97 | " 98 | return 0 " same amount of fields, all equal 99 | endfunction " ---------- end of function s:VersionComp ---------- 100 | " }}}3 101 | "------------------------------------------------------------------------------- 102 | " 103 | try 104 | " 105 | " collect all available version 106 | let g:TemplatesWizard_Version = 'searching' 107 | let g:TemplatesWizard_VersionSearch = [] 108 | " 109 | runtime! autoload/mmtemplates/wizard.vim 110 | " 111 | " select the newest one 112 | call sort ( g:TemplatesWizard_VersionSearch, 's:VersionComp' ) 113 | " 114 | let g:TemplatesWizard_VersionUse = g:TemplatesWizard_VersionSearch[ 0 ] 115 | " 116 | " run all scripts again, the newest one will be used 117 | runtime! autoload/mmtemplates/wizard.vim 118 | " 119 | unlet g:TemplatesWizard_VersionSearch 120 | unlet g:TemplatesWizard_VersionUse 121 | " 122 | finish 123 | " 124 | catch /.*/ 125 | " 126 | " an error occurred, skip ahead 127 | echohl WarningMsg 128 | echomsg 'Search for the newest version number failed.' 129 | echomsg 'Using this version ('.s:TemplatesWizard_Version.').' 130 | echohl None 131 | endtry 132 | " 133 | endif 134 | " }}}2 135 | "------------------------------------------------------------------------------- 136 | " 137 | let g:TemplatesWizard_Version = s:TemplatesWizard_Version " version number of this script; do not change 138 | " 139 | "---------------------------------------------------------------------- 140 | " === Modul Setup === {{{1 141 | "---------------------------------------------------------------------- 142 | " 143 | " platform specifics 144 | let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") 145 | let s:UNIX = has("unix") || has("macunix") || has("win32unix") 146 | " 147 | "------------------------------------------------------------------------------- 148 | " === Script: Auxiliary Functions === {{{1 149 | "------------------------------------------------------------------------------- 150 | " 151 | "------------------------------------------------------------------------------- 152 | " s:GetFileFromBrowser : Get a file from a GUI filebrowser. {{{2 153 | " 154 | " Parameters: 155 | " save - if true, select a file for saving (integer) 156 | " title - title of the window (string) 157 | " dir - directory to start browsing in (string) 158 | " default - default file name (string) 159 | " browsefilter - filter for selecting files (string, optional) 160 | " Returns: 161 | " file - the filename (string) 162 | " 163 | " Returns an empty string if no file was chosen by the user. 164 | "------------------------------------------------------------------------------- 165 | function! s:GetFileFromBrowser ( save, title, dir, default, ... ) 166 | " 167 | if s:MSWIN 168 | " overwrite 'b:browsefilter', only applicable under Windows 169 | if exists ( 'b:browsefilter' ) 170 | let bf_backup = b:browsefilter 171 | endif 172 | " 173 | if a:0 == 0 174 | let b:browsefilter = "Template Files (*.templates, ...)\tTemplates;*.template;*.templates\n" 175 | \ . "All Files (*.*)\t*.*\n" 176 | else 177 | let b:browsefilter = a:1 178 | endif 179 | endif 180 | " 181 | " open a file browser, returns an empty string if "Cancel" is pressed 182 | let file = browse ( a:save, a:title, a:dir, a:default ) 183 | " 184 | if s:MSWIN 185 | " reset 'b:browsefilter' 186 | if exists ( 'bf_backup' ) 187 | let b:browsefilter = bf_backup 188 | else 189 | unlet b:browsefilter 190 | endif 191 | endif 192 | " 193 | return file 194 | endfunction " ---------- end of function s:GetFileFromBrowser ---------- 195 | " 196 | "------------------------------------------------------------------------------- 197 | " s:HitEnter : Wait for enter key. {{{2 198 | " 199 | " Echoes "Hit return." and then waits for a key. 200 | " 201 | " Parameters: 202 | " - 203 | " Returns: 204 | " - 205 | "------------------------------------------------------------------------------- 206 | function! s:HitEnter () 207 | echo 'Hit return.' 208 | call getchar() 209 | endfunction " ---------- end of function s:HitEnter ---------- 210 | " 211 | "------------------------------------------------------------------------------- 212 | " s:Question : Ask the user a question. {{{2 213 | " 214 | " Parameters: 215 | " prompt - prompt, shown to the user (string) 216 | " highlight - "normal" or "warning" (string, default "normal") 217 | " Returns: 218 | " retval - the user input (integer) 219 | " 220 | " The possible values of 'retval' are: 221 | " 1 - answer was yes ("y") 222 | " 0 - answer was no ("n") 223 | " -1 - user aborted ("ESC" or "CTRL-C") 224 | "------------------------------------------------------------------------------- 225 | function! s:Question ( text, ... ) 226 | " 227 | let ret = -2 228 | " 229 | " highlight prompt 230 | if a:0 == 0 || a:1 == 'normal' 231 | echohl Search 232 | elseif a:1 == 'warning' 233 | echohl Error 234 | else 235 | echoerr 'Unknown option : "'.a:1.'"' 236 | return 237 | endif 238 | " 239 | " question 240 | echo a:text.' [y/n]: ' 241 | " 242 | " answer: "y", "n", "ESC" or "CTRL-C" 243 | while ret == -2 244 | let c = nr2char( getchar() ) 245 | " 246 | if c == "y" 247 | let ret = 1 248 | elseif c == "n" 249 | let ret = 0 250 | elseif c == "\" || c == "\" 251 | let ret = -1 252 | endif 253 | endwhile 254 | " 255 | " reset highlighting 256 | echohl None 257 | " 258 | return ret 259 | endfunction " ---------- end of function s:Question ---------- 260 | " 261 | "------------------------------------------------------------------------------- 262 | " s:UserInput : Input using a highlighting prompt. {{{2 263 | " 264 | " Parameters: 265 | " prompt - prompt, shown to the user (string) 266 | " text - default reply (string) 267 | " compl - type of completion, see :help command-completion (string, optional) 268 | " Returns: 269 | " retval - the user input (string) 270 | " 271 | " Returns an empty string if the input procedure was aborted by the user. 272 | "------------------------------------------------------------------------------- 273 | function! s:UserInput ( prompt, text, ... ) 274 | echohl Search " highlight prompt 275 | call inputsave() " preserve typeahead 276 | if a:0 == 0 || a:1 == '' 277 | let retval = input( a:prompt, a:text ) " read input 278 | else 279 | let retval = input( a:prompt, a:text, a:1 ) " read input (with completion) 280 | end 281 | call inputrestore() " restore typeahead 282 | echohl None " reset highlighting 283 | let retval = substitute( retval, '^\s\+', '', '' ) " remove leading whitespaces 284 | let retval = substitute( retval, '\s\+$', '', '' ) " remove trailing whitespaces 285 | return retval 286 | endfunction " ---------- end of function s:UserInput ---------- 287 | " 288 | "------------------------------------------------------------------------------- 289 | " s:VimrcCodeSnippet : Codesnippet for .vimrc. {{{2 290 | " 291 | " Parameters: 292 | " text - the snippet (string) 293 | " Returns: 294 | " - 295 | "------------------------------------------------------------------------------- 296 | function! s:VimrcCodeSnippet ( text ) 297 | " 298 | if a:text == '' 299 | return 300 | endif 301 | " 302 | aboveleft new 303 | put! = a:text 304 | set syntax=vim 305 | set nomodified 306 | normal! gg 307 | endfunction " ---------- end of function s:VimrcCodeSnippet ---------- 308 | " }}}2 309 | "------------------------------------------------------------------------------- 310 | " 311 | "------------------------------------------------------------------------------- 312 | " mmtemplates#wizard#SetupWizard : Setup wizard. {{{1 313 | " 314 | " Parameters: 315 | " library - the template library (dict) 316 | " Returns: 317 | " success - whether the operation was successful 318 | "------------------------------------------------------------------------------- 319 | function! mmtemplates#wizard#SetupWizard ( library ) 320 | " 321 | " ================================================== 322 | " parameters 323 | " ================================================== 324 | " 325 | if type( a:library ) == type( '' ) 326 | exe 'let t_lib = '.a:library 327 | elseif type( a:library ) == type( {} ) 328 | let t_lib = a:library 329 | else 330 | return s:ErrorMsg ( 'Argument "library" must be given as a dict or string.' ) 331 | endif 332 | " 333 | let list_display = [ 'What do you want to set up?' ] 334 | let list_wizards = [] 335 | let list_args = [] 336 | " 337 | call add ( list_display, len( list_display ).': personalization file (for your name, mail, ...), shared across plug-ins' ) 338 | call add ( list_wizards, 's:SetupPersonal' ) 339 | call add ( list_args, [] ) 340 | call add ( list_display, len( list_display ).': customization file (for custom templates)' ) 341 | call add ( list_wizards, 's:SetupCustom' ) 342 | call add ( list_args, [ 'without_person' ] ) 343 | call add ( list_display, len( list_display ).': customization file with personalization, combines the above two' ) 344 | call add ( list_wizards, 's:SetupCustom' ) 345 | call add ( list_args, [ 'with_person' ] ) 346 | " 347 | call add ( list_display, len( list_display ).': -abort-' ) 348 | " 349 | let d_idx = inputlist ( list_display ) 350 | let use_wizard = get ( list_wizards, d_idx-1, '' ) 351 | let use_args = get ( list_args, d_idx-1, [] ) 352 | echo "\n" 353 | " 354 | if d_idx >= 1 && use_wizard != '' 355 | call call ( use_wizard, [ t_lib ] + use_args ) 356 | endif 357 | " 358 | return 359 | endfunction " ---------- end of function mmtemplates#wizard#SetupWizard ---------- 360 | " 361 | "------------------------------------------------------------------------------- 362 | " s:SetupPersonal : Setup personalization template file. {{{1 363 | " 364 | " Parameters: 365 | " library - the template library (dict) 366 | " Returns: 367 | " success - whether the personalization template file was created successfully 368 | "------------------------------------------------------------------------------- 369 | function! s:SetupPersonal ( library ) 370 | " 371 | let t_lib = a:library 372 | " 373 | " ================================================== 374 | " do the job 375 | " ================================================== 376 | " 377 | " check setting g:Templates_UsePersonalizationFile 378 | " check property Templates::UsePersonalizationFile 379 | " 380 | " " start the wizard 381 | " if get ( a:data, 'ask_start_question', 1 ) && 1 != s:Question ( 'Template personalization missing. Start setup wizard?' ) 382 | " return 0 383 | " endif 384 | " 385 | let settings = mmtemplates#core#Resource ( a:library, 'settings_table' )[0] 386 | let personal_file = mmtemplates#core#FindPersonalizationFile (a:library ) 387 | " 388 | echo "\nThe template personalization file will be read by all template libraries which" 389 | \ ."\nsupport this feature. It should only contain information which are used by all" 390 | \ ."\ntemplate libraries, such as the name, mail address, ..." 391 | \ ."\nIt is located in a directory relative to runtimepath (see :help rtp), under the" 392 | \ ."\nsubdirectory and filename:" 393 | \ ."\n ".settings.Templates_PersonalizationFile 394 | " 395 | " does the personalization file already exist? 396 | if personal_file != '' && filewritable ( personal_file ) == 1 397 | echo "\nThe template personalization file already exists:" 398 | \ ."\n ".personal_file 399 | endif 400 | " 401 | call s:HitEnter () 402 | " 403 | " let the user select a location for the file 404 | if personal_file == '' 405 | let subdir = fnamemodify ( settings.Templates_PersonalizationFile, ':h' ) 406 | let filename = fnamemodify ( settings.Templates_PersonalizationFile, ':t' ) 407 | let filename = substitute ( filename, '\*$', 's', '' ) 408 | " 409 | let dir_list = split ( &g:runtimepath, ',' ) 410 | let dir_list_rw = [] 411 | let dir_list_display = [ 'Where should the file be located?' ] 412 | " 413 | for dir in dir_list 414 | " :TODO:12.02.2015 19:08:WM: search for duplicates 415 | if filewritable ( dir ) == 2 416 | call add ( dir_list_rw, dir.'/'.subdir ) 417 | call add ( dir_list_display, len( dir_list_rw ).': '.dir.'/'.subdir ) 418 | endif 419 | endfor 420 | call add ( dir_list_display, len( dir_list_rw )+1.': -abort-' ) 421 | " 422 | echo "\n" 423 | let d_idx = inputlist ( dir_list_display ) 424 | let personal_file = get ( dir_list_rw, d_idx-1, '' ) 425 | echo "\n" 426 | " 427 | if d_idx >= 1 && personal_file != '' 428 | let personal_file .= '/'.filename 429 | endif 430 | endif 431 | " 432 | " create the file if necessary 433 | if personal_file != '' && ! filereadable ( personal_file ) 434 | try 435 | call mkdir ( fnamemodify ( personal_file, ':h' ), 'p' ) 436 | catch /.*/ " fail quietly, the directory may already exist 437 | endtry 438 | try 439 | let sample_file = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Wizard::FilePersonal' )[0] 440 | call writefile ( readfile ( sample_file ), personal_file ) 441 | catch /.*/ " fail quietly, we check for the file later on 442 | endtry 443 | endif 444 | " 445 | " check the success 446 | if personal_file == '' 447 | " no file chosen 448 | echo "\nNo personalization file chosen." 449 | \ ."\nFor configuring the file manually, see:" 450 | \ ."\n :help g:Templates_PersonalizationFile" 451 | elseif ! filereadable ( personal_file ) 452 | " automatic setup failed 453 | let help_topic_missing = 0 454 | try 455 | help g:Templates_PersonalizationFile 456 | catch /.*/ " failed, print some more help below 457 | let help_topic_missing = 1 458 | endtry 459 | redraw 460 | echo "Failed to create the personalization file:" 461 | \ ."\n ".personal_file 462 | \ ."\nFor configuring the file manually, see:" 463 | \ ."\n :help g:Templates_PersonalizationFile" 464 | if help_topic_missing 465 | echo "... but redo your helptags first:" 466 | \ ."\n :helptags .../doc" 467 | endif 468 | else 469 | call mmtemplates#core#EnableTemplateFile ( t_lib, 'personal' ) 470 | " 471 | " automatic setup succeeded, start editing 472 | let plugin_name = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Wizard::PluginName' )[0] 473 | let filetype_name = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Wizard::FiletypeName' )[0] 474 | let maplead = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Mapleader' )[0] 475 | let reload_map = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::RereadTemplates::Map' )[0] 476 | " 477 | exe 'split '.fnameescape( personal_file ) 478 | redraw 479 | echo "Change your personal details and then reload the template library:" 480 | \ ."\n- use the menu entry \"".plugin_name." -> Snippets -> reread templates\"" 481 | \ ."\n- use the map \"".maplead.reload_map."\" inside a ".filetype_name." buffer" 482 | " 483 | return 1 484 | endif 485 | " 486 | return 0 487 | endfunction " ---------- end of function s:SetupPersonal ---------- 488 | " 489 | "------------------------------------------------------------------------------- 490 | " s:SetupCustom : Setup customization template file. {{{1 491 | " 492 | " Parameters: 493 | " library - the template library (dict) 494 | " mode - the mode "without_person" or "without_person" 495 | " Returns: 496 | " success - whether the customization template file was created successfully 497 | "------------------------------------------------------------------------------- 498 | function! s:SetupCustom ( library, mode ) 499 | " 500 | let t_lib = a:library 501 | " 502 | let plugin_name = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Wizard::PluginName' )[0] 503 | " 504 | " ================================================== 505 | " do the job 506 | " ================================================== 507 | " 508 | let settings = mmtemplates#core#Resource ( a:library, 'settings_table' )[0] 509 | let [ custom_file_info, file_error ] = mmtemplates#core#Resource ( t_lib, 'get', 'template_file', 'custom' ) 510 | " 511 | if file_error != '' 512 | echomsg 'Internal error (setup wizard):' 513 | echomsg ' '.file_error 514 | return 515 | endif 516 | " 517 | echo "\nThe template customization file will be read by the ".plugin_name." template" 518 | \ ."\nlibrary after the stock templates. The settings made there will overwrite the" 519 | \ ."\ndefault ones and the templates defined there will be added to the stock" 520 | \ ."\ntemplates. If a template is defined again with the same name, it overwrites the" 521 | \ ."\nprevious version." 522 | " 523 | " does the customization file already exist? 524 | let custom_file = '' 525 | let vimrc_hint = '' 526 | " 527 | if custom_file_info.available 528 | echo "\nThe template customization file already exists:" 529 | \ ."\n ".custom_file_info.filename 530 | let custom_file = custom_file_info.filename 531 | else 532 | echo "\nThe customization file will be stored here by default:" 533 | \ ."\n ".custom_file_info.filename 534 | endif 535 | " 536 | call s:HitEnter () 537 | " 538 | " file not available? 539 | if ! custom_file_info.available 540 | " 541 | " select a different location for the file? 542 | if 1 == s:Question ( 'Choose a different location?' ) 543 | " 544 | " how to get the filename 545 | let method = settings.Templates_TemplateBrowser 546 | " 547 | if method == 'browse' && ! has ( 'browse' ) || method == 'explore' 548 | let method = 'edit' 549 | endif 550 | " 551 | " get the filename 552 | if method == 'browse' 553 | let custom_file = s:GetFileFromBrowser ( 1, 554 | \ 'choose a custom template file', 555 | \ expand('$HOME/'), 556 | \ fnamemodify ( custom_file_info.filename, ':t' ) ) 557 | else 558 | " is empty in case of no input 559 | let custom_file = s:UserInput ( 'Choose a file: ', expand('$HOME/'), 'file' ) 560 | endif 561 | " 562 | " hint about changes in .vimrc 563 | if custom_file != '' 564 | let varname = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Wizard::CustomFileVariable' )[0] 565 | let vimrc_hint = 566 | \ "\" to always load the custom template file from that location,\n" 567 | \ ."\" add this line to your vimrc (".$MYVIMRC."):\n" 568 | \ ."let ".varname." = '".substitute( custom_file, "'", "''", 'g' )."'" 569 | endif 570 | else 571 | " use default instead 572 | let custom_file = custom_file_info.filename 573 | endif 574 | " 575 | endif 576 | " 577 | " create the file if necessary 578 | if custom_file != '' && ! filereadable ( custom_file ) 579 | try 580 | call mkdir ( fnamemodify ( custom_file, ':h' ), 'p' ) 581 | catch /.*/ " fail quietly, the directory may already exist 582 | endtry 583 | try 584 | if a:mode == 'without_person' 585 | let sample_file = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Wizard::FileCustomNoPersonal' )[0] 586 | else 587 | let sample_file = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Wizard::FileCustomWithPersonal' )[0] 588 | endif 589 | call writefile ( readfile ( sample_file ), custom_file ) 590 | catch /.*/ " fail quietly, we check for the file later on 591 | endtry 592 | endif 593 | " 594 | " check the success 595 | if custom_file == '' 596 | " no file chosen 597 | echo "\nNo customization file chosen." 598 | \ ."\nFor configuring the file manually, see the help of the plug-in." 599 | elseif ! filereadable ( custom_file ) 600 | " automatic setup failed 601 | echo "\nFailed to create the customization file:" 602 | \ ."\n ".custom_file 603 | \ ."\nFor configuring the file manually, see the help of the plug-in." 604 | else 605 | call s:VimrcCodeSnippet ( vimrc_hint ) 606 | " 607 | call mmtemplates#core#EnableTemplateFile ( t_lib, 'custom', custom_file ) 608 | " 609 | " automatic setup succeeded, start editing 610 | let filetype_name = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Wizard::FiletypeName' )[0] 611 | let maplead = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::Mapleader' )[0] 612 | let reload_map = mmtemplates#core#Resource ( t_lib, 'get', 'property', 'Templates::RereadTemplates::Map' )[0] 613 | " 614 | exe 'split '.fnameescape( custom_file ) 615 | redraw 616 | echo "Customize the file and then reload the template library:" 617 | \ ."\n- use the menu entry \"".plugin_name." -> Snippets -> reread templates\"" 618 | \ ."\n- use the map \"".maplead.reload_map."\" inside a ".filetype_name." buffer" 619 | if vimrc_hint != '' 620 | echo "\nTo always load the new file, update your vimrc." 621 | endif 622 | " 623 | return 1 624 | endif 625 | " 626 | return 0 627 | endfunction " ---------- end of function s:SetupCustom ---------- 628 | " }}}1 629 | "------------------------------------------------------------------------------- 630 | " 631 | "------------------------------------------------------------------------------- 632 | " vim: foldmethod=marker 633 | -------------------------------------------------------------------------------- /autoload/mmtoolbox/tools.vim: -------------------------------------------------------------------------------- 1 | "=============================================================================== 2 | " 3 | " File: tools.vim 4 | " 5 | " Description: Toolbox engine. 6 | " 7 | " Maps & Menus - Toolbox Engine 8 | " 9 | " VIM Version: 7.0+ 10 | " Author: Wolfgang Mehner, wolfgang-mehner@web.de 11 | " Organization: 12 | " Version: see variable g:Toolbox_Version below 13 | " Created: 29.12.2012 14 | " Revision: 30.09.2017 15 | " License: Copyright (c) 2012-2015, Wolfgang Mehner 16 | " This program is free software; you can redistribute it and/or 17 | " modify it under the terms of the GNU General Public License as 18 | " published by the Free Software Foundation, version 2 of the 19 | " License. 20 | " This program is distributed in the hope that it will be 21 | " useful, but WITHOUT ANY WARRANTY; without even the implied 22 | " warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 23 | " PURPOSE. 24 | " See the GNU General Public License version 2 for more details. 25 | "=============================================================================== 26 | 27 | "------------------------------------------------------------------------------- 28 | " Basic checks. {{{1 29 | "------------------------------------------------------------------------------- 30 | " 31 | " need at least 7.0 32 | if v:version < 700 33 | echohl WarningMsg 34 | echo 'The plugin tools/tools.vim needs Vim version >= 7.' 35 | echohl None 36 | finish 37 | endif 38 | " 39 | " prevent duplicate loading 40 | " need compatible 41 | if &cp || ( exists('g:Toolbox_Version') && g:Toolbox_Version != 'searching' && ! exists('g:Toolbox_DevelopmentOverwrite') ) 42 | finish 43 | endif 44 | " 45 | let s:Toolbox_Version = '1.3' " version number of this script; do not change 46 | " 47 | "---------------------------------------------------------------------- 48 | " --- Find Newest Version --- {{{2 49 | "---------------------------------------------------------------------- 50 | " 51 | if exists('g:Toolbox_DevelopmentOverwrite') 52 | " skip ahead 53 | elseif exists('g:Toolbox_VersionUse') 54 | " 55 | " not the newest one: abort 56 | if s:Toolbox_Version != g:Toolbox_VersionUse 57 | finish 58 | endif 59 | " 60 | " otherwise: skip ahead 61 | " 62 | elseif exists('g:Toolbox_VersionSearch') 63 | " 64 | " add own version number to the list 65 | call add ( g:Toolbox_VersionSearch, s:Toolbox_Version ) 66 | " 67 | finish 68 | " 69 | else 70 | " 71 | "------------------------------------------------------------------------------- 72 | " s:VersionComp : Compare two version numbers. {{{3 73 | " 74 | " Parameters: 75 | " op1 - first version number (string) 76 | " op2 - second version number (string) 77 | " Returns: 78 | " result - -1, 0 or 1, to the specifications of sort() (integer) 79 | "------------------------------------------------------------------------------- 80 | function! s:VersionComp ( op1, op2 ) 81 | " 82 | let l1 = split ( a:op1, '[.-]' ) 83 | let l2 = split ( a:op2, '[.-]' ) 84 | " 85 | for i in range( 0, max( [ len( l1 ), len( l2 ) ] ) - 1 ) 86 | " until now, all fields where equal 87 | if len ( l2 ) <= i 88 | return -1 " op1 has more fields -> sorts first 89 | elseif len( l1 ) <= i 90 | return 1 " op2 has more fields -> sorts first 91 | elseif str2nr ( l1[i] ) > str2nr ( l2[i] ) 92 | return -1 " op1 is larger here -> sorts first 93 | elseif str2nr ( l2[i] ) > str2nr ( l1[i] ) 94 | return 1 " op2 is larger here -> sorts first 95 | endif 96 | endfor 97 | " 98 | return 0 " same amount of fields, all equal 99 | endfunction " ---------- end of function s:VersionComp ---------- 100 | " }}}3 101 | "------------------------------------------------------------------------------- 102 | " 103 | try 104 | " 105 | " collect all available version 106 | let g:Toolbox_Version = 'searching' 107 | let g:Toolbox_VersionSearch = [] 108 | " 109 | runtime! autoload/mmtoolbox/tools.vim 110 | " 111 | " select the newest one 112 | call sort ( g:Toolbox_VersionSearch, 's:VersionComp' ) 113 | " 114 | let g:Toolbox_VersionUse = g:Toolbox_VersionSearch[ 0 ] 115 | " 116 | " run all scripts again, the newest one will be used 117 | runtime! autoload/mmtoolbox/tools.vim 118 | " 119 | unlet g:Toolbox_VersionSearch 120 | unlet g:Toolbox_VersionUse 121 | " 122 | finish 123 | " 124 | catch /.*/ 125 | " 126 | " an error occurred, skip ahead 127 | echohl WarningMsg 128 | echomsg 'Search for the newest version number failed.' 129 | echomsg 'Using this version ('.s:Toolbox_Version.').' 130 | echohl None 131 | endtry 132 | " 133 | endif 134 | " }}}2 135 | "------------------------------------------------------------------------------- 136 | " 137 | let g:Toolbox_Version = s:Toolbox_Version " version number of this script; do not change 138 | " 139 | "------------------------------------------------------------------------------- 140 | " Auxiliary functions {{{1 141 | "------------------------------------------------------------------------------- 142 | " 143 | "------------------------------------------------------------------------------- 144 | " s:ErrorMsg : Print an error message. {{{2 145 | " 146 | " Parameters: 147 | " line1 - a line (string) 148 | " line2 - a line (string) 149 | " ... - ... 150 | " Returns: 151 | " - 152 | "------------------------------------------------------------------------------- 153 | " 154 | function! s:ErrorMsg ( ... ) 155 | echohl WarningMsg 156 | for line in a:000 157 | echomsg line 158 | endfor 159 | echohl None 160 | endfunction " ---------- end of function s:ErrorMsg ---------- 161 | " 162 | "------------------------------------------------------------------------------- 163 | " s:GetGlobalSetting : Get a setting from a global variable. {{{2 164 | " 165 | " Parameters: 166 | " varname - name of the variable (string) 167 | " Returns: 168 | " - 169 | " 170 | " If g: exists, assign: 171 | " s: = g: 172 | "------------------------------------------------------------------------------- 173 | " 174 | function! s:GetGlobalSetting ( varname ) 175 | if exists ( 'g:'.a:varname ) 176 | exe 'let s:'.a:varname.' = g:'.a:varname 177 | endif 178 | endfunction " ---------- end of function s:GetGlobalSetting ---------- 179 | " 180 | "------------------------------------------------------------------------------- 181 | " s:GetToolConfig : Get the configuration from a global variable. {{{2 182 | " 183 | " Parameters: 184 | " plugin - the name of the plg-in (string) 185 | " name - the name of the tool (string) 186 | " Returns: 187 | " config - 'yes' or 'no' (string) 188 | " 189 | " Returns whether the tool should be loaded. 190 | " If the variable g:_UseTool_ exists, return its value. 191 | " Otherwise returns 'no'. 192 | "------------------------------------------------------------------------------- 193 | function! s:GetToolConfig ( plugin, name ) 194 | " 195 | let name = s:GetToolConfigVarName ( a:plugin, a:name ) 196 | if exists ( name ) 197 | return {name} 198 | endif 199 | return 'no' 200 | endfunction " ---------- end of function s:GetToolConfig ---------- 201 | " 202 | "------------------------------------------------------------------------------- 203 | " s:GetToolConfigVarName : Get the name of the configuration variable. {{{2 204 | " 205 | " Parameters: 206 | " plugin - the name of the plg-in (string) 207 | " name - the name of the tool (string) 208 | " Returns: 209 | " varname - name of the configuration variable (string) 210 | " 211 | " Returns the variable g:_UseTool_. 212 | "------------------------------------------------------------------------------- 213 | function! s:GetToolConfigVarName ( plugin, name ) 214 | return 'g:'.a:plugin.'_UseTool_'.a:name 215 | endfunction " ---------- end of function s:GetToolConfigVarName ---------- 216 | " }}}2 217 | "------------------------------------------------------------------------------- 218 | " 219 | "------------------------------------------------------------------------------- 220 | " Modul setup. {{{1 221 | "------------------------------------------------------------------------------- 222 | " 223 | " tool registry, 224 | " maps plug-in name -> toolbox 225 | if ! exists ( 's:ToolRegistry' ) 226 | let s:ToolRegistry = {} 227 | endif 228 | " 229 | "------------------------------------------------------------------------------- 230 | " NewToolbox : Create a new toolbox. {{{1 231 | "------------------------------------------------------------------------------- 232 | function! mmtoolbox#tools#NewToolbox ( plugin ) 233 | " 234 | " properties: 235 | " - plugin : the name (id) if the plugin 236 | " - mapleader : only required for menu creation, 237 | " for map creation, the current mapleader/maplocalleader is 238 | " used, it must already be set accordingly 239 | " - tools : dictionary holding the meta information about the tools 240 | " associates: name -> info 241 | " - unused : further tools which have not been loaded 242 | " - names : the names of all the tools, sorted alphabetically 243 | " - n_menu : the number of tools which create a menu 244 | " - menu_root : last root menu used for menu creation 245 | " - menu_mldr : last mapleader menu used for menu creation (escaped) 246 | let toolbox = { 247 | \ 'plugin' : a:plugin, 248 | \ 'mapleader' : '\', 249 | \ 'tools' : {}, 250 | \ 'unused' : {}, 251 | \ 'names' : [], 252 | \ 'n_menu' : 0, 253 | \ 'menu_root' : '', 254 | \ 'menu_mldr' : '', 255 | \ } 256 | " 257 | let s:ToolRegistry[ a:plugin ] = toolbox 258 | " 259 | return toolbox 260 | " 261 | endfunction " ---------- end of function mmtoolbox#tools#NewToolbox ---------- 262 | " 263 | "------------------------------------------------------------------------------- 264 | " s:LoadTool : Load a tool. {{{1 265 | " 266 | " Parameters: 267 | " toolbox - the toolbox (dict) 268 | " name_full - the full name of the tool (string) 269 | " name - the short name of the tool (string) 270 | " file - the script (string) 271 | " Returns: 272 | " success - tool loaded without errors, but might still be disabled (integer) 273 | "------------------------------------------------------------------------------- 274 | function! s:LoadTool ( toolbox, name_full, name, file ) 275 | 276 | let toolbox = a:toolbox 277 | let name_full = a:name_full 278 | let name = a:name 279 | 280 | " try to load and initialize 281 | try 282 | " 283 | " get tool information 284 | let retlist = {name_full}#GetInfo() 285 | " 286 | " assemble the entry 287 | let entry = { 288 | \ "name_full" : a:name_full, 289 | \ "name" : name, 290 | \ "prettyname" : retlist[0], 291 | \ "version" : retlist[1], 292 | \ "enabled" : 1, 293 | \ "domenu" : 1, 294 | \ "filename" : a:file, 295 | \ } 296 | " 297 | " process the flags 298 | if len ( retlist ) > 2 299 | if index ( retlist, 'nomenu', 2 ) != -1 300 | let entry.domenu = 0 301 | endif 302 | if index ( retlist, 'disabled', 2 ) != -1 303 | let entry.enabled = 0 304 | endif 305 | endif 306 | " 307 | " save the entry 308 | let toolbox.tools[ name ] = entry 309 | call add ( toolbox.names, name ) 310 | " 311 | if entry.enabled && entry.domenu 312 | let toolbox.n_menu += 1 313 | endif 314 | " 315 | return 1 316 | " 317 | catch /.*/ 318 | " could not load the plugin: ? 319 | call s:ErrorMsg ( "Could not load the tool \"".name."\" (".v:exception.")", 320 | \ " - occurred at " . v:throwpoint ) 321 | endtry 322 | " 323 | return 0 324 | " 325 | endfunction " ---------- end of function s:LoadTool ---------- 326 | " 327 | "------------------------------------------------------------------------------- 328 | " s:RegisterTool : Register an unused tool. {{{1 329 | " 330 | " Parameters: 331 | " toolbox - the toolbox (dict) 332 | " name_full - the full name of the tool (string) 333 | " name - the short name of the tool (string) 334 | " file - the script (string) 335 | " Returns: 336 | " - 337 | "------------------------------------------------------------------------------- 338 | function! s:RegisterTool ( toolbox, name_full, name, file ) 339 | " 340 | " assemble the entry 341 | " - also record which tools was loaded later on, to keep creating correct 342 | " menus 343 | let entry = { 344 | \ "name_full" : a:name_full, 345 | \ "name" : a:name, 346 | \ "filename" : a:file, 347 | \ "loaded" : 0, 348 | \ } 349 | " 350 | let a:toolbox.unused[ a:name ] = entry 351 | " 352 | endfunction " ---------- end of function s:RegisterTool ---------- 353 | " 354 | "------------------------------------------------------------------------------- 355 | " Load : Load the tools from various directories. {{{1 356 | "------------------------------------------------------------------------------- 357 | function! mmtoolbox#tools#Load ( toolbox, directories ) 358 | " 359 | " check the parameters 360 | if type( a:toolbox ) != type( {} ) 361 | return s:ErrorMsg ( 'Argument "toolbox" must be given as a dict.' ) 362 | elseif type( a:directories ) != type( [] ) 363 | return s:ErrorMsg ( 'Argument "directories" must be given as a list.' ) 364 | endif 365 | " 366 | let a:toolbox.n_menu = 0 367 | " 368 | " go through all directories 369 | for dir in a:directories 370 | " 371 | " is a directory 372 | if ! isdirectory ( dir ) 373 | continue 374 | endif 375 | " 376 | " go through all dir/*.vim 377 | for file in split( glob (dir.'/*.vim'), '\n' ) 378 | 379 | if file =~ 'autoload[/\\]\(.\{-}\)[/\\]\{1,2}\([^/\\]\+\)\.vim$' 380 | let mlist = matchlist( file, 'autoload[/\\]\(.\{-}\)[/\\]\{1,2}\([^/\\]\+\)\.vim$' ) 381 | let name_full = substitute( mlist[1], '[/\\]', '#', 'g' ).'#'.mlist[2] 382 | let name = mlist[2] 383 | else 384 | " invalid name 385 | continue 386 | endif 387 | 388 | " do not process 'tools.vim' (this script) 389 | if name == 'tools' 390 | continue 391 | endif 392 | " 393 | " do not load multiple times 394 | if has_key ( a:toolbox.tools, name ) 395 | continue 396 | endif 397 | " 398 | " check whether to use the tool 399 | if s:GetToolConfig ( a:toolbox.plugin, name ) == 'yes' 400 | call s:LoadTool ( a:toolbox, name_full, name, file ) 401 | else 402 | call s:RegisterTool ( a:toolbox, name_full, name, file ) 403 | endif 404 | " 405 | endfor 406 | " 407 | endfor 408 | " 409 | " sort the names 410 | call sort ( a:toolbox.names ) 411 | " 412 | endfunction " ---------- end of function mmtoolbox#tools#Load ---------- 413 | " 414 | "------------------------------------------------------------------------------- 415 | " s:LoadAdditionalTool : Load an additional tool. {{{1 416 | " 417 | " Parameters: 418 | " toolbox_name - the name of the toolbox (string) 419 | " name - the name of the tool (string) 420 | " Returns: 421 | " - 422 | "------------------------------------------------------------------------------- 423 | function! s:LoadAdditionalTool ( toolbox_name, name ) 424 | " 425 | let toolbox = s:ToolRegistry[ a:toolbox_name ] 426 | let name = a:name 427 | " 428 | " do not load multiple times 429 | if has_key ( toolbox.tools, name ) 430 | echo 'The tool "'.name.'" has already been loaded.' 431 | return 432 | endif 433 | " 434 | " check the 'unused' entry (should not cause any problems) 435 | if ! has_key ( toolbox.unused, name ) || toolbox.unused[name].loaded == 1 436 | echo 'Internal error #1 while loading the tool "'.name.'".' 437 | return 438 | endif 439 | " 440 | " check the 'menu_root' and 'menu_mldr' entry (should not cause any problems) 441 | if empty ( toolbox.menu_root ) || empty ( toolbox.menu_mldr ) 442 | echo 'Internal error #2 while loading the tool "'.name.'".' 443 | return 444 | endif 445 | " 446 | " load the tool 447 | let toolbox.unused[name].loaded = 1 448 | let success = s:LoadTool ( toolbox, toolbox.unused[name].name_full, name, toolbox.unused[name].filename ) 449 | " 450 | " create the menu entry 451 | if success 452 | call s:CreateToolMenu ( toolbox, name, toolbox.menu_root, toolbox.menu_mldr ) 453 | endif 454 | " 455 | echomsg 'To always load the tool "'.name.'", add this line to your vimrc:' 456 | echomsg ' let '.s:GetToolConfigVarName ( toolbox.plugin, name )." = 'yes'" 457 | endfunction " ---------- end of function s:LoadAdditionalTool ---------- 458 | " 459 | "------------------------------------------------------------------------------- 460 | " ToolEnabled : Whether a tool is enabled. {{{1 461 | "------------------------------------------------------------------------------- 462 | function! mmtoolbox#tools#ToolEnabled ( toolbox, name ) 463 | " 464 | " check the parameters 465 | if type( a:toolbox ) != type( {} ) 466 | return s:ErrorMsg ( 'Argument "toolbox" must be given as a dict.' ) 467 | endif 468 | " 469 | if type( a:name ) != type( '' ) 470 | return s:ErrorMsg ( 'Argument "name" must be given as a string.' ) 471 | endif 472 | " 473 | " has not been loaded? 474 | if ! has_key ( a:toolbox.tools, a:name ) 475 | return 0 476 | endif 477 | 478 | let entry = a:toolbox.tools[ a:name ] 479 | let enabled = 0 480 | 481 | try 482 | let enabled = {entry.name_full}#Property('get','enabled') 483 | catch /.*/ 484 | " fail quietly 485 | endtry 486 | 487 | return enabled 488 | endfunction " ---------- end of function mmtoolbox#tools#ToolEnabled ---------- 489 | " 490 | "------------------------------------------------------------------------------- 491 | " Property : Get/set a property. {{{1 492 | "------------------------------------------------------------------------------- 493 | function! mmtoolbox#tools#Property ( toolbox, property, ... ) 494 | " 495 | " check the parameters 496 | if type( a:toolbox ) != type( {} ) 497 | return s:ErrorMsg ( 'Argument "toolbox" must be given as a dict.' ) 498 | endif 499 | " 500 | if type( a:property ) != type( '' ) 501 | return s:ErrorMsg ( 'Argument "property" must be given as a string.' ) 502 | endif 503 | " 504 | " check the property 505 | if a:property == 'mapleader' 506 | " ok 507 | elseif a:property == 'empty-menu' 508 | return a:toolbox.n_menu == 0 509 | else 510 | return s:ErrorMsg ( 'Unknown property: '.a:property ) 511 | endif 512 | " 513 | " get/set the property 514 | if a:0 == 0 515 | return a:toolbox[ a:property ] 516 | else 517 | let a:toolbox[ a:property ] = a:1 518 | endif 519 | " 520 | endfunction " ---------- end of function mmtoolbox#tools#Property ---------- 521 | " 522 | "------------------------------------------------------------------------------- 523 | " GetList : Get the list of all tools. {{{1 524 | "------------------------------------------------------------------------------- 525 | function! mmtoolbox#tools#GetList ( toolbox ) 526 | " 527 | " check the parameters 528 | if type( a:toolbox ) != type( {} ) 529 | return s:ErrorMsg ( 'Argument "toolbox" must be given as a dict.' ) 530 | endif 531 | " 532 | " assemble the list 533 | let toollist = [] 534 | " 535 | for name in a:toolbox.names 536 | let entry = a:toolbox.tools[ name ] 537 | if entry.enabled 538 | call add ( toollist, entry.prettyname." (".entry.version.")" ) 539 | else 540 | call add ( toollist, entry.prettyname." (".entry.version.", disabled)" ) 541 | endif 542 | endfor 543 | " 544 | call add ( toollist, '(toolbox version '.g:Toolbox_Version.')' ) 545 | " 546 | return toollist 547 | " 548 | endfunction " ---------- end of function mmtoolbox#tools#GetList ---------- 549 | " 550 | "------------------------------------------------------------------------------- 551 | " Info : Echo debug information. {{{1 552 | "------------------------------------------------------------------------------- 553 | function! mmtoolbox#tools#Info ( toolbox ) 554 | " 555 | " check the parameters 556 | if type( a:toolbox ) != type( {} ) 557 | return s:ErrorMsg ( 'Argument "toolbox" must be given as a dict.' ) 558 | endif 559 | " 560 | let txt = '' 561 | " 562 | for name in a:toolbox.names 563 | let entry = a:toolbox.tools[ name ] 564 | " 565 | let line = entry.prettyname." (".entry.version."), " 566 | let line .= repeat ( " ", 25-len(line) ) 567 | if entry.enabled | let line .= "enabled, " 568 | else | let line .= "disabled, " | endif 569 | if entry.domenu | let line .= "menu, " 570 | else | let line .= "nomenu, " | endif 571 | let line .= "from: ".entry.filename."\n" 572 | " 573 | let txt .= line 574 | endfor 575 | " 576 | echo txt 577 | " 578 | endfunction " ---------- end of function mmtoolbox#tools#Info ---------- 579 | " 580 | "------------------------------------------------------------------------------- 581 | " AddMaps : Create maps for all tools. {{{1 582 | "------------------------------------------------------------------------------- 583 | function! mmtoolbox#tools#AddMaps ( toolbox ) 584 | " 585 | " check the parameters 586 | if type( a:toolbox ) != type( {} ) 587 | return s:ErrorMsg ( 'Argument "toolbox" must be given as a dict.' ) 588 | endif 589 | " 590 | " go through all the tools 591 | for name in a:toolbox.names 592 | let entry = a:toolbox.tools[ name ] 593 | " 594 | if ! entry.enabled 595 | continue 596 | endif 597 | " 598 | try 599 | " try to create the maps 600 | call {entry.name_full}#AddMaps() 601 | catch /.*/ 602 | " could not load the plugin: ? 603 | call s:ErrorMsg ( "Could not create maps for the tool \"".name."\" (".v:exception.")", 604 | \ " - occurred at " . v:throwpoint ) 605 | endtry 606 | endfor 607 | endfunction " ---------- end of function mmtoolbox#tools#AddMaps ---------- 608 | " 609 | "------------------------------------------------------------------------------- 610 | " s:CreateToolMenu : Create the sub-menu for a tool. {{{1 611 | " 612 | " Parameters: 613 | " toolbox - the toolbox (dict) 614 | " name - the name of the tool (string) 615 | " root - the root menu (string) 616 | " mleader - the map leader (string) 617 | " Returns: 618 | " - 619 | "------------------------------------------------------------------------------- 620 | function! s:CreateToolMenu ( toolbox, name, root, mleader ) 621 | " 622 | let entry = a:toolbox.tools[ a:name ] 623 | " 624 | if ! entry.enabled || ! entry.domenu 625 | return 626 | endif 627 | " 628 | " correctly escape the name 629 | " and add a shortcut 630 | let menu_item_r = escape ( entry.prettyname, ' .|\' ) 631 | let menu_item_l = substitute ( menu_item_r, '\V&', '\&&', 'g' ) 632 | let menu_scut = substitute ( menu_item_l, '\w', '\&&', '' ) 633 | let menu_root = a:root.'.'.menu_scut 634 | " 635 | " create the menu header 636 | exe 'amenu '.menu_root.'.'.menu_item_l.''.menu_item_r.' :echo "This is a menu header."' 637 | exe 'amenu '.menu_root.'.-SepHead- :' 638 | " 639 | try 640 | " try to create the menu 641 | call {entry.name_full}#AddMenu( menu_root, a:mleader ) 642 | catch /.*/ 643 | " could not load the plugin: ? 644 | call s:ErrorMsg ( "Could not create menus for the tool \"".a:name."\" (".v:exception.")", 645 | \ " - occurred at " . v:throwpoint ) 646 | endtry 647 | " 648 | endfunction " ---------- end of function s:CreateToolMenu ---------- 649 | " 650 | "------------------------------------------------------------------------------- 651 | " AddMenus : Create menus for all tools. {{{1 652 | "------------------------------------------------------------------------------- 653 | function! mmtoolbox#tools#AddMenus ( toolbox, root ) 654 | " 655 | " check the parameters 656 | if type( a:toolbox ) != type( {} ) 657 | return s:ErrorMsg ( 'Argument "toolbox" must be given as a dict.' ) 658 | endif 659 | " 660 | if type( a:root ) != type( '' ) 661 | return s:ErrorMsg ( 'Argument "root" must be given as a string.' ) 662 | endif 663 | " 664 | " correctly escape the mapleader 665 | if ! empty ( a:toolbox.mapleader ) | let mleader = a:toolbox.mapleader 666 | elseif exists ( 'g:maplocalleader' ) | let mleader = g:maplocalleader 667 | else | let mleader = '\' 668 | endif 669 | " 670 | if mleader == '' 671 | let mleader = '\' 672 | endif 673 | " 674 | let mleader = escape ( mleader, ' .|\' ) 675 | let mleader = substitute ( mleader, '\V&', '\&&', 'g' ) 676 | " 677 | " save the information for later use 678 | let a:toolbox.menu_root = a:root 679 | let a:toolbox.menu_mldr = mleader 680 | " 681 | " go through all the tools 682 | for name in a:toolbox.names 683 | call s:CreateToolMenu ( a:toolbox, name, a:root, mleader ) 684 | endfor 685 | " 686 | " create 'load more tools' below the other entries 687 | let root_level = len( split( a:root, '\%(\_^\|[^\\]\)\%(\\\\\)*\zs\.' ) ) 688 | let prio_prefix = repeat ( '.', root_level ) 689 | exe 'amenu '.prio_prefix.'600 '.a:root.'.-SepBottom- :' 690 | exe 'amenu '.prio_prefix.'600.400 '.a:root.'.load\ more\ tools.Available\ Tools :echo "This is a menu header."' 691 | exe 'amenu '.prio_prefix.'600.400 '.a:root.'.load\ more\ tools.-SepHead- :' 692 | " 693 | let shead = 'amenu '.a:root.'.load\ more\ tools.' 694 | " 695 | for name in sort ( keys ( a:toolbox.unused ) ) 696 | silent exe shead.name.' :call LoadAdditionalTool('.string( a:toolbox.plugin ).','.string( name ).')' 697 | endfor 698 | " 699 | " 700 | endfunction " ---------- end of function mmtoolbox#tools#AddMenus ---------- 701 | " }}}1 702 | "------------------------------------------------------------------------------- 703 | " 704 | " ===================================================================================== 705 | " vim: foldmethod=marker 706 | --------------------------------------------------------------------------------