diff --git a/README.md b/README.md index a46ccff..700b670 100644 --- a/README.md +++ b/README.md @@ -3,31 +3,26 @@ This repository hosts the latest development versions of various Vim plug-ins. Currently maintained by Wolfgang Mehner: [GitHub](https://github.com/WolfgangMehner) -[Vim.org](http://www.vim.org/account/profile.php?user_id=36934) +[Vim.org](https://www.vim.org/account/profile.php?user_id=36934) __Support for Various Programming Languages__ -Name | Supports | vim.org | GitHub ---- | --- | --- | --- -AWK-Support | AWK | [vim.org](http://www.vim.org/scripts/script.php?script_id=4415) | [GitHub](https://github.com/WolfgangMehner/awk-support) -Bash-Support | Bash | [vim.org](http://www.vim.org/scripts/script.php?script_id=365) | [GitHub](https://github.com/WolfgangMehner/bash-support) -C-Support | C/C++ & Doxygen | [vim.org](http://www.vim.org/scripts/script.php?script_id=213) | [GitHub](https://github.com/WolfgangMehner/c-support) -LaTeX-Support | LaTeX/LuaTeX/BibTeX | [vim.org](http://www.vim.org/scripts/script.php?script_id=4405) | [GitHub](https://github.com/WolfgangMehner/latex-support) -Lua-Support | Lua & C-API | [vim.org](http://www.vim.org/scripts/script.php?script_id=4950) | [GitHub](https://github.com/WolfgangMehner/lua-support) -Matlab-Support | Matlab | - | [GitHub](https://github.com/WolfgangMehner/matlab-support) -Perl-Support | Perl & POD | [vim.org](http://www.vim.org/scripts/script.php?script_id=556) | [GitHub](https://github.com/WolfgangMehner/perl-support) -Vim-Support | Vim-Script | [vim.org](http://www.vim.org/scripts/script.php?script_id=3931) | [GitHub](https://github.com/WolfgangMehner/vim-support) +Name | Supports | vim.org | GitHub | Screenshots +--- | --- | --- | --- | --- +AWK-Support | AWK | [vim.org](https://www.vim.org/scripts/script.php?script_id=4415) | [GitHub](https://github.com/WolfgangMehner/awk-support) | [here](https://wolfgangmehner.github.io/vim-plugins/awksupport) +Bash-Support | Bash | [vim.org](https://www.vim.org/scripts/script.php?script_id=365) | [GitHub](https://github.com/WolfgangMehner/bash-support) | [here](https://wolfgangmehner.github.io/vim-plugins/bashsupport) +C-Support | C/C++ & Doxygen | [vim.org](https://www.vim.org/scripts/script.php?script_id=213) | [GitHub](https://github.com/WolfgangMehner/c-support) | [here](https://wolfgangmehner.github.io/vim-plugins/csupport) +LaTeX-Support | LaTeX/LuaTeX/BibTeX | [vim.org](https://www.vim.org/scripts/script.php?script_id=4405) | [GitHub](https://github.com/WolfgangMehner/latex-support) | [here](https://wolfgangmehner.github.io/vim-plugins/latexsupport) +Lua-Support | Lua & C-API | [vim.org](https://www.vim.org/scripts/script.php?script_id=4950) | [GitHub](https://github.com/WolfgangMehner/lua-support) | [here](https://wolfgangmehner.github.io/vim-plugins/luasupport) +Perl-Support | Perl & POD | [vim.org](https://www.vim.org/scripts/script.php?script_id=556) | [GitHub](https://github.com/WolfgangMehner/perl-support) | [here](https://wolfgangmehner.github.io/vim-plugins/perlsupport) +Vim-Support | Vim-Script | [vim.org](https://www.vim.org/scripts/script.php?script_id=3931) | [GitHub](https://github.com/WolfgangMehner/vim-support) | [here](https://wolfgangmehner.github.io/vim-plugins/vimsupport) __Other Tools__ -Name | Description | vim.org | GitHub ---- | --- | --- | --- -Git-Support | Manage Git repos from within Vim | [vim.org](http://www.vim.org/scripts/script.php?script_id=4497) | [GitHub](https://github.com/WolfgangMehner/git-support) -Verilog-Support | SystemVerilog & UVM by [jmcneal](https://github.com/jmcneal) | - | [GitHub](https://github.com/jmcneal/verilog-support) - -Most of the plug-ins were originally developed by Fritz Mehner: -[GitHub](https://github.com/FritzMehner) -[Vim.org](http://www.vim.org/account/profile.php?user_id=169) +Name | Description | vim.org | GitHub | Screenshots +--- | --- | --- | --- | --- +Git-Support | Manage Git repos from within Vim | [vim.org](https://www.vim.org/scripts/script.php?script_id=4497) | [GitHub](https://github.com/WolfgangMehner/git-support) | [here](https://wolfgangmehner.github.io/vim-plugins/gitsupport) +Verilog-Support | SystemVerilog & UVM by [jmcneal](https://github.com/jmcneal) | - | [GitHub](https://github.com/jmcneal/verilog-support) | - # Installation @@ -35,7 +30,9 @@ We recommend downloading the latest official versions published on vim.org (see Or try the development snapshots in the individual GitHub repositories (see above). The versions available here might be buggy. -If you really want to use the versions from the repository, [consult this](https://github.com/WolfgangMehner/vim-plugins/wiki/Installation). +You can use this repository, as well as the ones linked above, with any plug-in manager. + +For more information, please [consult this](https://github.com/WolfgangMehner/vim-plugins/wiki/Installation). # Documentation @@ -43,17 +40,19 @@ Each plug-in comes with its own readme as well as an extensive documentation uti :help c-support - :help git-support + :help lua-support + +# Get Involved -# Mailing List +You are welcome to use the issue tracker to post questions, suggestions, and bug reports. -You can subscribe to the vim-plugins-list mailing list to post your questions or suggestions for improvement or to report bugs. -The list will also be used to announce new releases. -Visit the following page for subscribing to the mailing list: +Please help us keep track of all the issues and name your report/request appropriately: -[http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list](http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list) + "Bash-Support: " -The vim-plugins-list list is very low on traffic. + "C-Support: <title>" + + "...-Support: ..." # Contributing @@ -67,3 +66,9 @@ Please have a look [here](https://github.com/WolfgangMehner/vim-plugins/wiki/Con # License Published under the [GNU General Public License, Version 2](http://www.gnu.de/documents/gpl-2.0.en.html). + +# Credits + +Most of the plug-ins were originally developed by Fritz Mehner: +[GitHub](https://github.com/FritzMehner) +[Vim.org](https://www.vim.org/account/profile.php?user_id=169) diff --git a/autoload/mmtemplates/core.vim b/autoload/mmtemplates/core.vim index f466465..f941869 100644 --- a/autoload/mmtemplates/core.vim +++ b/autoload/mmtemplates/core.vim @@ -11,8 +11,8 @@ " Organization: " Version: see variable g:Templates_Version below " Created: 30.08.2011 -" Revision: 14.04.2017 -" License: Copyright (c) 2012-2016, Wolfgang Mehner +" Revision: 06.08.2020 +" License: Copyright (c) 2012-2020, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the @@ -23,11 +23,11 @@ " PURPOSE. " See the GNU General Public License version 2 for more details. "=============================================================================== -" + "------------------------------------------------------------------------------- " === Basic Checks === {{{1 "------------------------------------------------------------------------------- -" + " need at least 7.0 if v:version < 700 echohl WarningMsg @@ -35,15 +35,15 @@ if v:version < 700 echohl None finish endif -" + " prevent duplicate loading " need compatible if &cp || ( exists('g:Templates_Version') && g:Templates_Version != 'searching' && ! exists('g:Templates_DevelopmentOverwrite') ) finish endif -" -let s:Templates_Version = '1.1alpha' " version number of this script; do not change -" + +let s:Templates_Version = '1.1beta' " version number of this script; do not change + "---------------------------------------------------------------------- " --- Find Newest Version --- {{{2 "---------------------------------------------------------------------- @@ -133,13 +133,13 @@ else endif " }}}2 "------------------------------------------------------------------------------- -" + let g:Templates_Version = s:Templates_Version " version number of this script; do not change -" + "---------------------------------------------------------------------- " === Modul Setup === {{{1 "---------------------------------------------------------------------- -" + "------------------------------------------------------------------------------- " s:ApplyDefaultSetting : Write default setting to a global variable. {{{2 " @@ -152,13 +152,13 @@ let g:Templates_Version = s:Templates_Version " version number of this scrip " If g:<varname> does not exists, assign: " g:<varname> = value "------------------------------------------------------------------------------- -" + function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - let { 'g:'.a:varname } = a:value + if ! exists( 'g:'.a:varname ) + let {'g:'.a:varname} = a:value endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- -" +endfunction + "------------------------------------------------------------------------------- " s:GetGlobalSetting : Get a setting from a global variable. {{{2 " @@ -175,20 +175,20 @@ endfunction " ---------- end of function s:ApplyDefaultSetting ---------- " g:<varname> == 0 -> s:<varname> = "no" " otherwise -> s:<varname> = "yes" "------------------------------------------------------------------------------- -" + function! s:GetGlobalSetting ( varname, ... ) - if a:0 > 0 && a:1 == 'bin' && exists ( 'g:'.a:varname ) && type ( 0 ) == type ( { 'g:'.a:varname } ) - let { 's:'.a:varname } = { 'g:'.a:varname } == 0 ? 'no' : 'yes' - elseif exists ( 'g:'.a:varname ) - let { 's:'.a:varname } = { 'g:'.a:varname } + if a:0 > 0 && a:1 == 'bin' && exists( 'g:'.a:varname ) && type( 0 ) == type( {'g:'.a:varname} ) + let {'s:'.a:varname} = {'g:'.a:varname} == 0 ? 'no' : 'yes' + elseif exists( 'g:'.a:varname ) + let {'s:'.a:varname} = {'g:'.a:varname} endif - " - let s:Templates_AllSettings[ a:varname ] = { 's:'.a:varname } -endfunction " ---------- end of function s:GetGlobalSetting ---------- -" + + let s:Templates_AllSettings[ a:varname ] = {'s:'.a:varname} +endfunction + " }}}2 "------------------------------------------------------------------------------- -" + " platform specifics let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") diff --git a/autoload/mmtoolbox/bash/bashdb.vim b/autoload/mmtoolbox/bash/bashdb.vim new file mode 100644 index 0000000..2470a65 --- /dev/null +++ b/autoload/mmtoolbox/bash/bashdb.vim @@ -0,0 +1,895 @@ +"=============================================================================== +" +" File: bashdb.vim +" +" Description: Part of the Bash-Support toolbox. +" +" Vim/gVim integration of BashDB. +" +" See help file bashdbintegration.txt . +" +" VIM Version: 7.3+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Organization: +" Version: see variable g:BashDB_Version below +" Created: 28.09.2017 +" Revision: 19.04.2019 +" License: Copyright (c) 2017-2019, Wolfgang Mehner +" This program is free software; you can redistribute it and/or +" modify it under the terms of the GNU General Public License as +" published by the Free Software Foundation, version 2 of the +" License. +" This program is distributed in the hope that it will be +" useful, but WITHOUT ANY WARRANTY; without even the implied +" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +" PURPOSE. +" See the GNU General Public License version 2 for more details. +"=============================================================================== + +"------------------------------------------------------------------------------- +" === Basic checks === {{{1 +"------------------------------------------------------------------------------- + +" need at least 7.3 +if v:version < 703 + echohl WarningMsg + echo 'The plugin mmtoolbox/bashdb.vim needs Vim version >= 7.3.' + echohl None + finish +endif + +" prevent duplicate loading +" need compatible +if &cp || ( exists('g:BashDB_Version') && ! exists('g:BashDB_DevelopmentOverwrite') ) + finish +endif + +let g:BashDB_Version= '0.5' " version number of this script; do not change + +"------------------------------------------------------------------------------- +" === Auxiliary functions === {{{1 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" s:ApplyDefaultSetting : Write default setting to a global variable. {{{2 +" +" Parameters: +" varname - name of the variable (string) +" value - default value (string) +" Returns: +" - +" +" If g:<varname> does not exists, assign: +" g:<varname> = value +"------------------------------------------------------------------------------- + +function! s:ApplyDefaultSetting ( varname, value ) + if ! exists ( 'g:'.a:varname ) + let { 'g:'.a:varname } = a:value + endif +endfunction " ---------- end of function s:ApplyDefaultSetting ---------- + +"------------------------------------------------------------------------------- +" s:ErrorMsg : Print an error message. {{{2 +" +" Parameters: +" line1 - a line (string) +" line2 - a line (string) +" ... - ... +" Returns: +" - +"------------------------------------------------------------------------------- + +function! s:ErrorMsg ( ... ) + echohl WarningMsg + for line in a:000 + echomsg line + endfor + echohl None +endfunction " ---------- end of function s:ErrorMsg ---------- + +"------------------------------------------------------------------------------- +" s:GetGlobalSetting : Get a setting from a global variable. {{{2 +" +" Parameters: +" varname - name of the variable (string) +" glbname - name of the global variable (string, optional) +" Returns: +" - +" +" If 'glbname' is given, it is used as the name of the global variable. +" Otherwise the global variable will also be named 'varname'. +" +" If g:<glbname> exists, assign: +" s:<varname> = g:<glbname> +"------------------------------------------------------------------------------- + +function! s:GetGlobalSetting ( varname, ... ) + let lname = a:varname + let gname = a:0 >= 1 ? a:1 : lname + if exists ( 'g:'.gname ) + let { 's:'.lname } = { 'g:'.gname } + endif +endfunction " ---------- end of function s:GetGlobalSetting ---------- + +"------------------------------------------------------------------------------- +" s:ImportantMsg : Print an important message. {{{2 +" +" Parameters: +" line1 - a line (string) +" line2 - a line (string) +" ... - ... +" Returns: +" - +"------------------------------------------------------------------------------- + +function! s:ImportantMsg ( ... ) + echohl Search + echo join ( a:000, "\n" ) + echohl None +endfunction " ---------- end of function s:ImportantMsg ---------- + +"------------------------------------------------------------------------------- +" s:Question : Ask the user a question. {{{2 +" +" Parameters: +" prompt - prompt, shown to the user (string) +" highlight - "normal" or "warning" (string, default "normal") +" Returns: +" retval - the user input (integer) +" +" The possible values of 'retval' are: +" 1 - answer was yes ("y") +" 0 - answer was no ("n") +" -1 - user aborted ("ESC" or "CTRL-C") +"------------------------------------------------------------------------------- + +function! s:Question ( prompt, ... ) + + let ret = -2 + + " highlight prompt + if a:0 == 0 || a:1 == 'normal' + echohl Search + elseif a:1 == 'warning' + echohl Error + else + echoerr 'Unknown option : "'.a:1.'"' + return + end + + " question + echo a:prompt.' [y/n]: ' + + " answer: "y", "n", "ESC" or "CTRL-C" + while ret == -2 + let c = nr2char( getchar() ) + + if c == "y" + let ret = 1 + elseif c == "n" + let ret = 0 + elseif c == "\<ESC>" || c == "\<C-C>" + let ret = -1 + endif + endwhile + + " reset highlighting + echohl None + + return ret +endfunction " ---------- end of function s:Question ---------- + +"------------------------------------------------------------------------------- +" s:Redraw : Redraw depending on whether a GUI is running. {{{2 +" +" Example: +" call s:Redraw ( 'r!', '' ) +" Clear the screen and redraw in a terminal, do nothing when a GUI is running. +" +" Parameters: +" cmd_term - redraw command in terminal mode (string) +" cmd_gui - redraw command in GUI mode (string) +" Returns: +" - +"------------------------------------------------------------------------------- + +function! s:Redraw ( cmd_term, cmd_gui ) + if has('gui_running') + let cmd = a:cmd_gui + else + let cmd = a:cmd_term + endif + + let cmd = substitute ( cmd, 'r\%[edraw]', 'redraw', '' ) + if cmd != '' + silent exe cmd + endif +endfunction " ---------- end of function s:Redraw ---------- + +"------------------------------------------------------------------------------- +" s:ShellParseArgs : Turn cmd.-line arguments into a list. {{{2 +" +" Parameters: +" line - the command-line arguments to parse (string) +" Returns: +" list - the arguments as a list (list) +"------------------------------------------------------------------------------- + +function! s:ShellParseArgs ( line ) + + let list = [] + let curr = '' + + let line = a:line + + while line != '' + + if match ( line, '^\s' ) != -1 + " non-escaped space -> finishes current argument + let line = matchstr ( line, '^\s\+\zs.*' ) + if curr != '' + call add ( list, curr ) + let curr = '' + endif + elseif match ( line, "^'" ) != -1 + " start of a single-quoted string, parse past next single quote + let mlist = matchlist ( line, "^'\\([^']*\\)'\\(.*\\)" ) + if empty ( mlist ) + throw "ShellParseArgs:Syntax:no matching quote '" + endif + let curr .= mlist[1] + let line = mlist[2] + elseif match ( line, '^"' ) != -1 + " start of a double-quoted string, parse past next double quote + let mlist = matchlist ( line, '^"\(\%([^\"]\|\\.\)*\)"\(.*\)' ) + if empty ( mlist ) + throw 'ShellParseArgs:Syntax:no matching quote "' + endif + let curr .= substitute ( mlist[1], '\\\([\"]\)', '\1', 'g' ) + let line = mlist[2] + elseif match ( line, '^\\' ) != -1 + " escape sequence outside of a string, parse one additional character + let mlist = matchlist ( line, '^\\\(.\)\(.*\)' ) + if empty ( mlist ) + throw 'ShellParseArgs:Syntax:single backspace \' + endif + let curr .= mlist[1] + let line = mlist[2] + else + " otherwise parse up to next special char.: space, backslash, quote + let mlist = matchlist ( line, '^\([^[:space:]\\''"]\+\)\(.*\)' ) + let curr .= mlist[1] + let line = mlist[2] + endif + endwhile + + " add last argument + if curr != '' + call add ( list, curr ) + endif + + return list +endfunction " ---------- end of function s:ShellParseArgs ---------- + +"------------------------------------------------------------------------------- +" s:SID : Return the <SID>. {{{2 +" +" Parameters: +" - +" Returns: +" SID - the SID of the script (string) +"------------------------------------------------------------------------------- + +function! s:SID () + return matchstr ( expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$' ) +endfunction " ---------- end of function s:SID ---------- + +"------------------------------------------------------------------------------- +" s:UserInput : Input after a highlighted prompt. {{{2 +" +" Parameters: +" prompt - the prompt (string) +" text - the default input (string) +" compl - completion (string, optional) +" clist - list, if 'compl' is "customlist" (list, optional) +" Returns: +" input - the user input, an empty sting if the user hit <ESC> (string) +"------------------------------------------------------------------------------- + +function! s:UserInput ( prompt, text, ... ) + + echohl Search " highlight prompt + call inputsave() " preserve typeahead + if a:0 == 0 || a:1 == '' + let retval = input( a:prompt, a:text ) + elseif a:1 == 'customlist' + let s:UserInputList = a:2 + let retval = input( a:prompt, a:text, 'customlist,<SNR>'.s:SID().'_UserInputEx' ) + let s:UserInputList = [] + else + let retval = input( a:prompt, a:text, a:1 ) + endif + call inputrestore() " restore typeahead + echohl None " reset highlighting + + let retval = substitute( retval, '^\s\+', "", "" ) " remove leading whitespaces + let retval = substitute( retval, '\s\+$', "", "" ) " remove trailing whitespaces + + return retval + +endfunction " ---------- end of function s:UserInput ---------- + +"------------------------------------------------------------------------------- +" s:UserInputEx : ex-command for s:UserInput. {{{3 +"------------------------------------------------------------------------------- +function! s:UserInputEx ( ArgLead, CmdLine, CursorPos ) + if empty( a:ArgLead ) + return copy( s:UserInputList ) + endif + return filter( copy( s:UserInputList ), 'v:val =~ ''\V\<'.escape(a:ArgLead,'\').'\w\*''' ) +endfunction " ---------- end of function s:UserInputEx ---------- +" }}}3 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" s:WarningMsg : Print a warning/error message. {{{2 +" +" Parameters: +" line1 - a line (string) +" line2 - a line (string) +" ... - ... +" Returns: +" - +"------------------------------------------------------------------------------- + +function! s:WarningMsg ( ... ) + echohl WarningMsg + echo join ( a:000, "\n" ) + echohl None +endfunction " ---------- end of function s:WarningMsg ---------- + +" }}}2 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" === Module setup === {{{1 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" == Platform specific items == {{{2 +"------------------------------------------------------------------------------- + +let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") +let s:UNIX = has("unix") || has("macunix") || has("win32unix") + +let s:installation = 'standalone' +if exists ( 'g:Toolbox_Version' ) + let s:installation = 'toolbox' +endif + +if s:MSWIN + " MS Windows + + let s:plugin_dir = substitute( expand('<sfile>:p:h:h:h:h'), '\\', '/', 'g' ) +else + " Linux/Unix + + let s:plugin_dir = expand('<sfile>:p:h:h:h:h') +endif + +"------------------------------------------------------------------------------- +" == Various settings == {{{2 +"------------------------------------------------------------------------------- + +let s:BashDB_DDD_Exec = 'ddd' +let s:BashDB_Executable = 'bashdb' + +call s:GetGlobalSetting ( 'BashDB_DDD_Exec' ) +call s:GetGlobalSetting ( 'BashDB_Executable', 'BASH_bashdb' ) +call s:GetGlobalSetting ( 'BashDB_Executable' ) + +let s:BashDB_Debugger = 'xterm' " one of s:BashDB_DebuggerList +let s:BashDB_DebuggerList = [ 'xterm' ] +if executable ( s:BashDB_DDD_Exec ) + let s:BashDB_DebuggerList += [ 'ddd' ] +endif +if has ( 'terminal' ) + let s:BashDB_DebuggerList += [ 'terminal', 'integrated' ] +endif +call sort ( s:BashDB_DebuggerList ) + +call s:GetGlobalSetting ( 'BashDB_Debugger', 'BASH_Debugger' ) +call s:GetGlobalSetting ( 'BashDB_Debugger' ) + +if s:BashDB_Debugger == 'term' + let s:BashDB_Debugger = 'xterm' " downwards compatibility with Bash-Support +endif + +let s:Xterm_Executable = 'xterm' + +call s:GetGlobalSetting ( 'Xterm_Executable' ) +call s:ApplyDefaultSetting ( 'Xterm_Options', '-fa courier -fs 12 -geometry 80x24' ) + +"------------------------------------------------------------------------------- +" == Checks == {{{2 +"------------------------------------------------------------------------------- + +let s:Enabled = 1 + +if s:MSWIN || ! executable( s:BashDB_Executable ) + let s:Enabled = 0 +endif + +"------------------------------------------------------------------------------- +" == Custom commands == {{{2 +"------------------------------------------------------------------------------- + +" Cmd.-line completion {{{3 + +"------------------------------------------------------------------------------- +" s:GetDebuggerList : For cmd.-line completion. +"------------------------------------------------------------------------------- +function! s:DebuggerList (...) + return join ( s:BashDB_DebuggerList, "\n" ) +endfunction " ---------- end of function s:DebuggerList ---------- + +" }}}3 + +if s:Enabled == 1 + command! -nargs=* -complete=file BashDB :call <SID>Run(<q-args>) + command! -nargs=* BashDBCommand :call <SID>SendCmd(<q-args>) + command! -bang -nargs=? -complete=custom,<SID>DebuggerList BashDBDebugger :call mmtoolbox#bash#bashdb#Property('<bang>'=='!'?'echo':'set','debugger',<q-args>) + command! -bang -nargs=? -complete=shellcmd BashDBExecutable :call mmtoolbox#bash#bashdb#Property('<bang>'=='!'?'echo':'set','executable',<q-args>) + + command! -nargs=0 BashDBHelp :call <SID>HelpPlugin() + command! -bang -nargs=? BashDBSettings :call <SID>Settings(('<bang>'=='!')+str2nr(<q-args>)) +else + + " s:Disabled : Print why the script is disabled. {{{3 + function! s:Disabled () + let txt = "BashDB tool not working:\n" + if s:MSWIN + let txt .= "BashDB currently not supported under Windows" + elseif ! executable( s:BashDB_Executable ) + let txt .= "BashDB not executable" + else + let txt .= "unknown reason\n" + let txt .= "see :help toolbox-bashdb" + endif + call s:ImportantMsg ( txt ) + return + endfunction " ---------- end of function s:Disabled ---------- + " }}}3 + + command! -bang -nargs=* BashDB :call <SID>Disabled() + command! -nargs=0 BashDBHelp :call <SID>HelpPlugin() + command! -bang -nargs=? BashDBSettings :call <SID>Settings(('<bang>'=='!')+str2nr(<q-args>)) + +endif +" }}}2 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" GetInfo : Initialize the script. {{{1 +"------------------------------------------------------------------------------- +function! mmtoolbox#bash#bashdb#GetInfo () + if s:Enabled + return [ 'BashDB', g:BashDB_Version ] + else + return [ 'BashDB', g:BashDB_Version, 'disabled' ] + endif +endfunction " ---------- end of function mmtoolbox#bash#bashdb#GetInfo ---------- +" +"------------------------------------------------------------------------------- +" AddMaps : Add maps. {{{1 +"------------------------------------------------------------------------------- +function! mmtoolbox#bash#bashdb#AddMaps () +endfunction " ---------- end of function mmtoolbox#bash#bashdb#AddMaps ---------- +" +"------------------------------------------------------------------------------- +" AddMenu : Add menus. {{{1 +"------------------------------------------------------------------------------- +function! mmtoolbox#bash#bashdb#AddMenu ( root, esc_mapl ) + + exe 'amenu <silent> '.a:root.'.&run\ debugger<Tab>:BashDB :BashDB<CR>' + + exe 'amenu '.a:root.'.-Sep01- <Nop>' + + exe 'amenu '.a:root.'.set\ &debugger<Tab>:BashDBDebugger :BashDBDebugger ' + exe 'amenu '.a:root.'.set\ &executable<Tab>:BashDBExecutable :BashDBExecutable ' + + exe 'amenu '.a:root.'.-Sep02- <Nop>' + + exe 'amenu <silent> '.a:root.'.&settings<Tab>:BashDBSettings :BashDBSettings<CR>' + exe 'amenu <silent> '.a:root.'.tool\ &help<Tab>:BashDBHelp :BashDBHelp<CR>' + +endfunction " ---------- end of function mmtoolbox#bash#bashdb#AddMenu ---------- +" +"------------------------------------------------------------------------------- +" Property : Various settings. {{{1 +"------------------------------------------------------------------------------- +function! mmtoolbox#bash#bashdb#Property ( mode, key, ... ) + + " check the mode + if a:mode !~ 'echo\|get\|set' + return s:ErrorMsg ( 'BashDB : Unknown mode: '.a:mode ) + endif + + " check 3rd argument for 'set' + if a:mode == 'set' + if a:0 == 0 + return s:ErrorMsg ( 'BashDB : Not enough arguments for mode "set".' ) + endif + let val = a:1 + endif + + " check the key + if a:key == 'enabled' + let var = 's:Enabled' + elseif a:key == 'debugger' + let var = 's:BashDB_Debugger' + elseif a:key == 'executable' + let var = 's:BashDB_Executable' + else + return s:ErrorMsg ( 'BashDB : Unknown option: '.a:key ) + endif + + " perform the action + if a:mode == 'echo' + echo {var} + return + elseif a:mode == 'get' + return {var} + elseif a:key == 'debugger' + " check against the list of debuggers + if index ( s:BashDB_DebuggerList, val ) > -1 + let s:BashDB_Debugger = val + else + return s:ErrorMsg ( 'BashDB : Debugger unknown or not not enabled: '.val ) + endif + elseif a:key == 'executable' + " check against the list of debuggers + if executable ( val ) + let s:BashDB_Executable = val + else + return s:ErrorMsg ( 'BashDB : Not executable: '.val ) + endif + else + " action is 'set', but key is non of the above + return s:ErrorMsg ( 'BashDB : Option is read-only, can not set: '.a:key ) + endif + +endfunction " ---------- end of function mmtoolbox#bash#bashdb#Property ---------- +" +"------------------------------------------------------------------------------- +" s:HelpPlugin : Plugin help. {{{1 +"------------------------------------------------------------------------------- +function! s:HelpPlugin () + try + help bashdb-integration + catch + exe 'helptags '.s:plugin_dir.'/doc' + help bashdb-integration + endtry +endfunction " ---------- end of function s:HelpPlugin ---------- +" +"------------------------------------------------------------------------------- +" s:Settings : Plugin settings. {{{1 +"------------------------------------------------------------------------------- +function! s:Settings ( verbose ) + + if s:MSWIN | let sys_name = 'Windows' + elseif s:UNIX | let sys_name = 'UNIX' + else | let sys_name = 'unknown' | endif + + let bashdb_status = executable( s:BashDB_Executable ) ? '' : ' (not executable)' + let ddd_status = executable( s:BashDB_DDD_Exec ) ? '' : ' (not executable)' + + let txt = " BashDB-Tool settings\n\n" + \ .' plug-in installation : '.s:installation.' on '.sys_name."\n" + \ .' BashDB executable : '.s:BashDB_Executable.bashdb_status."\n" + if a:verbose + let txt .= + \ ' DDD executable : '.s:BashDB_DDD_Exec.ddd_status."\n" + endif + if s:installation == 'toolbox' + let txt .= + \ ' using toolbox : version '.g:Toolbox_Version."\n" + endif + if a:verbose + let txt .= "\n" + \ .' debugger : '.s:BashDB_Debugger."\n" + endif + let txt .= + \ "________________________________________________________________________________\n" + \ ." BashDB-Tool, Version ".g:BashDB_Version." / Wolfgang Mehner / wolfgang-mehner@web.de\n\n" + + if a:verbose == 2 + split BashDB_Settings.txt + put = txt + else + echo txt + endif +endfunction " ---------- end of function s:Settings ---------- + +"------------------------------------------------------------------------------- +" s:Run : Run the debugger. {{{1 +"------------------------------------------------------------------------------- +function! s:Run ( args ) + + if &filetype == 'sh' || &filetype == 'bash' + silent exe 'update' + endif + + let script_name = shellescape( expand('%:p') ) + + if a:args != '' + let script_args = ' '.a:args + elseif exists( 'b:BASH_ScriptCmdLineArgs' ) + let script_args = ' '.b:BASH_ScriptCmdLineArgs + else + let script_args = '' + endif + + if s:BashDB_Debugger == 'xterm' + " debugger is 'bashdb' in xterm + if ! executable( s:BashDB_Executable ) + return s:WarningMsg ( s:BashDB_Executable.' is not executable or not installed! ' ) + endif + + silent exe '!xterm '.g:Xterm_Options + \ .' -title '.shellescape( 'BashDB - '.expand('%:t') ) + \ .' -e '.s:BashDB_Executable.' -- '.script_name.script_args.' &' + elseif s:BashDB_Debugger == 'ddd' + " debugger is 'ddd' + if ! executable( s:BashDB_DDD_Exec ) + return s:WarningMsg ( s:BashDB_DDD_Exec.' is not executable or not installed! ' ) + endif + + silent exe '!ddd --debugger '.s:BashDB_Executable.' '.script_name.script_args.' &' + elseif s:BashDB_Debugger == 'terminal' + call s:ImportantMsg ( 'not implemented yet' ) + elseif s:BashDB_Debugger == 'integrated' + call s:StartInternal ( script_name.script_args ) + endif +endfunction " ---------- end of function s:Run ---------- + +"------------------------------------------------------------------------------- +" === Internal BashDB execution === {{{1 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" == Debugger state == {{{2 +" +" State of the internal debugger: +"------------------------------------------------------------------------------- + +let s:debug_status = '' +let s:debug_buf_ctrl = -1 +let s:debug_win_ctrl = -1 +let s:debug_buf_io = -1 +let s:debug_win_io = -1 + +let s:debug_buf_script = -1 +let s:debug_win_script = -1 + +"------------------------------------------------------------------------------- +" s:StartInternal : Start the internal debugger. {{{2 +" +" Parameters: +" args - cmd.-line arguments, script and its arguments (string) +" Returns: +" - +"------------------------------------------------------------------------------- +function! s:StartInternal ( args ) + + if s:debug_status != '' + return s:WarningMsg ( 'debugger already running' ) + endif + + " bashdb: uses --tty the other way around + let is_bashdb = 0 + let name_pty = 'BashDB - I/O' + let name_job = 'BashDB - CTRL' + if s:BashDB_Executable =~? '\cbashdb' + let is_bashdb = 1 + let name_pty = 'BashDB - CTRL' + let name_job = 'BashDB - I/O' + endif + + " script buffer/window + let s:debug_buf_script = bufnr( '%' ) + let s:debug_win_script = win_getid( winnr() ) + + " only the script I/O appears here + let s:debug_buf_io = term_start ( 'NONE', { + \ 'term_name' : name_pty, + \ } ) + let s:debug_win_io = win_getid( winnr() ) + + let tty = term_gettty ( s:debug_buf_io ) + + " start in another terminal, the control commands are run through this terminal + let arg_list = [ s:BashDB_Executable ] + let arg_list += [ '--tty', tty, '-x', tty ] + let arg_list += s:ShellParseArgs ( a:args ) + + " bashdb: switch order of windows (also see 'curwin' below) + if is_bashdb + belowright new + endif + + let s:debug_buf_ctrl = term_start ( arg_list, { + \ 'term_name' : name_job, + \ 'curwin' : is_bashdb, + \ 'exit_cb' : function ( 's:EndInternal' ), + \ } ) + let s:debug_win_ctrl = win_getid( winnr() ) + + " bashdb: switch the buffers + if is_bashdb + let [ s:debug_buf_io, s:debug_buf_ctrl ] = [ s:debug_buf_ctrl, s:debug_buf_io ] + let [ s:debug_win_io, s:debug_win_ctrl ] = [ s:debug_win_ctrl, s:debug_win_io ] + endif + + " now we're cooking + let s:debug_status = 'running' + + " set up script buffer + call win_gotoid( s:debug_win_script ) + + command! -buffer -nargs=0 Continue :call <SID>SendCmd('continue') + command! -buffer -nargs=0 Step :call <SID>SendCmd('step') + + command! -buffer -bang -nargs=0 Break :call <SID>Breakpoint('<bang>'=='!') + command! -buffer -nargs=0 Display :call <SID>DisplayVariable() + + if has( 'menu' ) + anoremenu <silent> WinBar.Run :BashDBCommand run<CR> + anoremenu <silent> WinBar.Cont :Continue<CR> + anoremenu <silent> WinBar.Step :Step<CR> + anoremenu <silent> WinBar.Quit :BashDBCommand quit<CR> + + anoremenu <silent> WinBar.Breakpoint :Break<CR> + anoremenu <silent> WinBar.Break\ Once :Break!<CR> + anoremenu <silent> WinBar.Display :Display<CR> + endif +endfunction " ---------- end of function s:StartInternal ---------- + +"------------------------------------------------------------------------------- +" s:EndInternal : Callback for BashDB exiting. {{{2 +" +" Parameters: +" job - the job (job) +" status - the status (number) +" Returns: +" - +"------------------------------------------------------------------------------- +function! s:EndInternal ( job, status ) + + " remove the debugger buffers + exe 'bwipe! '.s:debug_buf_io + if a:status == 0 + exe 'bwipe! '.s:debug_buf_ctrl + endif + + let s:debug_status = '' + + call win_gotoid( s:debug_win_script ) + + " remove the menus and commands + if has( 'menu' ) + aunmenu WinBar.Run + aunmenu WinBar.Cont + aunmenu WinBar.Step + aunmenu WinBar.Quit + + aunmenu WinBar.Breakpoint + aunmenu WinBar.Break\ Once + aunmenu WinBar.Display + endif + + delcommand Continue + delcommand Step + + delcommand Break + delcommand Display + + call s:Redraw ( 'r!', 'r' ) + + if a:status == 0 + call s:ImportantMsg ( s:BashDB_Executable.' done' ) + else + call s:ImportantMsg ( s:BashDB_Executable.' returned with error code '.a:status, ' use :bwipe! in the debugger buffer to properly close it' ) + endif + +endfunction " ---------- end of function s:EndInternal ---------- + +"------------------------------------------------------------------------------- +" s:SendCmd : Send a command to the debugger. {{{2 +" +" Parameters: +" cmd - the command (string) +" Returns: +" - +"------------------------------------------------------------------------------- +function! s:SendCmd ( cmd ) + if s:debug_status == '' + return s:WarningMsg ( 'debugger not running' ) + endif + + call term_sendkeys ( s:debug_buf_ctrl, a:cmd."\r" ) +endfunction " ---------- end of function s:SendCmd ---------- + +"------------------------------------------------------------------------------- +" s:Breakpoint : Send a break commands {{{2 +" +" Send a 'break' or 'tbreak' command. +" +" Parameters: +" once - if true, send tbreak, otherwise send break (integer) +" Returns: +" - +"------------------------------------------------------------------------------- +function! s:Breakpoint ( once ) + + let filename = expand ( '%:p' ) + let fileline = line ( '.' ) + + if a:once + call s:SendCmd ( 'tbreak '.filename.':'.fileline ) + else + call s:SendCmd ( 'break '.filename.':'.fileline ) + endif +endfunction " ---------- end of function s:Breakpoint ---------- + +"------------------------------------------------------------------------------- +" s:DisplayVariable : Send a display command. {{{2 +" +" Send a 'display' command for the variable under the cursor. +" +" Parameters: +" - +" Returns: +" - +"------------------------------------------------------------------------------- +function! s:DisplayVariable () + + let buf_line = getline('.') + let buf_pos = col('.') - 1 + let pattern = '$\?\k\+\|${.}\|$.' + let cnt = 1 + let pick = '' + + while 1 + let m_end = matchend ( buf_line, pattern, 0, cnt ) - 1 + if m_end < 0 + let pick = '' + break + elseif m_end >= buf_pos + let m_start = match ( buf_line, pattern, 0, cnt ) + if m_start <= buf_pos | let pick = buf_line[ m_start : m_end ] + else | let pick = '' | endif + break + endif + let cnt += 1 + endwhile + + if pick == '' + return s:ImportantMsg ( 'no variable under the cursor' ) + endif + + let pick = substitute ( pick, '^[^$]', '$&', '' ) + + call s:SendCmd ( 'display '.pick ) +endfunction " ---------- end of function s:DisplayVariable ---------- + +" }}}2 +"------------------------------------------------------------------------------- + +" }}}1 +"------------------------------------------------------------------------------- + +" ===================================================================================== +" vim: foldmethod=marker shiftwidth=2 tabstop=2 diff --git a/autoload/mmtoolbox/cmake.vim b/autoload/mmtoolbox/cmake.vim index d61667c..d986757 100644 --- a/autoload/mmtoolbox/cmake.vim +++ b/autoload/mmtoolbox/cmake.vim @@ -43,7 +43,7 @@ endif if &cp || ( exists('g:CMake_Version') && ! exists('g:CMake_DevelopmentOverwrite') ) finish endif -let g:CMake_Version= '0.9.2' " version number of this script; do not change +let g:CMake_Version= '0.9.3' " version number of this script; do not change " "------------------------------------------------------------------------------- " Auxiliary functions {{{1 @@ -291,7 +291,7 @@ let s:ErrorFormat_MakeAdditions = " " policy list {{{2 " -let s:Policies_Version = '2.8.12' +let s:Policies_Version = '3.10' let s:Policies_List = [ \ [ 'CMP0000', 'A minimum required CMake version must be specified.', '2.6.0' ], \ [ 'CMP0001', 'CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.', '2.6.0' ], @@ -309,7 +309,7 @@ let s:Policies_List = [ \ [ 'CMP0013', 'Duplicate binary directories are not allowed.', '2.8.0' ], \ [ 'CMP0014', 'Input directories must have CMakeLists.txt.', '2.8.0' ], \ [ 'CMP0015', 'link_directories() treats paths relative to the source dir.', '2.8.1' ], - \ [ 'CMP0016', 'target_link_libraries() reports error if only argument is not a target.', '2.8.3' ], + \ [ 'CMP0016', 'target_link_libraries() reports error if its only argument is not a target.', '2.8.3' ], \ [ 'CMP0017', 'Prefer files from the CMake module directory when including from there.', '2.8.4' ], \ [ 'CMP0018', 'Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.', '2.8.9' ], \ [ 'CMP0019', 'Do not re-expand variables in include and link information.', '2.8.11' ], @@ -317,6 +317,54 @@ let s:Policies_List = [ \ [ 'CMP0021', 'Fatal error on relative paths in INCLUDE_DIRECTORIES target property.', '2.8.12' ], \ [ 'CMP0022', 'INTERFACE_LINK_LIBRARIES defines the link interface.', '2.8.12' ], \ [ 'CMP0023', 'Plain and keyword target_link_libraries signatures cannot be mixed.', '2.8.12' ], + \ [ 'CMP0024', 'Disallow include export result.', '3.0' ], + \ [ 'CMP0025', 'Compiler id for Apple Clang is now AppleClang.', '3.0' ], + \ [ 'CMP0026', 'Disallow use of the LOCATION property for build targets.', '3.0' ], + \ [ 'CMP0027', 'Conditionally linked imported targets with missing include directories.', '3.0' ], + \ [ 'CMP0028', 'Double colon in target name means ALIAS or IMPORTED target.', '3.0' ], + \ [ 'CMP0029', 'The subdir_depends() command should not be called.', '3.0.' ], + \ [ 'CMP0030', 'The use_mangled_mesa() command should not be called.', '3.0' ], + \ [ 'CMP0031', 'The load_command() command should not be called.', '3.0' ], + \ [ 'CMP0032', 'The output_required_files() command should not be called.', '3.0' ], + \ [ 'CMP0033', 'The export_library_dependencies()command should not be called.', '3.0' ], + \ [ 'CMP0034', 'The utility_source() command should not be called.', '3.0' ], + \ [ 'CMP0035', 'The variable_requires() command should not be called.', '3.0' ], + \ [ 'CMP0036', 'The build_name() command should not be called.', '3.0' ], + \ [ 'CMP0037', 'Target names should not be reserved and should match a validity pattern.', '3.0' ], + \ [ 'CMP0038', 'Targets may not link directly to themselves.', '3.0' ], + \ [ 'CMP0039', 'Utility targets may not have link dependencies.', '3.0' ], + \ [ 'CMP0040', 'The target in the TARGET signature of add_custom_command() must exist and must be defined in current directory.', '3.0' ], + \ [ 'CMP0041', 'Error on relative include with generator expression.', '3.0' ], + \ [ 'CMP0042', 'MACOSX_RPATH is enabled by default.', '3.0' ], + \ [ 'CMP0043', 'Ignore COMPILE_DEFINITIONS_<Config> properties', '3.0' ], + \ [ 'CMP0044', 'Case sensitive <LANG>_COMPILER_ID generator expressions', '3.0' ], + \ [ 'CMP0045', 'Error on non-existent target in get_target_property.', '3.0' ], + \ [ 'CMP0046', 'Error on non-existent dependency in add_dependencies.', '3.0' ], + \ [ 'CMP0047', 'Use QCC compiler id for the qcc drivers on QNX.', '3.0' ], + \ [ 'CMP0048', 'The project() command manages VERSION variables.', '3.0' ], + \ [ 'CMP0049', 'Do not expand variables in target source entries.', '3.0' ], + \ [ 'CMP0050', 'Disallow add_custom_command SOURCE signatures.', '3.0' ], + \ [ 'CMP0051', 'List TARGET_OBJECTS in SOURCES target property.', '3.1' ], + \ [ 'CMP0052', 'Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES.', '3.1' ], + \ [ 'CMP0053', 'Simplify variable reference and escape sequence evaluation.', '3.1' ], + \ [ 'CMP0054', 'Only interpret if() arguments as variables or keywords when unquoted.', '3.1' ], + \ [ 'CMP0055', 'Strict checking for the break() command.', '3.2' ], + \ [ 'CMP0056', 'Honor link flags in try_compile() source-file signature.', '3.2' ], + \ [ 'CMP0057', 'Support new if() IN_LIST operator.', '3.3' ], + \ [ 'CMP0058', 'Ninja requires custom command byproducts to be explicit.', '3.3' ], + \ [ 'CMP0059', 'Do not treat DEFINITIONS as a built-in directory property.', '3.3' ], + \ [ 'CMP0060', 'Link libraries by full path even in implicit directories.', '3.3' ], + \ [ 'CMP0061', 'CTest does not by default tell make to ignore errors (-i).', '3.3' ], + \ [ 'CMP0062', 'Disallow install() of export() result.', '3.3' ], + \ [ 'CMP0063', 'Honor visibility properties for all target types.', '3.3' ], + \ [ 'CMP0064', 'Recognize TEST as a operator for the if() command.', '3.4' ], + \ [ 'CMP0065', 'Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property.', '3.4' ], + \ [ 'CMP0066', 'Honor per-config flags in try_compile() source-file signature.', '3.7' ], + \ [ 'CMP0067', 'Honor language standard in try_compile() source-file signature.', '3.8' ], + \ [ 'CMP0068', 'RPATH settings on macOS do not affect install_name.', '3.9' ], + \ [ 'CMP0069', 'INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.', '3.9' ], + \ [ 'CMP0070', 'Define file(GENERATE) behavior for relative paths.', '3.10' ], + \ [ 'CMP0071', 'Let AUTOMOC and AUTOUIC process GENERATED files.', '3.10' ], \ [ 'CMP????', 'There might be more policies not mentioned here, since this list is not maintained automatically.', '?.?.?' ], \ ] " @@ -605,9 +653,9 @@ function! s:Run ( args, cmake_only ) " silent exe 'update' | " write source file if necessary cclose - " - exe 'lchdir '.fnameescape( s:BuildLocation ) - " + + exe 'cd '.fnameescape( s:BuildLocation ) + if a:cmake_only == 1 " let g:CMakeDebugStr .= 'CMake only, ' " debug @@ -636,7 +684,9 @@ function! s:Run ( args, cmake_only ) let &g:errorformat = errorf_saved " let g:CMakeDebugStr .= 'success: '.( v:shell_error == 0 ).', ' " debug - " + + cd - + " errors occurred? if v:shell_error != 0 botright cwindow @@ -644,7 +694,6 @@ function! s:Run ( args, cmake_only ) redraw " redraw after cclose, before echoing call s:ImportantMsg ( 'CMake : CMake finished successfully.' ) endif - " else " let g:CMakeDebugStr .= 'CMake & make, ' " debug @@ -705,7 +754,9 @@ function! s:Run ( args, cmake_only ) endif " let g:CMakeDebugStr .= 'success: '.( v:shell_error == 0 ).', ' " debug - " + + cd - + " errors occurred? if v:shell_error != 0 botright cwindow @@ -727,13 +778,10 @@ function! s:Run ( args, cmake_only ) call s:ImportantMsg ( 'CMake : make finished successfully.' ) endif endif - " endif - " - lchdir - - " + let g:CMakeDebugStr .= 'done' " debug - " + endfunction " ---------- end of function s:Run ---------- " "------------------------------------------------------------------------------- @@ -766,11 +814,41 @@ endfunction " ---------- end of function s:PolicyListText ---------- "------------------------------------------------------------------------------- " s:OpenBuffer : Open a scratch buffer. {{{1 +" +" If a buffer called 'buf_name' already exists, jump to that buffer. Otherwise, +" open a buffer of the given name an set it up as a scratch buffer. It is +" deleted after the window is closed. +" +" Options: +" - showdir: the directory will be shown in the buffer list (set buf=nowrite) +" +" Settings: +" - buftype=nofile/nowrite (depending on the option 'showdir') +" - bufhidden=wipe +" - swapfile=0 +" - tabstop=8 +" +" Parameters: +" buf_name - name of the buffer (string) +" ... - options (string) +" Returns: +" opened - true, if a new buffer was opened (integer) "------------------------------------------------------------------------------- -function! s:OpenBuffer ( buf_name ) +function! s:OpenBuffer ( buf_name, ... ) - " a buffer like this already existing? - if bufnr ( a:buf_name ) != -1 + " options + let btype = 'nofile' + + for val in a:000 + if val == 'showdir' + let btype = 'nowrite' " like 'nofile', but the directory is shown in the buffer list + else + call s:ErrorMsg ( 'CMake : Unknown buffer option: '.val ) + endif + endfor + + " a buffer like this already opened on the current tab page? + if bufwinnr ( a:buf_name ) != -1 " yes -> go to the window containing the buffer exe bufwinnr( a:buf_name ).'wincmd w' return 0 @@ -781,22 +859,44 @@ function! s:OpenBuffer ( buf_name ) " buffer exists elsewhere? if bufnr ( a:buf_name ) != -1 - " yes -> settings of the new buffer + " yes -> reuse it silent exe 'edit #'.bufnr( a:buf_name ) return 0 else " no -> settings of the new buffer - silent exe 'file '.escape( a:buf_name, ' ' ) - setlocal noswapfile - setlocal bufhidden=wipe - setlocal tabstop=8 + let &l:buftype = btype + let &l:bufhidden = 'wipe' + let &l:swapfile = 0 + let &l:tabstop = 8 + call s:RenameBuffer( a:buf_name ) endif return 1 endfunction " ---------- end of function s:OpenBuffer ---------- +"------------------------------------------------------------------------------- +" s:RenameBuffer : Rename a scratch buffer. {{{1 +" +" Parameters: +" name - the new name (string) +" Returns: +" - +"------------------------------------------------------------------------------- +function! s:RenameBuffer ( name ) + + silent exe 'keepalt file '.fnameescape( a:name ) + +endfunction " ---------- end of function s:RenameBuffer ---------- + "------------------------------------------------------------------------------- " s:UpdateBuffer : Update a scratch buffer. {{{1 +" +" Replace the text in the buffer with 'text'. +" +" Parameters: +" text - the text to place in the buffer (string) +" Returns: +" - "------------------------------------------------------------------------------- function! s:UpdateBuffer ( text ) @@ -956,23 +1056,28 @@ function! s:ShowCache ( args ) return endif + if s:OpenBuffer ( 'CMake - cache', 'showdir' ) + silent exe 'nmap <silent> <buffer> q :close<CR>' + endif + " get the cache - exe 'lchdir '.fnameescape( s:BuildLocation ) + exe 'cd '.fnameescape( s:BuildLocation ) let [ success, text ] = s:TextFromSystem ( shellescape( s:CMake_Executable ).' -N '.args ) + let location = fnamemodify ( s:BuildLocation, ':p' ) - lchdir - + cd - if success == 0 + close + redraw " redraw after cclose, before echoing call s:WarningMsg ( 'CMake : Could not obtain the cache.' ) return endif - if s:OpenBuffer ( 'CMake - cache' ) - silent exe 'nmap <silent> <buffer> q :close<CR>' - endif - + call s:RenameBuffer ( location.'/CMake - cache' ) call s:UpdateBuffer ( text ) + endfunction " ---------- end of function s:ShowCache ---------- "------------------------------------------------------------------------------- diff --git a/autoload/mmtoolbox/doxygen.vim b/autoload/mmtoolbox/doxygen.vim index 3287c82..d9dffee 100644 --- a/autoload/mmtoolbox/doxygen.vim +++ b/autoload/mmtoolbox/doxygen.vim @@ -13,7 +13,7 @@ " Organization: " Version: see variable g:Doxygen_Version below " Created: 10.06.2012 -" Revision: 30.06.2014 +" Revision: 17.10.2017 " License: Copyright (c) 2012-2016, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as @@ -29,7 +29,7 @@ "------------------------------------------------------------------------------- " Basic checks. {{{1 "------------------------------------------------------------------------------- -" + " need at least 7.0 if v:version < 700 echohl WarningMsg @@ -37,14 +37,14 @@ if v:version < 700 echohl None finish endif -" + " prevent duplicate loading " need compatible if &cp || ( exists('g:Doxygen_Version') && ! exists('g:Doxygen_DevelopmentOverwrite') ) finish endif -let g:Doxygen_Version= '0.9.2' " version number of this script; do not change -" +let g:Doxygen_Version= '0.9.3' " version number of this script; do not change + "------------------------------------------------------------------------------- " Auxiliary functions. {{{1 "------------------------------------------------------------------------------- @@ -274,9 +274,9 @@ if s:Enabled == 1 command! -bang -nargs=? -complete=file DoxygenLogFile :call mmtoolbox#doxygen#Property('<bang>'=='!'?'echo':'set','log-file',<q-args>) command! -bang -nargs=? -complete=file DoxygenWarningFile :call mmtoolbox#doxygen#Property('<bang>'=='!'?'echo':'set','warning-file',<q-args>) command! -nargs=* -complete=file Doxygen :call <SID>Run(<q-args>) - command! -nargs=0 -complete=file DoxygenGenerateConfig :call <SID>GenerateConfig() - command! -nargs=0 -complete=file DoxygenEditConfig :call <SID>EditConfig() - command! -nargs=0 -complete=file DoxygenViewLog :call <SID>ViewLog() + command! -nargs=0 DoxygenGenerateConfig :call <SID>GenerateConfig() + command! -nargs=0 DoxygenEditConfig :call <SID>EditConfig() + command! -nargs=0 DoxygenViewLog :call <SID>ViewLog() command! -nargs=0 DoxygenWarnings :call <SID>Warnings() command! -nargs=0 DoxygenHelp :call <SID>Help() command! -bang -nargs=? DoxygenSettings :call <SID>Settings(('<bang>'=='!')+str2nr(<q-args>)) @@ -509,9 +509,9 @@ function! s:Run ( args ) let cmdlinearg = a:args endif " :TODO:27.10.2013 19:28:WM: 'cmdlinearg' is not correctly escaped for use under Windows - " - exe 'lchdir '.fnameescape( fnamemodify( s:ConfigFile, ':p:h' ) ) - " + + exe 'cd '.fnameescape( fnamemodify( s:ConfigFile, ':p:h' ) ) + let warn_log_file_configured = '' " if ! filereadable( s:ConfigFile ) @@ -535,12 +535,12 @@ function! s:Run ( args ) " write both the log and the warning file silent exe ':!'.shellescape( s:Doxygen_Executable ).' '.cmdlinearg.' 1> '.shellescape( s:LogFile ).' 2> '.shellescape( s:WarningFile ) endif - " - lchdir - - " + + cd - + " process the warnings call s:Warnings () - " + endfunction " ---------- end of function s:Run ---------- " "------------------------------------------------------------------------------- @@ -589,18 +589,18 @@ endfunction " ---------- end of function s:EditConfig ---------- " s:ViewLog : Edit the Doxygen configuration file. {{{1 "------------------------------------------------------------------------------- function! s:ViewLog () - " + " go to the directory of 's:ConfigFile', so that the standard for 's:LogFile' works - exe 'lchdir '.fnameescape( fnamemodify( s:ConfigFile, ':p:h' ) ) - " - if ! filereadable ( s:LogFile ) - return s:ErrorMsg ( 'Doxygen : File not readable: '.s:LogFile ) - endif - " + exe 'cd '.fnameescape( fnamemodify( s:ConfigFile, ':p:h' ) ) + let logfile = fnamemodify( s:LogFile, ":p" ) - " - lchdir - - " + + cd - + + if ! filereadable ( logfile ) + return s:ErrorMsg ( 'Doxygen : File not readable: '.logfile ) + endif + exe 'sview '.fnameescape( logfile ) endfunction " ---------- end of function s:ViewLog ---------- " @@ -608,15 +608,19 @@ endfunction " ---------- end of function s:ViewLog ---------- " s:Warnings : Send the warning file through QuickFix. {{{1 "------------------------------------------------------------------------------- function! s:Warnings () - " + silent exe 'update' | " write source file if necessary cclose - " + " go to the directory of 's:ConfigFile', so that the standard for " 's:WarningFile' works - exe 'lchdir '.fnameescape( fnamemodify( s:ConfigFile, ':p:h' ) ) - " + exe 'cd '.fnameescape( fnamemodify( s:ConfigFile, ':p:h' ) ) + + let warnfile = fnamemodify( s:WarningFile, ":p" ) + + cd - + " any errors? - if getfsize( s:WarningFile ) > 0 + if getfsize( warnfile ) > 0 " " save the current settings let errorf_saved = &l:errorformat @@ -624,7 +628,7 @@ function! s:Warnings () " read the file and process the errors let &l:errorformat = s:ErrorFormat " - exe 'cgetfile '.fnameescape( s:WarningFile ) + exe 'cgetfile '.fnameescape( warnfile ) " " restore the old settings let &l:errorformat = errorf_saved @@ -634,9 +638,7 @@ function! s:Warnings () redraw " redraw after cclose, before echoing call s:ImportantMsg ( "Doxygen : no warnings/errors" ) endif - " - lchdir - - " + endfunction " ---------- end of function s:Warnings ---------- "------------------------------------------------------------------------------- diff --git a/autoload/mmtoolbox/make.vim b/autoload/mmtoolbox/make.vim index 09e92dc..200a47b 100644 --- a/autoload/mmtoolbox/make.vim +++ b/autoload/mmtoolbox/make.vim @@ -13,7 +13,7 @@ " Organization: " Version: see variable g:Make_Version below " Created: 06.05.2013 -" Revision: 07.10.2016 +" Revision: 17.10.2017 " License: Copyright (c) 2013-2015, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as @@ -367,11 +367,11 @@ function! s:Run ( args ) if s:Makefile == '' exe 'make '.cmdlinearg else - exe 'lchdir '.fnameescape( fnamemodify( s:Makefile, ':p:h' ) ) - " + exe 'cd '.fnameescape( fnamemodify( s:Makefile, ':p:h' ) ) + exe 'make -f '.shellescape( s:Makefile ).' '.cmdlinearg - " - lchdir - + + cd - endif " botright cwindow diff --git a/autoload/mmtoolbox/tools.vim b/autoload/mmtoolbox/tools.vim index 7d05309..295681f 100644 --- a/autoload/mmtoolbox/tools.vim +++ b/autoload/mmtoolbox/tools.vim @@ -11,7 +11,7 @@ " Organization: " Version: see variable g:Toolbox_Version below " Created: 29.12.2012 -" Revision: 23.10.2014 +" Revision: 30.09.2017 " License: Copyright (c) 2012-2015, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as @@ -42,7 +42,7 @@ if &cp || ( exists('g:Toolbox_Version') && g:Toolbox_Version != 'searching' && ! finish endif " -let s:Toolbox_Version= '1.2' " version number of this script; do not change +let s:Toolbox_Version = '1.3' " version number of this script; do not change " "---------------------------------------------------------------------- " --- Find Newest Version --- {{{2 @@ -265,24 +265,27 @@ endfunction " ---------- end of function mmtoolbox#tools#NewToolbox ------- " " Parameters: " toolbox - the toolbox (dict) -" name - the name of the tool (string) +" name_full - the full name of the tool (string) +" name - the short name of the tool (string) " file - the script (string) " Returns: " success - tool loaded without errors, but might still be disabled (integer) "------------------------------------------------------------------------------- -function! s:LoadTool ( toolbox, name, file ) - " - let toolbox = a:toolbox - let name = a:name - " +function! s:LoadTool ( toolbox, name_full, name, file ) + + let toolbox = a:toolbox + let name_full = a:name_full + let name = a:name + " try to load and initialize try " " get tool information - let retlist = mmtoolbox#{name}#GetInfo() + let retlist = {name_full}#GetInfo() " " assemble the entry let entry = { + \ "name_full" : a:name_full, \ "name" : name, \ "prettyname" : retlist[0], \ "version" : retlist[1], @@ -326,17 +329,19 @@ endfunction " ---------- end of function s:LoadTool ---------- " " Parameters: " toolbox - the toolbox (dict) -" name - the name of the tool (string) +" name_full - the full name of the tool (string) +" name - the short name of the tool (string) " file - the script (string) " Returns: " - "------------------------------------------------------------------------------- -function! s:RegisterTool ( toolbox, name, file ) +function! s:RegisterTool ( toolbox, name_full, name, file ) " " assemble the entry " - also record which tools was loaded later on, to keep creating correct " menus let entry = { + \ "name_full" : a:name_full, \ "name" : a:name, \ "filename" : a:file, \ "loaded" : 0, @@ -370,10 +375,16 @@ function! mmtoolbox#tools#Load ( toolbox, directories ) " " go through all dir/*.vim for file in split( glob (dir.'/*.vim'), '\n' ) - " - " the name is the basename of the file - let name = fnamemodify( file, ':t:r' ) - " + + if file =~ 'autoload[/\\]\(.\{-}\)[/\\]\{1,2}\([^/\\]\+\)\.vim$' + let mlist = matchlist( file, 'autoload[/\\]\(.\{-}\)[/\\]\{1,2}\([^/\\]\+\)\.vim$' ) + let name_full = substitute( mlist[1], '[/\\]', '#', 'g' ).'#'.mlist[2] + let name = mlist[2] + else + " invalid name + continue + endif + " do not process 'tools.vim' (this script) if name == 'tools' continue @@ -386,9 +397,9 @@ function! mmtoolbox#tools#Load ( toolbox, directories ) " " check whether to use the tool if s:GetToolConfig ( a:toolbox.plugin, name ) == 'yes' - call s:LoadTool ( a:toolbox, name, file ) + call s:LoadTool ( a:toolbox, name_full, name, file ) else - call s:RegisterTool ( a:toolbox, name, file ) + call s:RegisterTool ( a:toolbox, name_full, name, file ) endif " endfor @@ -434,7 +445,7 @@ function! s:LoadAdditionalTool ( toolbox_name, name ) " " load the tool let toolbox.unused[name].loaded = 1 - let success = s:LoadTool ( toolbox, name, toolbox.unused[name].filename ) + let success = s:LoadTool ( toolbox, toolbox.unused[name].name_full, name, toolbox.unused[name].filename ) " " create the menu entry if success @@ -463,15 +474,16 @@ function! mmtoolbox#tools#ToolEnabled ( toolbox, name ) if ! has_key ( a:toolbox.tools, a:name ) return 0 endif - " + + let entry = a:toolbox.tools[ a:name ] let enabled = 0 - " + try - let enabled = mmtoolbox#{a:name}#Property('get','enabled') + let enabled = {entry.name_full}#Property('get','enabled') catch /.*/ " fail quietly endtry - " + return enabled endfunction " ---------- end of function mmtoolbox#tools#ToolEnabled ---------- " @@ -585,7 +597,7 @@ function! mmtoolbox#tools#AddMaps ( toolbox ) " try " try to create the maps - call mmtoolbox#{entry.name}#AddMaps() + call {entry.name_full}#AddMaps() catch /.*/ " could not load the plugin: ? call s:ErrorMsg ( "Could not create maps for the tool \"".name."\" (".v:exception.")", @@ -626,7 +638,7 @@ function! s:CreateToolMenu ( toolbox, name, root, mleader ) " try " try to create the menu - call mmtoolbox#{entry.name}#AddMenu( menu_root, a:mleader ) + call {entry.name_full}#AddMenu( menu_root, a:mleader ) catch /.*/ " could not load the plugin: ? call s:ErrorMsg ( "Could not create menus for the tool \"".a:name."\" (".v:exception.")", diff --git a/autoload/perlsupportprofiling.vim b/autoload/perlsupportprofiling.vim index d33023d..f88c91e 100644 --- a/autoload/perlsupportprofiling.vim +++ b/autoload/perlsupportprofiling.vim @@ -5,11 +5,12 @@ " Description: Plugin perl-support: Profiler support " " VIM Version: 7.0+ -" Author: Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Author: Fritz Mehner <mehner.fritz@web.de> " Version: 1.0 " Created: 22.02.2009 -" Revision: --- -" License: Copyright (c) 2009-2014, Dr. Fritz Mehner +" Revision: 27.09.2017 +" License: Copyright (c) 2009-2016, Fritz Mehner +" Copyright (c) 2017-2019, Wolfgang Mehner "=============================================================================== " " Exit quickly when: @@ -19,7 +20,7 @@ if exists("g:loaded_perlsupportprofiling") || &compatible finish endif -let g:loaded_perlsupportregex = "v1.0" +let g:loaded_perlsupportprofiling = "v1.0" " let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") diff --git a/autoload/perlsupportregex.vim b/autoload/perlsupportregex.vim index ca7210d..cd72652 100644 --- a/autoload/perlsupportregex.vim +++ b/autoload/perlsupportregex.vim @@ -6,10 +6,13 @@ " Regular expression explanation and visualization. " " VIM Version: 7.0+ -" Author: Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Author: Wolfgang Mehner <wolfgang-mehner@web.de> +" Fritz Mehner <mehner.fritz@web.de> " Version: 1.0 -" Created: 16.12.2008 18:16:55 -" License: Copyright 2008-2014, Dr. Fritz Mehner +" Created: 16.12.2008 +" Revision: 27.09.2017 +" License: Copyright (c) 2008-2016, Fritz Mehner +" Copyright (c) 2017-2019, Wolfgang Mehner "=============================================================================== " " Exit quickly when: @@ -19,7 +22,7 @@ if exists("g:loaded_perlsupportregex") || &compatible finish endif -let g:loaded_perlsupportregex = "v1.0" +let g:loaded_perlsupportregex = "v1.0.1" let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") " @@ -34,6 +37,65 @@ let s:Perl_PerlRegexVisualizeFlag = '' let s:Perl_PerlRegexPrematch = '' let s:Perl_PerlRegexMatch = '' " +"------------------------------------------------------------------------------- +" s:UserInput : Input after a highlighted prompt. {{{1 +" +" Parameters: +" prompt - the prompt (string) +" text - the default input (string) +" compl - completion (string, optional) +" clist - list, if 'compl' is "customlist" (list, optional) +" Returns: +" input - the user input, an empty sting if the user hit <ESC> (string) +"------------------------------------------------------------------------------- + +function! s:UserInput ( prompt, text, ... ) + + echohl Search " highlight prompt + call inputsave() " preserve typeahead + if a:0 == 0 || a:1 == '' + let retval = input( a:prompt, a:text ) + elseif a:1 == 'customlist' + let s:UserInputList = a:2 + let retval = input( a:prompt, a:text, 'customlist,<SNR>'.s:SID().'_UserInputEx' ) + let s:UserInputList = [] + else + let retval = input( a:prompt, a:text, a:1 ) + endif + call inputrestore() " restore typeahead + echohl None " reset highlighting + + let retval = substitute( retval, '^\s\+', "", "" ) " remove leading whitespaces + let retval = substitute( retval, '\s\+$', "", "" ) " remove trailing whitespaces + + return retval + +endfunction " ---------- end of function s:UserInput ---------- + +"------------------------------------------------------------------------------- +" s:SID : Return the <SID>. {{{2 +" +" Parameters: +" - +" Returns: +" SID - the SID of the script (string) +"------------------------------------------------------------------------------- +function! s:SID () + return matchstr ( expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$' ) +endfunction " ---------- end of function s:SID ---------- + +"------------------------------------------------------------------------------- +" s:UserInputEx : ex-command for s:UserInput. {{{2 +"------------------------------------------------------------------------------- +function! s:UserInputEx ( ArgLead, CmdLine, CursorPos ) + if empty( a:ArgLead ) + return copy( s:UserInputList ) + endif + return filter( copy( s:UserInputList ), 'v:val =~ ''\V\<'.escape(a:ArgLead,'\').'\w\*''' ) +endfunction " ---------- end of function s:UserInputEx ---------- +" }}}2 +"------------------------------------------------------------------------------- + "------------------------------------------------------------------------------ " run the regular expression analyzer YAPE::Regex::Explain {{{1 "------------------------------------------------------------------------------ @@ -177,10 +239,10 @@ function! perlsupportregex#Perl_RegexPickFlag ( mode ) normal gvy let s:Perl_PerlRegexVisualizeFlag = eval('@"') else - let s:Perl_PerlRegexVisualizeFlag = Perl_Input("regex modifier(s) [imsxg] : ", s:Perl_PerlRegexVisualizeFlag , '') + let s:Perl_PerlRegexVisualizeFlag = s:UserInput("regex modifier(s) [imsxg] : ", s:Perl_PerlRegexVisualizeFlag , '') endif let s:Perl_PerlRegexVisualizeFlag=substitute(s:Perl_PerlRegexVisualizeFlag, '[^imsxg]', '', 'g') - echomsg "regex modifier(s) : '".s:Perl_PerlRegexVisualizeFlag."'" + echomsg " regex modifier(s) : '".s:Perl_PerlRegexVisualizeFlag."'" endfunction " ---------- end of function perlsupportregex#Perl_RegexPickFlag ---------- " "------------------------------------------------------------------------------ @@ -655,7 +717,6 @@ endfunction " ---------- end of function perlsupportregex#Perl_RegexMatchSev " "------------------------------------------------------------------------------- " read the substitution characters for \n, \t, ... from the command line -" used in ftplugin/perl.vim "------------------------------------------------------------------------------- function! perlsupportregex#Perl_PerlRegexSubstitutions ( string ) let result = a:string diff --git a/awk-support/README.md b/awk-support/README.md index 59af873..cdb56cd 100644 --- a/awk-support/README.md +++ b/awk-support/README.md @@ -1,4 +1,4 @@ -README for awk-support.vim (Version 1.4pre) / June 28 2017 +README for awk-support.vim (Version 1.4pre) / April 19 2019 ================================================================================ * INSTALLATION @@ -56,7 +56,12 @@ structure which is needed below the local installation directory `$HOME/.vim/` This is the minimal content of the file `$HOME/.vimrc`. Create one if there is none or use the files in `$HOME/.vim/awk-support/rc` as a starting point. -(1.3) Set at least some personal details. Use the map `\ntw` inside a Awk buffer +(1.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME/.vim/doc/ + +(1.4) Set at least some personal details. Use the map `\ntw` inside a Awk buffer or the menu entry: Awk -> Snippets -> template setup wizard @@ -75,11 +80,6 @@ structure which is needed below the local installation directory `$HOME/.vim/` (Read more about the template system in the plug-in documentation.) -(1.4) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME/.vim/doc/ - (1.5) Consider additional settings in the file `$HOME/.vimrc`. The files `customization.vimrc` and `customization.gvimrc` are replacements or extensions for your `.vimrc` and `.gvimrc`. You may want to use parts of them. The files @@ -113,7 +113,12 @@ structure which is needed below the local installation directory This is the minimal content of the file `$HOME/_vimrc`. Create one if there is none or use the files in `$HOME/vimfiles/awk-support/rc` as a starting point. -(2.3) Set at least some personal details. Use the map `\ntw` inside a Awk buffer +(2.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME\vimfiles\doc\ + +(2.4) Set at least some personal details. Use the map `\ntw` inside a Awk buffer or the menu entry: Awk -> Snippets -> template setup wizard @@ -132,11 +137,6 @@ structure which is needed below the local installation directory (Read more about the template system in the plug-in documentation.) -(2.4) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME\vimfiles\doc\ - (2.5) Consider additional settings in the file `$HOME/_vimrc`. The files `customization.vimrc` and `customization.gvimrc` are replacements or extensions for your `_vimrc` and `_gvimrc`. You may want to use parts of them. The files @@ -176,14 +176,18 @@ RELEASE NOTES FOR VERSION 1.4pre ---------------------------------------------------------------------- - The templates which are inserted into new files as file skeletons can be specified in the templates library, via the property: - Awk::FileSkeleton::Script -- Add configuration variables 'g:Awk_Ctrl_j' and 'g:Awk_Ctrl_d' to control the - creation of the CTRL+J and CTRL+D maps. -- Rename setting 'g:Awk_Awk' into 'g:Awk_Executable'. - ('g:Awk_Awk' still works for backwards compatibility.) + `Awk::FileSkeleton::Script` +- Use `g:Xterm_Executable`. +- Use `g:Xterm_Options` instead of `g:Awk_XtermDefaults`. The setting + `g:Awk_XtermDefaults` still works for backwards compatibility. +- Add configuration variables `g:Awk_Ctrl_j` and `g:Awk_Ctrl_d` to control the + creation of the `CTRL+J` and `CTRL+D` maps. +- Rename setting `g:Awk_Awk` into `g:Awk_Executable`. + (`g:Awk_Awk` still works for backwards compatibility.) - New and reworked templates. - Minor corrections and improvements. + RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- -> see file `awk-support/doc/ChangeLog` diff --git a/awk-support/README.standalone.md b/awk-support/README.standalone.md index fb54a6c..cf7d039 100644 --- a/awk-support/README.standalone.md +++ b/awk-support/README.standalone.md @@ -3,8 +3,9 @@ Preface This repository is mainly for the use with plug-in managers. -The development happens here: -[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) +Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/awksupport.html). + +The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins). -------------------------------------------------------------------------------- diff --git a/awk-support/codesnippets/rule-file-not-found b/awk-support/codesnippets/rule-file-not-found new file mode 100644 index 0000000..0e9ef51 --- /dev/null +++ b/awk-support/codesnippets/rule-file-not-found @@ -0,0 +1,6 @@ +BEGINFILE { + if ( ERRNO != "" ) { + printf "file not found: %s", FILENAME + nextfile + } +} # ----- end BEGINFILE ----- diff --git a/awk-support/doc/awk-hotkeys.tex b/awk-support/doc/awk-hotkeys.tex index d91cf23..16d6e91 100644 --- a/awk-support/doc/awk-hotkeys.tex +++ b/awk-support/doc/awk-hotkeys.tex @@ -78,7 +78,7 @@ \textbf{\textsc{\Huge{Hot keys}}}\\ \vspace{1mm}% Key mappings for Vim and gVim.\\ -{\tiny \texttt{http://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ +{\tiny \texttt{https://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ \vspace{1.0mm} {\normalsize (i)} insert mode, {\normalsize (n)} normal mode, {\normalsize (v)} visual mode\\ \vspace{1.0mm} diff --git a/awk-support/rc/customization.gvimrc b/awk-support/rc/customization.gvimrc index 5ec7dbd..73ff4d7 100644 --- a/awk-support/rc/customization.gvimrc +++ b/awk-support/rc/customization.gvimrc @@ -1,14 +1,21 @@ -"=================================================================================== -" FILE: .gvimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" VERSION: 1.0 -" CREATED: 19.12.2012 -"=================================================================================== +"=============================================================================== " -"=================================================================================== +" File: customization.gvimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 16.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== " GENERAL SETTINGS -"=================================================================================== +"=============================================================================== + set cmdheight=2 " Make command line two lines high set mousehide " Hide the mouse when typing text @@ -18,39 +25,38 @@ highlight lCursor guibg=Cyan guifg=NONE highlight NonText guibg=grey80 highlight Constant gui=NONE guibg=grey95 highlight Special gui=NONE guibg=grey95 -" + let c_comment_strings=1 " highlight strings inside C comments -" + "------------------------------------------------------------------------------- " Moving cursor to other windows -" -" shift down : change window focus to lower one (cyclic) -" shift up : change window focus to upper one (cyclic) -" shift left : change window focus to one on left -" shift right : change window focus to one on right +" +" shift-down : change window focus to lower one (cyclic) +" shift-up : change window focus to upper one (cyclic) +" shift-left : change window focus to one on left +" shift-right : change window focus to one on right "------------------------------------------------------------------------------- nnoremap <s-down> <c-w>w nnoremap <s-up> <c-w>W nnoremap <s-left> <c-w>h nnoremap <s-right> <c-w>l -" -"------------------------------------------------------------------------------- -" some additional hot keys + "------------------------------------------------------------------------------- -" S-F3 - call gvim file browser +" Some additional hot keys +" +" shift-F3 : call gvim file browser "------------------------------------------------------------------------------- noremap <silent> <s-F3> :silent browse confirm e<CR> inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" + "------------------------------------------------------------------------------- -" toggle insert mode <--> 'normal mode with the <RightMouse>-key +" toggle insert mode <--> normal mode with the <RightMouse>-key "------------------------------------------------------------------------------- -" -nnoremap <RightMouse> <Insert> -inoremap <RightMouse> <ESC> -" + +nnoremap <RightMouse> <Insert> +inoremap <RightMouse> <ESC> + "------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets : ()[]{} +" use font with clearly distinguishable brackets: ()[]{} "------------------------------------------------------------------------------- "set guifont=Luxi\ Mono\ 14 -" diff --git a/awk-support/rc/customization.vimrc b/awk-support/rc/customization.vimrc index d18c5a8..ff9f55b 100644 --- a/awk-support/rc/customization.vimrc +++ b/awk-support/rc/customization.vimrc @@ -1,51 +1,59 @@ -"=================================================================================== -" FILE: .vimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" CREATED: 19.12.2012 -"=================================================================================== +"=============================================================================== " -"=================================================================================== +" File: customization.vimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 15.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== " GENERAL SETTINGS -"=================================================================================== +"=============================================================================== "------------------------------------------------------------------------------- " Use Vim settings, rather then Vi settings. " This must be first, because it changes other options as a side effect. "------------------------------------------------------------------------------- set nocompatible -" + "------------------------------------------------------------------------------- " Enable file type detection. Use the default filetype settings. " Also load indent files, to automatically do language-dependent indenting. "------------------------------------------------------------------------------- filetype plugin on filetype indent on -" + "------------------------------------------------------------------------------- " Switch syntax highlighting on. "------------------------------------------------------------------------------- -syntax on -" +syntax on + +"------------------------------------------------------------------------------- " Platform specific items: " - central backup directory (has to be created) " - default dictionary -" Uncomment your choice. -if has("win16") || has("win32") || has("win64") || +" Uncomment your choice. +" +" Using a backupdir under UNIX/Linux: you may want to include a line similar to: +" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; +" in one of your shell startup files (e.g. $HOME/.profile). +"------------------------------------------------------------------------------- +if has("win16") || has("win32") || has("win64") || \ has("win95") || has("win32unix") - " -" runtime mswin.vim -" set backupdir =$VIM\vimfiles\backupdir -" set dictionary=$VIM\vimfiles\wordlists/german.list +" runtime mswin.vim +" set backupdir =$VIM\vimfiles\backupdir +" set dictionary=$VIM\vimfiles\wordlists/german.list else -" set backupdir =$HOME/.vim.backupdir -" set dictionary=$HOME/.vim/wordlists/german.list +" set backupdir =$HOME/.vim.backupdir +" set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list endif -" -" Using a backupdir under UNIX/Linux: you may want to include a line similar to -" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; -" in one of your shell startup files (e.g. $HOME/.profile) -" + "------------------------------------------------------------------------------- " Various settings "------------------------------------------------------------------------------- @@ -56,12 +64,12 @@ set backspace=indent,eol,start " backspacing over everything in insert mode set backup " keep a backup file set browsedir=current " which directory to use for the file browser set complete+=k " scan the files given with the 'dictionary' option +set formatoptions+=j " remove comment leader when joining lines set history=50 " keep 50 lines of command line history set hlsearch " highlight the last used search pattern set incsearch " do incremental searching set listchars=tab:>.,eol:\$ " strings to use in 'list' mode set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines set popt=left:8pc,right:3pc " print options set ruler " show the cursor position all the time set shiftwidth=2 " number of spaces to use for each step of indent @@ -71,145 +79,149 @@ set tabstop=2 " number of spaces that a <Tab> counts for set visualbell " visual bell instead of beeping set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions set wildmenu " command-line completion in an enhanced mode -" -"=================================================================================== +set nowrap " do not wrap lines + +"------------------------------------------------------------------------------- +" Highlight paired brackets +"------------------------------------------------------------------------------- +"highlight MatchParen ctermbg=blue guibg=lightyellow + +"=============================================================================== " BUFFERS, WINDOWS -"=================================================================================== -" +"=============================================================================== + "------------------------------------------------------------------------------- -" The current directory is the directory of the file in the current window. +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). "------------------------------------------------------------------------------- if has("autocmd") - autocmd BufEnter * :lchdir %:p:h + augroup MyResetCursor + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + augroup END endif -" + "------------------------------------------------------------------------------- -" close window (conflicts with the KDE setting for calling the process manager) +" Change the working directory to the directory containing the current file "------------------------------------------------------------------------------- - noremap <C-Esc> :close<CR> -inoremap <C-Esc> <C-C>:close<CR> -" +if has("autocmd") + augroup MySetLocalDir + autocmd BufEnter * :lchdir %:p:h + augroup END +endif + "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" +"nnoremap <silent> <s-tab> :if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> +"inoremap <silent> <s-tab> <C-C>:if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> + "------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q (KDE): Write all changed buffers and exit Vim +" Leave the editor with Ctrl-q: Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nnoremap <C-q> :wqall<CR> -" -"------------------------------------------------------------------------------- -" When editing a file, always jump to the last known cursor position. -" Don't do it when the position is invalid or when inside an event handler -" (happens when dropping a file on gvim). + "------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif -endif " has("autocmd") +" Some additional hot keys " -"------------------------------------------------------------------------------- -" some additional hot keys -"------------------------------------------------------------------------------- " F2 - write file without confirmation " F3 - call file explorer Ex -" F4 - show tag under curser in the preview window (tagfile must exist!) +" F4 - show tag under cursor in the preview window (tagfile must exist!) " F5 - open quickfix error window " F6 - close quickfix error window " F7 - display previous error -" F8 - display next error -"------------------------------------------------------------------------------- -" -noremap <silent> <F2> :write<CR> -noremap <silent> <F3> :Explore<CR> -nnoremap <silent> <F4> :exe ":ptag ".expand("<cword>")<CR> -noremap <silent> <F5> :copen<CR> -noremap <silent> <F6> :cclose<CR> -noremap <silent> <F7> :cp<CR> -noremap <silent> <F8> :cn<CR> -" -inoremap <silent> <F2> <Esc>:write<CR> -inoremap <silent> <F3> <Esc>:Explore<CR> -inoremap <silent> <F4> <Esc>:exe ":ptag ".expand("<cword>")<CR> -inoremap <silent> <F5> <Esc>:copen<CR> -inoremap <silent> <F6> <Esc>:cclose<CR> -inoremap <silent> <F7> <Esc>:cp<CR> -inoremap <silent> <F8> <Esc>:cn<CR> -" -"------------------------------------------------------------------------------- -" Fast switching between buffers -" The current buffer will be saved before switching to the next one. -" Choose :bprevious or :bnext +" F8 - display next error +" F12 - list buffers and prompt for a buffer name "------------------------------------------------------------------------------- -" - noremap <silent> <s-tab> <Esc>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <Esc>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" -"------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim -"------------------------------------------------------------------------------- -nnoremap <C-q> :wqa<CR> -" -"------------------------------------------------------------------------------- -" comma always followed by a space -"------------------------------------------------------------------------------- -inorenoremap , ,<Space> -" + +noremap <silent> <F2> :write<CR> +noremap <silent> <F3> :Explore<CR> +nnoremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> +noremap <silent> <F5> :copen<CR> +noremap <silent> <F6> :cclose<CR> +noremap <silent> <F7> :cprevious<CR> +noremap <silent> <F8> :cnext<CR> +noremap <F12> :buffer <C-D> +noremap <S-F12> :sbuffer <C-D> + +inoremap <silent> <F2> <Esc>:write<CR> +inoremap <silent> <F3> <Esc>:Explore<CR> +inoremap <silent> <F4> <Esc>:execute ":ptag ".expand("<cword>")<CR> +inoremap <silent> <F5> <Esc>:copen<CR> +inoremap <silent> <F6> <Esc>:cclose<CR> +inoremap <silent> <F7> <Esc>:cprevious<CR> +inoremap <silent> <F8> <Esc>:cnext<CR> +inoremap <F12> <C-C>:buffer <C-D> +inoremap <S-F12> <C-C>:sbuffer <C-D> + "------------------------------------------------------------------------------- -" autocomplete parenthesis, brackets and braces +" Always wrap lines in the quickfix buffer "------------------------------------------------------------------------------- -inoremap ( ()<Left> -inoremap [ []<Left> -inoremap { {}<Left> -" -vnoremap ( s()<Esc>P<Right>% -vnoremap [ s[]<Esc>P<Right>% -vnoremap { s{}<Esc>P<Right>% -" +"autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak + +"=============================================================================== +" AUTOCOMPLETE BRACKETS, QUOTES +"=============================================================================== + "------------------------------------------------------------------------------- -" autocomplete quotes (visual and select mode) +" Autocomplete parenthesis, brackets and braces "------------------------------------------------------------------------------- -xnoremap ' s''<Esc>P<Right> -xnoremap " s""<Esc>P<Right> -xnoremap ` s``<Esc>P<Right> -" + +inoremap ( ()<Left> +inoremap [ []<Left> +inoremap { {}<Left> + +" surround content +vnoremap ( s()<Esc>P<Right>% +vnoremap [ s[]<Esc>P<Right>% +vnoremap { s{}<Esc>P<Right>% + +" surround content with additional spaces +vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% +vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% +vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% + "------------------------------------------------------------------------------- -" Change the working directory to the directory containing the current file +" Autocomplete quotes "------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufEnter * :lchdir %:p:h -endif " has("autocmd") -" -"=================================================================================== + +" surround content (visual and select mode) +vnoremap ' s''<Esc>P<Right> +vnoremap " s""<Esc>P<Right> +vnoremap ` s``<Esc>P<Right> + +"=============================================================================== " VARIOUS PLUGIN CONFIGURATIONS -"=================================================================================== -" +"=============================================================================== + "------------------------------------------------------------------------------- -" awk-support +" AWK-Support +" +" the settings are documented here: +" :help awksupport-custom-variables "------------------------------------------------------------------------------- -" -let tlist_awk_settings = 'awk;f:function;l:label' -" + +"let g:Awk_LoadMenus = 'yes' +"let g:Awk_CreateMenusDelayed = 'no' +"let g:Awk_RootMenu = '&Awk' +"let g:Awk_MapLeader = '\' + +"let g:Awk_InsertFileHeader = 'no' + "------------------------------------------------------------------------------- " taglist.vim : toggle the taglist window -" taglist.vim : define the title texts for make -" taglist.vim : define the title texts for qmake "------------------------------------------------------------------------------- - noremap <silent> <F11> <Esc><Esc>:Tlist<CR> -inoremap <silent> <F11> <Esc><Esc>:Tlist<CR> + noremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> +inoremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> let Tlist_GainFocus_On_ToggleOpen = 1 -let Tlist_Close_On_Select = 1 - - +let Tlist_Close_On_Select = 1 +let tlist_awk_settings = 'awk;f:function;l:label' diff --git a/bash-support/README.md b/bash-support/README.md index 5d81949..56c6165 100644 --- a/bash-support/README.md +++ b/bash-support/README.md @@ -1,4 +1,4 @@ -README for bash-support.vim (Version 4.4pre) / June 22 2017 +README for bash-support.vim (Version 5.0beta) / November 22 2020 ================================================================================ * INSTALLATION @@ -14,7 +14,7 @@ script, starting a debugger can be done with a keystroke. There are many additional hints and options which can improve speed and comfort when writing shell scripts. -This plug-in can be used with Vim version 7.x. +This plug-in can be used with Vim version 7.4+ and Neovim 0.2.1+. -------------------------------------------------------------------------------- @@ -57,12 +57,17 @@ structure which is needed below the local installation directory `$HOME/.vim/` This is the minimal content of the file `$HOME/.vimrc`. Create one if there is none or use the files in `$HOME/.vim/bash-support/rc` as a starting point. -(1.3) Set at least some personal details. Use the map `\ntw` inside a Bash buffer +(1.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME/.vim/doc/ + +(1.4) Set at least some personal details. Use the map `\ntw` inside a Bash buffer or the menu entry: Bash -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): @@ -76,11 +81,6 @@ structure which is needed below the local installation directory `$HOME/.vim/` (Read more about the template system in the plug-in documentation.) -(1.4) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME/.vim/doc/ - (1.5) Consider additional settings in the file `$HOME/.vimrc`. The files `customization.vimrc` and `customization.gvimrc` are replacements or extensions for your `.vimrc` and `.gvimrc`. You may want to use parts of them. The files @@ -92,7 +92,7 @@ structure which is needed below the local installation directory `$HOME/.vim/` The subdirectories in the zip archive `bash-support.zip` mirror the directory structure which is needed below the local installation directory -`$HOME/vimfiles/` (find the value of $HOME with `:echo $HOME` from inside Vim). +`$HOME/vimfiles/` (find the value of `$HOME` with `:echo $HOME` from inside Vim). (2.0) Save the template files in `$HOME/vimfiles/bash-support/templates/Templates` if you have changed any of them. @@ -114,12 +114,17 @@ structure which is needed below the local installation directory This is the minimal content of the file `$HOME/_vimrc`. Create one if there is none or use the files in `$HOME/vimfiles/bash-support/rc` as a starting point. -(2.3) Set at least some personal details. Use the map `\ntw` inside a Bash buffer +(2.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME\vimfiles\doc\ + +(2.4) Set at least some personal details. Use the map `\ntw` inside a Bash buffer or the menu entry: Bash -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): @@ -133,11 +138,6 @@ structure which is needed below the local installation directory (Read more about the template system in the plug-in documentation.) -(2.4) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME\vimfiles\doc\ - (2.5) Consider additional settings in the file `$HOME/_vimrc`. The files `customization.vimrc` and `customization.gvimrc` are replacements or extensions for your `_vimrc` and `_gvimrc`. You may want to use parts of them. The files @@ -155,17 +155,10 @@ There are a lot of features and options which can be used and influenced: * removing the root menu * using additional plug-ins -Look at the Bash Support help with: +Actions differ for different modes. Please read the documentation: :help bashsupport - +-----------------------------------------------+ - | +-------------------------------------------+ | - | | ** Please read the documentation ** | | - | | Actions differ for different modes! | | - | +-------------------------------------------+ | - +-----------------------------------------------+ - Any problems? See the TROUBLESHOOTING section at the end of the help file `doc/bashsupport.txt`. @@ -175,17 +168,35 @@ Any problems? See the TROUBLESHOOTING section at the end of the help file RELEASE NOTES ================================================================================ -RELEASE NOTES FOR VERSION 4.4pre +RELEASE NOTES FOR VERSION 5.0beta ---------------------------------------------------------------------- -- Add shell options and variables for BASH Version 4.4. +- Adapt for running under Neovim more smoothly. +- Add command `:Bash [<args>]` to run the interpreter with arguments. +- Add command `:BashCheck.` the run the syntax checker. +- Add command `:BashDirectRun` to run executable scripts without `g:BASH_Executable`. +- Add command `:BashOutputMethod` to set the output destination for `:Bash`. +- Add command `:BashExecutable` to set the executable during runtime. +- Add output method 'terminal' for running scripts in a terminal window + (requires +terminal). - The templates which are inserted into new files as file skeletons can be specified in the templates library, via the property: - Bash::FileSkeleton::Script -- Add configuration variables 'g:BASH_Ctrl_j' and 'g:BASH_Ctrl_d' to control the - creation of the CTRL+J and CTRL+D maps. -- New and reworked templates. + `Bash::FileSkeleton::Script` +- Use `g:Xterm_Executable`. +- Use `g:Xterm_Options` instead of `g:BASH_XtermDefaults`. The setting + `g:BASH_XtermDefaults` still works for backwards compatibility. +- Add configuration variables `g:BASH_Ctrl_j` and `g:BASH_Ctrl_d` to control the + creation of the `CTRL+J` and `CTRL+D` maps. +- Remove the definition of the maps `CTRL+F9`, `SHIFT+F9`, and `ALT+F9`. + Add them to your filetype plug-in if you want to use them. +- Integration of BashDB moved into the toolbox. +- Add shell options and variables for BASH Version 4.4 and 5.0. - Minor corrections and improvements. +Note: The filetype plug-in has been moved, and is thus not loaded automatically +anymore. Copy it from `bash-support/rc` to `ftplugin`, or add the commands there +to your own filetype plug-in. + + RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- -> see file `bash-support/doc/ChangeLog` @@ -229,10 +240,6 @@ ___The following files and extensions are for convenience only.___ ___bash-support.vim will work without them.___ ___The settings are explained in the files themselves.___ - ftplugin/sh.vim - Suggestion for a filetype plugin: - defines additional maps - ftdetect/template.vim ftplugin/template.vim syntax/template.vim @@ -260,6 +267,10 @@ ___The settings are explained in the files themselves.___ The file is commented. Append it to your .vimrc if you like. + bash-support/rc/sh.vim + Example filetype plug-ins for Bash: + defines additional maps + bash-support/rc/*.templates Sample template files for customization. Used by the template setup wizard. diff --git a/bash-support/README.standalone.md b/bash-support/README.standalone.md index fb54a6c..b3e3d0b 100644 --- a/bash-support/README.standalone.md +++ b/bash-support/README.standalone.md @@ -3,8 +3,29 @@ Preface This repository is mainly for the use with plug-in managers. -The development happens here: -[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) +Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/bashsupport.html). + +The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins). + + +Preview Version +================================================================================ + +___This is a preview version!___ + +Notable new features: + +- Call the Bash interpreter via the command-line: `:Bash <args>`. You can use it + to pass arguments to the script. +- Run Bash in a terminal window directly inside the editor. +- The template library now has shell options and variables for BASH Version 4.4. +- The debugger integration has been move into the toolbox, and comes with + extended functionality. + +The terminal window relies on the new `+terminal` feature, which becomes +available with a patch level of approx. `8.0.1000`. + +_Please read the release notes below._ -------------------------------------------------------------------------------- diff --git a/bash-support/doc/bash-hotkeys.tex b/bash-support/doc/bash-hotkeys.tex index f79bb8e..69baf3b 100644 --- a/bash-support/doc/bash-hotkeys.tex +++ b/bash-support/doc/bash-hotkeys.tex @@ -6,11 +6,11 @@ %% %% Version: see \Pluginversion %% Created: 20.05.2013 -%% Revision: 22.06.2017 +%% Revision: 17.02.2018 %% %% Author: Wolfgang Mehner, wolfgang-mehner@web.de %% (formerly Dr. Fritz Mehner (fgm), mehner.fritz@web.de) -%% Copyright: Copyright (c) 2013-2017, Wolfgang Mehner +%% Copyright: Copyright (c) 2013-2018, Wolfgang Mehner %% %%===================================================================================== @@ -30,7 +30,7 @@ \setlength\parindent{0pt} -\newcommand{\Pluginversion}{4.4pre} +\newcommand{\Pluginversion}{5.0alpha} \newcommand{\ReleaseDate}{\today} \newcommand{\Rep}{{\scriptsize{[n]}}} @@ -77,14 +77,12 @@ \vspace{1mm}% \textbf{\textsc{\Huge{Hot keys}}}\\ \vspace{1mm}% -Key mappings for Vim and gVim.\\ -{\tiny \texttt{http://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ -\vspace{1.0mm} -{\normalsize (i)} insert mode, {\normalsize (n)} normal mode, {\normalsize (v)} visual mode\\ +Key mappings for Vim/gVim/Neovim.\\ +{\tiny \texttt{https://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ \vspace{1.0mm} % %%====================================================================== -%% table, left part [[[1 +%% page 1 / table, left part [[[1 %%====================================================================== %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{60mm}|} @@ -93,95 +91,89 @@ %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{H}elp}}\\[1.0ex] -\hline \verb'\he' & English dictionary \hfill (n,i)\\ -\hline \verb'\hb' & display the Bash manual \hfill (n,i)\\ -\hline \verb'\hh' & help (Bash builtins) \hfill (n,i)\\ -\hline \verb'\hm' & show manual (cmd. line utilities) \hfill (n,i)\\ -\hline \verb'\hp' & help (plug-in) \hfill (n,i)\\ +\hline \verb'\he' & English dictionary \\ +\hline \verb'\hb' & display the Bash manual \\ +\hline \verb'\hh' & help (Bash builtins) \hfill (T)\\ +\hline \verb'\hm' & show manual (cmd. line utilities) \\ +\hline \verb'\hp' & help (plug-in) \\ \hline %%---------------------------------------------------------------------- %% main menu [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{B}ash}}\\[1.0ex] -\hline \verb'\bps' & \textbf{p}arameter \textbf{s}ubstitution (list) \hfill (n, i)\\ -\hline \verb'\bsp' & \textbf{s}pecial \textbf{p}arameters (list) \hfill (n, i)\\ -\hline \verb'\ben' & \textbf{en}vironment (list) \hfill (n, i)\\ -\hline \verb'\bbu' & \textbf{bu}iltins (list) \hfill (n, i)\\ -\hline \verb'\bse' & \textbf{se}t options (list) \hfill (n, i)\\ -\hline \verb'\bso' & \textbf{s}h\textbf{o}pts (list) \hfill (n, i)\\ +\hline \verb'\bps' & \textbf{p}arameter \textbf{s}ubstitution (list) \hfill (T)\\ +\hline \verb'\bsp' & \textbf{s}pecial \textbf{p}arameters (list) \hfill (T)\\ +\hline \verb'\ben' & \textbf{en}vironment (list) \hfill (T)\\ +\hline \verb'\bbu' & \textbf{bu}iltins (list) \hfill (T)\\ +\hline \verb'\bse' & \textbf{se}t options (list) \hfill (T)\\ +\hline \verb'\bso' & \textbf{s}h\textbf{o}pts (list) \hfill (T)\\ \hline %%---------------------------------------------------------------------- %% menu Comments [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{C}omments}} \\[1.0ex] -\hline \Rep\verb'\cl' & end-of-line comment \hfill (n, i, v)\\ -\hline \Rep\verb'\cj' & adjust end-of-line comments \hfill (n, i, v)\\ -\hline \verb'\cs' & set end-of-line comment col. \hfill (n)\\ +\hline \Rep\verb'\cl' & end-of-line comment \hfill (v)\\ +\hline \Rep\verb'\cj' & adjust end-of-line comments \hfill (v)\\ +\hline \verb'\cs' & set end-of-line comment col. \\ % -\hline \Rep\verb'\cc' & code $\rightarrow$ comment \hfill (n, i, v)\\ -\hline \Rep\verb'\co' & uncomment code \hfill (n, i, v)\\ +\hline \Rep\verb'\cc' & code $\rightarrow$ comment \hfill (v)\\ +\hline \Rep\verb'\co' & uncomment code \hfill (v)\\ % -\hline \verb'\cfr' & frame comment \hfill (n, i)\\ -\hline \verb'\cfu' & function description \hfill (n, i)\\ -\hline \verb'\ch' & file header \hfill (n, i)\\ -\hline \verb'\csh' & shebang \hfill (n, i)\\ -\hline \verb'\cd' & date \hfill (n, i)\\ -\hline \verb'\ct' & date \& time \hfill (n, i)\\ +\hline \verb'\cfr' & frame comment \\ +\hline \verb'\cfu' & function description \\ +\hline \verb'\ch' & file header \\ +\hline \verb'\csh' & shebang \\ +\hline \verb'\cd' & date \\ +\hline \verb'\ct' & date \& time \\ \hline \end{tabular}\\ %%~~~~~ TABULAR : end ~~~~~~~~~~ -%% -%\vfill -%% -%\begin{minipage}[b]{75mm}% -%\scriptsize{% -%\vspace{1mm} -%%\hrulefill\\ -% $^1$ {Linux/U**x only} \hspace{3mm} $^2$ {GUI only} -%}% -%\end{minipage}\\ +% ]]]2 % %%====================================================================== -%% table, middle part [[[1 +%% page 1 / table, middle part [[[1 %%====================================================================== %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{60mm}|} +%%---------------------------------------------------------------------- +%% menu Comments [[[2 +%%---------------------------------------------------------------------- \hline - \multicolumn{2}{|r|}{\textsl{\textbf{C}omments (cont)}} \\[1.0ex] -\hline \verb'\css' & script sections \hfill (n, i)\\ -\hline \verb'\ckc' & keyword comments \hfill (n, i)\\ -\hline \verb'\cma' & plug-in macros \hfill (n, i)\\ +\multicolumn{2}{|r|}{\textsl{\textbf{C}omments (cont)}} \\[1.0ex] +\hline \verb'\css' & script sections \hfill (T)\\ +\hline \verb'\ckc' & keyword comments \hfill (T)\\ +\hline \verb'\cma' & plug-in macros \hfill (T)\\ % -\hline \verb'\ce' & \texttt{echo} "\textsl{actual line}" \hfill (n, i)\\ -\hline \verb'\cr' & remove \texttt{echo} from actual line \hfill (n, i)\\ +\hline \verb'\ce' & \texttt{echo} "\textsl{actual line}" \hfill (v)\\ +\hline \verb'\cr' & remove \texttt{echo} from actual line \hfill (v)\\ \hline %%---------------------------------------------------------------------- %% menu Statements [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{S}tatements}} \\[1.0ex] -\hline \verb'\sc' & \verb'case in ... esac' \hfill (n, i)\\ -\hline \verb'\sei' & \verb'elif then' \hfill (n, i)\\ -\hline \verb'\sf' & \verb'for in do done' \hfill (n, i, v)\\ -\hline \verb'\sfo' & \verb'for ((...)) do done' \hfill (n, i, v)\\ -\hline \verb'\si' & \verb'if then fi' \hfill (n, i, v)\\ -\hline \verb'\sie' & \verb'if then else fi' \hfill (n, i, v)\\ -\hline \verb'\ss' & \verb'select in do done' \hfill (n, i, v)\\ -\hline \verb'\su' & \verb'until do done' \hfill (n, i, v)\\ -\hline \verb'\sw' & \verb'while do done' \hfill (n, i, v)\\ -\hline \verb'\sfu' & \verb'function' \hfill (n, i, v)\\ +\hline \verb'\sc' & \verb'case in ... esac' \\ +\hline \verb'\sei' & \verb'elif then' \\ +\hline \verb'\sf' & \verb'for in do done' \hfill (s)\\ +\hline \verb'\sfo' & \verb'for ((...)) do done' \hfill (s)\\ +\hline \verb'\si' & \verb'if then fi' \hfill (s)\\ +\hline \verb'\sie' & \verb'if then else fi' \hfill (s)\\ +\hline \verb'\ss' & \verb'select in do done' \hfill (s)\\ +\hline \verb'\su' & \verb'until do done' \hfill (s)\\ +\hline \verb'\sw' & \verb'while do done' \hfill (s)\\ +\hline \verb'\sfu' & \verb'function' \hfill (s)\\ % -\hline \verb'\se' & \verb'echo -e ""' \hfill (n, i, v)\\ -\hline \verb'\sp' & \verb'printf "%s"' \hfill (n, i, v)\\ +\hline \verb'\se' & \verb'echo -e ""' \hfill (s)\\ +\hline \verb'\sp' & \verb'printf "%s"' \hfill (s)\\ % -\hline \verb'\sae' & array element\ \ \ \verb'${.[.]}' \hfill (n, i, v)\\ -\hline \verb'\saa' & arr. elem.s (all) \ \verb'${.[@]}' \hfill (n, i, v)\\ -\hline \verb'\sas' & arr. elem.s (1 word) \ \verb'${.[*]}' \hfill (n, i, v)\\ -\hline \verb'\ssa' & subarray \ \verb'${.[@]::}' \hfill (n, i, v)\\ -\hline \verb'\san' & no. of arr. elem.s \ \verb'${.[@]}' \hfill (n, i, v)\\ -\hline \verb'\sai' & list of indices \ \verb'${.[*]}' \hfill (n, i, v)\\ +\hline \verb'\sae' & array element\ \ \ \verb'${.[.]}' \hfill (s)\\ +\hline \verb'\saa' & arr. elem.s (all) \ \verb'${.[@]}' \hfill (s)\\ +\hline \verb'\sas' & arr. elem.s (1 word) \ \verb'${.[*]}' \hfill (s)\\ +\hline \verb'\ssa' & subarray \ \verb'${.[@]::}' \hfill (s)\\ +\hline \verb'\san' & no. of arr. elem.s \ \verb'${.[@]}' \hfill (s)\\ +\hline \verb'\sai' & list of indices \ \verb'${.[*]}' \hfill (s)\\ \hline %% %%---------------------------------------------------------------------- @@ -189,32 +181,33 @@ %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{T}ests}} \\[1.0ex] -\hline \verb'\ta' & arithmetic tests \hfill (n, i)\\ -\hline \verb'\tfp' & file permissions \hfill (n, i)\\ -\hline \verb'\tft' & file types \hfill (n, i)\\ -\hline \verb'\tfc' & file characteristics \hfill (n, i)\\ -\hline \verb'\ts' & string comparisons \hfill (n, i)\\ -\hline \verb'\toe' & option is enabled \hfill (n, i)\\ -\hline \verb'\tvs' & variables has been set \hfill (n, i)\\ -\hline \verb'\tfd' & file descr. refers to a terminal \hfill (n, i)\\ -\hline \verb'\tm' & string matches regexp \hfill (n, i)\\ +\hline \verb'\ta' & arithmetic tests \hfill (T)\\ +\hline \verb'\tfp' & file permissions \hfill (T)\\ +\hline \verb'\tft' & file types \hfill (T)\\ +\hline \verb'\tfc' & file characteristics \hfill (T)\\ +\hline \verb'\ts' & string comparisons \hfill (T)\\ +\hline \verb'\toe' & option is enabled \\ +\hline \verb'\tvs' & variables has been set \\ +\hline \verb'\tfd' & file descr. refers to a terminal \\ +\hline \verb'\tm' & string matches regexp \\ \hline %% \end{tabular}\\ %%~~~~~ TABULAR : end ~~~~~~~~~~ +% ]]]2 % %%====================================================================== -%% table, right part [[[1 +%% page 1 / table, right part [[[1 %%====================================================================== %%~~~~~ TABULAR : begin ~~~~~~~~~~ -\begin{tabular}[]{|p{11mm}|p{62mm}|} +\begin{tabular}[]{|p{11mm}|p{60mm}|} %%---------------------------------------------------------------------- %% menu IO-Redirection [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{I}O-Redirection}} \\[1.0ex] -\hline \verb'\ior' & IO-redirections (list) \hfill (n, i)\\ -\hline \verb'\ioh' & here-document \hfill (n, i)\\ +\hline \verb'\ior' & IO-redirections (list) \hfill (T)\\ +\hline \verb'\ioh' & here-document \hfill (s)\\ \hline % %%---------------------------------------------------------------------- @@ -222,13 +215,13 @@ %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{P}attern Matching}} \\[1.0ex] -\hline \verb'pzo' & zero or one, \verb' ?( | )' \hfill (n, i)\\ -\hline \verb'pzm' & zero or more, \verb' *( | )' \hfill (n, i)\\ -\hline \verb'pom' & one or more, \verb' +( | )' \hfill (n, i)\\ -\hline \verb'peo' & exactly one, \verb' @( | )' \hfill (n, i)\\ -\hline \verb'pae' & anything except, \verb' !( | )' \hfill (n, i)\\ -\hline \verb'ppc' & POSIX classes \hfill (n, i)\\ -\hline \verb'pbr' & \verb'${BASH_REMATCH[0'$\ldots$\verb'3]}' \hfill (n, i)\\ +\hline \verb'\pzo' & zero or one, \verb' ?( | )' \hfill (s)\\ +\hline \verb'\pzm' & zero or more, \verb' *( | )' \hfill (s)\\ +\hline \verb'\pom' & one or more, \verb' +( | )' \hfill (s)\\ +\hline \verb'\peo' & exactly one, \verb' @( | )' \hfill (s)\\ +\hline \verb'\pae' & anything except, \verb' !( | )' \hfill (s)\\ +\hline \verb'\ppc' & POSIX classes \hfill (T)\\ +\hline \verb'\pbr' & \verb'${BASH_REMATCH[0'$\ldots$\verb'3]}' \hfill (T)\\ \hline % %%---------------------------------------------------------------------- @@ -236,38 +229,145 @@ %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{S\textbf{n}ippets}} \\[1.0ex] -\hline \verb'\nr' & read code snippet \hfill (n, i)\\ -\hline \verb'\nv' & view code snippet \hfill (n, i)\\ -\hline \verb'\nw' & write code snippet \hfill (n, i, v)\\ -\hline \verb'\ne' & edit code snippet \hfill (n, i)\\ +\hline \verb'\nr' & read code snippet \\ +\hline \verb'\nv' & view code snippet \\ +\hline \verb'\nw' & write code snippet \hfill (v)\\ +\hline \verb'\ne' & edit code snippet \\ % -\hline \verb'\ntl' & edit local templates \hfill (n, i)\\ -\hline \verb'\ntc' & edit custom templates \hfill (n, i)\\ -\hline \verb'\ntp' & edit personal templates \hfill (n, i)\\ -\hline \verb'\ntr' & reread the templates \hfill (n, i)\\ -\hline \verb'\ntw' & template setup wizard \hfill (n, i)\\ -\hline \verb'\nts' & choose style \hfill (n, i)\\ +\hline \verb'\ntl' & edit local templates \\ +\hline \verb'\ntc' & edit custom templates \\ +\hline \verb'\ntp' & edit personal templates \\ +\hline \verb'\ntr' & reread the templates \\ +\hline \verb'\ntw' & template setup wizard \\ +\hline \verb'\nts' & choose style \hfill (T)\\ \hline +\end{tabular}\\[1.0ex] +%%~~~~~ TABULAR : end ~~~~~~~~~~ +% +%%---------------------------------------------------------------------- +%% box Footnotes [[[2 +%%---------------------------------------------------------------------- +\begin{minipage}[b]{72mm}% +\scriptsize{% +all hotkeys work in normal and insert mode \\ +visual mode: {\normalsize (v)} use the range, +{\normalsize (s)} surround range \\ +tab-completion: {\normalsize (T)} specialized, +{\normalsize (F)} filenames +}% +\end{minipage} +% ]]]2 +% +\newpage +% +%%====================================================================== +%% page 2 / table, left part [[[1 +%%====================================================================== +% +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{11mm}|p{60mm}|} %%---------------------------------------------------------------------- %% menu Run [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{R}un}} \\[1.0ex] -\hline \verb'\rr' & update file, run script \hfill (n, i, v)\\ -\hline \verb'\ra' & set script cmd. line arguments \hfill (n, i)\\ -\hline \verb'\rba' & set Bash cmd. line arguments \hfill (n, i)\\ -\hline \verb'\rc' & update file, check syntax \hfill (n, i)\\ -\hline \verb'\rco' & syntax check options \hfill (n, i)\\ -\hline \verb'\rd' & start debugger \hfill (n, i)\\ -\hline \verb'\re' & make script executable/not exec. \hfill (n, i)\\ -\hline \verb'\rh' & hardcopy buffer \hfill (n, i, v)\\ -\hline \verb'\rs' & plug-in settings \hfill (n, i)\\ -\hline \verb'\rx' & set xterm size \hfill (n, i)\\ -\hline \verb'\ro' & change output destination \hfill (n, i)\\ +\hline \verb'\rr' & run script \hfill (v)\\ +\hline \verb'\rsa' & set script cmd. line arguments \hfill (F)\\ +\hline \verb'\ria' & set interp. cmd. line arguments \hfill (F)\\ +\hline \verb'\rk' & check syntax \\ +\hline \verb'\rso' & syntax check options \\ +\hline \verb'\ro' & change output destination \hfill (T)\\ +\hline \verb'\rd' & set ``direct run'' \hfill (T)\\ +\hline \verb'\rse' & set shell executable \hfill (T)\\ +\hline \verb'\rx' & set xterm size \\ +\hline \verb'\re' & make script executable/not exec. \\ +\hline \verb'\rh' & hardcopy buffer \hfill (v)\\ +\hline \verb'\rs' & plug-in settings \\ \hline -\end{tabular}\\ +\hline \verb'\ra' & set script cmd. line arguments \hfill {(\textit{d})}\\ +\hline \verb'\rba' & set interp. cmd. line arguments \hfill {(\textit{d})}\\ +\hline \verb'\rc' & check syntax \hfill {(\textit{d})}\\ +\hline \verb'\rco' & syntax check options \hfill {(\textit{d})}\\ +\hline +%%---------------------------------------------------------------------- +%% buffer "Bash Output" [[[2 +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{Buffer ``Bash Output''}} \\[1.0ex] +\hline \verb'\qf' & load errors into quickfix \\ +\hline \verb'\qj' & load into qf.~and jump to first error \\ +\hline +\end{tabular}\\[1.0ex] %%~~~~~ TABULAR : end ~~~~~~~~~~ % +%%---------------------------------------------------------------------- +%% box Footnotes [[[2 +%%---------------------------------------------------------------------- +\begin{minipage}[b]{72mm}% +\scriptsize{% +{\normalsize (\textit{d})} deprecated, will be removed in next version +}% +\end{minipage} +% ]]]2 +\columnbreak +% +%%====================================================================== +%% page 2 / table, middle part [[[1 +%%====================================================================== +% +%%---------------------------------------------------------------------- +%% Run Bash [[[2 +%%---------------------------------------------------------------------- +\begin{minipage}[b]{72mm}% +\large{\textbf{Run}}\\[1.0ex] +Run \textit{bash} with optional arguments: \\[0.5ex] +\texttt{:Bash [<args>]} \\[1.0ex] +Memorize script arguments: \\[0.5ex] +\texttt{:BashScriptArguments [<args>]} \\[0.5ex] +The memorize arguments are used if \texttt{:Bash} is invoked without arguments. \\[1.0ex] +Set interpreter arguments: \\[0.5ex] +\texttt{:BashInterpArguments [<args>]} +\end{minipage} +\\[2.5ex] +% +%%---------------------------------------------------------------------- +%% Check Syntax [[[2 +%%---------------------------------------------------------------------- +\begin{minipage}[b]{72mm}% +\large{\textbf{Syntax}}\\[1.0ex] +Run syntax checking: \\[0.5ex] +\texttt{:BashCheck} \\[1.0ex] +Set syntax checking options: \\[0.5ex] +\texttt{:BashSyntaxCheckOptions <opts>} +\end{minipage} +\\[2.5ex] +% +%%---------------------------------------------------------------------- +%% Options [[[2 +%%---------------------------------------------------------------------- +\begin{minipage}[b]{72mm}% +\large{\textbf{Options}}\\[1.0ex] +Set the output method: \\[0.5ex] +\texttt{:BashOutputMethod [<method>]} \\[1.0ex] +Set the shell executable: \\[0.5ex] +\texttt{:BashExecutable [<exec>]} \\[1.0ex] +Set ``direct run'': \\[0.5ex] +\texttt{:BashDirectRun [ yes | no ]} \\[0.5ex] +When set to \texttt{yes}, executable scripts will be run as the executable, instead of using \texttt{:BashExecutable}. +\end{minipage} +\\[2.5ex] +% +%%---------------------------------------------------------------------- +%% Debugger [[[2 +%%---------------------------------------------------------------------- +\begin{minipage}[b]{72mm}% +\large{\textbf{BashDB}}\\[1.0ex] +Run the debugger \texttt{bashdb}: \\[0.5ex] +\texttt{:BashDB} \\[1.0ex] +\dots +% TODO +\end{minipage} +% ]]]2 % \end{center}% \end{multicols}% diff --git a/bash-support/rc/customization.gvimrc b/bash-support/rc/customization.gvimrc index f7c64cf..ac5c8ec 100644 --- a/bash-support/rc/customization.gvimrc +++ b/bash-support/rc/customization.gvimrc @@ -1,20 +1,21 @@ "=============================================================================== " " File: customization.gvimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc " -" Description: suggestion for a personal configuration file ~/.gvimrc -" -" VIM Version: 7.0+ -" Author: Dr. Fritz Mehner (fgm), mehner.fritz@web.de -" Version: 1.0 -" Created: 18.05.2013 21:58 -" Revision: --- -" License: Copyright (c) 2013, Dr. Fritz Mehner +" VIM Version: 7.4+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 16.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019-2020, Wolfgang Mehner "=============================================================================== -" + "=============================================================================== " GENERAL SETTINGS "=============================================================================== + set cmdheight=2 " Make command line two lines high set mousehide " Hide the mouse when typing text @@ -24,39 +25,38 @@ highlight lCursor guibg=Cyan guifg=NONE highlight NonText guibg=grey80 highlight Constant gui=NONE guibg=grey95 highlight Special gui=NONE guibg=grey95 -" + let c_comment_strings=1 " highlight strings inside C comments -" + "------------------------------------------------------------------------------- " Moving cursor to other windows -" -" shift down : change window focus to lower one (cyclic) -" shift up : change window focus to upper one (cyclic) -" shift left : change window focus to one on left -" shift right : change window focus to one on right +" +" shift-down : change window focus to lower one (cyclic) +" shift-up : change window focus to upper one (cyclic) +" shift-left : change window focus to one on left +" shift-right : change window focus to one on right "------------------------------------------------------------------------------- nnoremap <s-down> <c-w>w nnoremap <s-up> <c-w>W nnoremap <s-left> <c-w>h nnoremap <s-right> <c-w>l -" -"------------------------------------------------------------------------------- -" some additional hot keys + "------------------------------------------------------------------------------- -" S-F3 - call gvim file browser +" Some additional hot keys +" +" shift-F3 : call gvim file browser "------------------------------------------------------------------------------- noremap <silent> <s-F3> :silent browse confirm e<CR> inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" + "------------------------------------------------------------------------------- -" toggle insert mode <--> 'normal mode with the <RightMouse>-key +" toggle insert mode <--> normal mode with the <RightMouse>-key "------------------------------------------------------------------------------- -" -nnoremap <RightMouse> <Insert> -inoremap <RightMouse> <ESC> -" + +nnoremap <RightMouse> <Insert> +inoremap <RightMouse> <ESC> + "------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets : ()[]{} +" use font with clearly distinguishable brackets: ()[]{} "------------------------------------------------------------------------------- "set guifont=Luxi\ Mono\ 14 -" diff --git a/bash-support/rc/customization.vimrc b/bash-support/rc/customization.vimrc index 9e99bd4..6c5f4d2 100644 --- a/bash-support/rc/customization.vimrc +++ b/bash-support/rc/customization.vimrc @@ -1,18 +1,17 @@ "=============================================================================== " " File: customization.vimrc -" +" " Description: suggestion for a personal configuration file ~/.vimrc -" -" VIM Version: 7.0+ -" Author: Dr. Fritz Mehner (fgm), mehner.fritz@web.de -" Version: 1.0 -" Created: 18.05.2013 21:59 -" Revision: --- -" License: Copyright (c) 2013, Dr. Fritz Mehner +" +" VIM Version: 7.4+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 15.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019-2020, Wolfgang Mehner "=============================================================================== -" "=============================================================================== " GENERAL SETTINGS "=============================================================================== @@ -22,38 +21,39 @@ " This must be first, because it changes other options as a side effect. "------------------------------------------------------------------------------- set nocompatible -" + "------------------------------------------------------------------------------- " Enable file type detection. Use the default filetype settings. " Also load indent files, to automatically do language-dependent indenting. "------------------------------------------------------------------------------- filetype plugin on filetype indent on -" + "------------------------------------------------------------------------------- " Switch syntax highlighting on. "------------------------------------------------------------------------------- -syntax on -" +syntax on + +"------------------------------------------------------------------------------- " Platform specific items: " - central backup directory (has to be created) " - default dictionary -" Uncomment your choice. -if has("win16") || has("win32") || has("win64") || +" Uncomment your choice. +" +" Using a backupdir under UNIX/Linux: you may want to include a line similar to: +" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; +" in one of your shell startup files (e.g. $HOME/.profile). +"------------------------------------------------------------------------------- +if has("win16") || has("win32") || has("win64") || \ has("win95") || has("win32unix") - " -" runtime mswin.vim -" set backupdir =$VIM\vimfiles\backupdir -" set dictionary=$VIM\vimfiles\wordlists/german.list +" runtime mswin.vim +" set backupdir =$VIM\vimfiles\backupdir +" set dictionary=$VIM\vimfiles\wordlists/german.list else -" set backupdir =$HOME/.vim.backupdir -" set dictionary=$HOME/.vim/wordlists/german.list +" set backupdir =$HOME/.vim.backupdir +" set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list endif -" -" Using a backupdir under UNIX/Linux: you may want to include a line similar to -" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; -" in one of your shell startup files (e.g. $HOME/.profile) -" + "------------------------------------------------------------------------------- " Various settings "------------------------------------------------------------------------------- @@ -64,12 +64,12 @@ set backspace=indent,eol,start " backspacing over everything in insert mode set backup " keep a backup file set browsedir=current " which directory to use for the file browser set complete+=k " scan the files given with the 'dictionary' option +set formatoptions+=j " remove comment leader when joining lines set history=50 " keep 50 lines of command line history set hlsearch " highlight the last used search pattern set incsearch " do incremental searching set listchars=tab:>.,eol:\$ " strings to use in 'list' mode set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines set popt=left:8pc,right:3pc " print options set ruler " show the cursor position all the time set shiftwidth=2 " number of spaces to use for each step of indent @@ -79,131 +79,152 @@ set tabstop=2 " number of spaces that a <Tab> counts for set visualbell " visual bell instead of beeping set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions set wildmenu " command-line completion in an enhanced mode -" -"=================================================================================== +set nowrap " do not wrap lines + +"------------------------------------------------------------------------------- +" Highlight paired brackets +"------------------------------------------------------------------------------- +"highlight MatchParen ctermbg=blue guibg=lightyellow + +"=============================================================================== " BUFFERS, WINDOWS -"=================================================================================== -" +"=============================================================================== + "------------------------------------------------------------------------------- -" The current directory is the directory of the file in the current window. +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). "------------------------------------------------------------------------------- if has("autocmd") - autocmd BufNewFile,BufRead * :lchdir %:p:h + augroup MyResetCursor + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + augroup END endif -" + "------------------------------------------------------------------------------- -" close window (conflicts with the KDE setting for calling the process manager) +" Change the working directory to the directory containing the current file "------------------------------------------------------------------------------- - noremap <C-Esc> :close<CR> -inoremap <C-Esc> <C-C>:close<CR> -" +if has("autocmd") + augroup MySetLocalDir + autocmd BufEnter * :lchdir %:p:h + augroup END +endif + "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" +"nnoremap <silent> <s-tab> :if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> +"inoremap <silent> <s-tab> <C-C>:if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> + "------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q (KDE): Write all changed buffers and exit Vim +" Leave the editor with Ctrl-q: Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nnoremap <C-q> :wqall<CR> -" -"------------------------------------------------------------------------------- -" When editing a file, always jump to the last known cursor position. -" Don't do it when the position is invalid or when inside an event handler -" (happens when dropping a file on gvim). + "------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif -endif " has("autocmd") +" Some additional hot keys " -"------------------------------------------------------------------------------- -" some additional hot keys -"------------------------------------------------------------------------------- " F2 - write file without confirmation " F3 - call file explorer Ex -" F4 - show tag under curser in the preview window (tagfile must exist!) +" F4 - show tag under cursor in the preview window (tagfile must exist!) " F5 - open quickfix error window " F6 - close quickfix error window " F7 - display previous error -" F8 - display next error +" F8 - display next error +" F12 - list buffers and prompt for a buffer name "------------------------------------------------------------------------------- -" -noremap <silent> <F2> :write<CR> -noremap <silent> <F3> :Explore<CR> -nnoremap <silent> <F4> :exe ":ptag ".expand("<cword>")<CR> -noremap <silent> <F5> :copen<CR> -noremap <silent> <F6> :cclose<CR> -noremap <silent> <F7> :cp<CR> -noremap <silent> <F8> :cn<CR> -" -inoremap <silent> <F2> <Esc>:write<CR> -inoremap <silent> <F3> <Esc>:Explore<CR> -inoremap <silent> <F4> <Esc>:exe ":ptag ".expand("<cword>")<CR> -inoremap <silent> <F5> <Esc>:copen<CR> -inoremap <silent> <F6> <Esc>:cclose<CR> -inoremap <silent> <F7> <Esc>:cp<CR> -inoremap <silent> <F8> <Esc>:cn<CR> -"------------------------------------------------------------------------------- -" autocomplete parenthesis, brackets and braces -"------------------------------------------------------------------------------- -inoremap ( ()<Left> -inoremap [ []<Left> -inoremap { {}<Left> -" -vnoremap ( s()<Esc>P -vnoremap [ s[]<Esc>P -vnoremap { s{}<Esc>P -" + +noremap <silent> <F2> :write<CR> +noremap <silent> <F3> :Explore<CR> +nnoremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> +noremap <silent> <F5> :copen<CR> +noremap <silent> <F6> :cclose<CR> +noremap <silent> <F7> :cprevious<CR> +noremap <silent> <F8> :cnext<CR> +noremap <F12> :buffer <C-D> +noremap <S-F12> :sbuffer <C-D> + +inoremap <silent> <F2> <Esc>:write<CR> +inoremap <silent> <F3> <Esc>:Explore<CR> +inoremap <silent> <F4> <Esc>:execute ":ptag ".expand("<cword>")<CR> +inoremap <silent> <F5> <Esc>:copen<CR> +inoremap <silent> <F6> <Esc>:cclose<CR> +inoremap <silent> <F7> <Esc>:cprevious<CR> +inoremap <silent> <F8> <Esc>:cnext<CR> +inoremap <F12> <C-C>:buffer <C-D> +inoremap <S-F12> <C-C>:sbuffer <C-D> + +"------------------------------------------------------------------------------- +" Always wrap lines in the quickfix buffer +"------------------------------------------------------------------------------- +"autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak + +"=============================================================================== +" AUTOCOMPLETE BRACKETS, QUOTES +"=============================================================================== + "------------------------------------------------------------------------------- -" autocomplete quotes +" Autocomplete parenthesis, brackets and braces "------------------------------------------------------------------------------- + +inoremap ( ()<Left> +inoremap [ []<Left> +inoremap { {}<Left> + +" surround content +vnoremap ( s()<Esc>P<Right>% +vnoremap [ s[]<Esc>P<Right>% +vnoremap { s{}<Esc>P<Right>% + +" surround content with additional spaces +vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% +vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% +vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% + +"------------------------------------------------------------------------------- +" Autocomplete quotes +"------------------------------------------------------------------------------- + +" surround content (visual and select mode) vnoremap ' s''<Esc>P<Right> vnoremap " s""<Esc>P<Right> vnoremap ` s``<Esc>P<Right> -" -inoremap ' '<Esc>:call QuoteInsertionWrapper("'")<CR>a -inoremap " "<Esc>:call QuoteInsertionWrapper('"')<CR>a -inoremap ` `<Esc>:call QuoteInsertionWrapper('`')<CR>a -" -"------------------------------------------------------------------------------- -" function QuoteInsertionWrapper {{{3 -" -" Add a second quote only if the left and the right character are not keyword -" characters and the right character is not the same quote. -"------------------------------------------------------------------------------- -function! QuoteInsertionWrapper (quote) - let col = col('.') - let line = getline('.') - if ( line[col-2] =~ '\k' ) - \ || ( line[col ] =~ '\k' ) - \ || ( line[col-2] =~ a:quote ) - \ || ( line[col ] =~ a:quote ) - return a:quote - else - return a:quote.a:quote."\<Left>" - endif -endfunction -" + "=============================================================================== " VARIOUS PLUGIN CONFIGURATIONS "=============================================================================== -" + "------------------------------------------------------------------------------- -" plugin bash-support.vim +" Bash-Support +" +" the settings are documented here: +" :help bashsupport-custom-variables "------------------------------------------------------------------------------- -" --empty -- -" + +"let g:BASH_LoadMenus = 'yes' +"let g:BASH_CreateMenusDelayed = 'no' +"let g:BASH_RootMenu = '&Bash' +"let g:BASH_MapLeader = '\' + +"let g:BASH_InsertFileHeader = 'no' + +"let g:BASH_OutputMethod = 'terminal' +"let g:BASH_DirectRun = 'yes' + +"let g:BASH_AlsoBash = [ '*.SlackBuild' , 'rc.*' ] + "------------------------------------------------------------------------------- " taglist.vim : toggle the taglist window "------------------------------------------------------------------------------- - noremap <silent> <F11> <Esc><Esc>:Tlist<CR> -inoremap <silent> <F11> <Esc><Esc>:Tlist<CR> + noremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> +inoremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> +let Tlist_GainFocus_On_ToggleOpen = 1 +let Tlist_Close_On_Select = 1 diff --git a/bash-support/rc/sh.vim b/bash-support/rc/sh.vim index 77762b7..446dd05 100644 --- a/bash-support/rc/sh.vim +++ b/bash-support/rc/sh.vim @@ -1,34 +1,75 @@ -"=============================================================================== +" ------------------------------------------------------------------------------ " -" File: sh.vim -" -" Description: Additonal maps for bash-support (version 4.0+) -" -" VIM Version: 7.0+ -" Author: Dr. Fritz Mehner (fgm), mehner.fritz@web.de -" Version: 1.0 -" Created: 20.05.2013 17:20 -" Revision: --- -" License: Copyright (c) 2013, Dr. Fritz Mehner -"=============================================================================== +" Vim filetype plugin file " -"------------------------------------------------------------------------------- -" additional mapping : single quotes around a Word (non-whitespaces) -" masks the normal mode command '' (jump to the position -" before the latest jump) -" additional mapping : double quotes around a Word (non-whitespaces) -"------------------------------------------------------------------------------- -nnoremap <buffer> '' ciW''<Esc>P -nnoremap <buffer> "" ciW""<Esc>P -" -"------------------------------------------------------------------------------- -" generate tests -" additional mapping : \t1 expands to [ -<CURSOR> ] -" additional mapping : \t2 expands to [ <CURSOR> - ] -"------------------------------------------------------------------------------- -nnoremap <buffer> <silent> <LocalLeader>t1 a[ - ]<Left><Left><Left> -inoremap <buffer> <silent> <LocalLeader>t1 [ - ]<Left><Left><Left> -" -nnoremap <buffer> <silent> <LocalLeader>t2 a[ - ]<Left><Left><Left><Left><Left> -inoremap <buffer> <silent> <LocalLeader>t2 [ - ]<Left><Left><Left><Left><Left> +" Language : Bash +" Plugin : bash-support.vim +" Revision : 08.10.2017 +" Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> +" (formerly Fritz Mehner <mehner.fritz@web.de>) " +" ------------------------------------------------------------------------------ + +" Only do this when not done yet for this buffer +if exists("b:did_bash_support_ftplugin") + finish +endif +let b:did_bash_support_ftplugin = 1 + +" ---------- Avoid a wrong syntax highlighting for $(..) and $((..)) --------- +let b:is_bash = 1 + +" ---------- Key mappings - Quotes ------------------------------------------- +" single quotes around a Word (non-whitespaces) +" masks the normal mode command '' (jump to the position before the latest jump) +" double quotes around a Word (non-whitespaces) +"nnoremap <buffer> '' ciW''<Esc>P +"nnoremap <buffer> "" ciW""<Esc>P + +" ---------- Key mappings - Tests -------------------------------------------- +" additional mapping : \t1 expands to [ -<CURSOR> ] +" additional mapping : \t2 expands to [ <CURSOR> - ] +"nnoremap <buffer> <silent> <LocalLeader>t1 a[ - ]<Left><Left><Left> +"inoremap <buffer> <silent> <LocalLeader>t1 [ - ]<Left><Left><Left> + +"nnoremap <buffer> <silent> <LocalLeader>t2 a[ - ]<Left><Left><Left><Left><Left> +"inoremap <buffer> <silent> <LocalLeader>t2 [ - ]<Left><Left><Left><Left><Left> + +" ---------- Set "maplocalleader" as configured using "g:BASH_MapLeader" ----- +call Bash_SetMapLeader () + +" maps defined here will use "g:BASH_MapLeader" as <LocalLeader> +" example: +"map <buffer> <LocalLeader>eg :echo "Example Map :)"<CR> + +" ---------- Run, compile, code checker -------------------------------------- +nnoremap <buffer> <silent> <C-F9> :Bash<CR> +inoremap <buffer> <silent> <C-F9> <C-C>:Bash<CR> +vnoremap <buffer> <C-F9> :Bash<CR> +" the ex-command :Bash handles the range in visual mode, do not escape via <C-C> + +nnoremap <buffer> <S-F9> :BashScriptArguments<Space> +inoremap <buffer> <S-F9> <C-C>:BashScriptArguments<Space> + +nnoremap <buffer> <A-F9> :BashCheck<CR> +inoremap <buffer> <A-F9> <C-C>:BashCheck<CR> + +" ---------- Debugger -------------------------------------------------------- + +" use F9 to start the debugger +"nnoremap <buffer> <silent> <F9> :BashDB<CR> +"inoremap <buffer> <silent> <F9> <C-C>:BashDB<CR> +"vnoremap <buffer> <silent> <F9> <C-C>:BashDB<CR> + +" map (D)ebugger (R)un +"nnoremap <buffer> <silent> <LocalLeader>dr :BashDB<CR> +"inoremap <buffer> <silent> <LocalLeader>dr <C-C>:BashDB<CR> +"vnoremap <buffer> <silent> <LocalLeader>dr <C-C>:BashDB<CR> +" map (D)ebugger (C)hoose method +"nnoremap <buffer> <LocalLeader>dc :BashDBDebugger<Space> +"inoremap <buffer> <LocalLeader>dc <C-C>:BashDBDebugger<Space> +"vnoremap <buffer> <LocalLeader>dc <C-C>:BashDBDebugger<Space> + +" ---------- Reset "maplocalleader" ------------------------------------------ +call Bash_ResetMapLeader () + diff --git a/bash-support/templates/environment.templates b/bash-support/templates/environment.templates index 8271489..824ce5b 100644 --- a/bash-support/templates/environment.templates +++ b/bash-support/templates/environment.templates @@ -7,6 +7,7 @@ 'BASH_ALIASES', 'BASH_ARGC', 'BASH_ARGV', +'BASH_ARGV0', 'BASH_CMDS', 'BASH_COMMAND', 'BASH_COMPAT', @@ -37,6 +38,8 @@ 'DIRSTACK', 'EMACS', 'ENV', +'EPOCHREALTIME', +'EPOCHSECONDS', 'EUID', 'EXECIGNORE', 'FCEDIT', @@ -59,6 +62,7 @@ 'IFS', 'IGNOREEOF', 'INPUTRC', +'INSIDE_EMACS', 'LANG', 'LC_ALL', 'LC_COLLATE', diff --git a/bash-support/templates/shelloptions.templates b/bash-support/templates/shelloptions.templates index 411cb00..fcda0d0 100644 --- a/bash-support/templates/shelloptions.templates +++ b/bash-support/templates/shelloptions.templates @@ -3,6 +3,7 @@ § ============================================================= == LIST: shopt == list == +'assoc_expand_once', 'autocd', 'cdable_vars', 'cdspell', @@ -16,6 +17,7 @@ 'compat41', 'compat42', 'compat43', +'compat44', 'complete_fullquote', 'direxpand', 'dirspell', @@ -39,6 +41,8 @@ 'interactive_comments', 'lastpipe', 'lithist', +'localvar_inherit', +'localvar_unset', 'login_shell', 'mailwarn', 'no_empty_cmd_completion', @@ -46,6 +50,7 @@ 'nocasematch', 'nullglob', 'progcomp', +'progcomp_alias', 'promptvars', 'restricted_shell', 'shift_verbose', diff --git a/c-support/README.md b/c-support/README.md index aadae84..c13f5b8 100644 --- a/c-support/README.md +++ b/c-support/README.md @@ -1,4 +1,4 @@ -README for c.vim (Version 6.2.1pre) / February 05 2017 +README for c.vim (Version 6.2.1beta) / November 22 2020 ================================================================================ * INSTALLATION @@ -13,9 +13,9 @@ comments, and code snippets. These code fragments are provided in an extendible template library. Syntax checking, compiling, running a program, running indent or code checkers can be done with a keystroke. There are many additional hints and options which can improve speed and comfort when writing C/C++. -See the help file csupport.txt for more information. +See the help file `csupport.txt` for more information. -This plugin can be used with Vim version 7.x. +This plug-in can be used with Vim version 7.x. -------------------------------------------------------------------------------- @@ -26,7 +26,7 @@ INSTALLATION A system-wide installation for all users can also be done. This will have further effects on how the plug-in works. For a step-by-step instruction, as well as an explanation of the other consequences, please see the help file -'doc/csupport.txt' or look up the documentation via: +`doc/csupport.txt` or look up the documentation via: :help csupport-system-wide @@ -34,14 +34,14 @@ well as an explanation of the other consequences, please see the help file (1) LINUX ---------------------------------------------------------------------- -The subdirectories in the zip archive c-support.zip mirror the directory -structure which is needed below the local installation directory $HOME/.vim/ -(find the value of $HOME with `:echo $HOME` from inside Vim). +The subdirectories in the zip archive `c-support.zip` mirror the directory +structure which is needed below the local installation directory `$HOME/.vim/` +(find the value of `$HOME` with `:echo $HOME` from inside Vim). -(1.0) Save the template files in '$HOME/.vim/c-support/templates/Templates' if - you have changed any of them. +(1.0) Save the template files in `$HOME/.vim/c-support/templates/Templates` + if you have changed any of them. -(1.1) Copy the zip archive c-support.zip to $HOME/.vim and run +(1.1) Copy the zip archive `c-support.zip` to `$HOME/.vim` and run unzip c-support.zip @@ -51,19 +51,24 @@ structure which is needed below the local installation directory $HOME/.vim/ $HOME/.vim/doc/... $HOME/.vim/plugin/c.vim -(1.2) Loading of plugin files must be enabled. If not use +(1.2) Loading of plug-in files must be enabled. If not use :filetype plugin on - This is the minimal content of the file '$HOME/.vimrc'. Create one if there - is none or use the files in $HOME/.vim/c-support/rc as a starting point. + This is the minimal content of the file `$HOME/.vimrc`. Create one if there + is none or use the files in `$HOME/.vim/c-support/rc` as a starting point. + +(1.3) Make the plug-in help accessible by typing the following command on the + Vim command line: -(1.3) Set at least some personal details. Use the map \ntw inside a C/C++ buffer + :helptags $HOME/.vim/doc/ + +(1.4) Set at least some personal details. Use the map `\ntw` inside a C/C++ buffer or the menu entry: C/C++ -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): @@ -72,22 +77,17 @@ structure which is needed below the local installation directory $HOME/.vim/ SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/.vim/templates/c.templates to customize or add to your + Use the file `$HOME/.vim/templates/c.templates` to customize or add to your C/C++ template library. It can also be set up via the wizard. - (Read more about the template system in the plugin documentation) - -(1.4) Make the plugin help accessible by typing the following command on the - Vim command line: - - :helptags $HOME/.vim/doc/ + (Read more about the template system in the plug-in documentation) -(1.5) Consider additional settings in the file '$HOME/.vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your .vimrc and .gvimrc. You may want to use parts of them. The files +(1.5) Consider additional settings in the file `$HOME/.vimrc`. The files + `customization.vimrc` and `customization.gvimrc` are replacements or extensions + for your `.vimrc` and `.gvimrc`. You may want to use parts of them. The files are documented. -(1.6) To enable additional tools, add these lines to your '$HOME/.vimrc'. To +(1.6) To enable additional tools, add these lines to your `$HOME/.vimrc`. To enable the CMake and Doxygen tools, use: let g:C_UseTool_cmake = 'yes' @@ -101,14 +101,14 @@ structure which is needed below the local installation directory $HOME/.vim/ (2) WINDOWS ---------------------------------------------------------------------- -The subdirectories in the zip archive c-support.zip mirror the directory -structure which is needed below the local installation directory $HOME/vimfiles/ -(find the value of $HOME with `:echo $HOME` from inside Vim). +The subdirectories in the zip archive `c-support.zip` mirror the directory +structure which is needed below the local installation directory `$HOME/vimfiles/` +(find the value of `$HOME` with `:echo $HOME` from inside Vim). -(2.0) Save the template files in '$HOME/vimfiles/c-support/templates/Templates' if +(2.0) Save the template files in `$HOME/vimfiles/c-support/templates/Templates` if you have changed any of them. -(2.1) Copy the zip archive c-support.zip to $HOME/vimfiles and run +(2.1) Copy the zip archive `c-support.zip` to `$HOME/vimfiles` and run unzip c-support.zip @@ -118,19 +118,24 @@ structure which is needed below the local installation directory $HOME/vimfiles/ $HOME/vimfiles/doc/... $HOME/vimfiles/plugin/c.vim -(2.2) Loading of plugin files must be enabled. If not use +(2.2) Loading of plug-in files must be enabled. If not use :filetype plugin on - This is the minimal content of the file '$HOME/_vimrc'. Create one if there - is none or use the files in $HOME/vimfiles/c-support/rc as a starting point. + This is the minimal content of the file `$HOME/_vimrc`. Create one if there + is none or use the files in `$HOME/vimfiles/c-support/rc` as a starting point. + +(2.3) Make the plug-in help accessible by typing the following command on the + Vim command line: -(2.3) Set at least some personal details. Use the map \ntw inside a C/C++ buffer + :helptags $HOME\vimfiles\doc\ + +(2.4) Set at least some personal details. Use the map `\ntw` inside a C/C++ buffer or the menu entry: C/C++ -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): @@ -139,22 +144,17 @@ structure which is needed below the local installation directory $HOME/vimfiles/ SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/vimfiles/templates/c.templates to customize or add to + Use the file `$HOME/vimfiles/templates/c.templates` to customize or add to your C/C++ template library. It can also be set up via the wizard. - (Read more about the template system in the plugin documentation) - -(2.4) Make the plugin help accessible by typing the following command on the - Vim command line: - - :helptags $HOME\vimfiles\doc\ + (Read more about the template system in the plug-in documentation) -(2.5) Consider additional settings in the file '$HOME/_vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your _vimrc and _gvimrc. You may want to use parts of them. The files +(2.5) Consider additional settings in the file `$HOME/_vimrc`. The files + `customization.vimrc` and `customization.gvimrc` are replacements or extensions + for your `_vimrc` and `_gvimrc`. You may want to use parts of them. The files are documented. -(2.6) To enable additional tools, add these lines to your '$HOME/_vimrc'. To +(2.6) To enable additional tools, add these lines to your `$HOME/_vimrc`. To enable the CMake and Doxygen tools, use: let g:C_UseTool_cmake = 'yes' @@ -164,8 +164,8 @@ structure which is needed below the local installation directory $HOME/vimfiles/ :help csupport-doxygen-enable -(2.7) Make sure the shell is set up correctly. The options 'shell', - 'shellcmdflag', 'shellquote', and 'shellxquote' must be set consistently. +(2.7) Make sure the shell is set up correctly. The options `shell`, + `shellcmdflag`, `shellquote`, and `shellxquote` must be set consistently. Compare `:help csupport-troubleshooting`. @@ -182,19 +182,12 @@ There are a lot of features and options which can be used and influenced: * C/C++ dictionaries for keyword completion * (re)moving the root menu -Look at the C-Support help with: +Actions differ for different modes. Please read the documentation: :help csupport - +-----------------------------------------------+ - | +-------------------------------------------+ | - | | ** PLEASE READ THE DOCUMENTATION ** | | - | | Actions differ for different modes! | | - | +-------------------------------------------+ | - +-----------------------------------------------+ - Any problems? See the TROUBLESHOOTING section at the end of the help file -'doc/csupport.txt'. +`doc/csupport.txt`. -------------------------------------------------------------------------------- @@ -206,11 +199,19 @@ RELEASE NOTES FOR VERSION 6.2.1 ---------------------------------------------------------------------- - The templates which are inserted into new files as file skeletons can be specified in the templates library, via properties: - C::FileSkeleton::Header, Cpp::FileSkeleton::Header, - C::FileSkeleton::Source, Cpp::FileSkeleton::Source -- Fix a problem with the path when setting 'Run->executable to run'. + `C::FileSkeleton::Header`, `Cpp::FileSkeleton::Header`, + `C::FileSkeleton::Source`, `Cpp::FileSkeleton::Source` +- Fix a problem with the path when setting `Run->executable to run`. - New and reworked templates. Change statement templates. +Note: The filetype plug-ins have been moved, and are thus not loaded +automatically anymore. Copy them from `c-support/rc` to `ftplugin`, +or add the commands there to your own filetype plug-ins. + +Note: Some configuration for `*.i`, `*.ii`, and quickfix files has been removed. +See `c-support/rc/customization.vimrc` for how to add them to your configuration +files. + Note: This reworks most of the statement templates. The loop and if templates which do not introduce a block have been remove entirely, since the templates without blocks save barely any typing. They do not make much sense in visual @@ -220,7 +221,7 @@ maps. RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- --> see file 'c-support/doc/ChangeLog' +-> see file `c-support/doc/ChangeLog` -------------------------------------------------------------------------------- @@ -269,12 +270,6 @@ ___The following files and extensions are for convenience only.___ ___c.vim will work without them.___ ___The settings are explained in the files themselves.___ - ftplugin/c.vim - Example filetype plug-in for C/C++: - defines additional maps - ftplugin/make.vim - Access hotkeys for make(1) in makefiles. - ftdetect/template.vim ftplugin/template.vim syntax/template.vim @@ -285,8 +280,6 @@ ___The settings are explained in the files themselves.___ c-support/doc/ChangeLog Complete change log. - c-support/rc/customization.cpp.vim - Additional mappings for C++. c-support/rc/customization.ctags Additional settings for use in .ctags to enable navigation through makefiles and qmake files with the @@ -306,6 +299,13 @@ ___The settings are explained in the files themselves.___ The file is commented. Append it to your .vimrc if you like. + c-support/rc/c.vim + c-support/rc/cpp.vim + Example filetype plug-in for C/C++: + defines additional maps + c-support/rc/make.vim + Access hotkeys for make(1) in makefiles. + c-support/rc/*.templates Sample template files for customization. Used by the template setup wizard. diff --git a/c-support/README.standalone.md b/c-support/README.standalone.md index fb54a6c..65dd0e0 100644 --- a/c-support/README.standalone.md +++ b/c-support/README.standalone.md @@ -3,8 +3,9 @@ Preface This repository is mainly for the use with plug-in managers. -The development happens here: -[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) +Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/csupport.html). + +The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins). -------------------------------------------------------------------------------- diff --git a/c-support/doc/c-hotkeys.tex b/c-support/doc/c-hotkeys.tex index 057e080..248ca63 100644 --- a/c-support/doc/c-hotkeys.tex +++ b/c-support/doc/c-hotkeys.tex @@ -6,7 +6,7 @@ %% %% Version: 1.0 %% Created: 10.11.2006 -%% Revision: none +%% Revision: 03.10.2017 %% %% Author: Wolfgang Mehner, wolfgang-mehner@web.de %% (formerly Dr. Fritz Mehner (fgm), mehner.fritz@web.de) @@ -78,7 +78,7 @@ \textbf{\textsc{\Huge{Hot keys}}}\\ \vspace{1mm}% Key mappings for Vim and gVim.\\ -{\tiny \texttt{http://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ +{\tiny \texttt{https://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ \vspace{1.0mm} {\normalsize (i)} insert mode, {\normalsize (n)} normal mode, {\normalsize (v)} visual mode\\ \vspace{1.0mm} @@ -141,8 +141,8 @@ %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{S}tatements}} \\ -\hline \verb'\sfo' & \verb'for { ; ; }' \hfill \textit{standard} (n,v,i)\\ -\hline \verb'\sfr' & \verb'for { : }' \hfill \textit{range-based} (n,v,i)\\ +\hline \verb'\sfo' & \verb'for ( ; ; )' \hfill \textit{standard} (n,v,i)\\ +\hline \verb'\sfr' & \verb'for ( : )' \hfill \textit{range-based} (n,v,i)\\ \hline \verb'\sd' & \verb'do { } while' \hfill (n,v,i)\\ \hline \verb'\sw' & \verb'while { }' \hfill (n,v,i)\\ \hline \verb'\sif' & \verb'if { }' \hfill (n,v,i)\\ @@ -302,15 +302,15 @@ \hline \verb'\rr' & run \hfill (n,i)\\ \hline \verb'\ra' & set comand line arguments \hfill (n,i)\\ \hline \verb'\rd' & start debugger \hfill (n,i)\\ -\hline \verb'\re' & executable to run$^1$ \hfill (n,i)\\ +\hline \verb'\re' & executable to run \hfill (n,i)\\ % -\hline \verb'\rp' & run \texttt{splint}$^2$ \hfill (n,i)\\ +\hline \verb'\rp' & run \texttt{splint}$^1$ \hfill (n,i)\\ \hline \verb'\rpa' & cmd. line arg. for \texttt{splint} \hfill (n,i)\\ % -\hline \verb'\rcc' & run \texttt{cppcheck}$^3$ \hfill (n,i)\\ +\hline \verb'\rcc' & run \texttt{cppcheck}$^2$ \hfill (n,i)\\ \hline \verb'\rccs'& severity for \texttt{cppcheck} \hfill (n,i)\\ % -\hline \verb'\rk' & run \texttt{ CodeCheck}$^4$ \hfill (n,i)\\ +\hline \verb'\rk' & run \texttt{ CodeCheck}$^3$ \hfill (n,i)\\ \hline \verb'\rka' & cmd. line arg. for \texttt{CodeCheck} \hfill (n,i)\\ % \hline \verb'\ri' & run \texttt{ indent} \hfill (n,i)\\ @@ -330,18 +330,18 @@ %% Tool Box : Make %%---------------------------------------------------------------------- \hline -\multicolumn{2}{|r|}{\textsl{Tool Box : \textbf{M}ake}} \\ -\hline \verb'\rm' & run \texttt{ make}$^1$ \hfill (n,i)\\ -\hline \verb'\rmc' & run \texttt{ make clean}$^1$ \hfill (n,i)\\ -\hline \verb'\rmd' & run \texttt{ make doc}$^1$ \hfill (n,i)\\ -\hline \verb'\rcm' & choose a makefile $^1$ \hfill (n,i)\\ -\hline \verb'\rma' & cmd. line arg. for \texttt{make}$^1$ \hfill (n,i)\\ +\multicolumn{2}{|r|}{\textsl{Tool Box : \textbf{M}ake}$^{4,5}$} \\ +\hline \verb'\rm' & run \texttt{ make} \hfill (n,i)\\ +\hline \verb'\rmc' & run \texttt{ make clean} \hfill (n,i)\\ +\hline \verb'\rmd' & run \texttt{ make doc} \hfill (n,i)\\ +\hline \verb'\rcm' & choose a makefile \hfill (n,i)\\ +\hline \verb'\rma' & cmd. line arg. for \texttt{make} \hfill (n,i)\\ \hline %%---------------------------------------------------------------------- %% Additional mappings %%---------------------------------------------------------------------- \hline -\multicolumn{2}{|r|}{\textbf{Additional Mappings}$^5$}\\ +\multicolumn{2}{|r|}{\textbf{Additional Mappings}$^4$}\\ \hline \hline \textbf{typing}& \textbf{expansion}\\ \hline \verb'/*' & \verb'/* */' \hfill (i)\\ @@ -368,11 +368,11 @@ % \scriptsize{% \hrulefill\\ -$^1$ also working for filetype \textbf{make}\\ -$^2$ \textit{www.splint.org}\\ -$^3$ \textit{cppcheck.sourceforge.net}\\ -$^4$ \textbf{CodeCheck}$^{TM}$ is a product of Abraxas Software, Inc.\\ -$^5$ defined in \verb'~/ftplugin/c.vim' +$^1$ \textit{www.splint.org}\\ +$^2$ \textit{cppcheck.sourceforge.net}\\ +$^3$ \textbf{CodeCheck}$^{TM}$ is a product of Abraxas Software, Inc.\\ +$^4$ see \verb'c-support/rc/c.vim' for how to define them \\ +$^5$ see \verb'c-support/rc/make.vim' for how to define them for filetype \textbf{make} }% % \end{minipage} diff --git a/c-support/rc/c.vim b/c-support/rc/c.vim new file mode 100644 index 0000000..e53c9aa --- /dev/null +++ b/c-support/rc/c.vim @@ -0,0 +1,51 @@ +" ------------------------------------------------------------------------------ +" +" Vim filetype plugin file +" +" Language : C +" Plugin : c.vim +" Revision : 03.10.2017 +" Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> +" (formerly Fritz Mehner <mehner.fritz@web.de>) +" +" ------------------------------------------------------------------------------ + +" Only do this when not done yet for this buffer +if exists("b:did_c_support_ftplugin") + finish +endif +let b:did_c_support_ftplugin = 1 + +" ---------- complete a classical C comment ---------------------------------- +" '/*' => '/* | */' (and surround selected area in visual mode) +"inoremap <buffer> /* /*<Space><Space>*/<Left><Left><Left> +"vnoremap <buffer> /* s/*<Space><Space>*/<Left><Left><Left><Esc>p + +" ---------- complete a classical C multi-line comment ----------------------- +" '/*<CR>' => /* +" * | +" */ +"inoremap <buffer> /*<CR> /*<CR><CR>/<Esc>kA<Space> + +" ---------- {<CR> always opens a block -------------------------------------- +"inoremap <buffer> {<CR> {<CR>}<Esc>O +"vnoremap <buffer> {<CR> S{<CR>}<Esc>Pk=iB + +" ---------- Set "maplocalleader" as configured using "g:C_MapLeader" -------- +call C_SetMapLeader () + +" ---------- Maps for the Make tool ------------------------------------------ + noremap <buffer> <silent> <LocalLeader>rm :Make<CR> +inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> + noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> +inoremap <buffer> <silent> <LocalLeader>rmc <C-C>:Make clean<CR> + noremap <buffer> <silent> <LocalLeader>rmd :Make doc<CR> +inoremap <buffer> <silent> <LocalLeader>rmd <C-C>:Make doc<CR> + noremap <buffer> <LocalLeader>rma :MakeCmdlineArgs<space> +inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> + noremap <buffer> <LocalLeader>rcm :MakeFile<space> +inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> + +" ---------- Reset "maplocalleader" ------------------------------------------ +call C_ResetMapLeader () + diff --git a/c-support/rc/cpp.vim b/c-support/rc/cpp.vim new file mode 100644 index 0000000..3615a13 --- /dev/null +++ b/c-support/rc/cpp.vim @@ -0,0 +1,41 @@ +" ------------------------------------------------------------------------------ +" +" Vim filetype plugin file +" +" Language : C++ +" Plugin : c.vim +" Revision : 03.10.2017 +" Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> +" +" ------------------------------------------------------------------------------ + +" Only do this when not done yet for this buffer +if exists("b:did_c_support_ftplugin") + finish +endif +let b:did_c_support_ftplugin = 1 + +" ---------- C++ I/O (speeds up typing) -------------------------------------- +"inoremap <buffer> >> <Space>>><Space> +"inoremap <buffer> << <Space><<<Space> +"inoremap <buffer> <<" <Space><< ""<Space><Left><Left> +"inoremap <buffer> <<; <Space><< "\n";<Left><Left><Left><Left> + +" ---------- Set "maplocalleader" as configured using "g:C_MapLeader" -------- +call C_SetMapLeader () + +" ---------- Maps for the Make tool ------------------------------------------ + noremap <buffer> <silent> <LocalLeader>rm :Make<CR> +inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> + noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> +inoremap <buffer> <silent> <LocalLeader>rmc <C-C>:Make clean<CR> + noremap <buffer> <silent> <LocalLeader>rmd :Make doc<CR> +inoremap <buffer> <silent> <LocalLeader>rmd <C-C>:Make doc<CR> + noremap <buffer> <LocalLeader>rma :MakeCmdlineArgs<space> +inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> + noremap <buffer> <LocalLeader>rcm :MakeFile<space> +inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> + +" ---------- Reset "maplocalleader" ------------------------------------------ +call C_ResetMapLeader () + diff --git a/c-support/rc/custom.templates b/c-support/rc/custom.templates index 390e493..0e5299d 100644 --- a/c-support/rc/custom.templates +++ b/c-support/rc/custom.templates @@ -9,10 +9,10 @@ SetStyle( 'C' ) § templates automatically included into new files § set the property to an empty string to disable the insertion -§SetProperty ( 'C::FileSkeleton::Header', 'Comments.file description impl' ) -§SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description header' ) -§SetProperty ( 'Cpp::FileSkeleton::Header', 'Comments.file description impl' ) -§SetProperty ( 'Cpp::FileSkeleton::Source', 'Comments.file description header' ) +§SetProperty ( 'C::FileSkeleton::Header', 'Comments.file description header' ) +§SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description impl' ) +§SetProperty ( 'Cpp::FileSkeleton::Header', 'Comments.file description header' ) +§SetProperty ( 'Cpp::FileSkeleton::Source', 'Comments.file description impl' ) § ------------------------------------------------------------- § A template definition is build like this: diff --git a/c-support/rc/custom_with_personal.templates b/c-support/rc/custom_with_personal.templates index d961f59..3c92305 100644 --- a/c-support/rc/custom_with_personal.templates +++ b/c-support/rc/custom_with_personal.templates @@ -36,10 +36,10 @@ SetStyle( 'C' ) § templates automatically included into new files § set the property to an empty string to disable the insertion -§SetProperty ( 'C::FileSkeleton::Header', 'Comments.file description impl' ) -§SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description header' ) -§SetProperty ( 'Cpp::FileSkeleton::Header', 'Comments.file description impl' ) -§SetProperty ( 'Cpp::FileSkeleton::Source', 'Comments.file description header' ) +§SetProperty ( 'C::FileSkeleton::Header', 'Comments.file description header' ) +§SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description impl' ) +§SetProperty ( 'Cpp::FileSkeleton::Header', 'Comments.file description header' ) +§SetProperty ( 'Cpp::FileSkeleton::Source', 'Comments.file description impl' ) § ------------------------------------------------------------- § A template definition is build like this: diff --git a/c-support/rc/customization.cpp.vim b/c-support/rc/customization.cpp.vim deleted file mode 100644 index eb882b2..0000000 --- a/c-support/rc/customization.cpp.vim +++ /dev/null @@ -1,48 +0,0 @@ -" ------------------------------------------------------------------------------ -" -" Vim filetype plugin file -" -" Language : C++ -" Plugin : c.vim -" Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> -" -" ------------------------------------------------------------------------------ -" -" Only do this when not done yet for this buffer -" -if exists("b:did_CPP_ftplugin") - finish -endif -let b:did_CPP_ftplugin = 1 -" -"------------------------------------------------------------------------------- -" additional mapping : C++ I/O -"------------------------------------------------------------------------------- -" -inoremap <buffer> >> <Space>>><Space> -inoremap <buffer> << <Space><<<Space> -inoremap <buffer> <<" <Space><< ""<Space><Left><Left> -inoremap <buffer> <<; <Space><< "\n";<Left><Left><Left><Left> -" -"------------------------------------------------------------------------------- -" set "maplocalleader" as configured using "g:C_MapLeader" -"------------------------------------------------------------------------------- -call C_SetMapLeader () -" -"------------------------------------------------------------------------------- -" additional mapping : Make tool -"------------------------------------------------------------------------------- - noremap <buffer> <silent> <LocalLeader>rm :Make<CR> -inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> - noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> -inoremap <buffer> <silent> <LocalLeader>rmc <C-C>:Make clean<CR> - noremap <buffer> <LocalLeader>rma :MakeCmdlineArgs<space> -inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> - noremap <buffer> <LocalLeader>rcm :MakeFile<space> -inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> -" -"------------------------------------------------------------------------------- -" reset "maplocalleader" -"------------------------------------------------------------------------------- -call C_ResetMapLeader () -" diff --git a/c-support/rc/customization.gvimrc b/c-support/rc/customization.gvimrc index dd90cd5..73ff4d7 100644 --- a/c-support/rc/customization.gvimrc +++ b/c-support/rc/customization.gvimrc @@ -1,14 +1,21 @@ -"=================================================================================== -" FILE: .gvimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" VERSION: 1.0 -" CREATED: 04.04.2009 -"=================================================================================== +"=============================================================================== " -"=================================================================================== +" File: customization.gvimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 16.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== " GENERAL SETTINGS -"=================================================================================== +"=============================================================================== + set cmdheight=2 " Make command line two lines high set mousehide " Hide the mouse when typing text @@ -18,39 +25,38 @@ highlight lCursor guibg=Cyan guifg=NONE highlight NonText guibg=grey80 highlight Constant gui=NONE guibg=grey95 highlight Special gui=NONE guibg=grey95 -" + let c_comment_strings=1 " highlight strings inside C comments -" + "------------------------------------------------------------------------------- " Moving cursor to other windows -" -" shift down : change window focus to lower one (cyclic) -" shift up : change window focus to upper one (cyclic) -" shift left : change window focus to one on left -" shift right : change window focus to one on right -"------------------------------------------------------------------------------- -nmap <s-down> <c-w>w -nmap <s-up> <c-w>W -nmap <s-left> <c-w>h -nmap <s-right> <c-w>l " +" shift-down : change window focus to lower one (cyclic) +" shift-up : change window focus to upper one (cyclic) +" shift-left : change window focus to one on left +" shift-right : change window focus to one on right "------------------------------------------------------------------------------- -" some additional hot keys -"------------------------------------------------------------------------------- -" S-F3 - call gvim file browser +nnoremap <s-down> <c-w>w +nnoremap <s-up> <c-w>W +nnoremap <s-left> <c-w>h +nnoremap <s-right> <c-w>l + "------------------------------------------------------------------------------- - map <silent> <s-F3> :silent browse confirm e<CR> -imap <silent> <s-F3> <Esc>:silent browse confirm e<CR> +" Some additional hot keys " +" shift-F3 : call gvim file browser "------------------------------------------------------------------------------- -" toggle insert mode <--> 'normal mode with the <RightMouse>-key + noremap <silent> <s-F3> :silent browse confirm e<CR> +inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> + "------------------------------------------------------------------------------- -" -nmap <RightMouse> <Insert> -imap <RightMouse> <ESC> -" +" toggle insert mode <--> normal mode with the <RightMouse>-key "------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets : ()[]{} + +nnoremap <RightMouse> <Insert> +inoremap <RightMouse> <ESC> + +"------------------------------------------------------------------------------- +" use font with clearly distinguishable brackets: ()[]{} "------------------------------------------------------------------------------- "set guifont=Luxi\ Mono\ 14 -" diff --git a/c-support/rc/customization.vimrc b/c-support/rc/customization.vimrc index b9735db..e03884f 100644 --- a/c-support/rc/customization.vimrc +++ b/c-support/rc/customization.vimrc @@ -1,51 +1,59 @@ -"=================================================================================== -" FILE: .vimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" CREATED: 04.04.2009 -"=================================================================================== +"=============================================================================== " -"=================================================================================== +" File: customization.vimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 15.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== " GENERAL SETTINGS -"=================================================================================== +"=============================================================================== "------------------------------------------------------------------------------- " Use Vim settings, rather then Vi settings. " This must be first, because it changes other options as a side effect. "------------------------------------------------------------------------------- set nocompatible -" + "------------------------------------------------------------------------------- " Enable file type detection. Use the default filetype settings. " Also load indent files, to automatically do language-dependent indenting. "------------------------------------------------------------------------------- filetype plugin on filetype indent on -" + "------------------------------------------------------------------------------- " Switch syntax highlighting on. "------------------------------------------------------------------------------- -syntax on -" +syntax on + +"------------------------------------------------------------------------------- " Platform specific items: " - central backup directory (has to be created) " - default dictionary -" Uncomment your choice. -if has("win16") || has("win32") || has("win64") || +" Uncomment your choice. +" +" Using a backupdir under UNIX/Linux: you may want to include a line similar to: +" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; +" in one of your shell startup files (e.g. $HOME/.profile). +"------------------------------------------------------------------------------- +if has("win16") || has("win32") || has("win64") || \ has("win95") || has("win32unix") - " -" runtime mswin.vim -" set backupdir =$VIM\vimfiles\backupdir -" set dictionary=$VIM\vimfiles\wordlists/german.list +" runtime mswin.vim +" set backupdir =$VIM\vimfiles\backupdir +" set dictionary=$VIM\vimfiles\wordlists/german.list else -" set backupdir =$HOME/.vim.backupdir -" set dictionary=$HOME/.vim/wordlists/german.list +" set backupdir =$HOME/.vim.backupdir +" set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list endif -" -" Using a backupdir under UNIX/Linux: you may want to include a line similar to -" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; -" in one of your shell startup files (e.g. $HOME/.profile) -" + "------------------------------------------------------------------------------- " Various settings "------------------------------------------------------------------------------- @@ -56,12 +64,12 @@ set backspace=indent,eol,start " backspacing over everything in insert mode set backup " keep a backup file set browsedir=current " which directory to use for the file browser set complete+=k " scan the files given with the 'dictionary' option +set formatoptions+=j " remove comment leader when joining lines set history=50 " keep 50 lines of command line history set hlsearch " highlight the last used search pattern set incsearch " do incremental searching set listchars=tab:>.,eol:\$ " strings to use in 'list' mode set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines set popt=left:8pc,right:3pc " print options set ruler " show the cursor position all the time set shiftwidth=2 " number of spaces to use for each step of indent @@ -71,151 +79,156 @@ set tabstop=2 " number of spaces that a <Tab> counts for set visualbell " visual bell instead of beeping set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions set wildmenu " command-line completion in an enhanced mode -" -"=================================================================================== +set nowrap " do not wrap lines + +"------------------------------------------------------------------------------- +" Highlight paired brackets +"------------------------------------------------------------------------------- +"highlight MatchParen ctermbg=blue guibg=lightyellow + +"=============================================================================== " BUFFERS, WINDOWS -"=================================================================================== -" +"=============================================================================== + "------------------------------------------------------------------------------- -" The current directory is the directory of the file in the current window. +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). "------------------------------------------------------------------------------- if has("autocmd") - autocmd BufEnter * :lchdir %:p:h + augroup MyResetCursor + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + augroup END endif -" + "------------------------------------------------------------------------------- -" close window (conflicts with the KDE setting for calling the process manager) +" Change the working directory to the directory containing the current file "------------------------------------------------------------------------------- - noremap <C-Esc> :close<CR> -inoremap <C-Esc> <C-C>:close<CR> -" +if has("autocmd") + augroup MySetLocalDir + autocmd BufEnter * :lchdir %:p:h + augroup END +endif + "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" +"nnoremap <silent> <s-tab> :if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> +"inoremap <silent> <s-tab> <C-C>:if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> + "------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q (KDE): Write all changed buffers and exit Vim +" Leave the editor with Ctrl-q: Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nnoremap <C-q> :wqall<CR> -" -"------------------------------------------------------------------------------- -" When editing a file, always jump to the last known cursor position. -" Don't do it when the position is invalid or when inside an event handler -" (happens when dropping a file on gvim). + "------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif -endif " has("autocmd") +" Some additional hot keys " -"------------------------------------------------------------------------------- -" some additional hot keys -"------------------------------------------------------------------------------- " F2 - write file without confirmation " F3 - call file explorer Ex -" F4 - show tag under curser in the preview window (tagfile must exist!) +" F4 - show tag under cursor in the preview window (tagfile must exist!) " F5 - open quickfix error window " F6 - close quickfix error window " F7 - display previous error -" F8 - display next error -"------------------------------------------------------------------------------- -" -map <silent> <F2> :write<CR> -map <silent> <F3> :Explore<CR> -nmap <silent> <F4> :exe ":ptag ".expand("<cword>")<CR> -map <silent> <F5> :copen<CR> -map <silent> <F6> :cclose<CR> -map <silent> <F7> :cp<CR> -map <silent> <F8> :cn<CR> -" -imap <silent> <F2> <Esc>:write<CR> -imap <silent> <F3> <Esc>:Explore<CR> -imap <silent> <F4> <Esc>:exe ":ptag ".expand("<cword>")<CR> -imap <silent> <F5> <Esc>:copen<CR> -imap <silent> <F6> <Esc>:cclose<CR> -imap <silent> <F7> <Esc>:cp<CR> -imap <silent> <F8> <Esc>:cn<CR> -" -"------------------------------------------------------------------------------- -" Fast switching between buffers -" The current buffer will be saved before switching to the next one. -" Choose :bprevious or :bnext +" F8 - display next error +" F12 - list buffers and prompt for a buffer name "------------------------------------------------------------------------------- -" - map <silent> <s-tab> <Esc>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -imap <silent> <s-tab> <Esc>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" -"------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim -"------------------------------------------------------------------------------- -nmap <C-q> :wqa<CR> -" -"------------------------------------------------------------------------------- -" comma always followed by a space -"------------------------------------------------------------------------------- -inoremap , ,<Space> -" + +noremap <silent> <F2> :write<CR> +noremap <silent> <F3> :Explore<CR> +nnoremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> +noremap <silent> <F5> :copen<CR> +noremap <silent> <F6> :cclose<CR> +noremap <silent> <F7> :cprevious<CR> +noremap <silent> <F8> :cnext<CR> +noremap <F12> :buffer <C-D> +noremap <S-F12> :sbuffer <C-D> + +inoremap <silent> <F2> <Esc>:write<CR> +inoremap <silent> <F3> <Esc>:Explore<CR> +inoremap <silent> <F4> <Esc>:execute ":ptag ".expand("<cword>")<CR> +inoremap <silent> <F5> <Esc>:copen<CR> +inoremap <silent> <F6> <Esc>:cclose<CR> +inoremap <silent> <F7> <Esc>:cprevious<CR> +inoremap <silent> <F8> <Esc>:cnext<CR> +inoremap <F12> <C-C>:buffer <C-D> +inoremap <S-F12> <C-C>:sbuffer <C-D> + "------------------------------------------------------------------------------- -" autocomplete parenthesis, brackets and braces +" Always wrap lines in the quickfix buffer "------------------------------------------------------------------------------- -inoremap ( ()<Left> -inoremap [ []<Left> -inoremap { {}<Left> -" -vnoremap ( s()<Esc>P<Right>% -vnoremap [ s[]<Esc>P<Right>% -vnoremap { s{}<Esc>P<Right>% -" +"autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak + +"=============================================================================== +" AUTOCOMPLETE BRACKETS, QUOTES +"=============================================================================== + "------------------------------------------------------------------------------- -" autocomplete quotes (visual and select mode) +" Autocomplete parenthesis, brackets and braces "------------------------------------------------------------------------------- -xnoremap ' s''<Esc>P<Right> -xnoremap " s""<Esc>P<Right> -xnoremap ` s``<Esc>P<Right> -" + +inoremap ( ()<Left> +inoremap [ []<Left> +inoremap { {}<Left> + +" surround content +vnoremap ( s()<Esc>P<Right>% +vnoremap [ s[]<Esc>P<Right>% +vnoremap { s{}<Esc>P<Right>% + +" surround content with additional spaces +vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% +vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% +vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% + "------------------------------------------------------------------------------- -" Change the working directory to the directory containing the current file +" Autocomplete quotes "------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufEnter * :lchdir %:p:h -endif " has("autocmd") -" -"=================================================================================== + +" surround content (visual and select mode) +vnoremap ' s''<Esc>P<Right> +vnoremap " s""<Esc>P<Right> +vnoremap ` s``<Esc>P<Right> + +"=============================================================================== " VARIOUS PLUGIN CONFIGURATIONS -"=================================================================================== -" +"=============================================================================== + "------------------------------------------------------------------------------- -" c.vim +" C-Support +" +" the settings are documented here: +" :help csupport-custom "------------------------------------------------------------------------------- -" -" --empty -- -" + +" use C syntax highlightinh for *.i ; use CPP for *.ii +"augroup MyFiletypeAdjust +"autocmd BufNewFile,BufReadPost *.i set filetype=c +"autocmd BufNewFile,BufReadPost *.ii set filetype=cpp +"augroup END + "------------------------------------------------------------------------------- " taglist.vim : toggle the taglist window " taglist.vim : define the title texts for make " taglist.vim : define the title texts for qmake "------------------------------------------------------------------------------- - noremap <silent> <F11> <Esc><Esc>:Tlist<CR> -inoremap <silent> <F11> <Esc><Esc>:Tlist<CR> + noremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> +inoremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> let Tlist_GainFocus_On_ToggleOpen = 1 -let Tlist_Close_On_Select = 1 +let Tlist_Close_On_Select = 1 let tlist_make_settings = 'make;v:variables;t:targets;i:includes' let tlist_qmake_settings = 'qmake;t:SystemVariables' -if has("autocmd") - " ---------- qmake : set filetype for *.pro ---------- - autocmd BufNewFile,BufRead *.pro set filetype=qmake -endif " has("autocmd") - +" qmake : set filetype for *.pro +"augroup MyFiletypeAdjust +"autocmd BufNewFile,BufRead *.pro set filetype=qmake +"augroup END diff --git a/ftplugin/make.vim b/c-support/rc/make.vim similarity index 80% rename from ftplugin/make.vim rename to c-support/rc/make.vim index 7f8c27d..a1afd27 100644 --- a/ftplugin/make.vim +++ b/c-support/rc/make.vim @@ -3,8 +3,8 @@ " Vim filetype plugin file " " Language : Make -" Plugin : c.vim / latex.vim / ... -" Revision : 15.04.2017 +" Plugin : c.vim / latex-support.vim / ... +" Revision : 03.10.2017 " Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> " (formerly Fritz Mehner <mehner.fritz@web.de>) " @@ -16,8 +16,10 @@ if exists("b:did_c_support_make") endif let b:did_c_support_make = 1 -" ---------- Maps for the Make tool ----------------------------- -" +" ---------- Set "maplocalleader" as configured using "g:C_MapLeader" -------- +"call C_SetMapLeader () + +" ---------- Maps for the Make tool ------------------------------------------ noremap <buffer> <silent> <LocalLeader>rm :Make<CR> inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> @@ -28,4 +30,7 @@ inoremap <buffer> <silent> <LocalLeader>rmd <C-C>:Make doc<CR> inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> noremap <buffer> <LocalLeader>rcm :MakeFile<space> inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> -" + +" ---------- Reset "maplocalleader" ------------------------------------------ +"call C_ResetMapLeader () + diff --git a/c-support/templates/Templates b/c-support/templates/Templates index c18915d..32fd2e1 100644 --- a/c-support/templates/Templates +++ b/c-support/templates/Templates @@ -26,10 +26,10 @@ SetStyle( 'C' ) § templates automatically included into new files § set the property to an empty string to disable the insertion -SetProperty ( 'C::FileSkeleton::Header', 'Comments.file description impl' ) -SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description header' ) -SetProperty ( 'Cpp::FileSkeleton::Header', 'Comments.file description impl' ) -SetProperty ( 'Cpp::FileSkeleton::Source', 'Comments.file description header' ) +SetProperty ( 'C::FileSkeleton::Header', 'Comments.file description header' ) +SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description impl' ) +SetProperty ( 'Cpp::FileSkeleton::Header', 'Comments.file description header' ) +SetProperty ( 'Cpp::FileSkeleton::Source', 'Comments.file description impl' ) § ========================================================== § File Includes and Shortcuts diff --git a/c-support/templates/c.idioms.template b/c-support/templates/c.idioms.template index 73c8fd7..220c347 100644 --- a/c-support/templates/c.idioms.template +++ b/c-support/templates/c.idioms.template @@ -31,7 +31,7 @@ static void<CURSOR> * Description: * ===================================================================================== */ -int + int main ( int argc, char *argv[] ) {<CURSOR> <SPLIT> return EXIT_SUCCESS; diff --git a/doc/awksupport.txt b/doc/awksupport.txt index d2890f8..9fbeff3 100644 --- a/doc/awksupport.txt +++ b/doc/awksupport.txt @@ -1,4 +1,4 @@ -*awksupport.txt* Awk Support Jun 28 2017 +*awksupport.txt* Awk Support Apr 19 2019 Awk Support *awk-support* *awksupport* @@ -379,8 +379,8 @@ For convenience consider to use maps like > noremap <silent> <F5> :copen<CR> noremap <silent> <F6> :cclose<CR> - noremap <silent> <F7> :cp<CR> - noremap <silent> <F8> :cn<CR> + noremap <silent> <F7> :cprevious<CR> + noremap <silent> <F8> :cnext<CR> < in your .vimrc file to jump to the error locations (F7,F8) and to open and close the error window (F5,F6). This makes navigation a lot easier (see also @@ -495,7 +495,7 @@ value. Possible values are 'vim', 'buffer' and 'xterm'. Vim (non-GUI) : The output destination can be toggled between (1) and (2) using the hotkey \ro . -The xterm defaults can be set in .vimrc by the variable g:Awk_XtermDefaults . +The xterm defaults can be set in .vimrc by the variable g:Xterm_Options . The default is "-fa courier -fs 12 -geometry 80x24" : font name : -fa courier font size : -fs 12 @@ -711,6 +711,9 @@ g:Awk_Printheader '%<%f%h%m%< %=%{strftime('%x %X')} Page %N' 'vim.exe' (Windows) g:Awk_MapLeader '\' +g:Xterm_Executable 'xterm' +g:Xterm_Options '-fa courier -fs 12 -geometry 80x24' + ------------------------------------------------------------------------------ Global Variable Description ------------------------------------------------------------------------------ @@ -734,6 +737,9 @@ g:Awk_LineEndCommColDefault default starting column for line end comments g:Awk_Printheader hardcopy header format g:Awk_MapLeader the map leader for hotkeys (see|awksupport-usage-vim|) +g:Xterm_Executable The xterm executable (see |awksupport-xterm|). +g:Xterm_Options The xterm options (see |awksupport-xterm|). + To override the defaults add appropriate assignments in '.vimrc', e.g. > let g:Awk_MapLeader = ',' diff --git a/doc/bashdbintegration.txt b/doc/bashdbintegration.txt new file mode 100644 index 0000000..7a5ad59 --- /dev/null +++ b/doc/bashdbintegration.txt @@ -0,0 +1,261 @@ +*bashdbintegration.txt* BashDB Integration Oct 08 2017 + +BashDB Integration *bashdb-integration* + + Plug-in version 0.5 + for Vim version 7.0 and above + Wolfgang Mehner <wolfgang-mehner at web.de> + +The BashDB integration can run bashdb inside Vim/gVim. It is modelled after +the GDB integration |:Termdebug|. + +============================================================================== +0. TABLE OF CONTENTS *bashdb-integration-contents* +============================================================================== + + 1. Introduction |bashdb-integration-intro| + 2. Commands |bashdb-integration-commands| + 2.1 Debugger Integration |bashdb-integration-db-control| + 3. Configuration |bashdb-integration-config| + + A. Change Log |bashdb-integration-change-log| + +============================================================================== +1. INTRODUCTION *bashdb-integration-intro* +============================================================================== + +This tool starts the debugger 'bashdb' or the frontend 'ddd'. Your version of +the bash must be prepared for debugging and the debugger must be installed +(see http://bashdb.sourceforge.net/). When Vim is compiled with the |+terminal| +feature, the debugger can be run inside the editor. + +The debugger can be run right inside Vim (requires |+terminal|), by setting > + :BashDBDebugger integrated +and then starting the debugging for the script in the current buffer via > + :BashDB [<args>] +The optional arguments are passed on the debugged script. + +The output is split into two terminal windows. The debugging can be controlled +from the buffer containing the script. E.g. breakpoints can be set for the +line under the cursor. + +Furthermore, the debugger can be run in a terminal window, but without further +integration > + :BashDBDebugger terminal +or in a separate xterm > + :BashDBDebugger xterm +or in the frontend ddd > + :BashDBDebugger ddd +< +The debugger integration is controlled via a number of ex-commands, see below. + + Command Short Description + ---------------------------------------------------------------------------- + |:BashDB| [<args>] run the debugger + |:BashDBCommand| [<args>] send a command to the debugger + (only with the method "integrated") + + |:BashDBDebugger| <method> set the debugging method: + ddd, terminal, xterm, or integrated + |:BashDBExecutable| <exec> set the debugger executable: + bashdb, zshdb, ... + + |:BashDBSettings| shows the plug-in settings + |:BashDBHelp| help for the BashDB integration + ---------------------------------------------------------------------------- + +Detailed explanations are given in the section |bashdb-integration-commands|. + +============================================================================== +2. COMMANDS *bashdb-integration-commands* +============================================================================== + +This chapter provides detailed explanations of all the commands. + +------------------------------------------------------------------------------ + *:BashDB* + :BashDB [<args>] ~ + +Run the debugger for the script in the current buffer. The arguments are +passed to the script. + +Cooperates with |bash-support|. When arguments are set for the current buffer +via |:BashScriptArguments| and none are given on the command line, then the +arguments set with Bash Support are passed to the script. + +------------------------------------------------------------------------------ + *:BashDBDebugger* + :BashDBDebugger <method> ~ + :BashDBDebugger! ~ + +Set the debugging method. The 2nd version echoes the current method. + +The method "integrated" runs the debugger inside Vim. This enables further +commands to control the compiler, see |bashdb-integration-db-control|. + +The method "terminal" runs the debugger in a terminal window, but without +further integration. + +The other two methods are mostly for backwards compatibility with the old +debugger features of |bash-support| (before version 4.4). + + Method Short Description + ---------------------------------------------------------------------------- + integrated Run in integrated mode. + terminal Run in a |terminal| window. + xterm Run bashdb in an external xterm. + ddd Run in DDD. + ---------------------------------------------------------------------------- + +Set the default using |g:BashDB_Debugger|. + +------------------------------------------------------------------------------ + *:BashDBExecutable* + :BashDBExecutable <exec> ~ + :BashDBExecutable! ~ + +Set the debugger executable. The 2nd version echoes the current executable. + +This look peculiar, but sort of works: > + :BashDBExecutable zshdb +Use bashdb again: > + :BashDBExecutable bashdb +< +Set the default using |g:BashDB_Executable|. + +------------------------------------------------------------------------------ + *:BashDBHelp* + :BashDBHelp ~ + +Open the help for the BashDB integration. + +------------------------------------------------------------------------------ + *:BashDBSettings* + :BashDBSettings ~ + :BashDBSettings! ~ + +Show the plug-in settings. The second version is verbose. + +------------------------------------------------------------------------------ +2.1 DEBUGGER INTEGRATION *bashdb-integration-db-control* +------------------------------------------------------------------------------ + +When running the integrated debugger, various commands can be used to send +control commands to it. + +------------------------------------------------------------------------------ + *:BashDBCommand* + :BashDBCommand [<args>] ~ + +Send the command to the debugger. Since you can enter commands in the debugger +buffer itself, this is mainly for creating mappings, e.g.: + +Use CTRL-d t to display a backtrace, and CTRL-d ib to list the breakpoints: > + :nnoremap <buffer> <c-d>t :BashDBCommand backtrace<CR> + :nnoremap <buffer> <c-d>ib :BashDBCommand info breakpoints<CR> +These maps should be placed in the shell filetype plug-in "ftplugin/sh.vim". + +------------------------------------------------------------------------------ + +These commands are only available while running the debugger, and only in the +buffer from which the debugger was started. + +Sends the "continue" and "step" commands: + :Continue ~ + :Step ~ + +Set a breakpoint for the line under the cursor ("!" for a one-time breakpoint): + :Break ~ + :Break! ~ +Add the variable under the cursor to the "display" list: + :Display ~ + +These commands can also be used to create custom mappings, e.g.: + +Use CTRL-d s to step, CTRL-d c to continue, and CTRL-d b to set a breakpoints: > + :nnoremap <buffer> <c-d>s :Step<CR> + :nnoremap <buffer> <c-d>c :Continue<CR> + :nnoremap <buffer> <c-d>b :Break<CR> +These maps should be placed in the shell filetype plug-in "ftplugin/sh.vim". + +============================================================================== +3. CONFIGURATION *bashdb-integration-config* +============================================================================== + +The tool is configured via a number of global variables, which can be set in +the .vimrc file. + + Variable Default Description and further information + ---------------------------------------------------------------------------- + |g:BashDB_Debugger| 'xterm' the debugging method + |g:BashDB_Executable| 'bashdb' the debugger executable + |g:BashDB_DDD_Exec| 'ddd' the DDD executable + + g:Xterm_Executable 'xterm' the xterm executable (^1) + g:Xterm_Options '...' the xterm default settings (^1) + + g:BASH_Debugger n/a the method, deprecated (^2) + g:BASH_bashdb n/a the executable, deprecated (^2) + ---------------------------------------------------------------------------- + +(^1) UNIX only, see |bashdb-integration-xterm| +(^2) *g:BASH_Debugger* and *g:BASH_bashdb* are deprecated, and only included +for backwards compatibility with the old debugger features of |bash-support| +(before version 4.4) + +------------------------------------------------------------------------------ + *g:BashDB_Debugger* +The default debugging method is set by g:BashDB_Debugger: > + let g:BashDB_Debugger = 'integrated' +< +The possible settings are listed below: + + Value Short Description + ---------------------------------------------------------------------------- + integrated Run in integrated mode. + terminal Run in a |terminal| window. + xterm Run bashdb in an external xterm. + ddd Run in DDD. + ---------------------------------------------------------------------------- + +------------------------------------------------------------------------------ + *g:BashDB_Executable* *g:BashDB_DDD_Exec* +The debugger executable is set by g:BashDB_Executable: > + let g:BashDB_Executable = 'zshdb' +< +The debugger executable is set by g:BashDB_DDD_Exec: > + let g:BashDB_DDD_Exec = '/usr/local/bin/ddd' +< +------------------------------------------------------------------------------ + *bashdb-integration-xterm* +The xterm related functionality is only available under UNIX. It is used to +run interactive commands. + + g:Xterm_Executable +The xterm executable is set by g:Xterm_Executable, for example: > + let g:Xterm_Executable = '/usr/local/bin/xterm' +< + g:Xterm_Options +Set additional options for xterm. The default is: > + let g:Xterm_Options = '-fa courier -fs 12 -geometry 80x24' +< +For example, use these arguments for black letters on a white background: > + let g:Xterm_Options = '-fg black -bg white -fs 12 -geometry 80x24' +< +See the man-page of xterm for the possible options. + +The behavior can be changed on the fly by settings the variable to a different +value on the command line. + +============================================================================== +A. CHANGE LOG *bashdb-integration-change-log* +============================================================================== + +------------------------------------------------------------------------------ + RELEASE NOTES FOR VERSION 0.5 +------------------------------------------------------------------------------ + +- Initial upload. + +============================================================================== +vim:filetype=help:textwidth=78:expandtab:tabstop=2:norl: diff --git a/doc/bashsupport.txt b/doc/bashsupport.txt index 63026b0..bba59f0 100644 --- a/doc/bashsupport.txt +++ b/doc/bashsupport.txt @@ -1,9 +1,9 @@ -*bashsupport.txt* Bash Support Jun 20 2017 +*bashsupport.txt* Bash Support Nov 22 2020 Bash Support *bash-support* *bashsupport* - Plug-in version 4.4pre - for Vim version 7.0 and above + Plug-in version 5.0beta + for Vim version 7.4 and above Wolfgang Mehner <wolfgang-mehner@web.de> Fritz Mehner <mehner.fritz@web.de> @@ -14,14 +14,9 @@ running a script, starting a debugger can be done with a keystroke. There are many additional hints and options which can improve speed and comfort when writing shell scripts. This plug-in can be used for Bash up to version 4.4. -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -++ The plug-in version 4.0+ is a rewriting of version 3.12.1. ++ -++ The versions 4.0+ are based on a new and more powerful template system ++ -++ (please see |template-support|for more information). ++ -++ The template syntax has changed! ++ -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +============================================================================== +0. TABLE OF CONTENTS *bashsupport-contents* +============================================================================== 1. Usage with GUI |bashsupport-usage-gvim| 1.1 Menu 'Comments' |bashsupport-comments| @@ -47,11 +42,12 @@ writing shell scripts. This plug-in can be used for Bash up to version 4.4. 1.7.4 Save and check syntax |bashsupport-syntax-check| 1.7.4.1 Error format |bashsupport-errorformat| 1.7.4.2 Syntax check options |bashsupport-syntax-check-options| - 1.7.5 Start debugger |bashsupport-debugger| - 1.7.6 Hardcopy |bashsupport-hardcopy| - 1.7.7 Xterm size |bashsupport-xterm| - 1.7.8 Output redirection |bashsupport-output| - 1.8 Menu 'Help' |bashsupport-help| + 1.7.5 Hardcopy |bashsupport-hardcopy| + 1.7.6 Xterm size |bashsupport-xterm| + 1.7.7 Output redirection |bashsupport-output| + 1.8 Menu 'Tool Box' |bashsupport-toolbox| + 1.8.1 BashDB |bashsupport-toolbox-bashdb| + 1.9 Menu 'Help' |bashsupport-help| 2. Usage without GUI |bashsupport-usage-vim| 3. Hot keys |bashsupport-hotkeys| 4. Customization and configuration |bashsupport-customization| @@ -400,14 +396,12 @@ The default is the value of $SHELL (Linux/U**X) or 'bash.exe' (Windows). 1.7.2 Script command line arguments *bashsupport-cmdline-args* ----------------------------------- - + *:BashScriptArguments* The item 'script cmd. line arg.' calls an input dialog which asks for command line arguments. These arguments are forwarded to the script which is run by the 'run' item. The arguments are kept until you change them. For file names -tab-expansion will work. The ex command -> +tab-expansion will work. The ex command > :BashScriptArguments ... -< can also be used to set the command line arguments for the current script. The arguments belong to the current buffer (that is, each buffer can have its @@ -459,40 +453,7 @@ options' typing for instance after the prompt. The options entered this way are buffer related. The global options set in '.vimrc' and the buffer related options are checked. - -1.7.5 START DEBUGGER *bashsupport-debugger* --------------------- - -Start the debugger 'bashdb' or the frontend 'ddd' from the menu entry -Run->debug (GUI), with hotkey \rd or F9. Your version of the bash must be -prepared for debugging and the debugger must be installed (see -http://bashdb.sourceforge.net/). - -(1) Using bashdb -When using gvim or vim running under a GUI the debugger will be started in an -independent xterm. This is done because the shell integration in gvim has -deficiencies (see also :h shell-window). - -When using vim from a console terminal the debugger will be started as -> - :!xterm <xterm defaults> -e bashdb -- <script> <arguments> & -< -The debugger now will be run inside vim. - -(2) Using ddd -The frontend ddd can be started via the menu or the hotkeys instead of bashdb -as described above. The preference can be set with the global variable -g:BASH_Debugger (possible values: 'term', 'ddd' ) in '.vimrc' : -> - let g:BASH_Debugger = 'ddd' -< -The default is 'term'. - -In all cases the command line arguments from the argument setting -(|bashsupport-cmdline-args|) are passed to the debugger. - - -1.7.6 Hardcopy *bashsupport-hardcopy* +1.7.5 Hardcopy *bashsupport-hardcopy* -------------- Generates a PostScript file from the whole buffer or from a marked region. The @@ -515,13 +476,13 @@ or by setting a global variable in the file '.vimrc', e.g. : < See |printheader| and |strftime()| for more details. -1.7.7 Xterm size *bashsupport-xterm* +1.7.6 Xterm size *bashsupport-xterm* ---------------- The size of the xterm (see below) can be changes for the current session. The size has to be specified as COLUMNS LINES (e.g. 96 32 ). -1.7.8 Output redirection *bashsupport-output* +1.7.7 Output redirection *bashsupport-output* ------------------------ The last menu entry 'output: ... ' has 3 states: @@ -568,9 +529,9 @@ The wrapper shows the complete command line and the return code of the script. Appearance of the xterm ----------------------- The appearance of the xterm can be controlled by the global variable -g:BASH_XtermDefaults. The assignment +g:Xterm_Options. The assignment > - let g:BASH_XtermDefaults = "-fa courier -fs 10 -geometry 96x32" + let g:Xterm_Options = "-fa courier -fs 10 -geometry 96x32" < placed in '.vimrc' would override the defaults. The defaults are > @@ -580,14 +541,47 @@ FreeType font 'courier', FreeType font size 12 point, window width 80 characters, window height 24 lines. The default output method is VIM. The preferred output method can be selected -in '.vimrc' by the global variable g:BASH_OutputGvim, e.g. +in '.vimrc' by the global variable g:BASH_OutputMethod, e.g. +> + let g:BASH_OutputMethod = "xterm" +< +The methods are "cmd-line", "quickfix", "buffer", "xterm", and "terminal". The +method "xterm" requires xterm(1), and is only available under UNIX. The method +"terminal" requires the |+terminal| feature. + +------------------------------------------------------------------------------ +1.8 Menu 'Tool Box' *bashsupport-toolbox* +------------------------------------------------------------------------------ + +Tools which provide related but independent functionalities are located in the +Tool Box. An examples is the tool for BashDB integration. The Tool Box has its +own documentation: |toolbox|. +To switch the Tool Box off, add the following line to the file .vimrc > - let g:BASH_OutputGvim = "xterm" + let g:BASH_UseToolbox = 'no' < -The methods are "vim", "buffer" and "xterm". +1.8.1 BashDB *bashsupport-toolbox-bashdb* +The tool box for BashDB provides a small set of menu items and ex commands +for controlling bashdb. Please see |bashdb-integration|. +To switch the BashDB tool box off, add the following line to the file .vimrc +> + let g:Bash_UseTool_bashdb = 'no' +< +The hotkeys for the BashDB integration can easily be defined by the user in +the file '~/.vim/ftplugin/sh.vim'. See 'bash-support/rc/sh.vim' for examples. + +These maps would (R)un the debugger, and (C)hoose the debugging method: > + nnoremap <buffer> <silent> <LocalLeader>dr :BashDB<CR> + inoremap <buffer> <silent> <LocalLeader>dr <C-C>:BashDB<CR> + vnoremap <buffer> <silent> <LocalLeader>dr <C-C>:BashDB<CR> + + nnoremap <buffer> <LocalLeader>dc :BashDBDebugger<Space> + inoremap <buffer> <LocalLeader>dc <C-C>:BashDBDebugger<Space> + vnoremap <buffer> <LocalLeader>dc <C-C>:BashDBDebugger<Space> +< ------------------------------------------------------------------------------ -1.8 MENU 'Help' *bashsupport-help* +1.9 MENU 'Help' *bashsupport-help* ------------------------------------------------------------------------------ Item 'Bash manual' @@ -736,16 +730,18 @@ Legend: (i) insert mode, (n) normal mode, (v) visual mode -- Run ---------------------------------------------------- [n]\rr update file, run script (n, i) - \ra set script cmd. line arguments (n, i) - \rba set Bash cmd. line arguments (n, i) - \rc update file, check syntax (n, i) - \rco syntax check options (n, i) - \rd start debugger (n, i) + \rsa set script cmd. line arguments (n, i) + \ria set Bash cmd. line arguments (n, i) + \rk update file, check syntax (n, i) + \rso syntax check options (n, i) + \ro change output destination (n, i) + \rd set "direct run" (n, i) + \rse set shell executable (n, i) + \rx set xterm size (*) (n, i) + \re make script executable/not exec.(*) (in ) \rh hardcopy buffer to FILENAME.ps (n, i) \rs plug-in settings (n, i) - \rt set xterm size (*) (n, i) - \ro change output destination (n, i) -- Bash help ---------------------------------------------- @@ -756,7 +752,7 @@ Legend: (i) insert mode, (n) normal mode, (v) visual mode \hm displays the manual for the (n, i) Bash command under the cursor The tab expansion is active. - \hbs Displays the Vim help page for (n, i) + \hp Displays the Vim help page for (n, i) this plug-in. (*) Linux/UNIX only @@ -866,10 +862,9 @@ g:BASH_Dictionary_File $HOME."/.vim/bash-support/wordlists/bash.list" g:BASH_RootMenu '&Bash.' g:BASH_GuiSnippetBrowser 'gui' -g:BASH_OutputGvim 'vim' (Linux/U**X) - 'xterm' (Windows) -g:BASH_XtermDefaults '-fa courier -fs 12 -geometry 80x24' -g:BASH_Debugger 'term' +g:BASH_OutputMethod 'cmd-line' (Vim/gVim) + 'terminal' (Neovim) +g:BASH_DirectRun 'no' g:BASH_LineEndCommColDefault 49 g:BASH_SyntaxCheckOptionsGlob '' g:BASH_Printheader '%<%f%h%m%< %=%{strftime('%x %X')} Page %N' @@ -884,8 +879,23 @@ g:BASH_MapLeader '\' g:BASH_Errorformat '%f:\ line\ %l:\ %m' g:BASH_AlsoBash [] +g:Xterm_Executable 'xterm' +g:Xterm_Options '-fa courier -fs 12 -geometry 80x24' ------------------------------------------------------------------------------ +Several options are supported for backwards compatibility only. Use the new +variables for new configurations. + + ---------------------------------------------------------------------------- + old option new option + ---------------------------------------------------------------------------- + g:BASH_OutputGvim g:BASH_OutputMethod + g:BASH_XtermDefaults g:Xterm_Options + + g:BASH_Debugger |g:BashDB_Debugger| (see |bashdb-integration|) + g:BASH_bashdb |g:BashDB_Executable| (see |bashdb-integration|) + ---------------------------------------------------------------------------- + 1. group: Defines the text which will be inserted for the tags when a template is read in (see |bashsupport-templates|). @@ -907,10 +917,12 @@ g:BASH_AlsoBash [] (see |bashsupport-custom-root|). g:BASH_GuiSnippetBrowser : code snippet browser: 'gui', 'commandline' - 3. group: g:BASH_OutputGvim : Target for a script output + 3. group: g:BASH_OutputMethod : target for a script output (see |bashsupport-output|). - g:BASH_XtermDefaults : The xterm defaults (see |bashsupport-xterm|). - g:BASH_Debugger : the debugger called by F9 (term, ddd). + g:BASH_DirectRun : run executable scripts without + using 'g:BASH_Executable' + g:Xterm_Executable : The xterm executable (see |bashsupport-xterm|). + g:Xterm_Options : The xterm options (see |bashsupport-xterm|). g:BASH_LineEndCommColDefault : default starting column for line end comments g:BASH_SyntaxCheckOptionsGlob : shopt options used with syntax checking g:BASH_Printheader : hardcopy header format @@ -1287,8 +1299,8 @@ You can use Vim's dictionary feature CTRL-X, CTRL-K (and CTRL-P, CTRL-N). 7. ADDITIONAL MAPPINGS *bashsupport-ad-mappings* ============================================================================== -Some suggestions are in 'bash-support/rc/sh.vim'. This is a filetype plug-in -and would go to '$HOME/.vim/ftplugin/'. +Additional mappings can be defined in the file '~/.vim/ftplugin/sh.vim'. Some +suggestions can be found in 'bash-support/rc/sh.vim'. ============================================================================== 8. WINDOWS PARTICULARITIES *bashsupport-windows* @@ -1346,37 +1358,29 @@ CYGWIN with the value "nodosfilewarning". ============================================================================== * I do not see any new main menu item. + - The menu is only created upon opening the first Bash file (*.sh). + This behavior can be changed: + :help |bashsupport-custom-variables| - Was the archive extracted into the right directory? - -* How can I see what was loaded? - - Use ':scriptnames' from the Vim command line. - -* No main menu item. + See the section INSTALLATION in bash-support/README.md. - Loading of plug-in files must be enabled. If not use -> - :filetype plugin on -< + :filetype plugin on This is the minimal content of the file '$HOME/.vimrc'. Create one if there is none, or better use customization.vimrc. -* Most key mappings do not work. - - They are defined in a filetype plugin in '$HOME/.vim/ftplugin/'. Use - ':filetype' to check if filetype plug-ins are enabled. If not, add the line -> - filetype plugin on -< - to the file '~/.vimrc'. +* How can I see what was loaded? + - Use ':scriptnames' from the Vim command line. * Some hotkeys do not work. - - The hotkeys might be in use by your graphical desktop environment. Under - KDE Ctrl-F9 is the hotkey which let you switch to the 9. desktop. The key + - The hotkeys might be in use by your graphical desktop environment. Under + KDE Ctrl-F9 is the hotkey which let you switch to the 9th desktop. The key settings can usually be redefined. ============================================================================== 10. Release Notes *bashsupport-release-notes* ============================================================================== -See files 'README.md' and 'ChangeLog'. +See file 'bash-support/doc/ChangeLog'. ============================================================================== vim:tw=78:expandtab:ts=2:ft=help:norl: diff --git a/doc/csupport.txt b/doc/csupport.txt index 849a0c1..2d24f15 100644 --- a/doc/csupport.txt +++ b/doc/csupport.txt @@ -1,8 +1,8 @@ -*csupport.txt* C/C++ Support Feb 05 2017 +*csupport.txt* C/C++ Support Nov 22 2020 C/C++ Support *c-support* *csupport* - Plug-in version 6.2.1pre + Plug-in version 6.2.1beta for Vim version 7.0 and above Wolfgang Mehner <wolfgang-mehner@web.de> (formerly Fritz Mehner <mehner.fritz@web.de>) @@ -1067,7 +1067,8 @@ To switch the make tool box off add the following line to the file .vimrc > let g:C_UseTool_make = 'no' < -The hotkeys for the make tool are defined in the file ~/.vim/ftplugin/c.vim . +The maps for the make tool can be defined in the file '~/.vim/ftplugin/c.vim'. +Compare the example filetype plug-in 'c-support/rc/c.vim'. 1.8.2 Other Tools *csupport-toolbox-others* @@ -1409,7 +1410,7 @@ The hotkeys are defined in the file type plugin c.vim. All hotkeys from the non-GUI mode also work for gVim (see |csupport-usage-vim|). Shift-F2 can be used to switch between source files and header files if the -plugin a.vim (http://vim.sourceforge.net/scripts/script.php?script_id=31) is +plugin a.vim (https://www.vim.org/scripts/script.php?script_id=31) is present. To suppress the creation of a new header file when switching from a source file the file ~/.vimrc should contain a line > @@ -1498,7 +1499,7 @@ The variable plugin_dir will automatically be set to one of the following values g:C_CodeSnippets : The name of the code snippet directory (see |csupport-snippets|). g:C_CplusCompiler : The name of the C++ compiler. - g:C_Ctrl_j : hotkey Ctrl-j 'on'/'off' (see |csupport-CTRL-j|) + g:C_Ctrl_j : hotkey Ctrl-j 'on'/'off' (see |csupport-CTRL-J|) g:C_CustomTemplateFile : sets the custom template file (see|csupport-templates|) g:C_Debugger : the default debugging: 'gdb', 'kdbg', or 'ddd' g:C_Dictionary_File : The name(s) of the dictionary file(s) used for @@ -1831,7 +1832,7 @@ The text inside the brackets is userdefined and can be empty. The text can be composed from letters (uppercase and lowercase), digits, and underscores. After the insertion of an template these jump targets will be highlighted. -5.3.3 Command Ctrl-j *csupport-CTRL-j* +5.3.3 Command Ctrl-j *csupport-CTRL-J* Use the command Ctrl-j to jump to the next target. The target will be removed and the mode will switched to insertion. Ctrl-j works in normal and in insert @@ -1864,17 +1865,17 @@ The file skeletons are controlled via these properties, which can be set in one of the template files. For each filetype, the headers and source files can be different: > - SetProperty ( 'C::FileSkeleton::Header', 'Comments.file description impl' ) - SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description header' ) - SetProperty ( 'Cpp::FileSkeleton::Header', 'Comments.file description impl' ) - SetProperty ( 'Cpp::FileSkeleton::Source', 'Comments.file description header' ) + SetProperty ( 'C::FileSkeleton::Header', 'Comments.file description header' ) + SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description impl' ) + SetProperty ( 'Cpp::FileSkeleton::Header', 'Comments.file description header' ) + SetProperty ( 'Cpp::FileSkeleton::Source', 'Comments.file description impl' ) < This inserts only comments to describe the file. To disable the insertion for one of these types, set the property to an empty string: > SetProperty ( 'C::FileSkeleton::Source', '' ) In general, these properties are semicolon-separated lists of templates to be inserted: > - SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description header; ;Comments.all sections.implementation, C' ) + SetProperty ( 'C::FileSkeleton::Source', 'Comments.file description impl; ;Comments.all sections.implementation, C' ) This will insert the file description and the file section comments (see |csupport-comm-sections|). If a space appears as an entry in the list, an empty line is inserted: > @@ -2038,8 +2039,8 @@ See |folding| for more information on folding. 9. Additional Mappings *csupport-ad-mappings* ============================================================================== -There are a few additional filetype specific key mappings defined in -'~/.vim/ftplugin/c.vim'. +Additional mappings can be defined in the file '~/.vim/ftplugin/c.vim'. +Compare the example filetype plug-in 'c-support/rc/c.vim'. Complete a classical C comment: '/*' => '/* | */' (modes: i,v). @@ -2054,15 +2055,16 @@ Open a block (modes: i,v): } In visual mode the content of the new block will be indented. -The file customization.cpp.vim provides additional insert mode mappings to -facilitate writting cin and cout statements, e.g. +The file 'c-support/rc/cpp.vim' provides additional insert mode mappings to +facilitate writing cin and cout statements, e.g. > - '<<' -> ' << |' - '<<"' -> ' << "|" ' - '<<;' -> ' << "|\n";' - '>>' -> ' >> |' + '<<' -> ' << |' + '<<"' -> ' << "|" ' + '<<;' -> ' << "|\n";' + '>>' -> ' >> |' < -Copy this file to ~/.vim/ftplugin and rename it to 'cpp.vim'. +Copy the files 'c-support/rc/c.vim' or 'c-support/rc/cpp.vim' +to '~/.vim/ftplugin'. ============================================================================== 10. WINDOWS PARTICULARITIES *csupport-windows* diff --git a/doc/gitsupport.txt b/doc/gitsupport.txt deleted file mode 100644 index 98d283d..0000000 --- a/doc/gitsupport.txt +++ /dev/null @@ -1,1327 +0,0 @@ -*gitsupport.txt* Git Support Jul 23 2016 - -Git Support *git-support* *gitsupport* - - Plug-in version 0.9.3 - for Vim version 7.0 and above - Wolfgang Mehner <wolfgang-mehner at web.de> - -Integration of Git for Vim/gVim. The plug-in at hand allows to use Git from -within Vim, eliminating the need for context switches. The output of commands -like "git status" is written into buffers, and the commit can be manipulated -from right there. Further commands allow to quickly add the file in the -current buffer or show its diff. See the chapter |gitsupport-introduction| for -a quick overview and a short guide to this documentation. - -============================================================================== -0. TABLE OF CONTENTS *gitsupport-contents* -============================================================================== - - 1. Introduction |gitsupport-introduction| - 2. Overview |gitsupport-overview| - 2.1 Menu |gitsupport-overview-menu| - 2.2 Workflow |gitsupport-overview-work| - 3. Commands |gitsupport-commands| - 3.1 Command-Line Completion |gitsupport-cmds-cmd-line| - 4. Syntax Highlighting |gitsupport-syntax| - 4.1 Branch |gitsupport-syn-branch| - 4.2 Commit |gitsupport-syn-commit| - 4.3 Diff |gitsupport-syn-diff| - 4.4 Grep |gitsupport-syn-grep| - 4.5 Log |gitsupport-syn-log| - 4.6 Status |gitsupport-syn-status| - 5. Custom Menus |gitsupport-menus| - 6. Configuration |gitsupport-configuration| - 6.1 Executable |gitsupport-config-executable| - 6.2 Menus |gitsupport-config-menus| - 6.3 Maps |gitsupport-config-maps| - 6.4 Settings |gitsupport-config-settings| - 6.5 Xterm |gitsupport-config-xterm| - - A. Troubleshooting - Known Issues |gitsupport-troubleshooting| - B. Release Notes - Change Log |gitsupport-release-notes| - C. Credits |gitsupport-credits| - -============================================================================== -1. INTRODUCTION *gitsupport-introduction* -============================================================================== - -Git Support defines two types of commands. The first kind provides convenient -access to various Git commands which manipulate the working directory and -staging area. The second kind redirects the output from Git commands like "git -status" into buffers. For each such buffer maps are defined which can be used -to run other commands. For example, after running :GitStatus, you can use maps -like "a" and "c" to add or check out the file under the cursor, provided its -name appears in the section "Changes not staged for commit:". Each buffer has -a map <SHIFT-F1> for showing a short help. - -All commands are listed in a menu "Git". It provides convenient access to all -the commands and gives an overview of the plug-in's functionality. The plug-in -supports custom menu entries, which can be configured easily. - -The next chapter |gitsupport-overview| gives an overview of the plug-in, fol- -lowed by a detailed description of the commands in |gitsupport-commands|. The -customization of the syntax highlighting is explained in |gitsupport-syntax|, -the customizable menu entries in |gitsupport-menus|. The chapter -|gitsupport-configuration| documents further configurations. - -============================================================================== -2. OVERVIEW *gitsupport-overview* -============================================================================== - -The following commands are provided by Git Support. Each command is executed -in the current working directory, just as it would work on the shell. You can -run the commands in every subdirectory of the project. - - Command Short Description - ---------------------------------------------------------------------------- - |:Git| <cmd> [<args>] (run) git <cmd> <args> - |:Git|! <cmd> [<args>] (buf) git <cmd> <args> - |:GitRun| <cmd> [<args>] (run) git <cmd> <args> - |:GitBuf| <cmd> [<args>] (buf) git <cmd> <args> - - |:GitAdd| [<args>] (run) git add <args> - |:GitBlame| [<args>] (buf) git blame <args> (supports ranges) - |:GitBranch| (buf) git branch - |:GitBranch| <args> (run) git branch <args> - |:GitCheckout| [<args>] (run) git checkout <args> - |:GitCommit| [<args>] (run) git commit <args> - |:GitCommit| --dry-run [<args>] (buf) git commit --dry-run <args> - |:GitCommitFile| [<file>] (run) git commit -F <file> - |:GitCommitMerge| (run) git commit -F <base>/.git/MERGE_MSG - |:GitCommitMsg| <msg> (run) git commit -m "<msg>" - |:GitDiff| [<args>] (buf) git diff <args> - |:GitFetch| [<args>] (run) git fetch <args> - |:GitGrep| <args> (buf) git grep <args> - |:GitGrepTop| <args> (buf) git grep <args> (^1) - |:GitHelp| [<args>] (buf) git help <args> - |:GitLog| [<args>] (buf) git log <args> - |:GitMerge| [<args>] (run) git merge <args> - |:GitMergeUpstream| [<args>] (run) git merge <args> <upstream-branch> - |:GitMove| [<args>] (run) git mv <args> - |:GitMv| [<args>] (run) git mv <args> - |:GitPull| [<args>] (run) git pull <args> - |:GitPush| [<args>] (run) git push <args> - |:GitRemote| (buf) git remote - |:GitRemote| <args> (run) git remote <args> - |:GitRemove| [<args>] (run) git rm <args> - |:GitRm| [<args>] (run) git rm <args> - |:GitReset| [<args>] (run) git reset <args> - |:GitShow| [<args>] (buf) git show <args> - |:GitStash| [<args>] (run) git stash <args> - |:GitStash| list [<args>] (buf) git stash list <args> - |:GitStash| show [<args>] (buf) git stash show <args> - |:GitSlist| (buf) git stash list - |:GitStatus| [<path>] (buf) git status - |:GitTag| (buf) git tag - |:GitTag| <args> (run) git tag <args> - - |:GitK| <args> start gitk with the given arguments - |:GitBash| <args> run git in an external terminal - - |:GitEdit| <fileid> edit the file referred to by <fileid> - - |:GitSupportHelp| show plug-in help - |:GitSupportSettings| show plug-in settings - ---------------------------------------------------------------------------- - -(run) runs the command after asking for confirmation -(buf) runs the command and redirects its output in a new buffer -(^1) runs the command within the context of the top-level directory - -When a command opens a new buffer, several maps are defined for this buffer. -Hitting <SHIFT-F1> always prints a short help with all available maps. - -The default argument for GitAdd, GitBlame, GitCheckout, GitCommitFile, GitRm, -GitRemove and GitReset is the current buffer. - -When called without arguments, the commands GitBranch and GitRemote open a -buffer, otherwise they run the respective Git command with the given -arguments. - -Names of Git objects can be completed while on the Vim command-line, similar -to the way words can be completed in buffers using CTRL-P (see |i_CTRL-P|). -The names of branches, commands, remotes and tags can be completed that way. -This feature has to be enabled by hand, see |gitsupport-cmds-cmd-line| for -details. - ------------------------------------------------------------------------------- -2.1 MENU *gitsupport-overview-menu* ------------------------------------------------------------------------------- - -Git Support comes with a menu "Git" which contains all commands for convenient -access. The menu contains several entries which open buffers for a quick -overview of your repository: branch, log, status, ... - -All commands are listed in the menu "git ...". Each entry opens the command- -line and inserts the respective command, awaiting further input. This menu -provides an overview of the plug-in's functionality. - -The menu "file" contains several commands which can be run on the current -buffer. Each entry runs the command directly. This is designed to support the -work on the current file: viewing diffs, adding or checking out the file, ... - -Some special commands are provided in the menu "specials". See their documen- -tation for further help. - -The menu "custom" is configurable by the user. It can be used to list Git -commands with regularly used combination of flags. (see |gitsupport-menus|) - -To quickly jump to important files, such as config and ignore files, use the -menu "edit". (or the command |:GitEdit|) - ------------------------------------------------------------------------------- -2.2 WORKFLOW *gitsupport-overview-work* ------------------------------------------------------------------------------- - -To be completely honest, the plug-in in its current state is probably best -suited for my own workflow. This is the main reason why simply running -|:GitCommit| without arguments currently does not work, and why there is a -|:GitCommitFile| command. - -I keep a file like 'project/commit.txt' around and protocol the changes while -working on the files. This has the advantage that names of variables, -functions or classes can quickly be inserted using <CTRL-P>. Intermediate -results can be staged using |:GitAdd|, so the output of |:GitDiff| is clean -again. After a look at the output of |:GitStatus| and assembling the release -in the status buffer, I finalize the commit message in 'project/commit.txt'. -Running |:GitCommitFile| on the buffer commits the changes using the contents -of the file as the message. - -I am convinced, since you do not have to leave Vim to manage your repository, -that this is a better way of doing things. Editing the commit message in a -window gives you the chance to browse around your project in the environment -your already working in. You furthermore can have a look at logs, compare -different branches or add another file while writing the commit message. And -seeing how you use Vim for a big project like the kinds of projects you manage -in a version control system, you obviously do not have a problem dealing with -one further file. - -============================================================================== -3. COMMANDS *gitsupport-commands* -============================================================================== - -Whenever a command opens a buffer, several maps are defined for this buffer. -Hitting <SHIFT-F1> always prints a short help with all available maps. All -buffers can be closed via <q> and updated via <u>. - ------------------------------------------------------------------------------- - *:Git* *:GitRun* *:GitBuf* - :Git <cmd> [<args>] ~ - :GitRun <cmd> [<args>] ~ - :Git! <cmd> [<args>] ~ - :GitBuf <cmd> [<args>] ~ - -Executes "git <cmd> ...". The last two versions redirect the output into a -buffer. - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitAdd* - :GitAdd [<args>] ~ - :GitAdd! [<args>] ~ - -Executes "git add ...". The second version forces the add. If no arguments are -given, adds the current buffer. - -Examples: - -Add the current buffer: > - :GitAdd -Similarly: > - :GitAdd -- % -Is equivalent to: > - git add -- <currentfile> - -Add all the Vim scripts in the current directory: > - :GitAdd! *.vim -Is equivalent to: > - git add -f *.vim - ------------------------------------------------------------------------------- - *:GitBlame* - :[range]GitBlame ~ - :[range]GitBlame <args> ~ - -The first version opens a buffer containing the output of Git's blame for the -current buffer. The second version runs blame for the given arguments. When a -range is given, the output is limited to these lines. - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - - of file under cursor: open file (edit) - oj file under cursor: open and jump to the corresponding line - - cs commit under cursor: show - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitBranch* - :GitBranch ~ - :GitBranch <args> ~ - -The first version opens a buffer listing all branches, including remote ones. -The second version executes "git branch ...". - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - - branch under the cursor ... - ch checkout - cr use as starting point for creating a new branch - de delete - De / DE delete (via -D) - me merge with current branch - re use as upstream for rebase - rn rename - su set as upstream from current branch - cs show the commit - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitCheckout* - :GitCheckout [<args>] ~ - -Executes "git checkout ...". - -Examples: - -Check out the file in the current buffer: > - :GitCheckout -- % -(Might require running ":e" to update the buffer itself.) - -Check out the branch "master": > - :GitCheckout master - -Settings: -- |g:Git_CheckoutExpandEmpty| - ------------------------------------------------------------------------------- - *:GitCommit* *:GitCommitFile* *:GitCommitMsg* - :GitCommit [<args>] ~ - :GitCommitFile [<file>] ~ - :GitCommitMsg <msg> ~ - -The first version runs "git commit" with the given arguments. If the arguments -include the "--dry-run" flag, the output is redirected into a buffer. The -second version takes the commit message from the given file (default: current -buffer). The third version uses the commit message provided on the command -line. - -Note The command :GitCommit currently can not be run without arguments. Supply - the commit message using either the -m or -F options, or by using the - other versions :GitCommitFile or :GitCommitMsg. - - *:GitCommitMerge* -Commit a merge: - - :GitCommitMerge ~ - -This version commits changes from a merge conflict. It first looks for the -base (toplevel) directory of the repository (<base>) and checks whether there -is a file <base>/.git/MERGE_HEAD located there. Then the changes are committed -via: > - git commit -F <base>/.git/MERGE_MSG -The file MERGE_MSG contains the standard message for merges, which looks -similar to this: -> - Merge remote-tracking branch 'origin/master' - - Conflicts: - somedir/thefile.txt -< -Note I do not know whether this is a "proper" usage of Git. However, it seems - to work and even the files in the .git/ directory which indicate the - merge conflict (MERGE_HEAD, MERGE_MSG, ...) are gone afterwards. - - -Examples: - -Make a small commit: > - :GitCommitMsg Minor changes. -Is equivalent to: > - git commit -m "Minor changes." - -Make a larger commit, take the commit message from a file: > - :GitCommitFile commit.txt -Is equivalent to: > - git commit -F commit.txt - -Amend the previous commit: > - :GitCommit --amend -F commit.txt -Is equivalent to: > - git commit --amend -F commit.txt - ------------------------------------------------------------------------------- - *:GitDiff* - :GitDiff ~ - :GitDiff <args> ~ - -Both version run diff for the given arguments. The behavior of the first -version depends on the setting |g:Git_DiffExpandEmpty|. -By default, the first version opens the diff showing all unstaged changes. If -|g:Git_DiffExpandEmpty| is set to 'yes', only the diff of the current file is -shown. This makes the behavior of :GitDiff more consistent with commands like -|:GitAdd|. - -Inside the diff buffer, use the map 'of' to open the file under the cursor. -The map 'oj' will jump to line in the file corresponding to the line in the -diff output. -The chunk under the cursor can be added, checked out and reset using 'ac', -'cc', and 'rc'. In visual mode only the selected lines are applied. - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - - file under cursor ... - of open file (edit) - oj open and jump to the position under the cursor - - chunk under cursor ... - ac add to index (add chunk) - cc undo change (checkout chunk) - rc remove from index (reset chunk) - -> in visual mode, these maps only apply the selected lines - ---------------------------------------------------------------------------- - -Example: - -Show the diff for the current file: > - :GitDiff % - -Show the diff for a file Vector.cc and its header Vector.h: > - :GitDiff Vector.* -Is equivalent to: > - git diff Vector.* - -Settings: -- |g:Git_DiffExpandEmpty| - ------------------------------------------------------------------------------- - *:GitFetch* - :GitFetch [<args>] ~ - -Executes "git fetch ...". - ------------------------------------------------------------------------------- - *:GitGrep* *:GitGrepTop* - :GitGrep <args> ~ - :GitGrepTop <args> ~ - -The first version opens a buffer containing the output of Git's grep. The -second version runs grep within the context of the top-level directory of the -repository. - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - - of file under cursor: open file (edit) - oj file under cursor: open and jump to the corresponding line - <Enter> file under cursor: open and jump to the corresponding line - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitHelp* - :GitHelp [<args>] ~ - -Opens a buffer containing the help for one of Git's commands. If no command is -given, opens the help for Git itself. Use tab-completion for convenience. - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - ---------------------------------------------------------------------------- - -Example: - -Show the help for the add command: > - :GitHelp add -Is equivalent to: > - git help add - ------------------------------------------------------------------------------- - *:GitLog* - :GitLog ~ - :GitLog <args> ~ - -The first version opens a buffer containing the log for the current branch. -The second version runs log for the given arguments. - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - - commit under the cursor ... - ch checkout - cr use as starting point for creating a new branch - sh / cs show the commit - ta tag the commit - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitMerge* *:GitMergeUpstream* - :GitMerge [<args>] ~ - :GitMergeUpstream [<args>] ~ - -The first version executes "git merge ...". The second version automatically -obtains the name of the upstream branch and merges it into the current branch. -arguments can still be given: > - :GitMergeUpstream --ff-only -Is equivalent to: > - git merge --ff-only <upstream-branch> -< ------------------------------------------------------------------------------- - *:GitMove* *:GitMv* - :GitMove [<args>] ~ - :GitMv [<args>] ~ - -Both versions behave the same. Executes "git mv ...". - ------------------------------------------------------------------------------- - *:GitPull* - :GitPull [<args>] ~ - -Executes "git pull ...". - ------------------------------------------------------------------------------- - *:GitPush* - :GitPush [<args>] ~ - -Executes "git push ...". - ------------------------------------------------------------------------------- - *:GitRemote* - :GitRemote ~ - :GitRemote <args> ~ - -The first version opens a buffer listing all the remotes together with their -URLs. The second version executes "git remote ...". - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - - remote under the cursor ... - fe fetch - ph push - pl pull - rm remove - rn rename - su set-url - sh show - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitRemove* *:GitRm* - :GitRemove [<args>] ~ - :GitRm [<args>] ~ - -Both versions behave the same. Executes "git rm ...". If no arguments are -given, removes the current buffer. - -Example: - -Reset the current file: > - :GitRemove -Is equivalent to: > - git rm -- <currentfile> - ------------------------------------------------------------------------------- - *:GitReset* - :GitReset [<args>] ~ - -Executes "git reset ...". - -Example: - -Reset the current file: > - :GitReset -- % - -Settings: -- |g:Git_ResetExpandEmpty| - ------------------------------------------------------------------------------- - *:GitShow* - :GitShow [<args>] ~ - -Opens a buffer containing the output of "git show ...". For commits and -annotated tags, shows the commit/tag message and the diff. For blobs a -separate buffer is opened. - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitStash* *:GitSlist* - :GitStash [<args>] ~ - :GitStash list [<args>] ~ - :GitStash show [<args>] ~ - :GitSlist ~ - -The first version executes "git stash ...". The second and third version open -buffers listing the stashes or showing a stash. The command ":GitSlist" is a -shorthand for ":GitStash list" - -The buffer for ":GitStash list" defines the following maps: - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - - sh show the stash under the cursor - sp show the stash in patch form - - sa save with a message - pu create a new stash (push) - - stash under the cursor ... - ap apply - po pop - dr drop - br create and checkout a new branch - ---------------------------------------------------------------------------- - -The buffer for ":GitStash show" defines the following maps: - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitStatus* - :GitStatus [<path>] ~ - -Opens a buffer showing the current status. Several different actions can be -performed for the file under the cursor, see below. - -A path can be given as an argument to restrict the output to changes in that -folder, for example the current one: > - :GitStatus . -The paths will be printed relative to the given path, not the current working -directory, as Git would do it. The special argument "/" has the same effect as -passing the top-level directory of the repository: > - :GitStatus / -In any case, :GitStatus respects the option "status.relativePaths". - -The map 'od' opens the diff for the file under the cursor. The normal behavior -is to open the "default" diff between the index and the working tree. In the -section containing the staged files, titled "Changes to be committed", this -behavior is different. The default behavior is to open the diff displaying the -staged changes. This can be modified using |g:Git_StatusStagedOpenDiff|. - -The map 'D' to remove untracked files is special, in that it does not run a -Git command. - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer - - toggle ... - i show ignored files - s short output - v verbose output - - file under cursor ... - a add - ap add --patch (^1) - c checkout - cp checkout --patch (^1) - ch checkout HEAD (set index and working tree to HEAD) - od open diff - of open file (edit) - oj open file (edit) - ol open log (with --stat) - r reset - rp reset --patch (^1) - D delete from file system (only untracked files) - ---------------------------------------------------------------------------- - -(^1) requires working "git bash" - -Settings: -- |g:Git_StatusStagedOpenDiff| - ------------------------------------------------------------------------------- - *:GitTag* - :GitTag [-n[<num>]] [--contains <commit>] [-l [<pattern>...]] ~ - :GitTag <args> ~ - -The first version opens a buffer listing the tags. The second version executes -"git tag ...". - - Map Meaning - ---------------------------------------------------------------------------- - S-F1 help: show a list of all maps - q close the buffer - u update the buffer (list only) - - tag under cursor ... - ch checkout - cr use as starting point for creating a new branch - de delete - me merge with current branch - sh show the tag - cs show the commit - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitK* - :GitK <args> ~ - -Starts gitk with the given arguments. - ------------------------------------------------------------------------------- - *:GitBash* - :GitBash <args> ~ - -Runs git in an external terminal. Useful for interactive commands, for -example: > - :GitBash add --patch % -< -Windows: If called without arguments, starts the git bash in interactive mode. - ------------------------------------------------------------------------------- - *:GitEdit* - :GitEdit <fileid> ~ - -Edit the file referred to by <fileid>, which must be one of the IDs below. -Use tab-completion for convenience. - - ID File - ---------------------------------------------------------------------------- - config-global $HOME/.gitconfig - config-local $GIT_CONFIG or .git/config - description .git/description - hooks .git/hooks/ - ignore-global -> value of "core.excludesfile" - ignore-local .gitignore - ignore-private .git/info/exclude - modules .gitmodules - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - *:GitSupportHelp* *:GitSupportSettings* - :GitSupportHelp ~ - -Opens the help for Git Support. - - :GitSupportSettings ~ - :GitSupportSettings! ~ - -Shows the plug-in settings. The second version is verbose. - ------------------------------------------------------------------------------- -3.1 COMMAND-LINE COMPLETION *gitsupport-cmds-cmd-line* ------------------------------------------------------------------------------- - *g:Git_MapCompleteBranch* *g:Git_MapCompleteCommand* - *g:Git_MapCompleteRemote* *g:Git_MapCompleteTag* -The user can configure maps to complete the names of branches, remotes, tags -and Git-commands on the command-line. The command-line is set up to complete -filenames using "tab". Other elements are completed using special keys, which -may be configured like this: -> - let g:Git_MapCompleteBranch = '<c-b>' " complete branches, CTRL-B - let g:Git_MapCompleteCommand = '<c-s>' " complete commands, CTRL-S - let g:Git_MapCompleteRemote = '<c-r>' " complete remotes, CTRL-R - let g:Git_MapCompleteTag = '<c-t>' " complete tags, CTRL-T -< -These maps are not set up by default. Only if one of these variables is set, -then the corresponding map is created. - -Normally, the part between the cursor and the last space is completed. For -example, with the cursor at ^: > - :GitShow ma - ^ -Using CTRL-B (for completing branches) would result in: > - :GitShow master - ^ -Using CTRL-B again would go back to the beginning or another branch starting -with "ma...": > - :GitShow maintain-v1.1 - ^ -For completing branches and tags a special rule is used. If the part between -the cursor and the last space contains a ".." or "...", then only the part -starting at the dots is completed: > - :GitShow feature.dev..ma - ^ -Using CTRL-B will still result in: > - :GitShow feature.dev..master - ^ -< -If the part after the last space starts with "--some-option=", the part follow -the "=" is completed: > - :GitK --select-commit=ma - ^ -Using CTRL-B will also correctly complete the name of the branch: > - :GitK --select-commit=master - ^ -< -Completing for Git commands and options is performed with the maps configured -via |g:Git_MapCompleteCommand|. For the first word after |:Git|, |:GitRun|, -|:GitBash|, ..., the names of Git commands are complete: > - :GitBash a - :GitBash add - :GitBash apply - :GitBash a... -If the Git command has been recognized, such as: > - :GitDiff - :Git! diff - :GitBash diff -then command-line options are completed: > - :GitBash diff --c - :GitBash diff --cached - :GitBash diff --color-words - :GitBash diff --c... -< -============================================================================== -4. SYNTAX HIGHLIGHTING *gitsupport-syntax* -============================================================================== - -Git Support comes with syntax highlighting for various kinds of Git output. -The appearance can be changed by the user, by adding custom settings to the -file .vimrc. - -The default configuration is to use Vim's own syntax categories as fallbacks, -which should achieve a certain interoperability with Vim's colorschemes. - - Category Short Description Example - ---------------------------------------------------------------------------- - GitComment comments (uses 'Comment') see :GitStatus - GitHeading a heading (bold font) diff header - GitHighlight1 a highlight (uses 'Identifier') current branch - GitHighlight2 another highlight (uses 'PreProc') commit hash - GitHighlight3 another highlight (underlined) diff range - GitWarning a warning (uses 'WarningMsg') - GitSevere a stern warning (uses 'ErrorMsg') - - GitAdd an added file/line (uses 'DiffAdd') diff output - GitRemove a removed file/line (uses 'DiffDelete') diff output - GitConflict a (merge) conflict (uses 'DiffText') diff output - - GitGrepPath a path (uses 'Directory') grep output - GitGrepLineNr a line number (uses 'LineNr') grep output - ---------------------------------------------------------------------------- - -Suggestions for a syntax highlighting which resemble Git's own highlighting -can be found in the file "git-support/rc/additions.vimrc". For a bright -background it suggests the following settings: > - - highlight GitHeading cterm=bold gui=bold - highlight GitHighlight1 ctermfg=Green guifg=DarkGreen - highlight GitHighlight2 ctermfg=DarkYellow guifg=DarkYellow - highlight GitHighlight3 cterm=bold ctermfg=Cyan gui=bold guifg=DarkCyan - highlight GitAdd ctermfg=Green guifg=SeaGreen - highlight GitRemove ctermfg=Red guifg=Red - highlight GitConflict cterm=bold ctermfg=White ctermbg=Red - \ gui=bold guifg=White guibg=Red - -Example: > - -To display the current branch in yellow instead of green use: > - highlight GitBranchCurrent ctermfg=Yellow guifg=DarkYellow - ------------------------------------------------------------------------------- -4.1 BRANCH *gitsupport-syn-branch* ------------------------------------------------------------------------------- - -Only the current branch is highlighted. - - Category Short Description - ---------------------------------------------------------------------------- - GitBranchCurrent the current branch (line starting with "*") - -> uses GitHighlight1 - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- -4.2 COMMIT *gitsupport-syn-commit* ------------------------------------------------------------------------------- - -Highlights characters exceeding the maximal length of a line: - 1st line - max. 50 characters - 2st line - should be empty - others - max. 76 characters - - Category Short Description - ---------------------------------------------------------------------------- - GitWarning characters exceeding the maximal length of the line - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- -4.3 DIFF *gitsupport-syn-diff* ------------------------------------------------------------------------------- - -The headers of the output for each file are highlighted, as well as each range -"@@ <range> @@" and inserted and deleted lines. Folds are created for each -file and subfolds for each block (starting with "@@ <range> @@"). For unmerged -files, regions with conflicts are highlighted as well. -This highlighting is also used for ":GitStash show" - - Category Short Description - ---------------------------------------------------------------------------- - GitDiffHeader the header generated for each file - (lines like "diff ...", "index ...", ...) - -> uses GitHeading - GitWhiteTab whitespaces before a tab in an inserted line - -> uses GitSevere - GitTrailingWhite trailing whitespaces in an inserted line - -> uses GitSevere - ---------------------------------------------------------------------------- - GitDiffRange the range of a single block of the output - (line "@@ <range> @@ ...") - -> uses GitHighlight3 - GitDiffLineP inserted lines (lines starting with "+") - -> uses GitAdd - GitDiffLineM removed lines (lines starting with "-") - -> uses GitRemove - ---------------------------------------------------------------------------- - GitMergeRange the range of a single block of the output - (line "@@@ <range> @@@ ...") - -> uses GitHighlight3 - GitMergeLineP inserted lines (lines starting with "+ " or " +") - -> uses GitAdd - GitMergeLineM removed lines (lines starting with "- " or " -") - -> uses GitRemove - GitMergeConflict lines signaling regions with conflicts - (lines like "++<<<<<<< HEAD", "++=======" or - "++>>>>>>> master") - -> uses GitConflict - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- -4.4 GREP *gitsupport-syn-grep* ------------------------------------------------------------------------------- - -Highlights the path and (optional) line number at the beginning of each line. - - Category Short Description - ---------------------------------------------------------------------------- - GitGrepPath the path at the beginning of each line - GitGrepLineNr the line number following it - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- -4.5 LOG *gitsupport-syn-log* ------------------------------------------------------------------------------- - -The name of each commit and the information about the author, date, ... are -highlighted. Folds are created for each commit. -This highlighting is also used for ":GitStash list", ":GitShow <commit>" and -":GitShow <tag>". - - Category Short Description - ---------------------------------------------------------------------------- - GitLogHash the name of the commit (line "commit <hash>") - -> uses GitHighlight2 - GitLogRef refs obtained with "git log --decorate" - -> uses GitHighlight1 - GitLogInfo information about the commit - (lines like "Author: ..." or "Date: ...") - -> uses GitHighlight1 - GitStashName the name of a stash (line "stash@{123}: ...") - -> no highlighting by default - GitTagName the name of the tag (line "tag <name>") - -> uses GitHighlight2 - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- -4.6 STATUS *gitsupport-syn-status* ------------------------------------------------------------------------------- - -Various items are hightlighted, like the headlines of each section and the -files (in green and red). Adds a fold for each section "Changes to be -committed:", "Changes not staged for commit:", ... - - Category Short Description - ---------------------------------------------------------------------------- - GitStatusHeader the header of each section - (lines like "# Changes not staged for commit:") - -> uses GitHeading - GitStatusComment additional help inserted into the output - (lines like "# (use 'git add <file>...' to ...)") - -> uses GitComment - GitStagedFile files listed as "to be committed" - -> uses GitAdd - GitModifiedFile files listed as "not staged for commit" - -> uses GitRemove - GitUntrackedFile files listed as "untracked" - -> uses GitRemove - GitIgnoredFile files listed as "ignored" - -> uses GitRemove - GitUnmergedFile files listed as "unmerged" - -> uses GitRemove - ---------------------------------------------------------------------------- - -============================================================================== -5. CUSTOM MENUS *gitsupport-menus* -============================================================================== - *g:Git_CustomMenu* -The custom menu entries offer convenient access to often used Git commands, -especially those with regularly used combinations of flags. All custom menu -entries appear in the sub menu "Git->custom". They are defined via the global -variable 'g:Git_CustomMenu': -> - let g:Git_CustomMenu = [ - \ [ 'log, grep &commit msg..', ':GitLog', ':GitLog -i --grep="<CURSOR>"' ], - \ [ 'log, grep &diff output', ':GitLog', ':GitLog -p -S "<CURSOR>"' ], - \ [ 'log, &graph', ':GitLog', ':GitLog --graph<EXECUTE>' ], - \ [ '-SEP1-', '', '' ], - \ [ '&merge, ff only', ':GitMerge', ':GitMerge --ff-only <CURSOR>' ], - \ [ '&merge, no commit', ':GitMerge', ':GitMerge --no-commit <CURSOR>' ], - \ [ '&merge, abort', ':GitMerge', ':GitMerge --abort<EXECUTE>' ], - \ ] -< -The variable must contain a list of lists of strings. A |List| is constructed -using square brackets containing a number of comma-separated entries. Each -list contained in 'g:Git_CustomMenu' defines a menu entry. It consists of -three strings. The first defines the submenu and the menu entry, the second -the right-aligned side of the menu entry and the third the command triggered -by the entry. - -The menu entry is a string, where dots and ampersands have special meanings. -Dots structure the menu by defining submenus. To put the entries from above -into a submenu "log", use: -> - let g:Git_CustomMenu = [ - \ [ '&log.grep &commit msg..', ':GitLog', ':GitLog -i --grep="<CURSOR>"' ], - \ [ '&log.grep &diff output', ':GitLog', ':GitLog -p -S "<CURSOR>"' ], - \ [ '&log.-SEP1-', '', '' ], - \ [ '&log.&graph', ':GitLog', ':GitLog --graph<EXECUTE>' ], - ... -< -Ampersands set shortcuts for menu entries and submenus. To include a literal -dot or ampersands use '..' or '&&' respectively. Separators are inserted if -the name of the entry starts and ends with a minus. They can also appear in -submenus. - -The third string defines the command associated with the entry. If it contains -the <EXECUTE> tag at the end, the command will be executed directly. The <CR> -tag, which advanced Vim users will be familiar with, is also supported. If the -command contains the <CURSOR> tag instead, the command will be shown on the -command line, with the cursor at that position. Now the user can configure the -call before executing it. - -Furthermore, <WORD> is replaced with the |word| under the cursor (|<cword>| or -|<cWORD>| can be used as well). The tag <FILE> is replaced with the name of the -file under the cursor, <BUFFER> with the name of the file loaded in the -current buffer. - -These tags are available: - - Tag Short Description - ---------------------------------------------------------------------------- - <EXECUTE> execute the command immediately - <CURSOR> open the command-line with the cursor at this position - - <BUFFER> the name of the current buffer - <FILE> the file under the cursor (see |<cfile>|) - <WORD> the word under the cursor (see |<cword>|) - ---------------------------------------------------------------------------- - -The file "git-support/rc/additions.vimrc" contains the standard value for -'g:Git_CustomMenu', as a basis for customization. - -============================================================================== -6. CONFIGURATION *gitsupport-configuration* -============================================================================== - -The configuration is done via a number of global variables, which can be set -in the .vimrc file. - - Variable Default Description and further information - ---------------------------------------------------------------------------- - |g:Git_BinPath| '' the path to the Git binaries (^1) - |g:Git_Executable| 'git' the Git executable (^1) - |g:Git_GitKExecutable| 'gitk' the gitk executable (^1) - |g:Git_GitKScript| '' the gitk script (^1) - |g:Git_GitBashExecutable| 'xterm' the git bash executable (^1) (^2) - |g:Git_LoadMenus| 'yes' whether to load the menus - ('yes' or 'no') - |g:Git_RootMenu| '&Git' name and shortcut of the root menu - |g:Git_CustomMenu| [ ... ] custom menu entries - - expansion of empty argument lists to the current file: - |g:Git_CheckoutExpandEmpty| 'no' for |:GitCheckout| - |g:Git_DiffExpandEmpty| 'no' for |:GitDiff| - |g:Git_ResetExpandEmpty| 'no' for |:GitReset| - - |g:Git_OpenFoldAfterJump| 'yes' whether commands which open a file - open the folds under the cursor - |g:Git_StatusStagedOpenDiff| 'cached' how to execute "open diff" from - inside the status buffer in section - "Changes to be committed" - - g:Xterm_Executable 'xterm' the xterm executable (^3) - g:Xterm_Options '...' the xterm default settings (^3) - ---------------------------------------------------------------------------- - -(^1) - The Unix defaults are as follows: - |g:Git_BinPath| - -empty- - |g:Git_Executable| - g:Git_BinPath + git - |g:Git_GitKExecutable| - g:Git_BinPath + gitk - |g:Git_GitKScript| - -empty- - the Windows defaults are as follows: - |g:Git_BinPath| - C:\Program Files\Git\bin\ - |g:Git_Executable| - g:Git_BinPath + git.exe - |g:Git_GitKExecutable| - g:Git_BinPath + tclsh.exe - |g:Git_GitKScript| - g:Git_BinPath + gitk - |g:Git_GitBashExecutable| - g:Git_BinPath + sh.exe -(^2) under UNIX, the default for g:Git_GitBashExecutable is the value of - g:Xterm_Executable, which in turn is "xterm" -(^3) UNIX only, see |gitsupport-config-xterm| - ------------------------------------------------------------------------------- -6.1 EXECUTABLE *gitsupport-config-executable* ------------------------------------------------------------------------------- - *g:Git_BinPath* -The path to the executables is set by g:Git_BinPath: > - let g:Git_BinPath = '/usr/local/bin/' -Since git and gitk will be on the path, this will not be necessary on most -UNIX systems. - -For Windows, set up the binary path similar to this: > - let g:Git_BinPath = 'C:\Program Files\Git\bin\' -< -The defaults for |g:Git_Executable|, |g:Git_GitKExecutable|, |g:Git_GitKScript| -and |g:Git_GitBashExecutable| are derived from g:Git_BinPath. However, the -setting g:Git_BinPath is only used to derive the defaults. If one of the -executables is set explicitly, it has to be set with the whole path. - - *g:Git_Executable* -The executable is set by g:Git_Executable. You should use the English language -environment: > - let g:Git_Executable = 'LANG=en_US git' -< -For Windows, set up the executable similar to this: > - let g:Git_Executable = 'C:\Program Files\Git\bin\git.exe' -< - *g:Git_GitKExecutable* *g:Git_GitKScript* -Sets the gitk executable. You should use the English language environment: > - let g:Git_Executable = 'LANG=en_US gitk' -< -For Windows, set up gitk similar to this, the interpreter and the gitk script -have to be given separately: > - let g:Git_GitKExecutable = 'C:\Program Files\Git\bin\tclsh.exe' - let g:Git_GitKScript = 'C:\Program Files\Git\bin\gitk' -< - *g:Git_GitBashExecutable* -Sets the git bash executable. Under UNIX "xterm" is used. - -For Windows, set up the executable similar to this: > - let g:Git_GitBashExecutable= 'C:\Program Files\Git\bin\sh.exe' -< ------------------------------------------------------------------------------- -6.2 MENUS *gitsupport-config-menus* ------------------------------------------------------------------------------- - *g:Git_LoadMenus* -The creation of the menus is controlled by g:Git_LoadMenus. The default -setting: > - let g:Git_LoadMenus = 'yes' -causes the menus to appear right away after starting Vim. -The automatic creation of the menus is prevented by: > - let g:Git_LoadMenus = 'no' -Now the menus can only be loaded by using the tool menu entry 'Tools->Load -Git Support'. - ------------------------------------------------------------------------------- - *g:Git_RootMenu* -The name and shortcut of the root menu is set via g:Git_RootMenu. The -character prefixed by '&' will be the shortcut. - -Example: > - let g:Git_RootMenu = 'G&it' -Sets the shortcut to 'i'. - ------------------------------------------------------------------------------- -6.3 MAPS *gitsupport-config-maps* ------------------------------------------------------------------------------- - -You can add hotkeys for your favorite commands by adding maps to your .vimrc. - -With these lines, <F10> will open the status buffer: > - noremap <silent> <F10> :GitStatus<CR> - inoremap <silent> <F10> <C-C>:GitStatus<CR> -< ------------------------------------------------------------------------------- -6.4 SETTINGS *gitsupport-config-settings* ------------------------------------------------------------------------------- - *g:Git_CheckoutExpandEmpty* *g:Git_DiffExpandEmpty* - *g:Git_ResetExpandEmpty* -The default behavior of |:GitDiff|, when called without arguments, is to show -a diff containing all unstaged changes. - -In order to make the behavior more consistent with commands like |:GitAdd|, -this can be changed by setting: > - let g:Git_DiffExpandEmpty = 'yes' -Now calling ":GitDiff" without any arguments opens a buffer displaying only -the changes of the file in the current buffer, which is the same as calling: > - :GitDiff % -So the empty argument list is "expanded". -But even with g:Git_DiffExpandEmpty == 'yes', you can still display a diff -containing all changes by calling: > - :GitDiff -- -This is not detected to be an empty argument list. - -Similarly, the behavior of |:GitCheckout| and |:GitReset| can be changed to -operate on the file in the current buffer when called without arguments, by -setting: > - let g:Git_CheckoutExpandEmpty = 'yes' - let g:Git_ResetExpandEmpty = 'yes' -< -The possible settings are listed below: - - Value Meaning :GitDiff expands to ... - ---------------------------------------------------------------------------- - 'yes' expand empty argument list git diff -- <file> - 'no' (default) Git's standard behavior git diff - ---------------------------------------------------------------------------- - -The behavior can be changed on the fly by settings the variable to a different -value on the command line. - ------------------------------------------------------------------------------- - *g:Git_OpenFoldAfterJump* -Some maps jump from Git buffers to files. By default they open all the folds -under the cursor via |zv|. This behavior can be switched off by settings: > - let g:Git_OpenFoldAfterJump = 'no' -< -The possible settings are listed below: - - Value Meaning - ---------------------------------------------------------------------------- - 'yes' (default) open all the folds under the cursor - 'no' do not - ---------------------------------------------------------------------------- - -The behavior can be changed on the fly by settings the variable to a different -value on the command line. - ------------------------------------------------------------------------------- - *g:Git_StatusStagedOpenDiff* -Within the status buffer, the map 'od' can be used to display the diff for the -file under the cursor. The normal behavior is to open the "default" diff -between the index and the working tree. In the section containing the staged -files, titled "Changes to be committed", this behavior is different and can be -controlled by g:Git_StatusStagedOpenDiff. Setting > - let g:Git_StatusStagedOpenDiff = 'cached' -means the diff will be opened displaying the staged changes. - -The other possible settings are listed below: - - Value Meaning Open diff via ... - ---------------------------------------------------------------------------- - 'cached' (default) staged changes git diff --cached -- <file> - 'head' all changes git diff HEAD -- <file> - any other unstaged changes git diff -- <file> - ---------------------------------------------------------------------------- - -The behavior can be changed on the fly by settings the variable to a different -value on the command line. - ------------------------------------------------------------------------------- -6.5 XTERM *gitsupport-config-xterm* ------------------------------------------------------------------------------- - -The xterm related functionality is only available under UNIX. It is used to -run interactive commands. - - g:Xterm_Executable -The xterm executable is set by g:Xterm_Executable, for example: > - let g:Xterm_Executable = '/usr/local/bin/xterm' -< - g:Xterm_Options -Set additional options for xterm. The default is: > - let g:Xterm_Options = '-fa courier -fs 12 -geometry 80x24' -< -For example, use these arguments for black letters on a white background: > - let g:Xterm_Options = '-fg black -bg white -fs 12 -geometry 80x24' -< -See the man-page of xterm for the possible options. - -The behavior can be changed on the fly by settings the variable to a different -value on the command line. - -============================================================================== -A. TROUBLESHOOTING - KNOWN ISSUES *gitsupport-troubleshooting* -============================================================================== - -* How can I see what was loaded? - - Use ':scriptnames' from the Vim command line. - -* git is not running. - - Is "git" executable from the command line? - - Is the $PATH variable set correctly? - - Are the settings correct? See: - :help |gitsupport-config-executable| - -* Windows: When entered on the Vim command line, commands containing filenames - as arguments cause errors such as "... file not found ...". - - This may happen if filenames contain special characters such as spaces. - The Vim command line escapes those differently then Windows expects them - to be escaped. - - However, a filename containing spaces can always be escape using quotes: - :GitAdd "help 1.txt" - - If you already are in the corresponding buffer, simply use: - :GitAdd - ------------------------------------------------------------------------------- - -* :GitBlame does not work correctly when the visual area consists only of the - first line. - - This seems to be a weakness with Vim's support for ranges. At least I - could not find a way around this. - - Workaround: Run :GitBlame on the first two lines. - - The usefulness of :GitBlame supporting ranges by far outweighs this - downside, in my opinion. - -============================================================================== -B. RELEASE NOTES - CHANGE LOG *gitsupport-release-notes* -============================================================================== - -See files 'git-support/README.md' and 'git-support/doc/ChangeLog'. - -============================================================================== -C. CREDITS *gitsupport-credits* -============================================================================== - -Jinhu Lu (vim.org user name: KingTiger): -- the idea for command-line completion of branches, remotes, tags, ... - (|gitsupport-cmds-cmd-line|) is taken from his plug-in "cmdline completion" - ( http://www.vim.org/scripts/script.php?script_id=3531 ) - -============================================================================== -vim:tw=78:expandtab:ts=2:ft=help:norl: diff --git a/doc/latexsupport.txt b/doc/latexsupport.txt index 8e314ea..10c4860 100644 --- a/doc/latexsupport.txt +++ b/doc/latexsupport.txt @@ -1,22 +1,26 @@ -*latexsupport.txt* LaTeX Support Jul 28 2017 +*latexsupport.txt* LaTeX Support Nov 22 2020 LaTeX Support *latex-support* *latexsupport* - Plug-in version 1.3alpha - for Vim version 7.0 and above + Plug-in version 2.0beta + for Vim version 7.4 and above Wolfgang Mehner <wolfgang-mehner@web.de> Fritz Mehner <mehner.fritz@web.de> -LaTeX-IDE for Vim/gVim. It is written to considerably speed up typesetting a -document in a consistent style. This is done by inserting complete statements, -idioms, code snippets, and comments. Compiling and viewing a document, format -conversion and running make can be done with a few keystrokes. +LaTeX-IDE for Vim/gVim/Neovim. It is written to considerably speed up +typesetting a document in a consistent style. This is done by inserting +complete statements, idioms, code snippets, and comments. Compiling and +viewing a document, format conversion and running make can be done with +a few keystrokes. +See the chapter |latexsupport-introduction| for a quick overview and a short +guide to this documentation. ============================================================================== 0. TABLE OF CONTENTS *latexsupport-contents* ============================================================================== 1. Introduction |latexsupport-introduction| + 2. Usage |latexsupport-usage| 2.1 Comments |latexsupport-usage-comments| 2.1.1 End-of-Line Comments |latexsupport-usage-comments-eol| @@ -33,35 +37,33 @@ conversion and running make can be done with a few keystrokes. 2.6 Hardcopy |latexsupport-usage-hardcopy| 2.7 Help |latexsupport-usage-help| 2.8 Toolbox |latexsupport-usage-toolbox| + 3. Templates |latexsupport-templates| 3.1 Introduction |latexsupport-templates-introduction| - 3.2 Jump Tags |latexsupport-templates-jump-tags| - 3.3 Split Tags |latexsupport-templates-split-tags| - 3.4 Macros |latexsupport-templates-macros| - 3.5 Template Files |latexsupport-templates-files| - 3.6 Template Libraries |latexsupport-templates-libs| - -4. Customization |latexsupport-customization| -4.1 Files |latexsupport-custom-files| -4.2 Global Variables |latexsupport-custom-variables| -4.3 The Root Menu |latexsupport-custom-root| -4.4 System-wide installation |latexsupport-system-wide| - -5. Template Files and Tags |latexsupport-old-templ| -5.1 Template Files |latexsupport-old-templ-files| -5.2 Macros |latexsupport-old-templ-macros| -5.2.1 Formating Date and Time |latexsupport-old-templ-date| -5.3 Templates |latexsupport-old-templ-names| -5.3.1 Template definition |latexsupport-old-templ-definition| -5.3.2 The jump tags <+text+> etc. |latexsupport-old-templ-jumptags| -5.3.3 Command Ctrl-j |latexsupport-Ctrl-j| -5.4 File Skeletons |latexsupport-file-skeleton| - -6. LaTeX Dictionary |latexsupport-dictionary| + 3.2 Customization |latexsupport-templates-custom| + 3.3 Jump Tags |latexsupport-templates-jump-tags| + 3.4 Split Tags |latexsupport-templates-split-tags| + 3.5 Macros |latexsupport-templates-macros| + 3.6 Template Files |latexsupport-templates-files| + 3.7 Template Libraries |latexsupport-templates-libs| + 3.8 File Skeletons |latexsupport-file-skeleton| + + 4. Configuration |latexsupport-configuration| + 4.1 Typesetters, Viewers, Converters |latexsupport-config-external| + 4.2 Menus |latexsupport-config-menus| + 4.3 Maps |latexsupport-config-maps| + 4.4 Comments |latexsupport-config-comments| + 4.5 Snippets |latexsupport-config-snippets| + 4.6 Dictionary |latexsupport-config-dictionary| + 4.7 Hardcopy |latexsupport-config-hardcopy| + 4.8 Toolbox |latexsupport-config-toolbox| + + 5. System-wide Installation |latexsupport-system-wide| A. Overview of Mappings |latexsupport-mappings| - B. Troubleshooting - Known Issues |latexsupport-troubleshooting| - C. Release Notes - Change Log |latexsupport-release-notes| + B. Files |latexsupport-files| + C. Troubleshooting - Known Issues |latexsupport-troubleshooting| + D. Release Notes - Change Log |latexsupport-release-notes| ============================================================================== 1. INTRODUCTION *latexsupport-introduction* @@ -80,7 +82,7 @@ auto completion.) The features of the plug-in are: - Turn code lines into comments and vice versa. |latexsupport-usage-comments-lines| -- Open the online documentation for a given function. +- Open the online documentation for a given package or command. |latexsupport-usage-help| - Run the typesetter. |latexsupport-usage-run| - Change the typesetter on-the-fly. |latexsupport-usage-run| @@ -91,10 +93,10 @@ The features of the plug-in are: - Make integration. |latexsupport-usage-toolbox| The usage of most features is described in the chapter |latexsupport-usage|. -The chapter |latexsupport-templates| gives a short introduction to the template -system. The LaTeX executables and some other features may require some -configuration, which is documented in the chapter |luasupport-configuration|. -How to do a system-wide installation is outlined in |luasupport-system-wide|. +The chapter |latexsupport-templates| gives a short introduction to the +template system. The LaTeX executables and other features may require some +configuration, which is documented in the chapter |latexsupport-configuration|. +How to do a system-wide installation is outlined in |latexsupport-system-wide|. The template system comes with its own documentation, which mainly aims at the advanced user (see |templatesupport.txt|). @@ -105,13 +107,14 @@ advanced user (see |templatesupport.txt|). Features are accessible via menu entries and maps. Most maps are preceded by a mapleader. The leader is an acute accent "´", if the standard configuration is -used. (The default mapleader in Vim, the backslash "\", is not an appropriate -choice for typesetting in LaTeX.) +used. +(The default mapleader in Vim, the backslash "\", is not an appropriate choice +for typesetting in LaTeX. The mapleader is configured via |g:Latex_MapLeader|) If the root menu 'LaTeX' is not visible you also can load it with the item "Load LaTeX Support" from the "Tools" menu. The item "Unload LaTeX Support" can be used to unload the LaTeX root menu. -(Compare |latexsupport-custom-root|.) +(Compare |latexsupport-config-menus|.) ------------------------------------------------------------------------------ 2.1 COMMENTS *latexsupport-usage-comments* @@ -155,7 +158,7 @@ be changed by setting a global variable in the file .vimrc , e.g. : > The starting column can also be set by the menu item "Comments->adjust end-of-line com.". Just position the cursor in an arbitrary column (normal mode; the column number is shown in the Vim status line) and choose this menu -item. This setting is done individually for each buffer. +item. This setting is stored individually for each buffer. If the cursor was at the end of a line you will be asked for a column number because this position is most likely not the desired starting column. @@ -176,12 +179,17 @@ comments in the marked block will be aligned: \begin{flushleft} % comment 2 \large{\textbf{Ex Commands}}\\[1.0ex] % comment 3 < +Another way is to use the hotkey `´cj`. In normal and insert mode the current +line will be adjusted. To adjust n lines starting with the current one use +`n\cj`. + ------------------------------------------------------------------------------ 2.1.2 Toggle Comment Lines *latexsupport-usage-comments-lines* The comment sign % can be inserted or removed at the beginning of the current -line or for a marked block. A single line does not need to be marked. +line or for a marked block, using the menu item 'comment' (or `´cc`). A single +line does not need to be marked. For a marked block containing only lines with a '%' in the first column (and possibly empty lines) all lines will be uncommented. A marked block containing @@ -202,7 +210,7 @@ files (see |latexsupport-templates|). The 'Text' and 'Math' menus contain the most frequently used statements. The menu entries insert some code into the buffer. Almost all menu entries also have a map, making the same behavior accessible more quickly. E.g. the menu -entry "Text->environment" has the map ´e . +entry "Text->environment" has the map `´e`. Many statements behave differently depending on the mode. @@ -217,6 +225,8 @@ statement will be inserted: | \end{center} < +The character '|' marks the cursor position after insertion. + VISUAL MODE ------------------------------- @@ -234,13 +244,13 @@ by the statement: \end{center} < This "split mode" works for many of the menu entries. With the word 'Length' -selected, the map ´msq or the menu entry "Math->sqrt" will surround it with +selected, the map `´msq` or the menu entry "Math->sqrt" will surround it with the sqrt-statement: > ... \sqrt[|]{Length} ... < Lots of submenus are only associated with one map. E.g. all the entries in -"Math->spaces->..." can be accessed via the map ´msp . You will be prompted +"Math->spaces->..." can be accessed via the map `´msp`. You will be prompted for your choice. Use tab-expansion to display the choices and the arrow keys to select an item: > @@ -294,7 +304,7 @@ snippet file. Otherwise the marked area will be written to a file. Insert a snippet ---------------- -Select the appropriate file from the snippet directory ("read code snippet"). +Select the appropriate file from the snippet directory via "read code snippet". The inserted lines will be indented. Indentation / no indentation @@ -329,13 +339,13 @@ them if appropriate. ------------------------------------------------------------------------------ External tools like the typesetters and BibTeX can be run with a keystroke. -(See Section |luasupport-config-executable| for the configuration.) +(See Section |latexsupport-config-external| for the configuration.) Feature Menu Entry Map ---------------------------------------------------------------------------- run the typesetter Run.save + run typesetter <LocalLeader>rr run lacheck Run.save + run lacheck <LocalLeader>rla - set the main document Run.set main document <LocalLeader>rsd + set the main document Run.set main document <LocalLeader>rmd view errors from last BG Run.view last errors <LocalLeader>re open the resulting DVI Run.View.DVI <LocalLeader>rdvi @@ -343,16 +353,16 @@ External tools like the typesetters and BibTeX can be run with a keystroke. open the resulting PS Run.View.PS <LocalLeader>rps convert the result Run.Convert.###->### <LocalLeader>rc - run makeglossaries run makeglossaries <LocalLeader>rmg - run makeindex run makeindex <LocalLeader>rmi - run BibTeX run bibtex <LocalLeader>rbi + run makeglossaries Run.run makeglossaries <LocalLeader>rmg + run makeindex Run.run makeindex <LocalLeader>rmi + run BibTeX Run.run bibtex <LocalLeader>rbi change the typesetter Run.choose typesetter <LocalLeader>rt set the processing mode Run.external processing <LocalLeader>rp ---------------------------------------------------------------------------- The functionality is also available through ex-commands. These commands can -also be used to set different maps in the ftplugin. +also be used to set different maps in the |ftplugin|. Command Explanation ---------------------------------------------------------------------------- @@ -371,16 +381,16 @@ also be used to set different maps in the ftplugin. *:LatexConvert* [<doc>] convert a document ---------------------------------------------------------------------------- -To run the typesetter for the tex file in the current buffer, use the map ´rr , +To run the typesetter for the tex file in the current buffer, use the map `´rr`, the menu entry "Run->save + run typesetter" or the ex-command |:Latex|. Using the command, you can also run LaTeX for other files: > :Latex some_other_doc.tex < -You can run the typesetter in the background (requires the |+job| feature). -Choose the processing mode via |:LatexProcessing|: > +You can run the typesetter in the background (requires the |+job| feature or +Neovim). Choose the processing mode via |:LatexProcessing|: > :LatexProcessing background Now you can continue working while your document is compiling. After the -typesetter finished a message is displayed. In case of errors, you can load +typesetter finishes, a message is displayed. In case of errors, you can load them into the |quickfix| buffer using: > :LatexErrors < @@ -390,6 +400,9 @@ tools for the file in the current buffer. You can set the main document via: > :LatexMainDoc <tex-file> Now, when running the typesetter, the working directory will be changed before compiling the main document. +The call `:LatexView` without arguments will now show the PDF or DVI belonging +to the main document. E.g., when the main doc is `mydir/somefile.tex`, the +file `mydir/somefile.pdf` will be opened in the PDF viewer. ------------------------------------------------------------------------------ @@ -409,19 +422,19 @@ editing "myfile.tex" in the current buffer, then the defaults are as follows: ---------------------------------------------------------------------------- :Latex yes myfile.tex yes (|+job|) :LatexCheck no myfile.tex no - :LatexBibtex myfile + :LatexBibtex yes myfile no :LatexMakeglossaries myfile :LatexMakeindex myfile.idx - :LatexView myfile.dvi always (forked) - (with typesetter *tex) - :LatexView myfile.pdf always (forked) - (with typesetter *latex) - :LatexConvert myfile.FROM + :LatexView yes myfile.dvi always (forked) + (with typesetter tex or latex) + :LatexView yes myfile.pdf always (forked) + (with typesetter pdf[la]tex or lua[la]tex) + :LatexConvert yes myfile.FROM yes (|+job|) (the default name depends on the conversion operation: FROM-TO) ---------------------------------------------------------------------------- Some commands use background processing if it has been set as the processing -mode. The viewers are always run in the background, since that are forked and +mode. The viewers are always run in the background, since they are forked and do not rely on the |+job| feature. ------------------------------------------------------------------------------ @@ -432,7 +445,7 @@ The default typesetter is 'pdflatex'. This can be changed by assigning one of the values 'tex', 'latex', 'pdftex', 'luatex', and 'lualatex' to the variable |g:Latex_Typesetter| in your .vimrc file: > let g:Latex_Typesetter = 'latex' -The typesetter can be changes on-the-fly using: > +The typesetter can be changed on-the-fly using: > :LatexTypesetter <typesetter> The way the typesetters are called can be changed in the .vimrc file, by using one of these configuration variables: @@ -452,7 +465,7 @@ To define the following function keys in normal, visual, and insert mode: F9 run typesetter CTRL-F9 run viewer -Add these lines to your Latex filetype plug-in: > +add these lines to your Latex filetype plug-in: > nnoremap <buffer> <F9> :Latex<CR> inoremap <buffer> <F9> <Esc>:Latex<CR> @@ -471,7 +484,7 @@ code checker has found in the code. It is controlled by the commands: - |:copen| and |:cclose| : open or close the quickfix window -- |:cnext| and |:cprevious| : jump to the next previous error +- |:cnext| and |:cprevious| : jump to the next or previous error The fastest way of using them is to put maps like this into your .vimrc file: > @@ -482,7 +495,7 @@ The fastest way of using them is to put maps like this into your .vimrc file: < You can now use F5 and F6 to open and close the quickfix window and F7 and F8 to jump to the errors. -Compare the file 'customization.vimrc', see |latexsupport-custom-files|. +Compare the file 'customization.vimrc', see |latexsupport-files|. ------------------------------------------------------------------------------ 2.6 HARDCOPY *latexsupport-usage-hardcopy* @@ -505,7 +518,7 @@ The printheader on top of each page can be set via |g:Latex_Printheader|. 2.7 HELP *latexsupport-usage-help* ------------------------------------------------------------------------------ -This submenu offers convenient access to various documentations. +This sub-menu offers convenient access to various documentations. Feature Menu Entry Map ---------------------------------------------------------------------------- @@ -520,10 +533,9 @@ name of a package. The entry 'English' opens an online dictionary for the word under the cursor. -The browser for opening the online documentation, or the English dictionary, +The browser for opening online documentation, such as the English dictionary, can be configured by setting a global variable in your ~/.vimrc (see -|g:Templates_InternetBrowserExec| and |g:Templates_InternetBrowserFlags|): -> +|g:Templates_InternetBrowserExec| and |g:Templates_InternetBrowserFlags|): > let g:Templates_InternetBrowserExec = 'firefox' < ------------------------------------------------------------------------------ @@ -532,7 +544,7 @@ can be configured by setting a global variable in your ~/.vimrc (see More functionality, not directly related to LaTeX, is provided in the so-called "Toolbox". By default, an integration for Make is inserted into the -toolbox. For the configuration, see |luasupport-config-toolbox|. The toolbox +toolbox. For the configuration, see |latexsupport-config-toolbox|. The toolbox comes with its own documentation, see |toolbox| and |toolbox-make|. To switch the Tool Box off add the following line to the file .vimrc : > @@ -572,7 +584,8 @@ This plug-in makes heavy use of an extendible template library. A template library can assist in speeding up the writing of code, while at the same time ensuring a consistent style. The templates are written in an easy to use markup language, which enables the user to customize templates without much -hassle. +hassle. The menu shortcuts (e.g. 'c' for the Comments menu) and the maps +(e.g. `´ct` to insert date and time) are also defined in the template library. Templates are short pieces of text which can be included into source code or text of any other kind. But they are not just plain text, they can be extended @@ -586,7 +599,39 @@ replacement text will then be used in the template while it is inserted. Hitting <ESC> or entering an empty text will abort template insertion. ------------------------------------------------------------------------------ -3.2 JUMP TAGS *latexsupport-templates-jump-tags* +3.2 CUSTOMIZATION *latexsupport-templates-custom* +------------------------------------------------------------------------------ + +The master template file is `$HOME/.vim/latex-support/templates/Templates` for +a user installation and `$VIM/vimfiles/latex-support/templates/Templates` for +a system-wide installation (see |latexsupport-system-wide|). + +The template library is customized via your local template files. Use the menu +entries "Snippets -> edit local templates", "Snippets -> edit custom +templates", or "Snippets -> edit personal templates" to get there. + +The master template file can be edited itself to adapt the templates/menus to +the users need. Alternatively, a custom template file can be added (see +|g:Latex_CustomTemplateFile|), which eliminates the need to edit stock +templates. + +The personalization (name, email, ..., date and time format) can be done in a +special personalization template file (see |g:Templates_PersonalizationFile|). +It will be read by all plug-ins which support this feature, so it should only +contain basic information not pertaining to a specific programming language. +It can be set up using a wizard, which is run by the map `´ntw` or the menu +entry "Snippets -> template setup wizard". Afterwards, use the menu entry +"Snippets -> reread templates" to apply the changes. + +Further template files can be added using the call: > + call mmtemplates#config#Add ( 'latex', '<PATH>/some.templates', 'example', 'nte' ) +The first parameter adds the file to your LaTeX templates, the second is the +path. The remaining two optional parameters specify the symbolic name for +these templates and the map to edit them. The map is `´nte` in this example, +if the standard mapleader is set. + +------------------------------------------------------------------------------ +3.3 JUMP TAGS *latexsupport-templates-jump-tags* ------------------------------------------------------------------------------ Templates can include special tags, which mark positions where text needs to @@ -605,23 +650,33 @@ Use the <CTRL-J> to jump to the next tag. The maps works in normal and insert mode. Use <CTRL-D> to delete optional tags on the same line, for example: > string.match ( <+str+>, <+pattern+>, [+init+] ) The optional argument "init" can be written down after jumping to the tag -using <CTRL-J> or deleted together with the comma using <CTRL-D>. +using <CTRL-J> or deleted together with the comma using <CTRL-D>. The optional +tags are: `[+TAGNAME+]` `[-TAGNAME-]` + +The tags written with minus signs are removed when the template is used in +visual mode, compare the next section: `{-TAGNAME-}` `<-TAGNAME->` `[-TAGNAME-]` ------------------------------------------------------------------------------ -3.3 SPLIT TAGS *latexsupport-templates-split-tags* +3.4 SPLIT TAGS *latexsupport-templates-split-tags* ------------------------------------------------------------------------------ -Some templates include so-called split tags and therefore can use to surround -some lines of code, or to surround a part of the current line. +Some templates include so-called split tags and can use to surround some lines +of code, or to surround a part of the current line. Example: +The template "Math.frac" contains a split tag for the nominator: +> + == Math.frac == insert, map:mfr, sc:f == + \frac{<CURSOR><SPLIT>}{<+denominator+>} + == ENDTEMPLATE == +< Consider the formula: > $ c = a + b $ < -The template "Math.frac" contains a split tag for the nominator. After -selecting "a + b" and inserting the template, the result looks like this: +After selecting "a + b" and inserting the template, the result looks like +this: > $ c = \frac{a + b}{<+denominator+>} $ < @@ -629,10 +684,10 @@ The cursor is placed within the first pair of brackets, use <CTRL-J> to jump to the denominator. ------------------------------------------------------------------------------ -3.4 MACROS *latexsupport-templates-macros* +3.5 MACROS *latexsupport-templates-macros* ------------------------------------------------------------------------------ -Macros are placeholder which get replace while a template is inserted. The +Macros are placeholders which get replace while a template is inserted. The template library defines several macros used for personalization: > SetMacro( 'AUTHOR', 'YOUR NAME' ) @@ -666,10 +721,17 @@ for the format specifiers: SetFormat( 'TIME', '%H:%M' ) SetFormat( 'YEAR', 'year %Y' ) < +This sets the format for the date to the preferred representation for your +current locale, the time will be inserted as 10:24 and the year will be +represented using four digits. + ------------------------------------------------------------------------------ -3.5 TEMPLATE FILES *latexsupport-templates-files* +3.6 TEMPLATE FILES *latexsupport-templates-files* ------------------------------------------------------------------------------ +The template definitions are spread out over several template files. These can +contain comments, lines starting with a section sign (§) are ignored. + Template files can include several further files: > IncludeFile( 'comments.templates' ) An included file will be processed before the remainder of the including file. @@ -683,7 +745,7 @@ A template definition starts with a template header with the following syntax: The options are described here: |template-support-options| ------------------------------------------------------------------------------ -3.6 TEMPLATE LIBRARIES *latexsupport-templates-libs* +3.7 TEMPLATE LIBRARIES *latexsupport-templates-libs* ------------------------------------------------------------------------------ The template system comes with several auxiliary functions. @@ -715,15 +777,9 @@ you want, save it, and click on the menu item "reread templates" to read in the file(s) and to rebuild the internal representation of the templates. For how to use these files to configure and personalize the template library, -see |luasupport-config-template-cstm|. - -For help with setting up the template library, use the setup wizard -"Snippets -> template setup wizard". - -Template Style --------------- -The template system supports different template styles. If there are more than -one style the menu item 'choose style' let you choose a style on the fly. +see |latexsupport-templates-custom|. For help with setting up the template +library, use the setup wizard: + Latex -> Snippets -> template setup wizard Template Browser ---------------- @@ -733,214 +789,249 @@ this behavior by setting a global variable in your ~/.vimrc (see > let g:Templates_TemplateBrowser = 'browse' < -============================================================================== -4. CUSTOMIZATION *latexsupport-customization* -============================================================================== - ------------------------------------------------------------------------------- -4.1 FILES *latexsupport-custom-files* ------------------------------------------------------------------------------- - -README.md The starting point. - -autoload/mmtemplates/core The template system plug-in. - -doc/latexsupport.txt The latex-support help file for the local help. -doc/templatesupport.txt The template system help file for the local help. - -plugin/latex-support.vim The LaTeX plug-in for Vim/gVim. - -latex-support/codesnippets/ The code snippets directory. - -latex-support/templates/* The template files. +Template Style +-------------- +The template system supports different template styles. If there are more than +one style the menu item "choose style" let you choose a style on the fly. + +Template Locations +------------------ + *g:Latex_LocalTemplateFile* *g:Latex_GlobalTemplateFile* + *g:Latex_CustomTemplateFile* +The variables `g:Latex_LocalTemplateFile` and `g:Latex_GlobalTemplateFile` set the +locations and names of the local and global template files, respectively. +The standard locations of the template files can be changed via these +configuration variables, e.g.: > + let g:Latex_CustomTemplateFile = $HOME.'/.vim/my-templates/latex.templates' +< + Variable Default Linux + ---------------------------------------------------------------------------- + g:Latex_CustomTemplateFile $HOME/.vim/templates/latex.templates + g:Latex_GlobalTemplateFile $VIMRUNTIME/latex-support/templates/Templates + g:Latex_LocalTemplateFile $HOME/.vim/latex-support/templates/Templates + ---------------------------------------------------------------------------- + Variable Default Windows + ---------------------------------------------------------------------------- + g:Latex_CustomTemplateFile $HOME/vimfiles/templates/latex.templates + g:Latex_GlobalTemplateFile $VIMRUNTIME/latex-support/templates/Templates + g:Latex_LocalTemplateFile $HOME/vimfiles/latex-support/templates/Templates + ---------------------------------------------------------------------------- -latex-support/wordlists/latex-keywords.list A file used as dictionary for - automatic word completion. This file is referenced - in the file customization.vimrc. - ---------------- ------------------------------------------------------------- ---------------- The following files and extensions are for convenience only. - latex-support.vim will work without them. - ------------------------------------------------------------- - -latex-support/rc/make.vim Additional filetype plug-in. -latex-support/rc/tex.vim Additional filetype plug-in. -latex-support/rc/customization.ctags Additional settings I use in ~.ctags. -latex-support/rc/customization.gvimrc Additional settings I use in ~.gvimrc. -latex-support/rc/customization.vimrc Additional settings I use in ~.vimrc: - incremental search, tabstop, hot keys, font, - use of dictionaries, ... The file is commented. - Append it to your .vimrc if you like. -latex-support/doc/latex-hotkeys.pdf Reference card for the key mappings. - The mappings can also be used with the non-GUI Vim, - where the menus are not available. -latex-support/doc/ChangeLog The change log. +The personalization file is located in a directory relative to |runtimepath|: > + <RUNTIMEPATH>/templates/personal.templates +For configuring the personalization file, see |g:Templates_PersonalizationFile|. ------------------------------------------------------------------------------ -4.2 GLOBAL VARIABLES *latexsupport-custom-variables* +3.8 FILE SKELETONS *latexsupport-file-skeleton* ------------------------------------------------------------------------------ + *g:Latex_InsertFileProlog* +If g:Latex_InsertFileProlog is set to "yes", a file skeleton is automatically +inserted into new LaTeX documents. The list of templates used to create this +skeleton is specified in the template library. For this purpose a property is +used, which can for example be set in the customization file +(see |latexsupport-templates-custom|). -Several global variables are checked after the plug-in has been loaded to customize it: +This automatic insertion can be switched off by adding this to the `.vimrc`: > + let g:Latex_InsertFileProlog = 'no' +< + *Latex::FileSkeleton::Script* +The file skeleton is controlled via this property, which can be set in one +of the template files: > + SetProperty ( 'Latex::FileSkeleton::Script', 'Comments.file prolog' ) +This inserts only a comment box to document the file. To disable the insertion +completely, set the property to an empty string: > + SetProperty ( 'Latex::FileSkeleton::Script', '' ) +In general, this property is a semicolon-separated list of templates to be +inserted: > + SetProperty ( 'Latex::FileSkeleton::Script', 'Comments.file prolog; ;Skeleton.packages; ;Skeleton.document' ) +This will insert a file description, and two file skeleton templates, one with +"\usepackage" commands and one with a skeleton of the document environment. If +a space appears as an entry in the list, an empty line is inserted: > + '...; ;...' +< +============================================================================== +4. CONFIGURATION *latexsupport-configuration* +============================================================================== ------------------------------------------------------------------------------- - global variable default value ------------------------------------------------------------------------------- +The basic configuration is done via a number of global variables, which can be +set in the `.vimrc` file. All the typesetters, viewers, and converters calls can +also be adapted, see below. + + Variable Default Description + ---------------------------------------------------------------------------- + |g:Latex_TexFlavor| 'latex' filetype when starting to edit + an empty file *.tex + |g:Latex_Typesetter| 'pdflatex' the typesetter used on start-up + |g:Latex_Processing| 'foreground' how to run external processes + + |g:Latex_LoadMenus| 'auto' when to load the menus ('startup', + 'auto' or 'manual') + |g:Latex_RootMenu| 'LaTe&X' name and shortcut of the root menu + |g:Latex_MapLeader| '´' the |maplocalleader| used for maps + |g:Latex_Ctrl_j| 'yes' generate the <CTRL-J> map + |g:Latex_Ctrl_d| 'yes' generate the <CTRL-D> map + + |g:Latex_InsertFileProlog| 'yes' insert a file header automatically + |g:Latex_LineEndCommColDefault| standard column used for end-of- + 49 line comments + + |g:Latex_CodeSnippets| (see below) directory with code snippets + |g:Latex_GuiSnippetBrowser| 'gui' browser to select code snippets + + |g:Latex_LocalTemplateFile| (see Chp. 3) the local top-level template file + |g:Latex_GlobalTemplateFile| (see Chp. 3) the global top-level template file + |g:Latex_CustomTemplateFile| (see Chp. 3) the optional custom template file + |g:Templates_PersonalizationFile| + (see Chp. 3) the personalization template file + + |g:Latex_Dictionary_File| '' word list used for completion + |g:Latex_Printheader| '...' printheader used for hardcopy + + |g:Latex_UseToolbox| 'yes' use the toolbox + |g:Latex_UseTool_make| 'yes' use the make tool + + |g:Templates_InternetBrowserExec| the browser executable + |g:Templates_InternetBrowserFlags| additional browser flags + ---------------------------------------------------------------------------- - -- Linux/Unix --------------------------------------------------------------- - g:Latex_Latex 'latex -src-specials -file-line-error -interaction=nonstopmode' - g:Latex_Tex 'tex -src-specials -file-line-error -interaction=nonstopmode' - g:Latex_Pdflatex 'pdflatex -src-specials -file-line-error -interaction=nonstopmode' - g:Latex_Pdftex 'pdftex -src-specials -file-line-error -interaction=nonstopmode' - g:Latex_Lualatex 'lualatex --file-line-error --interaction=nonstopmode' - g:Latex_Luatex 'luatex --file-line-error --interaction=nonstopmode' - g:Latex_Bibtex "bibtex" - - g:Latex_DviViewer "xdvi" - g:Latex_PsViewer "gv" - g:Latex_PdfViewer "acroread" - - g:Latex_DviPdf 'dvipdft' - g:Latex_DviPng 'dvipng' - g:Latex_DviPs 'dvips' - g:Latex_PdfPng 'convert' - g:Latex_PsPdf 'ps2pdf' - - g:Latex_CustomTemplateFile $HOME.'/.vim/templates/latex.templates' - g:Latex_GlobalTemplateFile $VIMRUNTIME.'/latex-support/templates/Templates' - g:Latex_LocalTemplateFile $HOME.'/.vim/latex-support/templates/Templates' - - -- MS Windows --------------------------------------------------------------- - g:Latex_Latex 'latex.exe -src-specials -file-line-error -interaction=nonstopmode' - g:Latex_Tex 'tex.exe -src-specials -file-line-error -interaction=nonstopmode' - g:Latex_Pdflatex 'pdflatex.exe -src-specials -file-line-error -interaction=nonstopmode' - g:Latex_Bibtex 'bibtex.exe' - - g:Latex_Pdftex 'pdftex.exe -src-specials -file-line-error -interaction=nonstopmode' - g:Latex_DviViewer 'dviout.exe' - g:Latex_PsViewer '' - g:Latex_PdfViewer '' - - g:Latex_DviPdf 'dvipdfm.exe' - g:Latex_DviPng 'dvipng.exe' - g:Latex_DviPs 'dvips.exe' - g:Latex_PdfPng '' - g:Latex_PsPdf 'ps2pdf.exe' - - g:Latex_CustomTemplateFile $HOME.'/vimfiles/templates/latex.templates' - g:Latex_GlobalTemplateFile $VIMRUNTIME.'/latex-support/templates/Templates' - g:Latex_LocalTemplateFile $HOME.'/vimfiles/latex-support/templates/Templates' - - -- all ---------------------------------------------------------------------- - g:Latex_CodeSnippets root_dir.'latex-support/codesnippets/' - g:Latex_CreateMenusDelayed 'yes' - g:Latex_Dictionary_File '' - g:Latex_GuiSnippetBrowser 'gui' - g:Latex_InsertFileProlog 'yes' - g:Latex_Ctrl_j 'yes' - g:Latex_Ctrl_d 'yes' - g:Latex_LineEndCommColDefault 49 - g:Latex_LoadMenus 'yes' - g:Latex_MapLeader '´' - g:Latex_Printheader "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" - g:Latex_RootMenu 'LaTe&X' - g:Latex_TexFlavor 'latex' - g:Latex_Typesetter 'pdflatex' - g:Latex_Processing 'foreground' - -The variable root_dir will automatically be set to one of the following values: - $HOME.'/.vim/' for Linux/Unix - $VIM.'/vimfiles/' for MS-Windows +Further customization is carried out in the template library, see +|latexsupport-templates-custom| and |latexsupport-file-skeleton|. ------------------------------------------------------------------------------ - DESCRIPTION + *g:Latex_TexFlavor* +When a new file `*.tex` is created, Vim sets its filetype to 'plaintex'. The +maps and automations this plug-in provides only work for the filetype 'latex'. +The plug-in therefore automatically adjusts the filetype of newly created +`*.tex` files to 'latex'. This behavior can be switched off by setting: > + g:Latex_TexFlavor = 'plaintex' +< +------------------------------------------------------------------------------ +4.1 Typesetters, Viewers, Converters *latexsupport-config-external* ------------------------------------------------------------------------------ - *g:Latex_Latex* -The command line used to call the LaTeX typesetter. - - *g:Latex_Tex* -The command line used to call the TeX typesetter. - - *g:Latex_Pdflatex* -The command line used to call the pdfLaTeX typesetter. - - *g:Latex_Pdftex* -The command line used to call the pdfTeX typesetter. - - *g:Latex_Lualatex* -The command line used to call the luaLaTeX typesetter. - - *g:Latex_Luatex* -The command line used to call the luaTeX typesetter. - - *g:Latex_Bibtex* -The command line used to call bibtex. - - *g:Latex_DviViewer* -The command line used to call a DVi viewer. - - *g:Latex_PsViewer* -The command line used to call a PS viewer. - - *g:Latex_PdfViewer* -The command line used to call a PDF viewer. - - *g:Latex_DviPdf* -The command line used to call a DVI to PDF converter. - - *g:Latex_DviPng* -The command line used to call a DVI to Png converter. - - *g:Latex_DviPs* -The command line used to call a DVI to PS converter. - - *g:Latex_PdfPng* -The command line used to call a PDF to Png converter. - - *g:Latex_PsPdf* -The command line used to call a PS to PDF converter. - - *g:Latex_CodeSnippets* -The name of the (non-standard) code snippet directory (see below). - *g:Latex_CreateMenusDelayed* -Delaying the initialization until the first TeX/LaTeX file is opened. +The typesetter are configured using the variables `g:Latex_<typesetter>`: - *g:Latex_CustomTemplateFile* -Sets the custom template file, path+name, used to overwrite stock templates -(see|latexsupport-templates|). + Variable Default Linux + ---------------------------------------------------------------------------- + *g:Latex_Latex* latex -src-specials -file-line-error -interaction=nonstopmode + *g:Latex_Tex* tex -src-specials -file-line-error -interaction=nonstopmode + *g:Latex_Pdflatex* pdflatex -src-specials -file-line-error -interaction=nonstopmode + *g:Latex_Pdftex* pdftex -src-specials -file-line-error -interaction=nonstopmode + *g:Latex_Lualatex* lualatex --file-line-error --interaction=nonstopmode + *g:Latex_Luatex* luatex --file-line-error --interaction=nonstopmode + *g:Latex_Bibtex* bibtex + ---------------------------------------------------------------------------- - *g:Latex_Dictionary_File* -Path and filename of the LaTeX word list used for dictionary completion. + Variable Default Windows + ---------------------------------------------------------------------------- + g:Latex_Latex latex.exe -src-specials -file-line-error -interaction=nonstopmode + g:Latex_Tex tex.exe -src-specials -file-line-error -interaction=nonstopmode + g:Latex_Pdflatex pdflatex.exe -src-specials -file-line-error -interaction=nonstopmode + g:Latex_Pdftex pdftex.exe -src-specials -file-line-error -interaction=nonstopmode + g:Latex_Bibtex bibtex.exe + ---------------------------------------------------------------------------- - *g:Latex_GlobalTemplateFile* -Sets the global template file, path+name (see|latexsupport-templates|). + *g:Latex_Typesetter* +The typesetter used on start-up is set via `g:Latex_Typesetter`: > + let g:Latex_Typesetter = 'lualatex' +Possible values are 'pdflatex', 'pdftex', 'latex', 'tex', 'lualatex', or +'luatex', corresponding to the typesetters listed above. The typesetter can be +changed on-the-fly using: > + :LatexTypesetter <typesetter> +< +------------------------------------------------------------------------------ - *g:Latex_GuiSnippetBrowser* -Code snippet browser: 'gui', 'commandline'. +The viewers are configured using the variables `g:Latex_<format>Viewer`: - *g:Latex_InsertFileProlog* -Insert file description comment in a new file ('yes', 'no'). + Variable Default Linux Default Windows + ---------------------------------------------------------------------------- + *g:Latex_DviViewer* xdvi dviout.exe + *g:Latex_PdfViewer* acroread + *g:Latex_PsViewer* gv + ---------------------------------------------------------------------------- -*g:Latex_Ctrl_j* *g:Latex_Ctrl_d* -Create maps Ctrl-J and Ctrl-D ('yes', 'no') -(compare |latexsupport-templates-jump-tags|) +For example: > + let g:Latex_PdfViewer = 'evince' +< +------------------------------------------------------------------------------ - *g:Latex_LineEndCommColDefault* -Default starting column for line-end comments. +The converters are configured using the variables `g:Latex_<from><to>`: - *g:Latex_LoadMenus* -Load menus and mappings ("yes", "no") at startup. + Variable Default Linux Default Windows + ---------------------------------------------------------------------------- + *g:Latex_DviPdf* dvipdft dvipdfm.exe + *g:Latex_DviPng* dvipng dvipng.exe + *g:Latex_DviPs* dvips dvips.exe + *g:Latex_EpsPdf* ps2pdf -dEPSCrop n/a + *g:Latex_PdfPng* convert n/a + *g:Latex_PsPdf* ps2pdf ps2pdf.exe + ---------------------------------------------------------------------------- - *g:Latex_LocalTemplateFile* -Sets the local template file, path+name (see|latexsupport-templates|). +------------------------------------------------------------------------------ + *g:Latex_Processing* +External programs such as the typesetter can be run in the background by +setting the variable: > + g:Latex_Processing = 'background' +< + Value Meaning + ---------------------------------------------------------------------------- + 'foreground' blocks the editor until the external process is done + 'background' runs the process asynchronously and displays a message + once it is done (requires the |+job| feature or Neovim) + ---------------------------------------------------------------------------- - *g:Latex_MapLeader* -Map leader for hotkeys (|latexsupport-mappings|). +The behavior can be changed on-the-fly using the menu entry or the ex-command: > + :LatexProcessing <typesetter> +< +------------------------------------------------------------------------------ +4.2 MENUS *latexsupport-config-menus* +------------------------------------------------------------------------------ + *g:Latex_LoadMenus* +The creation of the menus is controlled by `g:Latex_LoadMenus`. The default +setting: > + let g:Latex_LoadMenus = 'auto' +causes the templates to be loaded and the menus to be created when the first +LaTeX file is opened. +The menus appear right away after starting Vim with the setting: > + let g:Latex_LoadMenus = 'startup' +This has the disadvantage that the templates have to be loaded during the +startup of Vim, which might cause a noticeable slowdown on older systems. +The automatic creation of the menus is prevented by: > + let g:Latex_LoadMenus = 'manual' +Now the menus can only be loaded by using the tool menu entry "Tools -> Load +LaTeX Support". + + *g:Latex_CreateMenusDelayed* +The old setting `g:Latex_CreateMenusDelayed` still works for backwards +compatibility, use the above values for |g:Latex_LoadMenus| instead. + + *g:Latex_RootMenu* +The name and shortcut of the root menu is set via `g:Latex_RootMenu`. The +character prefixed by '&' will be the shortcut. +> +Example: > + let g:Latex_RootMenu = '&Plugin.&LaTeX' +Creates the LaTeX menu as a submenu of "Plugin", and sets the shortcut to 'l'. -The mapleader can also be used in the ftplugin, by calling the functions -*Latex_SetMapLeader()* and *Latex_ResetMapLeader()* . The maps created between -the two calls will use |g:Latex_MapLeader| as the |<LocalLeader>|: +------------------------------------------------------------------------------ +4.3 MAPS *latexsupport-config-maps* +------------------------------------------------------------------------------ + *g:Latex_MapLeader* +All the maps the plug-in creates use |maplocalleader|. It can be changed by +setting the variable `g:Latex_MapLeader`. If it contains the empty string, +Vim's default (backslash) is used. + +Example: > + let g:Latex_MapLeader = '#' +Sets the mapleader to '#'. + + *Latex_SetMapLeader()* + *Latex_ResetMapLeader()* +The configured mapleader can also be used in the |ftplugin|, by calling the +functions `Latex_SetMapLeader()` and `Latex_ResetMapLeader()`. The maps +created between the two calls will use |g:Latex_MapLeader| as the +|<LocalLeader>|: > call Latex_SetMapLeader () @@ -948,65 +1039,111 @@ the two calls will use |g:Latex_MapLeader| as the |<LocalLeader>|: call Latex_ResetMapLeader () < + *g:Latex_Ctrl_j* *g:Latex_Ctrl_d* +The creation of the <CTRL-J> and <CTRL-D> maps is controlled by the variables +`g:Latex_Ctrl_j` and `g:Latex_Ctrl_d`, respectively. To disable <CTRL-D>, set the +variable to "no": > + let g:Latex_Ctrl_d = 'no' +< +------------------------------------------------------------------------------ +4.4 COMMENTS *latexsupport-config-comments* +------------------------------------------------------------------------------ - *g:Latex_Printheader* -Hardcopy header format. - - *g:Latex_RootMenu* -The name of the plug-in root menu. - - *g:Latex_TexFlavor* -The filetype when starting with an empty file ('latex', 'plaintex') +When a new TeX file is opened, the plug-in automatically inserts a file +header, which is the template "Comments -> file prolog". This behavior can be +switched off by adding this to the .vimrc: > + let g:Latex_InsertFileProlog = 'no' +The behavior can be changed on the fly by settings the variable to a different +value on the command line. - *g:Latex_Typesetter* -The typesetter used by the run command ('<mapleader>rr', or menu item): -'pdflatex', 'pdftex', 'latex', or 'tex'. +Further customization of the file skeletons is possible through use of the +template library (see |latexsupport-file-skeleton|). - *g:Latex_Processing* -The way external programs such as the typesetter are run: -'foreground' blocks the editor until the external process is done. -'background' runs the process asynchronously and displays a message once it is -done. Requires the |+job| feature. + *g:Latex_LineEndCommColDefault* +The standard column used for end-of-line comments is configured using +`g:Latex_LineEndCommentColumn`. The column can then be set individually for each +buffer, using the menu entry "Comments -> set end-of-line com. col.". +Example: > + g:Latex_LineEndCommColDefault = 59 +< ------------------------------------------------------------------------------ -4.3 THE ROOT MENU *latexsupport-custom-root* +4.5 SNIPPETS *latexsupport-config-snippets* ------------------------------------------------------------------------------ + *g:Latex_CodeSnippets* +The variable `g:Latex_Snippets` sets the location of the code snippet directory. +The default value depends on the type of installation and the operating +system. -The root menu is not visible by default. The root menu 'LaTeX' will appear -after the first file with extension 'tex' has been opened. -When the root menu is visible all templates have been loaded and the internal -data structures are built. On a slow computer this may cause a noticeable -delay when starting the editor. Therefor loading the templates is delayed to -the point where the first TeX/LaTeX file will be loaded. -To load the menu anyway when the editor starts add the following line to -~/.vimrc : -> - let g:Latex_CreateMenusDelayed = 'no' +(Path separators are always written as slashes '/', even for Windows.) + +For a local installation, the default will be (UNIX/Linux): > + s:Latex_Snippets = $HOME.'/.vim/latex-support/codesnippets/' +or (Windows): > + s:Latex_Snippets = $HOME.'/vimfiles/latex-support/codesnippets' < -The variable g:Latex_RootMenu, if set in .vimrc or in .gvimrc, gives the name of -the single gVim root menu item in which the LaTeX submenus are contained. The -default is -> - 'LaTe&X' +For a sytem-wide installation, the default will be: > + s:Latex_Snippets = $VIM.'/vimfiles/latex-support/codesnippets' < -If you want to set the plug-in root menu as a submenu into another menu, e.g. -your own with the name 'Plugin', this is done by the following line in -'.vimrc' -> - let g:Latex_RootMenu = '&Plugin.LaTe&X' +Example: + +To set a different code snippet directory, add this line to your vimrc: > + let g:Latex_Snippets = $HOME.'/myvim/tex/codesnippets/' < -The appearance of the root menu item can also be controlled by the global -variable g:Latex_LoadMenus. The line + *g:Latex_GuiSnippetBrowser* +Code snippets can either be selected in a file browser, by setting: > + let g:Latex_GuiSnippetBrowser = 'gui' +or on the command line by setting: > + let g:Latex_GuiSnippetBrowser = 'commandline' +< +------------------------------------------------------------------------------ +4.6 DICTIONARY *latexsupport-config-dictionary* +------------------------------------------------------------------------------ + *g:Latex_Dictionary_File* +The file "latex-keywords.list" contains words used as dictionary for automatic +word completion. This feature is enabled by default. The default word list is > + $HOME/.vim/latex-support/wordlists/latex-keywords.list +If you want to use an additional list MyLatex.List put the following line into +the vimrc: > - let g:Latex_LoadMenus = 'no' + let g:Latex_Dictionary_File = "$HOME/.vim/latex-support/wordlists/latex-keywords.list,". + \ "$HOME/any_of_my_directories/MyLatex.List" < -prevents the root menu item from appearing when the editor starts. You can -switch it on (and off again) from the tools menu. The default for this -variable is 'yes'. +The right side is a comma separated list of files. Note the point at the end +of the first line (string concatenation) and the backslash in front of the +second line (continuation line). +You can then use Vim's dictionary feature |i_CTRL-X_CTRL-K| inside tex-files, +and also |i_CTRL-P| and |i_CTRL-N|, depending on how 'complete' is set. ------------------------------------------------------------------------------ -4.4 System-wide installation *latexsupport-system-wide* +4.7 HARDCOPY *latexsupport-config-hardcopy* ------------------------------------------------------------------------------ + *g:Latex_Printheader* +The printheader used by "Run -> hardcopy to filename.ps" is set via the +variable `g:Latex_Printheader`. It is temporarily set as the value of +'printheader' while printing the hardcopy. See the documentation of the +option 'printheader' for the possible contents of `g:Latex_Printheader`. The +default is: > + let g:Latex_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" +< +The behavior can be changed on the fly by settings the variable to a different +value on the command line. + +------------------------------------------------------------------------------ +4.8 TOOLBOX *latexsupport-config-toolbox* +------------------------------------------------------------------------------ + *g:Latex_UseToolbox* + *g:Latex_UseTool_make* +The loading of the toolbox can be prevented by adding this setting to the +vimrc: > + let g:Latex_UseToolbox = 'no' +A single tool can be disabled by setting `g:Latex_UseTool_<toolname>`, in case +of the "make" tool: > + let g:Latex_UseTool_make = 'no' +< +============================================================================== +5. SYSTEM-WIDE INSTALLATION *latexsupport-system-wide* +============================================================================== A system-wide installation (one installation for all users) is done as follows. @@ -1014,8 +1151,8 @@ follows. As *** SUPERUSER *** : (1) Find the Vim installation directory. -The Vim ex command ':echo $VIM' gives '/usr/local/share/vim' or something like -that. Beyond this directory you will find the Vim installation, e.g. in +The Vim ex-command `:echo $VIM` gives '/usr/local/share/vim' or something like +that. Beyond this directory you will find the Vim installation, e.g. in '/usr/local/share/vim/vim73' if Vim version 7.3 has been installed (Windows: 'C:\Program Files\Vim'). @@ -1023,22 +1160,21 @@ that. Beyond this directory you will find the Vim installation, e.g. in (Windows: 'C:\Program Files\Vim\vimfiles'). (3) Install LaTeX Support -Copy the archive latex-support.zip to this new directory and unpack it: -> +Copy the archive 'latex-support.zip' to this new directory and unpack it: > unzip latex-support.zip < -(4) Generate the help tags: -> +(4) Generate the help tags: > :helptags $VIM/vimfiles/doc < SPECIAL CASES. Some Linux distributions use non-standard names for Vim directories. SUSE has a directory '/usr/share/vim/site' to put plug-ins in. -These directories will not be found automatically. After installing the -plug-in below '/usr/share/vim/site' the use of the templates will be enabled by -the following line in '~/.vimrc': +These directories will not be found automatically. After installing the +plug-in below '/usr/share/vim/site' the use of the templates will be enabled +by the following line in '$HOME/.vimrc': > let g:Latex_GlobalTemplateFile = '/usr/share/vim/site/latex-support/templates/Templates' < +------------------------------------------------------------------------------ As *** USER *** : @@ -1051,10 +1187,10 @@ and should contain only information relevant for all template libraries. You can set some macros in this file with your personal information in order to obtain personalized comments, e.g. something like this: > - SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) - SetMacro( 'AUTHORREF', 'fgm' ) - SetMacro( 'EMAIL', 'mehner.fritz@web.de' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) + SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) + SetMacro( 'AUTHORREF', 'WM' ) + SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) < Use the custom template file for LaTeX templates which override the global templates or to add new ones. @@ -1062,268 +1198,13 @@ templates or to add new ones. The old system (before version 1.2), using a "local" template file, > ~/.vim/latex-support/templates is still supported for backwards compatibility. -> + Create your private snippet directory: > - mkdir --parents ~/.vim/latex-support/codesnippets -You may want to copy the snippets comming with this plug-in (in + mkdir --parents $HOME/.vim/latex-support/codesnippets +You may want to copy the snippets coming with this plug-in (in $VIM/vimfiles/latex-support/codesnippets) into the new directory or to set a link to the global directory. -============================================================================== -5. TEMPLATE FILES AND TAGS *latexsupport-old-templ* -============================================================================== - -Nearly all menu items insert code snippets or comments. All of these are -contained within template files and can be changed by the user to meet their -requirements. The menu shortcuts (e.g. 'c' for the Comments menu) and the -menu item hotkeys (e.g. '´ct' insert date and time) are also defined in the -templates. -The template engine comes as a separate plug-in contributed by Wolfgang Mehner. -This section is a short introduction to this template system. Please see -|templatesupport.txt| for more information. - -The master template file is '$HOME/.vim/latex-support/templates/Templates' for -a user installation and '$VIM/vimfiles/latex-support/templates/Templates' for -a system-wide installation (see |latexsupport-system-wide|). - -The master template file can be edited itself to adapt the templates/menus to -the users need. Alternatively, a custom template file can be added (see -|g:Latex_CustomTemplateFile|), which eliminates the need to edit stock -templates. The personalization (name, email, ..., date and time format) can be -done in a special personalization template file. It will be read by all -plug-ins which support this feature, so it should only contain basic -information not pertaining to a specific programming language. It can be set -up using a wizard, which is run by the map \ntw or the menu entry: - LaTeX -> Snippets -> template setup wizard - -Further template files can be added using the call: > - call mmtemplates#config#Add ( 'latex', '<PATH>/some.templates', 'example', 'nte' ) -The first parameter adds the file to your LaTeX templates, the second is the -path. The remaining two optional parameters specify the symbolic name for -these templates and the map to edit them. The map is '\nte' in this example, -if the standard mapleader is set. - ------------------------------------------------------------------------------- -5.1 TEMPLATE FILES *latexsupport-old-templ-files* ------------------------------------------------------------------------------- - -The master template file starts with various settings followed by templates -for single menu items or better by including other template files grouping the -templates according to the menu structure of this plug-in. The master file -usually looks like this: - -Example: -> - § ========================================================== - § Settings - § ========================================================== - - SetMacro( 'AUTHOR', 'YOUR NAME' ) - SetMacro( 'AUTHORREF', '' ) - SetMacro( 'EMAIL', '' ) - SetMacro( 'ORGANIZATION', '' ) - SetMacro( 'COMPANY', '' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - SetMacro( 'LICENSE', 'GNU General Public License' ) - - § ============================================================= - § File Includes - § ============================================================= - - MenuShortcut( 'Comments', 'c' ) - MenuShortcut( 'Text', 't' ) - MenuShortcut( 'Math', 'm' ) - MenuShortcut( 'Document', 'd' ) - MenuShortcut( 'BibTeX', 'b' ) - MenuShortcut( 'Wizard', 'w' ) - MenuShortcut( 'Help', 'h' ) - - IncludeFile( 'comments.templates' ) - IncludeFile( 'text.templates' ) - IncludeFile( 'math.templates' ) - IncludeFile( 'document.templates' ) - IncludeFile( 'bibtex.templates' ) - IncludeFile( 'wizard.templates' ) -< -Lines starting with a section sign (§) are comments. The section starting with -> - SetMacro( 'AUTHOR', 'YOUR NAME' ) -< -assigns values to predefined tags (macros). Arbitrary user-defined macros are -possible. The macro name must follows the rules for a C language identifier: -first character letter or underscore; case matters; digits are allowed -beginning with the second character. -Some of the macros assigned here are placeholders, they will be overwritten by -template files read later on, which contain the user's configuration. - -The statement -> - IncludeFile( 'comments.templates' ) -< -includes the templates from the file 'comments.templates' (in the same -directory). An absolute path would also be possible. The statement -> - MenuShortcut( 'Comments', 'c' ) -< -sets 'c' as the shortcut for the Comments menu. - ------------------------------------------------------------------------------- -5.2 MACROS *latexsupport-old-templ-macros* ------------------------------------------------------------------------------- - -The following macro names are predefined. The first group is used to -personalize templates. -> - |BASENAME| filename without path and suffix - |DATE| the preferred date representation for the current locale - without the time - |FILENAME| filename without path - |PATH| path without filename - |SUFFIX| filename suffix - |TIME| the preferred time representation for the current locale - without the date and the time zone or name or abbreviation - |YEAR| the year as a decimal number including the century -< - ---------------------------------------------------------------------------- - PREDEFINED TAGS USED IN TEMPLATES - ---------------------------------------------------------------------------- - <CURSOR> The cursor position after insertion of a template. - <+text+>,<-text-> See |latexsupport-old-templ-jumptags|. - {+text+},{-text-} - [+text+],[-text-] - - <SPLIT> The split point when inserting in visual mode - (see|latexsupport-old-templ|) - -A dependent template file can start with its own command section. There is no -need to have all user defined macros in the master file. - ------------------------------------------------------------------------------- - -5.2.1 Formating Date and Time *latexsupport-old-templ-date* - -The format for *|DATE|* ,*|TIME|* , and*|YEAR|* can be set by the user. The -defaults are: -> - |DATE| '%x' - |TIME| '%X' - |YEAR| '%Y' -< -See the manual page of the C function strftime() for the format. The accepted -format depends on your system, thus this is not portable! The maximum length -of the result is 80 characters. - -User defined formats can be set using the following function calls in the -master template file is '$HOME/.vim/latex-support/templates/Templates', e.g. -> - SetFormat( 'DATE', '%D' ) - SetFormat( 'TIME', '%H:%M' ) - SetFormat( 'YEAR', 'year %Y' ) - ------------------------------------------------------------------------------- -5.3 TEMPLATES *latexsupport-old-templ-names* ------------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - -5.3.1 Template definition *latexsupport-old-templ-definition* - -The template behind a menu item is identified by a given name. The first part -of the name identifies the menu name, the second part identifies the item. -A template definition starts with a template header with the following syntax: - - == menu_name.template_name == options == - -The options are described here: |template-support-options|. - ------------------------------------------------------------------------------- - -5.3.2 The jump tags <+text+> etc. *latexsupport-old-templ-jumptags* - -There are four jump tag types which can be used as jump targets in templates: - - <+text+> Can be jumped to by hitting Ctrl-j. - {+text+} Same as <+text+>. Used in cases where indentation gives unwanted - results with the first one. - - <-text-> Same as the two above. Will be removed if the template is used - {-text-} in visual mode. - - [+text+] The "optional" tag. Serves as a jump tag, but can be deleted using - Ctrl-d. - [-text-] Same as above, removed in visual mode. - -The text inside the brackets is userdefined and can be empty. The text can be -composed from letters (uppercase and lowercase), digits, and underscores. -After the insertion of an template these jump targets will be highlighted. - ------------------------------------------------------------------------------- - -5.3.3 Command Ctrl-j *latexsupport-Ctrl-j* - -Use the command Ctrl-j to jump to the next target. The target will be removed -and the mode will switched to insertion. Ctrl-j works in normal and in insert -mode. The template for an if-else-statement can be written as follows: -> - == Statements.if, else == map:sie, sc:i == - if <CURSOR> - <SPLIT><-IF_PART-> - else - <+ELSE_PART+> - endif -< -The cursor will be set as shown. When the condition is specified a Ctrl-j let -you jump to the target <-IF PART-> and deletes it. When the block is written -a Ctrl-j leads you to the else-part. The target <+ELSE_PART+> disappears and -you can type on. - ------------------------------------------------------------------------------- -5.4 FILE SKELETONS *latexsupport-file-skeleton* ------------------------------------------------------------------------------- - *g:Latex_InsertFileProlog* -If g:Latex_InsertFileProlog is set to "yes", a file skeleton is automatically -inserted into new LaTeX documents. The list of templates used to create this -skeleton is specified in the template library. For this purpose a property is -used, which can for example be set in the customization file -(see |latexsupport-templates|). - - *Latex::FileSkeleton::Script* -The file skeleton is controlled via this properties, which can be set in one -of the template files: -> - SetProperty ( 'Latex::FileSkeleton::Script', 'Comments.file prolog' ) -< -This inserts only a comment box to document the file. To disable the insertion -completely, set the property to an empty string: > - SetProperty ( 'Latex::FileSkeleton::Script', '' ) -In general, this property is a semicolon-separated list of templates to be -inserted: > - SetProperty ( 'Latex::FileSkeleton::Script', 'Comments.file prolog; ;Skeleton.packages; ;Skeleton.document' ) -This will insert a file description, and two file skeleton templates, one with -"\usepackage" commands and one with a skeleton of the document environment. If -a space appears as an entry in the list, an empty line is inserted: > - '...; ;...' -< -============================================================================== -6. LATEX DICTIONARY *latexsupport-dictionary* -============================================================================== - -The file latex-keywords.list contains words used as dictionary for automatic -word completion. This feature is enabled by default. The default word list is -> - $HOME/.vim/latex-support/wordlists/latex-keywords.list -< -If you want to use an additional list MyLatex.List put the following line into - .vimrc : -> - let g:Latex_Dictionary_File = "$HOME/.vim/latex-support/wordlists/latex-keywords.list,". - \ "$HOME/any_of_my_directories/MyLatex.List" -< -The right side is a comma separated list of files. Note the point at the end -of the first line (string concatenation) and the backslash in front of the -second line (continuation line). -You can use Vim's dictionary feature CTRL-X, CTRL-K (and CTRL-P, CTRL-N). - ============================================================================== A. OVERVIEW OF MAPPINGS *latexsupport-mappings* ============================================================================== @@ -1335,186 +1216,246 @@ All mappings are filetype specific; they are only defined for buffers with filetype 'tex' to minimize conflicts with mappings from other plug-ins. Furthermore, the mapleader can be changed using the setting |g:Latex_MapLeader|. -Some mappings can be used with a range (of lines). In normal mode > - \cl -appends a end-of-line comment to the current line, whereas > - 4\cl +All maps work in normal and insert mode. Additionally some mappings can be +used with a range (of lines). In normal mode > + ´cl +appends a end-of-line comment to the current line, whereas > + 4´cl appends end-of-line comments to the 4 lines starting with the current line. -Legend: (i) insert mode, (n) normal mode, (v) visual mode - [n] range +Legend: visual mode: (v) use range, (s) surround content, + [n] range + tab-completion: (T) specialized, (F) filenames + + ----------------------------------------------------------------- + Jump Tags + ----------------------------------------------------------------- + <CTRL-J> jump to next tag + <CTRL-D> delete an optional tag ----------------------------------------------------------------- Help ----------------------------------------------------------------- - ´he open an English dictionary for (ni) - the word under the cursor - ´ht start texdoc (ni) - ´hp displays plugin help (ni) + + for the word under the cursor ... + ´he open an English dictionary + ´ht start texdoc + + ´hp display plug-in help ----------------------------------------------------------------- Comments ----------------------------------------------------------------- - [n]´cl end-of-line comment (niv) - [n]´cj adjust end-of-line comments (niv) - ´cs set end-of-line comment col. (n) - [n]´cc toggle comment (niv) + [n]´cl end-of-line comment (v) + [n]´cj adjust end-of-line comments (v) + ´cs set end-of-line comment col. + [n]´cc toggle comment (v) - ´cfr1 frame comment, type 1 (ni) - ´cfr2 frame comment, type 2 (ni) - ´cfr3 frame comment, type 3 (ni) - ´cp file prolog (ni) + ´cfr1 frame comment, type 1 + ´cfr2 frame comment, type 2 + ´cfr3 frame comment, type 3 + ´cp file prolog - ´cm plug-in macros (ni) - ´cd date (ni) - ´ct date & time (ni) + ´cm plug-in macros (T) + ´cd date + ´ct date & time ----------------------------------------------------------------- Document ----------------------------------------------------------------- - ´dc document class (ni) - ´di indices (ni) - ´dti title (ni) - ´dbi bibliography (ni) - ´dac addcontentsline (ni) - - ´dln newlength (ni) - ´dls setlength (ni) - ´dla addtolength (ni) - ´dlp print length (ni) - ´dlt set length to (ni) + ´dc document class (T) + ´di indices (T) + ´dti title + ´dbi bibliography (T) + ´dac addcontentsline + + ´dln newlength + ´dls setlength + ´dla addtolength + ´dlp print length + ´dlt set length to ----------------------------------------------------------------- Text ----------------------------------------------------------------- - ´e environment (niv) - ´to organization (ni) - ´ts section (ni) - ´tld list environment, description (ni) - ´tle list environment, enumerate (ni) - ´tli list environment, itemize (ni) - ´tll list environment, list (ni) - ´tlit list environment, item (ni) - ´tlil list environment, item+labels (ni) - ´tf font style (niv) - ´tfs font size (niv) - ´tq quotes (niv) - ´tsp spacing (ni) - ´tal line alignment + spacing (niv) - ´tac accents (niv) - ´ttc textcomp characters (ni) - - ´tbi bibitem (ni) - ´tci cite (ni) - ´tfo footnote (ni) - ´tin index (ni) - ´tla label (ni) - ´tma marginpar (ni) - ´tco newcommand (ni) - ´tnc nocite (ni) - ´tpa pageref (ni) - ´tre ref (ni) - ´tur url (niv) + ´e environment (s, T) + ´to organization (T) + ´ts section (T) + ´tld list environment, description + ´tle list environment, enumerate + ´tli list environment, itemize + ´tll list environment, list + ´tlit list environment, item + ´tlil list environment, item+labels + ´tf font style (s, T) + ´tfs font size (s, T) + ´tq quotes (s, T) + ´tsp spacing (T) + ´tal line alignment + spacing (s, T) + ´tac accents (T) + ´ttc textcomp characters (T) + + ´tbi bibitem + ´tci cite + ´tfo footnote + ´tin index + ´tla label + ´tma marginpar + ´tco newcommand + ´tnc nocite + ´tpa pageref + ´tre ref + ´tur url (s) ----------------------------------------------------------------- Math ----------------------------------------------------------------- - ´msp spaces (ni) - ´mac accents (ni) - ´mfs font styles (ni) - ´md delimiter (ni) - ´mf functions (ni) - ´mgl lowercase greek (ni) - ´mgu uppercase greek (ni) - ´mo operators (ni) - ´mr relations (ni) - ´mar arrows (ni) - - ´me equation+label (niv) - ´mea eqnarray+label (niv) - - ´mca cases (niv) - ´mch choose (niv) - ´mfr frac (niv) - ´mma matrix (ni) - ´mnr nth root (niv) - ´mon operatorname (niv) - ´mov overset (niv) - ´mpr prod (niv) - ´msi sideset (niv) - ´msq sqrt (niv) - ´msu sum (niv) - ´mun underset (niv) + ´msp spaces (T) + ´mac accents (T) + ´mfs font styles (T) + ´md delimiter (T) + ´mf functions (T) + ´mgl lowercase greek (T) + ´mgu uppercase greek (T) + ´mo operators (T) + ´mr relations (T) + ´mar arrows (T) + + ´me equation+label (s) + ´mea eqnarray+label (s) + + ´mca cases + ´mch choose (s) + ´mfr frac (s) + ´mma matrix + ´mnr nth root (s) + ´mon operatorname (s) + ´mov overset (s) + ´mpr prod (s) + ´msi sideset (s) + ´msq sqrt (s) + ´msu sum (s) + ´mun underset (s) ----------------------------------------------------------------- Wizard ----------------------------------------------------------------- - ´wll lstlisting (niv) - ´wlil lstinputlisting (ni) - ´wlin lstinline (niv) - ´wls lstset (ni) - - ´wtt table (niv) - ´wtf table, floating (niv) - ´wtg tabbing (ni) - ´wtr tabular (ni) - - ´wf figure (ni) - ´wff floatingfigure (ni) - ´wwf wrapfigure (ni) - - ´wbf fbox (niv) - ´wbfr framebox (niv) - ´wbm mbox (niv) - ´wbmb makebox (niv) - ´wmp minipage (niv) - ´wbp parbox (niv) + ´wll lstlisting (s) + ´wlil lstinputlisting + ´wlin lstinline (s) + ´wls lstset (T) + + ´wtt table (s) + ´wtf table, floating (s) + ´wtg tabbing + ´wtr tabular + + ´wf figure + ´wff floatingfigure + ´wwf wrapfigure + + ´wbf fbox (s) + ´wbfr framebox (s) + ´wbm mbox (s) + ´wbmb makebox (s) + ´wmp minipage (s) + ´wbp parbox (s) ----------------------------------------------------------------- Snippets ----------------------------------------------------------------- - ´nr read code snippet (ni) - ´nw write code snippet (niv) - ´nv view code snippet (ni) - ´ne edit code snippet (ni) - - ´ntg edit global templates (ni) - ´ntl edit local templates (ni) - ´ntc edit custom templates (ni) - ´ntp edit personal templates (ni) - ´ntr reread templates (ni) - ´ntw template setup wizard (ni) - ´nts choose style (ni) + ´nr read code snippet + ´nw write code snippet (v) + ´nv view code snippet + ´ne edit code snippet + + ´ntg edit global templates + ´ntl edit local templates + ´ntc edit custom templates + ´ntp edit personal templates + ´ntr reread templates + ´ntw template setup wizard + ´nts choose style (T) ----------------------------------------------------------------- Run ----------------------------------------------------------------- - ´rr save + run typesetter (ni) - ´rla save + run lacheck (ni) - ´rsd set main document (ni) - ´re view errors from bg. process (ni) - ´rdvi view DVI (ni) - ´rpdf view PDF (ni) - ´rps view PS (ni) - ´rc run a converter (ni) - ´rmg run makeglossaries (ni) - ´rmi run makeindex (ni) - ´rbi run bibtex (ni) - ´rt choose the typesetter (ni) - ´rp method for external processing (ni) - ´rh hardcopy buffer to postscript (niv) - ´rse show plugin settings (ni) + ´rr save + run typesetter + ´rla save + run lacheck + ´rmd set main document (F) + ´re view errors from bg. process + ´rdvi view DVI + ´rpdf view PDF + ´rps view PS + ´rc run a converter (T) + ´rmg run makeglossaries + ´rmi run makeindex + ´rbi run bibtex + ´rt choose the typesetter (T) + ´rp method for external processing (T) + ´rh hardcopy buffer to postscript (v) + ´rs show plug-in settings ----------------------------------------------------------------- Tool Box ----------------------------------------------------------------- - ´rm run make (ni) - ´rmc run make clean (ni) - ´rma command line arguments for make (ni) - ´rcm choose make file (ni) + ´rm run make + ´rmc run make clean + ´rma command line arguments for make (F) + ´rcm choose make file (F) + +============================================================================== +B. FILES *latexsupport-files* +============================================================================== + +README.md The starting point. + +autoload/mmtemplates/* The template system. +autoload/mmtoolbox/* The toolbox (make, ...). + +doc/latexsupport.txt The help file for LaTeX Support. +doc/templatesupport.txt The help file for the template system. +doc/toolbox*.txt The help files for the toolbox. + +plugin/latex-support.vim The LaTeX plug-in for Vim/gVim/Neovim. + +latex-support/codesnippets/ The code snippets directory. + +latex-support/templates/* The template files. + +latex-support/wordlists/latex-keywords.list + A file used as the dictionary + for automatic word completion. + +-------------------------------------------------------------- + The following files and extensions are for convenience only. + `latex-support.vim` will work without them. +-------------------------------------------------------------- + +ftdetect/template.vim +ftplugin/template.vim +syntax/template.vim Additional files for working with templates. + +latex-support/... + .../doc/latex-hotkeys.pdf Reference card for the key mappings. + .../doc/ChangeLog The change log. + +latex-support/... + .../rc/customization.ctags Additional settings for use in .ctags. + .../rc/customization.gvimrc Additional settings for use in .gvimrc. + .../rc/customization.vimrc Additional settings for use in .vimrc: + incremental search, tabstop, hot keys, + font, use of dictionaries, ... + The file is commented. Append it to your + .vimrc if you like. + + .../rc/make.vim Suggestion for a filetype plug-in. + .../rc/tex.vim Suggestion for a filetype plug-in. + .../rc/*.templates Sample template files for customization. + Used by the customization template setup wizard. ============================================================================== -B. TROUBLESHOOTING - KNOWN ISSUES *latexsupport-troubleshooting* +C. TROUBLESHOOTING - KNOWN ISSUES *latexsupport-troubleshooting* ============================================================================== * Some menus, such as "LaTeX -> Math -> greek lowercase" are not displayed @@ -1526,7 +1467,7 @@ B. TROUBLESHOOTING - KNOWN ISSUES *latexsupport-troubleshooting* Create one if there is none, or better use customization.vimrc. ============================================================================== -C. RELEASE NOTES - CHANGE LOG *latexsupport-release-notes* +D. RELEASE NOTES - CHANGE LOG *latexsupport-release-notes* ============================================================================== See files 'latex-support/README.md' and 'latex-support/doc/ChangeLog'. diff --git a/doc/luaref53.txt b/doc/luaref53.txt index d05041a..a6e83d5 100644 --- a/doc/luaref53.txt +++ b/doc/luaref53.txt @@ -1,9 +1,9 @@ -*luaref53.txt* Lua 5.3 Reference Manual May 30 2016 +*luaref53.txt* Lua 5.3 Reference Manual Jul 14 2020 -Lua 5.3.4 Reference Manual *lua53* *luaref53* +Lua 5.3.6 Reference Manual *lua53* *luaref53* by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes -Copyright © 2015 - 2016 Lua.org, PUC-Rio. Freely available under the terms of +Copyright © 2015 - 2020 Lua.org, PUC-Rio. Freely available under the terms of the Lua license (see http://www.lua.org/license.html). Formated for Vim help by @@ -84,7 +84,7 @@ Formated for Vim help by Lua 5.3 Reference Manual by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes -Copyright © 2015-2017 Lua.org, PUC-Rio. Freely available under the terms of +Copyright © 2015-2020 Lua.org, PUC-Rio. Freely available under the terms of the Lua license (see http://www.lua.org/license.html). ------------------------------------------------------------------------------ @@ -178,13 +178,13 @@ The type thread represents independent threads of execution and it is used to implement coroutines (see |lua53-sec2.6|). Lua threads are not related to operating-system threads. Lua supports coroutines on all systems, even those that do not support threads natively. -The type table implements associative arrays, that is, arrays that can be -indexed not only with numbers, but with any Lua value except nil and NaN. (Not -a Number is a special value used to represent undefined or unrepresentable -numerical results, such as 0/0.) Tables can be heterogeneous; that is, they -can contain values of all types (except nil). Any key with value nil is not -considered part of the table. Conversely, any key that is not part of a table -has an associated value nil. +The type table implements associative arrays, that is, arrays that can have as +indices not only numbers, but any Lua value except nil and NaN. (Not a Number +is a special value used to represent undefined or unrepresentable numerical +results, such as 0/0.) Tables can be heterogeneous; that is, they can contain +values of all types (except nil). Any key with value nil is not considered +part of the table. Conversely, any key that is not part of a table has an +associated value nil. Tables are the sole data-structuring mechanism in Lua; they can be used to represent ordinary arrays, lists, symbol tables, sets, records, graphs, trees, etc. To represent records, Lua uses the field name as an index. The language @@ -281,7 +281,8 @@ function to perform the addition. The key for each event in a metatable is a string with the event name prefixed by two underscores; the corresponding values are called metamethods. In the previous example, the key is "__add" and the metamethod is the function that -performs the addition. +performs the addition. Unless stated otherwise, metamethods should be function +values. You can query the metatable of any value using the |lua53-getmetatable| function. Lua queries metamethods in metatables using a raw access (see |lua53-rawget|). So, to retrieve the metamethod for event ev in object o, Lua @@ -366,9 +367,9 @@ operation is identified by its corresponding key. a <= b is equivalent to not (b < a). As with the other comparison operators, the result is always a boolean. (This use of the __lt event can be removed in future versions; it is also slower than a real __le metamethod.) -- __index: The indexing access table[key]. This event happens when table is - not a table or when key is not present in table. The metamethod is looked up - in table. +- __index: The indexing access operation table[key]. This event happens when + table is not a table or when key is not present in table. The metamethod is + looked up in table. Despite the name, the metamethod for this event can be either a function or a table. If it is a function, it is called with table and key as arguments, and the result of the call (adjusted to one value) is the result of the @@ -725,11 +726,8 @@ Square brackets are used to index a table: > var ::= prefixexp '[' exp ']' < -The meaning of accesses to table fields can be changed via metatables. An -access to an indexed variable t[i] is equivalent to a call -gettable_event(t,i). (See |lua53-sec2.4| for a complete description of the -gettable_event function. This function is not defined or callable in Lua. We -use it here only for explanatory purposes.) +The meaning of accesses to table fields can be changed via metatables (see +|lua53-sec2.4|). The syntax var.Name is just syntactic sugar for var["Name"]: > var ::= prefixexp '.' Name @@ -847,13 +845,11 @@ exchanges the values of x and y, and x, y, z = y, z, x < cyclically permutes the values of x, y, and z. -The meaning of assignments to global variables and table fields can be changed -via metatables. An assignment to an indexed variable t[i] = val is equivalent -to settable_event(t,i,val). (See |lua53-sec2.4| for a complete description of -the settable_event function. This function is not defined or callable in Lua. -We use it here only for explanatory purposes.) An assignment to a global name x = val is equivalent to the assignment _ENV.x = val (see |lua53-sec2.2|). +The meaning of assignments to table fields and global variables (which are +actually table fields, too) can be changed via metatables (see +|lua53-sec2.4|). ------------------------------------------------------------------------------ 3.3.4 Control Structures *lua53-sec3.3.4* @@ -1049,17 +1045,17 @@ Here are some examples: g(f(), x) -- f() is adjusted to 1 result g(x, f()) -- g gets x plus all results from f() a,b,c = f(), x -- f() is adjusted to 1 result (c gets nil) - a,b = ... -- a gets the first vararg parameter, b gets + a,b = ... -- a gets the first vararg argument, b gets -- the second (both a and b can get nil if there - -- is no corresponding vararg parameter) + -- is no corresponding vararg argument) a,b,c = x, f() -- f() is adjusted to 2 results a,b,c = f() -- f() is adjusted to 3 results return f() -- returns all results from f() - return ... -- returns all received vararg parameters + return ... -- returns all received vararg arguments return x,y,f() -- returns x, y, and all results from f() {f()} -- creates a list with all results from f() - {...} -- creates a list with all vararg parameters + {...} -- creates a list with all vararg arguments {f(), nil} -- f() is adjusted to 1 result < Any expression enclosed in parentheses always results in only one value. Thus, @@ -1170,9 +1166,11 @@ denote the same mathematical value. Tables, userdata, and threads are compared by reference: two objects are considered equal only if they are the same object. Every time you create a new object (a table, userdata, or thread), this new object is different from any -previously existing object. Closures with the same reference are always equal. -Closures with any detectable difference (different behavior, different -definition) are always different. +previously existing object. A closure is always equal to itself. Closures with +any detectable difference (different behavior, different definition) are +always different. Closures created at different times but with no detectable +differences may be classified as equal or not (depending on internal caching +details). You can change the way that Lua compares tables and userdata by using the "eq" metamethod (see |lua53-sec2.4|). Equality comparisons do not convert strings to numbers or vice versa. Thus, @@ -1334,8 +1332,8 @@ A function call in Lua has the following syntax: In a function call, first prefixexp and args are evaluated. If the value of prefixexp has type function, then this function is called with the given arguments. Otherwise, the prefixexp "call" metamethod is called, having as -first parameter the value of prefixexp, followed by the original call -arguments (see |lua53-sec2.4|). +first argument the value of prefixexp, followed by the original call arguments +(see |lua53-sec2.4|). The form > functioncall ::= prefixexp ':' Name args @@ -1669,7 +1667,7 @@ The panic function, as its name implies, is a mechanism of last resort. Programs should avoid it. As a general rule, when a C function is called by Lua with a Lua state, it can do whatever it wants on that Lua state, as it should be already protected. However, when C code operates on other Lua states -(e.g., a Lua parameter to the function, a Lua state stored in the registry, or +(e.g., a Lua argument to the function, a Lua state stored in the registry, or the result of |lua53-lua_newthread|), it should use them only in API calls that cannot raise errors. The panic function runs as if it were a message handler (see |lua53-sec2.3|); @@ -2020,7 +2018,7 @@ lua_close ~ < Destroys all objects in the given Lua state (calling the corresponding garbage-collection metamethods, if any) and frees all dynamic memory used by -this state. On several platforms, you may not need to call this function, +this state. In several platforms, you may not need to call this function, because all resources are naturally released when the host program ends. On the other hand, long-running programs that create multiple states, such as daemons or web servers, will probably need to close states as soon as they are @@ -3608,7 +3606,7 @@ Gets information about a specific function or function invocation. To get information about a function invocation, the parameter ar must be a valid activation record that was filled by a previous call to |lua53-lua_getstack| or given as argument to a hook (see |lua53-lua_Hook|). -To get information about a function you push it onto the stack and start the +To get information about a function, you push it onto the stack and start the what string with the character '>'. (In that case, lua_getinfo pops the function from the top of the stack.) For instance, to know in which line a function f was defined, you can write the following code: @@ -4200,7 +4198,7 @@ luaL_getmetafield ~ int luaL_getmetafield (lua_State *L, int obj, const char *e); < Pushes onto the stack the field e from the metatable of the object at index -obj and returns the type of pushed value. If the object does not have a +obj and returns the type of the pushed value. If the object does not have a metatable, or if the metatable does not have this field, pushes nothing and returns LUA_TNIL. @@ -4411,7 +4409,7 @@ This macro is defined as follows: < In words, if the argument arg is nil or absent, the macro results in the default dflt. Otherwise, it results in the result of calling func with the -state L and the argument index arg as parameters. Note that it evaluates the +state L and the argument index arg as arguments. Note that it evaluates the expression dflt only if needed. ------------------------------------------------------------------------------ @@ -5622,9 +5620,9 @@ combinations are allowed in describing a character class: [0-7%l%-] represents the octal digits plus the lowercase letters plus the '-' character. You can put a closing square bracket in a set by positioning it as the first - character in the set. You can put an hyphen in a set by positioning it as - the first or the last character in the set. (You can also use an escape for - both cases.) + character in the set. You can put a hyphen in a set by positioning it as the + first or the last character in the set. (You can also use an escape for both + cases.) The interaction between ranges and classes is not defined. Therefore, patterns like [%a-z] or [a-%%] have no meaning. - [^set]: represents the complement of set, where set is interpreted as above. @@ -5853,8 +5851,8 @@ Returns the destination table a2. *lua53-table.pack* table.pack (...) ~ -Returns a new table with all parameters stored into keys 1, 2, etc. and with a -field "n" with the total number of parameters. Note that the resulting table +Returns a new table with all arguments stored into keys 1, 2, etc. and with a +field "n" with the total number of arguments. Note that the resulting table may not be a sequence. ------------------------------------------------------------------------------ @@ -5936,7 +5934,7 @@ Returns the arc sine of x (in radians). math.atan (y [, x]) ~ Returns the arc tangent of y/x (in radians), but uses the signs of both -parameters to find the quadrant of the result. (It also handles correctly the +arguments to find the quadrant of the result. (It also handles correctly the case of x being zero.) The default value for x is 1, so that the call math.atan(y) returns the arc tangent of y. @@ -6137,7 +6135,7 @@ meanings from C: io.stdin, io.stdout, and io.stderr. The I/O library never closes these files. Unless otherwise stated, all I/O functions return nil on failure (plus an error message as a second result and a system-dependent error code as a third -result) and some value different from nil on success. On non-POSIX systems, +result) and some value different from nil on success. In non-POSIX systems, the computation of the error message and error code in case of errors may be not thread safe, because they rely on the global C variable errno. @@ -6163,7 +6161,7 @@ io.input ([file]) ~ When called with a file name, it opens the named file (in text mode), and sets its handle as the default input file. When called with a file handle, it simply sets this file handle as the default input file. When called without -parameters, it returns the current default input file. +arguments, it returns the current default input file. In case of errors this function raises the error, instead of returning an error code. @@ -6178,7 +6176,8 @@ detects the end of file, it returns no values (to finish the loop) and automatically closes the file. The call io.lines() (with no file name) is equivalent to io.input():lines("*l"); that is, it iterates over the lines of the default -input file. In this case it does not close the file when the loop ends. +input file. In this case, the iterator does not close the file when the loop +ends. In case of errors this function raises the error, instead of returning an error code. @@ -6390,7 +6389,7 @@ according to the same rules as the ISO C function strftime. When called without arguments, date returns a reasonable date and time representation that depends on the host system and on the current locale. (More specifically, os.date() is equivalent to os.date("%c").) -On non-POSIX systems, this function may be not thread safe because of its +In non-POSIX systems, this function may be not thread safe because of its reliance on C function gmtime and C function localtime. ------------------------------------------------------------------------------ @@ -6503,7 +6502,7 @@ os.tmpname () ~ Returns a string with a file name that can be used for a temporary file. The file must be explicitly opened before its use and explicitly removed when no longer needed. -On POSIX systems, this function also creates a file with that name, to avoid +In POSIX systems, this function also creates a file with that name, to avoid security risks. (Someone else might create the file with wrong permissions in the time between getting the name and creating the file.) You still have to open the file to use it and to remove it (even if you do not use it). @@ -6580,10 +6579,10 @@ explicit local variables, but also parameters, temporaries, etc. The first parameter or local variable has index 1, and so on, following the order that they are declared in the code, counting only the variables that are active in the current scope of the function. Negative indices refer to vararg -parameters; -1 is the first vararg parameter. The function returns nil if -there is no variable with the given index, and raises an error when called -with a level out of range. (You can call |lua53-debug.getinfo| to check -whether the level is valid.) +arguments; -1 is the first vararg argument. The function returns nil if there +is no variable with the given index, and raises an error when called with a +level out of range. (You can call |lua53-debug.getinfo| to check whether the +level is valid.) Variable names starting with '(' (open parenthesis) represent variables with no known names (internal variables such as loop control variables, and variables from chunks saved without debug information). @@ -6638,7 +6637,7 @@ combination of the following characters, with the given meaning: Moreover, with a count different from zero, the hook is called also after every count instructions. When called without arguments, |lua53-debug.sethook| turns off the hook. -When the hook is called, its first parameter is a string describing the event +When the hook is called, its first argument is a string describing the event that has triggered its call: "call" (or "tail call"), "return", "line", and "count". For line events, the hook also gets the new line number as its second parameter. Inside a hook, you can call getinfo with level 2 to get more @@ -6731,7 +6730,7 @@ standard libraries, including the debug library. Its usage is: < The options are: - -e stat: executes string stat; -- -l mod: "requires" mod; +- -l mod: "requires" mod and assigns the result to global @mod; - -i: enters interactive mode after running script; - -v: prints version information; - -E: ignores environment variables; @@ -6774,7 +6773,7 @@ followed by the other arguments. For instance, the call > $ lua -e "print(arg[1])" < -will print "-e". If there is a script, the script is called with parameters +will print "-e". If there is a script, the script is called with arguments arg[1], ..., arg[#arg]. (Like all chunks in Lua, the script is compiled as a vararg function.) In interactive mode, Lua repeatedly prompts and waits for a line. After @@ -6866,9 +6865,8 @@ The standard paths in the official distribution may change between versions. - The following functions were deprecated in the mathematical library: atan2, cosh, sinh, tanh, pow, frexp, and ldexp. You can replace math.pow(x,y) with x^y; you can replace math.atan2 with math.atan, which now accepts one or two - parameters; you can replace math.ldexp(x,exp) with x * 2.0^exp. For the - other operations, you can either use an external library or implement them - in Lua. + arguments; you can replace math.ldexp(x,exp) with x * 2.0^exp. For the other + operations, you can either use an external library or implement them in Lua. - The searcher for C loaders used by |lua53-require| changed the way it handles versioned names. Now, the version should come after the module name (as is usual in most other tools). For compatibility, that searcher still @@ -6882,7 +6880,7 @@ The standard paths in the official distribution may change between versions. 8.3 Changes in the API *lua53-sec8.3* ------------------------------------------------------------------------------ -- Continuation functions now receive as parameters what they needed to get +- Continuation functions now receive as arguments what they needed to get through lua_getctx, so lua_getctx has been removed. Adapt your code accordingly. - Function |lua53-lua_dump| has an extra parameter, strip. Use 0 as the value @@ -6972,10 +6970,10 @@ Numeral, and LiteralString, see |lua53-sec3.1|.) ------------------------------------------------------------------------------ Last update: -Mon Jan 9 13:30:53 BRST 2017 +Tue Jul 14 10:32:39 UTC 2020 Formated for Vim help: -Tue Jan 31 16:01:50 CET 2017 +Sun Nov 01 11:18:30 CET 2020 ============================================================================== vim:tw=78:expandtab:ts=4:ft=help:norl: diff --git a/doc/luasupport.txt b/doc/luasupport.txt index fdb3cf1..a7aca32 100644 --- a/doc/luasupport.txt +++ b/doc/luasupport.txt @@ -1,17 +1,17 @@ -*luasupport.txt* Lua Support Jul 02 2017 +*luasupport.txt* Lua Support Feb 11 2018 Lua Support *lua-support* *luasupport* - Plug-in version 1.0.1pre + Plug-in version 1.1alpha for Vim version 7.0 and above Wolfgang Mehner <wolfgang-mehner at web.de> -Lua-IDE for Vim/gVim. It is written to considerably speed up writing code in -a consistent style. This is done by inserting complete statements, idioms and -comments. These code fragments are provided in an extendible template library. -This plug-in helps with running and compiling Lua scripts, applying the code -checker, and provides quick access to the online documentation of the Lua -functions. +Lua-IDE for Vim/gVim/Neovim. It is written to considerably speed up writing +code in a consistent style. This is done by inserting complete statements, +idioms and comments. These code fragments are provided in an extendible +template library. This plug-in helps with running and compiling Lua scripts, +applying the code checker, and provides quick access to the online +documentation of the Lua functions. See the chapter |luasupport-introduction| for a quick overview and a short guide to this documentation. @@ -22,6 +22,7 @@ Lua is: Copyright 1994-2017 Lua.org, PUC-Rio. ============================================================================== 1. Introduction |luasupport-introduction| + 2. Usage |luasupport-usage| 2.1 Comments |luasupport-usage-comments| 2.1.1 End-of-Line Comments |luasupport-usage-comments-eol| @@ -35,11 +36,17 @@ Lua is: Copyright 1994-2017 Lua.org, PUC-Rio. 2.6 Help |luasupport-usage-help| 2.7 C-API Templates |luasupport-usage-capi| 2.8 Toolbox |luasupport-usage-toolbox| + 3. Templates |luasupport-templates| 3.1 Introduction |luasupport-templates-introduction| - 3.2 Jump Tags |luasupport-templates-jump-tags| - 3.3 Split Tags |luasupport-templates-split-tags| - 3.4 Auxiliary Functions |luasupport-templates-aux| + 3.2 Customization |luasupport-templates-custom| + 3.3 Jump Tags |luasupport-templates-jump-tags| + 3.4 Split Tags |luasupport-templates-split-tags| + 3.5 Macros |luasupport-templates-macros| + 3.6 Template Files |luasupport-templates-files| + 3.7 Template Libraries |luasupport-templates-libs| + 3.8 File Skeletons |luasupport-file-skeleton| + 4. Configuration |luasupport-configuration| 4.1 Executables |luasupport-config-executable| 4.1.1 Direct Run |luasupport-config-direct-run| @@ -49,16 +56,15 @@ Lua is: Copyright 1994-2017 Lua.org, PUC-Rio. 4.3 Maps |luasupport-config-maps| 4.4 Comments |luasupport-config-comments| 4.5 Snippets |luasupport-config-snippets| - 4.6 Template Library |luasupport-config-template-lib| - 4.7 Template Customization |luasupport-config-template-cstm| - 4.8 Hardcopy |luasupport-config-hardcopy| - 4.9 Browser |luasupport-config-browser| - 4.10 Toolbox |luasupport-config-toolbox| + 4.6 Hardcopy |luasupport-config-hardcopy| + 4.7 Toolbox |luasupport-config-toolbox| + 5. System-wide Installation |luasupport-system-wide| - A. Troubleshooting - Known Issues |luasupport-troubleshooting| - B. Release Notes - Change Log |luasupport-release-notes| - C. Credits |luasupport-credits| + A. Overview of Mappings |luasupport-mappings| + B. Troubleshooting - Known Issues |luasupport-troubleshooting| + C. Release Notes - Change Log |luasupport-release-notes| + D. Credits |luasupport-credits| ============================================================================== 1. INTRODUCTION *luasupport-introduction* @@ -90,9 +96,9 @@ The features of the plug-in are: The usage of most features is described in the chapter |luasupport-usage|. The chapter |luasupport-templates| gives a short introduction to the template -system. The Lua executables and some other features may require some -configuration, which is documented in the chapter |luasupport-configuration|. -How to do a system-wide installation is outlined in |luasupport-system-wide|. +system. The Lua executables and other features may require some configuration, +which is documented in the chapter |luasupport-configuration|. How to do a +system-wide installation is outlined in |luasupport-system-wide|. The template system comes with its own documentation, which mainly aims at the advanced user (see |templatesupport.txt|). @@ -104,6 +110,11 @@ advanced user (see |templatesupport.txt|). Features are accessible via menu entries and maps. Most maps are preceded by a mapleader. The leader is a backslash, if the standard configuration is used. +If the root menu 'Lua' is not visible you also can load it with the item +"Load Lua Support" from the "Tools" menu. The item "Unload Lua Support" +can be used to unload the Lua root menu. +(Compare |luasupport-config-menus|.) + ------------------------------------------------------------------------------ 2.1 COMMENTS *luasupport-usage-comments* ------------------------------------------------------------------------------ @@ -290,8 +301,8 @@ The file in the current buffer can be run or compiled with a keystroke. check the code Run.check code <LocalLeader>rk make script executable Run.make script exec./not <LocalLeader>re - load quickfix list (^1) Run.buffer "Lua Output". ... <LocalLeader>qf - ... and jump to error (^1) Run.buffer "Lua Output". ... <LocalLeader>qj + load quickfix list (^1) Run.buffer "Lua Output/Term" <LocalLeader>qf + ... and jump to error (^1) Run.buffer "Lua Output/Term" <LocalLeader>qj output method for "run" Run.output method <LocalLeader>ro change "direct run" Run.direct run <LocalLeader>rd @@ -299,8 +310,8 @@ The file in the current buffer can be run or compiled with a keystroke. change the compiler Run.set compiler exec. <LocalLeader>rsc ---------------------------------------------------------------------------- -(^1) Works only inside the buffer "Lua Output", where running a script echoes - the script's output, see |luasupport-config-output|. +(^1) Works only inside a buffer "Lua Output" or "Lua Terminal", where running +a script echoes the script's output, see |luasupport-config-output|. The functionality is also available through ex-commands. These commands can also be used to set different maps in the ftplugin. @@ -412,7 +423,7 @@ documentation of Lua functions or an English dictionary. The online reference can be opened very conveniently for Lua functions. Simply place the cursor on the name of a function in your source code, and use the menu entry or the map to open the online reference for that function. -(See Section |luasupport-config-browser| for the configuration.) +(See below for the configuration.) For file handle methods help will be show as well. Every method call of the form > @@ -433,12 +444,17 @@ The following URL will be opened in your browser (using "\hl"): > or the following help topic will be shown (using "\h2"): > :help lua52-math.sin < +The browser for opening online documentation, such as the English dictionary, +can be configured by setting a global variable in your ~/.vimrc (see +|g:Templates_InternetBrowserExec| and |g:Templates_InternetBrowserFlags|): > + let g:Templates_InternetBrowserExec = 'firefox' +< ------------------------------------------------------------------------------ 2.7 C-API TEMPLATES *luasupport-usage-capi* ------------------------------------------------------------------------------ This plug-in is shipped with templates for Lua's C-API. They can be used with -the C-Support plug-in (www.vim.org/scripts/script.php?script_id=213). +the C-Support plug-in (https://www.vim.org/scripts/script.php?script_id=213). The templates have to be added to C-Support's (!) template library, so they can be used when editing C code. Find out the path where the plug-in is @@ -482,7 +498,7 @@ Lua Support (see |g:Lua_MapLeader|). The following sections provide a short overview of the template system. See the documentation of the template system for a more in-depth discussion: -|templatesupport.txt| +|templatesupport.txt|, particularly |template-support-basics| ------------------------------------------------------------------------------ 3.1 INTRODUCTION *luasupport-templates-introduction* @@ -492,7 +508,8 @@ This plug-in makes heavy use of an extendible template library. A template library can assist in speeding up the writing of code, while at the same time ensuring a consistent style. The templates are written in an easy to use markup language, which enables the user to customize templates without much -hassle. +hassle. The menu shortcuts (e.g. 'c' for the Comments menu) and the maps +(e.g. `\cd` to insert the date) are also defined in the template library. Templates are short pieces of text which can be included into source code or text of any other kind. But they are not just plain text, they can be extended @@ -506,7 +523,39 @@ replacement text will then be used in the template while it is inserted. Hitting <ESC> or entering an empty text will abort template insertion. ------------------------------------------------------------------------------ -3.2 JUMP TAGS *luasupport-templates-jump-tags* +3.2 CUSTOMIZATION *luasupport-templates-custom* +------------------------------------------------------------------------------ + +The master template file is `$HOME/.vim/lua-support/templates/Templates` for +a user installation and `$VIM/vimfiles/lua-support/templates/Templates` for +a system-wide installation (see |luasupport-system-wide|). + +The template library is customized via your local template files. Use the menu +entries "Snippets -> edit local templates", "Snippets -> edit custom +templates", or "Snippets -> edit personal templates" to get there. + +The master template file can be edited itself to adapt the templates/menus to +the users need. Alternatively, a custom template file can be added (see +|g:Lua_CustomTemplateFile|), which eliminates the need to edit stock +templates. + +The personalization (name, email, ..., date and time format) can be done in a +special personalization template file (see |g:Templates_PersonalizationFile|). +It will be read by all plug-ins which support this feature, so it should only +contain basic information not pertaining to a specific programming language. +It can be set up using a wizard, which is run by the map `\ntw` or the menu +entry "Snippets -> template setup wizard". Afterwards, use the menu entry +"Snippets -> reread templates" to apply the changes. + +Further template files can be added using the call: > + call mmtemplates#config#Add ( 'lua', '<PATH>/some.templates', 'example', 'nte' ) +The first parameter adds the file to your Lua templates, the second is the +path. The remaining two optional parameters specify the symbolic name for +these templates and the map to edit them. The map is `\nte` in this example, +if the standard mapleader is set. + +------------------------------------------------------------------------------ +3.3 JUMP TAGS *luasupport-templates-jump-tags* ------------------------------------------------------------------------------ Templates can include special tags, which mark positions where text needs to @@ -525,25 +574,38 @@ Use the <CTRL-J> to jump to the next tag. The maps works in normal and insert mode. Use <CTRL-D> to delete optional tags on the same line, for example: > string.match ( <+str+>, <+pattern+>, [+init+] ) The optional argument "init" can be written down after jumping to the tag -using <CTRL-J> or deleted together with the comma using <CTRL-D>. +using <CTRL-J> or deleted together with the comma using <CTRL-D>. The optional +tags are: `[+TAGNAME+]` `[-TAGNAME-]` + +The tags written with minus signs are removed when the template is used in +visual mode, compare the next section: `{-TAGNAME-}` `<-TAGNAME->` `[-TAGNAME-]` ------------------------------------------------------------------------------ -3.3 SPLIT TAGS *luasupport-templates-split-tags* +3.4 SPLIT TAGS *luasupport-templates-split-tags* ------------------------------------------------------------------------------ -Some templates include so-called split tags and therefore can use to surround -some lines of code. +Some templates include so-called split tags and can use to surround some lines +of code, or to surround a part of the current line. Example: +The template "Statements.if, else" contains a split tag for the if-branch: +> + == Statements.if, else == below, map:sie, sc:i == + if <CURSOR> then + <SPLIT>{-IF_PART-} + else + {+ELSE_PART+} + end + == ENDTEMPLATE == +< Consider the lines: > a = 1; b = 2; < -The template "Statements.if, else" contains a split tag between "if" and -"else". After selecting the two lines and inserting the template, the result -looks like this: +After selecting the two lines and inserting the template, the result looks +like this: > if <CURSOR IS PLACED HERE> a = 1; @@ -552,10 +614,73 @@ looks like this: {+ELSE_PART+} end < -After adding the condition, use <CTRL-J> to jump to the else-part. +The tag `<-IF_PART->`is removed because it is written with a minus signs. The +cursor is placed where the condition must go. Use <CTRL-J> to jump to the +else-branch. ------------------------------------------------------------------------------ -3.4 AUXILIARY FUNCTIONS *luasupport-templates-aux* +3.5 MACROS *luasupport-templates-macros* +------------------------------------------------------------------------------ + +Macros are placeholders which get replace while a template is inserted. The +template library defines several macros used for personalization: +> + SetMacro( 'AUTHOR', 'YOUR NAME' ) + SetMacro( 'AUTHORREF', '' ) + SetMacro( 'EMAIL', '' ) + SetMacro( 'ORGANIZATION', '' ) + SetMacro( 'COMPANY', '' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) + SetMacro( 'LICENSE', 'GNU General Public License' ) +< +These macros are used by some templates, e.g. the file description. Arbitrary +user-defined macros are possible. The macro name must follows the rules for a +C language identifier: first character letter or underscore; case matters; +digits are allowed beginning with the second character. +> +Some predefined macros can help make comments much richer: +> + |BASENAME| filename without path and suffix + |FILENAME| filename without path + |PATH| path without filename + |SUFFIX| filename suffix + + |DATE| the date + |TIME| the time + |YEAR| the year +< +The date and time formats can be set in the template library, see |strftime()| +for the format specifiers: +> + SetFormat( 'DATE', '%D' ) + SetFormat( 'TIME', '%H:%M' ) + SetFormat( 'YEAR', 'year %Y' ) +< +This sets the format for the date to the preferred representation for your +current locale, the time will be inserted as 10:24 and the year will be +represented using four digits. + +------------------------------------------------------------------------------ +3.6 TEMPLATE FILES *luasupport-templates-files* +------------------------------------------------------------------------------ + +The template definitions are spread out over several template files. These can +contain comments, lines starting with a section sign (§) are ignored. + +Template files can include several further files: > + IncludeFile( 'comments.templates' ) +An included file will be processed before the remainder of the including file. + +The template behind a menu item is identified by a given name. The first part +of the name identifies the menu name, the second part identifies the item. +A template definition starts with a template header with the following syntax: + + == menu_name.template_name == options == + +The options are described here: |template-support-options| + +------------------------------------------------------------------------------ +3.7 TEMPLATE LIBRARIES *luasupport-templates-libs* ------------------------------------------------------------------------------ The template system comes with several auxiliary functions. @@ -577,16 +702,89 @@ The template system comes with several auxiliary functions. (^1) system-wide installation only -"Snippets -> edit ... templates" will open a file browser in the directory -containing your template library. This feature is merely a fast way to jump to -the files. After the templates have been edited, they need to be read again. +The menu items "Snippets -> edit ... templates" open various template files. The +stock templates are usually located in the "local" template file: > + ~/.vim/lua-support/templates/Templates +The template files named "custom" and "personal" can be used for +customization, which avoids editing the stock templates. +There may be dependent files loaded from the main files. Change whatever file +you want, save it, and click on the menu item "reread templates" to read in +the file(s) and to rebuild the internal representation of the templates. For how to use these files to configure and personalize the template library, -see |luasupport-config-template-cstm|. +see |luasupport-templates-custom|. For help with setting up the template +library, use the setup wizard: + Snippets -> template setup wizard + +Template Browser +---------------- +When editing a template file, it is selected via |:Explore|. You can change +this behavior by setting a global variable in your ~/.vimrc (see +|g:Templates_TemplateBrowser|): +> + let g:Templates_TemplateBrowser = 'browse' +< +Template Style +-------------- +The template system supports different template styles. If there are more than +one style the menu item "choose style" let you choose a style on the fly. + +Template Locations +------------------ + *g:Lua_LocalTemplateFile* *g:Lua_GlobalTemplateFile* + *g:Lua_CustomTemplateFile* +The variables `g:Lua_LocalTemplateFile` and `g:Lua_GlobalTemplateFile` set the +locations and names of the local and global template files, respectively. +The standard locations of the template files can be changed via these +configuration variables, e.g.: > + let g:Lua_CustomTemplateFile = $HOME.'/.vim/my-templates/lua.templates' +< + Variable Default Linux + ---------------------------------------------------------------------------- + g:Lua_CustomTemplateFile $HOME/.vim/templates/lua.templates + g:Lua_GlobalTemplateFile $VIMRUNTIME/lua-support/templates/Templates + g:Lua_LocalTemplateFile $HOME/.vim/lua-support/templates/Templates + ---------------------------------------------------------------------------- + + Variable Default Windows + ---------------------------------------------------------------------------- + g:Lua_CustomTemplateFile $HOME/vimfiles/templates/lua.templates + g:Lua_GlobalTemplateFile $VIMRUNTIME/lua-support/templates/Templates + g:Lua_LocalTemplateFile $HOME/vimfiles/lua-support/templates/Templates + ---------------------------------------------------------------------------- -For help with setting up the template library, use the setup wizard -"Snippets -> template setup wizard". +The personalization file is located in a directory relative to |runtimepath|: > + <RUNTIMEPATH>/templates/personal.templates +For configuring the personalization file, see |g:Templates_PersonalizationFile|. +------------------------------------------------------------------------------ +3.8 FILE SKELETONS *luasupport-file-skeleton* +------------------------------------------------------------------------------ + *g:Lua_InsertFileHeader* +If g:Lua_InsertFileProlog is set to "yes", a file skeleton is automatically +inserted into new Lua documents. The list of templates used to create this +skeleton is specified in the template library. For this purpose a property is +used, which can for example be set in the customization file +(see |luasupport-templates-custom|). + +This automatic insertion can be switched off by adding this to the `.vimrc`: > + let g:Lua_InsertFileProlog = 'no' +< + *Lua::FileSkeleton::Script* +The file skeleton is controlled via this property, which can be set in one +of the template files: > + SetProperty ( 'Lua::FileSkeleton::Script', 'Comments.file description' ) +This inserts only a comment to describe the file. To disable the insertion set +the property to an empty string: > + SetProperty ( 'Lua::FileSkeleton::Script', '' ) +In general, this property is a semicolon-separated list of templates to be +inserted: > + SetProperty ( 'Lua::FileSkeleton::Script', 'Comments.shebang;Comments.file description; ;Files.module' ) +This will insert a shebang, a file description comment, and the module file +template. If a space appears as an entry in the list, an empty line is +inserted: > + '...; ;...' +< ============================================================================== 4. CONFIGURATION *luasupport-configuration* ============================================================================== @@ -598,7 +796,7 @@ set in the .vimrc file. ---------------------------------------------------------------------------- |g:Lua_BinPath| '' the path to the Lua binaries (^1) |g:Lua_Executable| 'lua' the lua executable (^1) - |g:Lua_OutputMethod| 'vim-io' the method for running Lua + |g:Lua_OutputMethod| (see below) the method for running Lua |g:Lua_CompilerExec| 'luac' the luac executable (^1) |g:Lua_CompiledExtension| 'luac' extension used for compile chunks @@ -615,11 +813,12 @@ set in the .vimrc file. |g:Lua_SnippetDir| (see below) directory with code snippers |g:Lua_SnippetBrowser| 'gui' browser to select code snippets - |g:Lua_LocalTemplateFile| (see below) the local top-level template file - |g:Lua_GlobalTemplateFile| (see below) the global top-level template file - |g:Lua_CustomTemplateFile| (see below) the optional custom template file + + |g:Lua_LocalTemplateFile| (see Chp. 3) the local top-level template file + |g:Lua_GlobalTemplateFile| (see Chp. 3) the global top-level template file + |g:Lua_CustomTemplateFile| (see Chp. 3) the optional custom template file |g:Templates_PersonalizationFile| - (see below) the personalization template file + (see Chp. 3) the personalization template file |g:Lua_Printheader| '...' printheader used for hardcopy @@ -628,11 +827,13 @@ set in the .vimrc file. g:Xterm_Executable 'xterm' the xterm executable (^2) g:Xterm_Options '...' the xterm default settings (^2) + + |g:Templates_InternetBrowserExec| the browser executable + |g:Templates_InternetBrowserFlags| additional browser flags ---------------------------------------------------------------------------- -Further customization is carried out in the template library: -- |luasupport-config-template-cstm| -- |luasupport-config-browser| +Further customization is carried out in the template library, see +|luasupport-templates-custom| and |luasupport-file-skeleton|. (^1) The Unix defaults are as follows: @@ -680,7 +881,6 @@ entries or the map "\rsc" (see |luasupport-usage-run|). The extension for compiled Lua chunks can be changed by setting the variable g:Lua_CompiledExtension, for example in the .vimrc: > let g:Lua_CompiledExtension = 'lc' -< The behavior can be changed on the fly by settings the variable to a different value on the command line. @@ -718,24 +918,34 @@ The initial method for output redirection can be set via g:Lua_OutputMethod: > Afterwards, it can be changed on the fly using the menu entries or the map "\ro" (see |luasupport-usage-run|). -Use the mode 'vim-io' for scripts with little input and output. The mode +Use the mode 'cmd-line' for scripts with little input and output. The mode 'xterm' runs the command in a separate xterm, which also supports input, but does not block the editor. The output is available until the window is closed. -The modes 'vim-qf' and 'buffer' do not support interactive input, but provide -quickfix support. With 'buffer' the output is redirected into a buffer, named -"Lua Output", and thus is available for detailed analysis afterwards. +The modes 'quickfix' and 'buffer' do not support interactive input, but +provide quickfix support. With 'buffer' the output is redirected into a +buffer, named "Lua Output", and thus is available for detailed analysis +afterwards. + +The command can be run in a |terminal| window, if Vim is compiled with the +|+terminal| feature. The output can be loaded into quickfix, using the maps +"\qf" or "\qj" in the terminal window. The possible settings are listed below: Value Meaning ---------------------------------------------------------------------------- - 'vim-io' (default) run on the Vim command-line (supports input operations) - 'vim-qf' print output on the Vim cmd.-line (supports quickfix) - 'buffer' redirect the output into a buffer (supports quickfix) - 'xterm' run in a separate xterm (supports input operations; - UNIX only, see |luasupport-config-xterm|) + 'buffer' redirect the output into a buffer (supports |quickfix|) + 'cmd-line' (^1) run on the Vim command-line (supports input operations) + 'quickfix' print output or start quickfix (supports |quickfix|) + 'terminal' (^2) run in a terminal window (support input operations + and quickfix, via the maps \qf and \qj) + 'xterm' (^3) run in a separate xterm (supports input operations) ---------------------------------------------------------------------------- +(^1) default for Vim/gVim, not in Neovim +(^2) default for Neovim, requires |+terminal| or Neovim +(^3) UNIX only, see |luasupport-config-xterm| + ------------------------------------------------------------------------------ 4.1.3 Xterm *luasupport-config-xterm* @@ -774,7 +984,7 @@ This has the disadvantage that the templates have to be loaded during the startup of Vim, which might cause a noticeable slowdown on older systems. The automatic creation of the menus is prevented by: > let g:Lua_LoadMenus = 'manual' -Now the menus can only be loaded by using the tool menu entry "Tools.Load +Now the menus can only be loaded by using the tool menu entry "Tools -> Load Lua Support". *g:Lua_RootMenu* @@ -818,34 +1028,21 @@ variable to "no": > ------------------------------------------------------------------------------ 4.4 COMMENTS *luasupport-config-comments* ------------------------------------------------------------------------------ - *g:Lua_InsertFileHeader* + When a new Lua file is opened, the plug-in automatically inserts a file header, which is the template "Comments -> file description". This behavior can be switched off by adding this to the .vimrc: > let g:Lua_InsertFileHeader = 'no' -< The behavior can be changed on the fly by settings the variable to a different value on the command line. - *Lua::FileSkeleton::Script* -The file skeletons are controlled via this property, which can be set in one -of the template files: > - SetProperty ( 'Lua::FileSkeleton::Script', 'Comments.file description' ) -This inserts only a comment to describe the file. To disable the insertion set -the property to an empty string: > - SetProperty ( 'Lua::FileSkeleton::Script', '' ) -In general, these properties are semicolon-separated lists of templates to be -inserted: > - SetProperty ( 'Lua::FileSkeleton::Script', 'Comments.shebang;Comments.file description; ;Files.module' ) -This will insert a shebang, a file description comment, and the module file -template. If a space appears as an entry in the list, an empty line is -inserted: > - '...; ;...' -< +Further customization of the file skeletons is possible through use of the +template library (see |luasupport-file-skeleton|). + *g:Lua_LineEndCommentColumn* The standard column used for end-of-line comments is configured using g:Lua_LineEndCommentColumn. The column can then be set individually for each -buffer, using the menu entry "Comments.set end-of-line com. col.". +buffer, using the menu entry "Comments -> set end-of-line com. col.". Example: > let g:Lua_LineEndCommentColumn = 59 @@ -860,17 +1057,14 @@ system. (Path separators are always written as slashes '/', even for Windows.) - For a local installation, the default will be (UNIX/Linux): > - s:Lua_SnippetDir = $HOME.'/.vim/lua/codesnippets/' + s:Lua_SnippetDir = $HOME.'/.vim/lua-support/codesnippets/' or (Windows): > - s:Lua_SnippetDir = $HOME.'/vimfiles/lua/codesnippets' -< + s:Lua_SnippetDir = $HOME.'/vimfiles/lua-support/codesnippets' For a sytem-wide installation, the default will be: > - s:Lua_SnippetDir = $VIM.'/vimfiles/lua/codesnippets' + s:Lua_SnippetDir = $VIM.'/vimfiles/lua-support/codesnippets' < - Example: To set a different code snippet directory, add this line to your vimrc: > @@ -883,129 +1077,21 @@ or on the command line by setting: > let g:Lua_SnippetBrowser = 'cmd-line' < ------------------------------------------------------------------------------ -4.6 TEMPLATE LIBRARY *luasupport-config-template-lib* ------------------------------------------------------------------------------- - *g:Lua_LclTemplateFile* *g:Lua_GlbTemplateFile* - *g:Lua_LocalTemplateFile* *g:Lua_GlobalTemplateFile* - *g:Lua_CustomTemplateFile* -The variables g:Lua_LocalTemplateFile and g:Lua_GlobalTemplateFile set the -locations and names of the local and global template files, respectively. -The default for the local and global template files depend on the type of the -installation. - -(Path separators are always written as slashes '/', even for Windows.) - - -Local installation: - -If the plug-in lua-support.vim can be found somewhere in the $HOME directory: > - <RUNTIMEPATH>/plugin/lua-support.vim -The default for the local template file is: > - g:Lua_LocalTemplateFile - = '<RUNTIMEPATH>/lua-support/templates/Templates' -There is no global template file. - - -System-wide installation (|luasupport-system-wide|): - -The default for the global template file is: > - g:Lua_GlobalTemplateFile - = $VIM.'/vimfiles/lua-support/templates/Templates' -The default for the local template file is (UNIX/Linux): > - s:Lua_LocalTemplateFile - = $HOME.'/.vim/lua-support/templates/Templates' -or (Windows): > - s:Lua_LocalTemplateFile - = $HOME.'/vimfiles/lua-support/templates/Templates' -< - -Independent of the type of installation, the default custom template file is: > - s:Lua_CustomTemplateFile = $HOME.'/.vim/templates/lua.templates' -The personalization file is located in a directory relative to |runtimepath|: > - <RUNTIMEPATH>/templates/personal.templates -For configuring the personalization file, see |g:Templates_PersonalizationFile|. - -Using the custom and personalization template files will give the average -user sufficient options for customization. Adding even more template files is -possible though, using the function "mmtemplates#config#Add". Each call to the -function configures an additional template file: > - call mmtemplates#config#Add ( "lua", filename, symbolic_name, edit_map ) -For the filetype "lua", the file 'filename' will be loaded. It is associated -with the name 'symbolic_name'. The map 'edit_map' can be used to open the file -for editing. The third and fourth argument are optional and will be replaced -by default values if missing. - - -Example: - -To set a different custom template file, set this variable in your vimrc: > - let g:Lua_CustomTemplateFile = $HOME.'/myvim/lua/templates/my.templates' -< ------------------------------------------------------------------------------- -4.7 TEMPLATE CUSTOMIZATION *luasupport-config-template-cstm* ------------------------------------------------------------------------------- - -The template library is customized via your local template files. Use the menu -entries "Snippets -> edit local templates", "Snippets -> edit custom -templates", or "Snippets -> edit personal templates" to get there. - -The personalization template file is used to set personal information, and -will be read by other plug-ins which use this feature. Use "Snippets -> -template setup wizard" for help with its setup. Since it is used by all -plug-ins, it should only contain information which is independent of a -specific programming language. The location can be configured via -|g:Templates_PersonalizationFile|. - -You should fill in your name and other information there: -> - SetMacro( 'AUTHOR', 'Your Name' ) - SetMacro( 'AUTHORREF', 'YN' ) - SetMacro( 'EMAIL', 'your-email@i-use-vim.org' ) - ... -< -The format of the date and time which is inserted in the templates can be -configured as well (using the same format as the C function 'strftime'): -> - SetFormat( 'DATE', '%x' ) - SetFormat( 'TIME', '%H:%M' ) - SetFormat( 'YEAR', '%Y' ) -< -This sets the format for the date to the preferred representation for your -current locale, the time will be inserted as 10:24 and the year will be -represented using four digits. - -Afterwards, use the menu entry "Snippets -> reread templates" to apply the -changes. - -The custom template file can be used to set the personal information and/or to -change or add Lua templates. The custom template file eliminates the need to -edit the stock templates provided in the local template file (or the global -template file for global installations). Its path and filename can be -configured via |g:Lua_CustomTemplateFile|. - ------------------------------------------------------------------------------- -4.8 HARDCOPY *luasupport-config-hardcopy* +4.6 HARDCOPY *luasupport-config-hardcopy* ------------------------------------------------------------------------------ *g:Lua_Printheader* The printheader used by "Run -> hardcopy to filename.ps" is set via the -variable g:Lua_Printheader. It is temporarily set as the value of +variable `g:Lua_Printheader.` It is temporarily set as the value of 'printheader' while printing the hardcopy. See the documentation of the -option 'printheader' for the possible contents of g:Lua_Printheader. - +option 'printheader' for the possible contents of `g:Lua_Printheader.`The +default is: > + let g:Lua_Printheader = "%<%f%h%m%< %=%{strftime('%x %H:%M')} Page %N" +< The behavior can be changed on the fly by settings the variable to a different value on the command line. ------------------------------------------------------------------------------ -4.9 BROWSER *luasupport-config-browser* ------------------------------------------------------------------------------- - -Opening the online reference for various items is a feature of the template -library. The browser has to be configured using these variables: -- |g:Templates_InternetBrowserExec| -- |g:Templates_InternetBrowserFlags| - ------------------------------------------------------------------------------- -4.10 TOOLBOX *luasupport-config-toolbox* +4.7 TOOLBOX *luasupport-config-toolbox* ------------------------------------------------------------------------------ *g:Lua_UseToolbox* *g:Lua_UseTool_make* @@ -1054,7 +1140,7 @@ SPECIAL CASES. Some Linux distributions use non-standard names for Vim directories. SUSE has a directory '/usr/share/vim/site' to put plug-ins in. These directories will not be found automatically. After installing the plug-in below '/usr/share/vim/site' the use of the templates will be enabled -by the following line in '~/.vimrc' (see |luasupport-config-template-lib|): +by the following line in '~/.vimrc' (see |g:Lua_GlobalTemplateFile|): > let g:Lua_GlobalTemplateFile = \ '/usr/share/vim/site/lua-support/templates/Templates' @@ -1065,16 +1151,173 @@ As *** USER *** : Use the template setup wizard "Snippets -> template setup wizard" to add your personalization. Use the custom template file for further customization. (see -|luasupport-config-template-cstm|) +|luasupport-templates-custom|) + +The personalization file will be read by all plug-ins supporting this feature, +and should contain only information relevant for all template libraries. You +can set some macros in this file with your personal information in order to +obtain personalized comments, e.g. something like this: +> + SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) + SetMacro( 'AUTHORREF', 'WM' ) + SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) +< +Use the custom template file for Vim templates which override the global +templates or to add new ones. + +============================================================================== +A. OVERVIEW OF MAPPINGS *luasupport-mappings* +============================================================================== + +Almost all functionality is accessible using key mappings. + +All mappings are filetype specific; they are only defined for buffers with +filetype 'lua' to minimize conflicts with mappings from other plug-ins. +Furthermore, the mapleader can be changed using the setting |g:Lua_MapLeader|. + +All maps work in normal and insert mode. Additionally some mappings can be +used with a range (of lines). In normal mode > + \cl +appends a end-of-line comment to the current line, whereas > + 4\cl +appends end-of-line comments to the 4 lines starting with the current line. + +Hint: Typing speed matters. The combination of a leader ('\') and the +following character(s) will only be recognized for a short time. + +Legend: visual mode: (v) use range, (s) surround content, + [n] range + tab-completion: (T) specialized, (F) filenames + + -- Jump Tags ----------------------------------------- + + <CTRL-J> jump to next tag + <CTRL-D> delete an optional tag + + -- Help ---------------------------------------------- + + for the word under the cursor ... + \he open an English dictionary + \hl open online reference manual + \h1 open manual for Lua 5.1 inside Vim + \h2 open manual for Lua 5.2 inside Vim + \h3 open manual for Lua 5.3 inside Vim + + \hs display plug-in help + + -- Comments ------------------------------------------ + + [n]\cl end-of-line comment (v) + [n]\cj adjust end-of-line comments (v) + \cs set end-of-line comment column + [n]\cc comment code (v) + [n]\co uncomment code (v) + [n]\ct toggle comments (v) + [n]\cil insert long comment (v) + [n]\crl remove long comment (v) + [n]\ca function description (auto) (v) + + \cfr frame comment + \cfb frame comment, big + \cfi file description + \cfu function description + \cb shebang + \cke keyword comments (T) + \cma plug-in macros (T) + \cd date + + -- Statements ----------------------------------------- + + \sfr for, range (s) + \sfi for, in (s) + \sw while (s) + \sr repeat (s) + + \sif if ... end (s) + \sie if ... else ... endif (s) + \sei elseif + \sel else + + \sb do ... end (block) (s) + + -- Idioms ---------------------------------------------- + + \if function definition (s) + \in inline function def. (s) + \im metamethod (s, T) + + \it table constructor (s) + + \il library functions (T) + \iv library variables (T) + \ii iterators (s, T) + + \iof open file + \iot open tempfile + \iop open pipe + + \ip add to path + + -- Objects --------------------------------------------- + + \ot class metatable + \oc class constructor (s) + \ois class, is_object function + \om method (s) + + \im metamethod (s, T) + + -- Regular Expressions --------------------------------- + + \xca captures (s) + \xco collection (s) + \xcl character class (T) + \xe escape magic character + + -- Snippets -------------------------------------------- + + \ni insert code snippet + [n]\nc create code snippet (v) + \nv view code snippet + \ne edit code snippet + + \ntg edit global template file + \ntl edit local template file + \ntc edit custom template file + \ntp edit personal template file + \ntr reread template file + \ntw template setup wizard + \nts choose template style (T) + + -- Run ------------------------------------------------- + + \rr run the script + \rc compile the script + \rk check the code + \re make script executable + + \ro output method for "run" + \rd change "direct run" + \rse change the interpreter + \rsc change the compiler + + [n]\rh hardcopy buffer (v) + \rs plug-in settings + + -- Buffer "Lua Output/Term" ---------------------------- + + \qf load quickfix list + \qj ... and jump to first error ============================================================================== -A. TROUBLESHOOTING - KNOWN ISSUES *luasupport-troubleshooting* +B. TROUBLESHOOTING - KNOWN ISSUES *luasupport-troubleshooting* ============================================================================== * I do not see any new main menu item. - - The menu is only created upon opening the first Lua file (*.m). + - The menu is only created upon opening the first Lua file (*.lua). This behavior can be changed: - :help luasupport-config-menus + :help |luasupport-config-menus| - Was the archive extracted into the right directory? See the section INSTALLATION in lua-support/README.md. - Loading of plug-in files must be enabled. If not use @@ -1097,13 +1340,13 @@ A. TROUBLESHOOTING - KNOWN ISSUES *luasupport-troubleshooting* :set shellxquote=\" ============================================================================== -B. RELEASE NOTES - CHANGE LOG *luasupport-release-notes* +C. RELEASE NOTES - CHANGE LOG *luasupport-release-notes* ============================================================================== See files 'lua-support/README.md' and 'lua-support/doc/ChangeLog'. ============================================================================== -C. CREDITS *luasupport-credits* +D. CREDITS *luasupport-credits* ============================================================================== Fritz Mehner (vim.org user name: mehner) for a number of things: @@ -1113,10 +1356,10 @@ Fritz Mehner (vim.org user name: mehner) for a number of things: well Luis Carvalho (Kozure): -- the idea for suppling Lua's reference manual in Vim's help format is taken +- the idea for supplying Lua's reference manual in Vim's help format is taken from his plug-in "luarefvim", which contains previous versions of the reference manual - ( http://vim.sourceforge.net/scripts/script.php?script_id=1291 ) + ( https://www.vim.org/scripts/script.php?script_id=1291 ) ============================================================================== vim:tw=78:expandtab:ts=2:ft=help:norl: diff --git a/doc/matlabsupport.txt b/doc/matlabsupport.txt deleted file mode 100644 index cac31b6..0000000 --- a/doc/matlabsupport.txt +++ /dev/null @@ -1,767 +0,0 @@ -*matlabsupport.txt* Matlab Support Mar 25 2014 - -Matlab Support *matlab-support* *matlabsupport* - - Plug-in version 0.8rc2 - for Vim version 7.0 and above - Wolfgang Mehner <wolfgang-mehner at web.de> - -MATLAB-IDE for Vim/gVim. It is written to considerably speed up writing code -in a consistent style. This is done by inserting complete statements, idioms -and comments. These code fragments are provided in an extendible template -library. This plug-in also supports the use of the MATLAB code checker "mlint" -and provides quick access to the online documentation of the Matlab functions. -See the chapter |matlabsupport-introduction| for a quick overview and a short -guide to this documentation. - -The MathWorks, Inc and MATLAB are registered trademarks of The MathWorks, Inc. - -============================================================================== -0. TABLE OF CONTENTS *matlabsupport-support-contents* -============================================================================== - - 1. Introduction |matlabsupport-introduction| - 2. Usage |matlabsupport-usage| - 2.1 Comments |matlabsupport-usage-comments| - 2.1.1 End-of-Line Comments |matlabsupport-usage-comments-eol| - 2.1.2 Comment Lines |matlabsupport-usage-comments-lines| - 2.1.3 Automated Comments |matlabsupport-usage-comments-auto| - 2.2 Snippets |matlabsupport-usage-snippets| - 2.3 Use mlint |matlabsupport-usage-mlint| - 2.3.1 Using QuickFix |matlabsupport-usage-mlint-qf| - 2.4 Help |matlabsupport-usage-help| - 3. Templates |matlabsupport-templates| - 3.1 Introduction |matlabsupport-templates-introduction| - 3.2 Jump Tags |matlabsupport-templates-jump-tags| - 3.3 Split Tags |matlabsupport-templates-split-tags| - 3.4 Auxiliary Functions |matlabsupport-templates-aux| - 4. Configuration |matlabsupport-configuration| - 4.1 Menus |matlabsupport-config-menus| - 4.2 Maps |matlabsupport-config-maps| - 4.3 Comments |matlabsupport-config-comments| - 4.4 Snippets |matlabsupport-config-snippets| - 4.5 Mlint |matlabsupport-config-mlint| - 4.6 Template Library |matlabsupport-config-template-lib| - 4.7 Template Customization |matlabsupport-config-template-cstm| - 4.8 Browser |matlabsupport-config-browser| - 5. System-wide Installation |matlabsupport-system-wide| - - A. Troubleshooting - Known Issues |matlabsupport-troubleshooting| - B. Release Notes - Change Log |matlabsupport-release-notes| - C. Credits |matlabsupport-credits| - -============================================================================== -1. INTRODUCTION *matlabsupport-introduction* -============================================================================== - -After the first Matlab file (*.m) has been opened, the menu "Matlab" appears -in the menu bar. It holds entries for all the templates (such as -"Statements->for" or "Idioms->function"), as well as some other functionality. -The letters on the right name maps, which can also be used to access all the -capabilities. -The menus are also created if a GUI is not running. They can be used via > - :emenu Matlab. -(Use the arrow keys for navigation, <Enter> to select an entry and <TAB> for -auto completion.) - -The features of the plug-in are: -- Turn code lines into comments and vice versa. - |matlabsupport-usage-comments-lines| -- Automatically add comments for functions and its parameters. - |matlabsupport-usage-comments-auto| -- Open the online documentation for a given function. - |matlabsupport-usage-help| -- Invoke the code checker "mlint". |matlabsupport-usage-mlint| -- Manage code snippets. |matlabsupport-usage-snippets| -- An extendible template library. |matlabsupport-templates| - -The usage of most features is described in the chapter |matlabsupport-usage|. -The chapter |matlabsupport-templates| gives a short introduction to the -template system. The code checker "mlint" and some other features require some -configuration, which is documented in the chapter |matlabsupport-configuration|. -How to do a system-wide installation is outlined in |matlabsupport-system-wide|. - -The template system comes with its own documentation, which mainly aims at the -advanced user (see |templatesupport.txt|). - -============================================================================== -2. USAGE *matlabsupport-usage* -============================================================================== - -Features are accessible via menu entries and maps. Most maps are preceded by a -mapleader. The leader is backslash, if the standard configuration is used. - ------------------------------------------------------------------------------- -2.1 COMMENTS *matlabsupport-usage-comments* ------------------------------------------------------------------------------- - -Besides the templates, there is some other functionality provided in the menu -"Comments". - - Feature Menu Entry Map - ---------------------------------------------------------------------------- - add end-of-line comments Comments.end-of-line comment <LocalLeader>cl - adjust end-of-line com. Comments.adjust end-of-line c. <LocalLeader>cj - set end-of-line column Comments.set end-of-line col. <LocalLeader>cs - - code to comment Comments.code -> comment <LocalLeader>cc - comment to code Comments.comment -> code <LocalLeader>co - toggle comments Comments.toggle code <-> com. <LocalLeader>ct - - automatic function Comments.func. desc. (auto) <LocalLeader>ca - description - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- - -2.1.1 End-of-Line Comments *matlabsupport-usage-comments-eol* - -End-of-line comments can be added using the map \cl or the menu entry -"Comments -> end-of-line comment". They will all start in the same column. The -number of this column is set to a default value at first (see -|g:Matlab_LineEndCommentColumn|), but can be set for each buffer individually -using "Comments -> set end-of-line col.". This causes the column currently -under the cursor to be used in the future. -Existing comments can be adjusted to this column using \cj or the menu entry -"Comments -> adjust end-of-line com.". - -In normal and insert mode, the current line will be changed. In visual mode -the entire selected range is edited. The maps can also be used with a line -count: > - 3\cl -to add end-of-line comments to three lines at once. - -Example: - -If the mouse cursor is placed on the first line: > - - s.name = 'file.txt'; - s.type = 'csv'; - s.cols = 4; -< -and the map 3\cl is used, the result will be: > - - s.name = 'file.txt'; % <CURSOR IS PLACED HERE> - s.type = 'csv'; % - s.cols = 4; % -< -Now each field of the struct can be documented. - ------------------------------------------------------------------------------- - -2.1.2 Comment Lines *matlabsupport-usage-comments-lines* - -Lines of code can be changed into comments and vice versa with just a few -keystrokes. In normal and insert mode, the comment, uncomment and toggle -functions will change the current line. In visual mode the entire selected -range is affected. -The maps can also be used together with a count, such as: > - 4\cc -to change the current line and the three lines below it into comments. - -Example: - -If the following lines are select: > - - %file = 'settings1.txt'; - %debug = true; - file = 'settings2.txt'; - debug = false; -< -and the map \ct (toggle) is used, the result will be: > - - file = 'settings1.txt'; - debug = true; - %file = 'settings2.txt'; - %debug = false; -< ------------------------------------------------------------------------------- - -2.1.3 Automated Comments *matlabsupport-usage-comments-auto* - -A skeleton for a comment can be created automatically for a given function. -This works on the current line or a selected range of lines. After choosing -the function definition line, use "Comments -> function description (auto)". -The results will be slightly different, depending on whether the function is -the primary function of the file or another function. -The appearance (and placement) can be change in the template library. - -Example: - -Consider the function definition: -> - function n = norm ( vector, p ) - - n = ... -< -After placing the cursor on the function definition line, invoke the auto -comment. The result will look like this: -> - function n = norm ( vector, p ) - %NORM <CURSOR IS PLACED HERE>. - % {+DETAILS+} - % - % Parameters: vector - {+DESCRIPTION+}. ({+TYPE+}) - % p - {+DESCRIPTION+}. ({+TYPE+}) - % Returns: n - {+DESCRIPTION+}. ({+TYPE+}) - - n = ... -< -After typing a brief description, use <CTRL-J> to jump to the various tags: > - {+TAG+} -and fill in the information (see Sec. |matlabsupport-templates-jump-tags|). - ------------------------------------------------------------------------------- -2.2 SNIPPETS *matlabsupport-usage-snippets* ------------------------------------------------------------------------------- - -Useful code snippets can be kept in a central place. This way, they can -quickly be inserted into the code, using "Snippets -> insert code snippet". -New snippets can be created from existing lines of code be selecting them in -visual mode and saving them using "Snippets -> create code snippet". - -Code snippets are kept in a directory which can be changed using the setting -|g:Matlab_SnippetDir|. - - Feature Menu Entry Map - ---------------------------------------------------------------------------- - insert code snippet Snippets.insert code snippet <LocalLeader>ni - create code snippet Snippets.create code snippet <LocalLeader>nc - view code snippet Snippets.view code snippet <LocalLeader>nv - edit code snippet Snippets.edit code snippet <LocalLeader>ne - ---------------------------------------------------------------------------- - ------------------------------------------------------------------------------- -2.3 USE MLINT *matlabsupport-usage-mlint* ------------------------------------------------------------------------------- - -The plug-in assists in the usage of the Matlab code checker 'mlint'. -(See Section |matlabsupport-config-mlint| for the configuration.) - - Feature Menu Entry Map - ---------------------------------------------------------------------------- - check the code Run.check code <LocalLeader>rk - ignore a warning Run.ignore warning <LocalLeader>ri - ---------------------------------------------------------------------------- - -After invoking the code checker, "No warnings." will be prompted or the -|quickfix| window will open. You can quickly go through all the warning by -using the commands |:cnext| and |:cprevious|. The fastest way of using them -are maps. (see |matlabsupport-usage-mlint-qf|) -After jumping to a warning you can automatically insert a special comment to -ignore it. - -Example: - -The code checker will complain about the unused parameter: -> - function s = sum ( a, b, c ) - s = a + b; - end -< -Ignoring it will automatically insert the comment: -> - function s = sum ( a, b, c ) %#ok<INUSD> - s = a + b; - end -< ------------------------------------------------------------------------------- - -2.3.1 Using QuickFix *matlabsupport-usage-mlint-qf* - -Vim's QuickFix facility is described here: |quickfix.txt|. It offers a -convenient way to go through all the errors which a program like a compiler or -code checker has found in the code. - -It is controlled by the commands: -- |:copen| and |:cclose| : open or close the quickfix window -- |:cnext| and |:cprevious| : jump to the next previous error - -The fastest way of using them is to put maps like this into your .vimrc file: -> - map <silent> <F5> :copen<CR> - map <silent> <F6> :cclose<CR> - map <silent> <F7> :cprevious<CR> - map <silent> <F8> :cnext<CR> -< -You can now use F5 and F6 to open and close the quickfix window and F7 and F8 -to jump to the errors. - ------------------------------------------------------------------------------- -2.4 HELP *matlabsupport-usage-help* ------------------------------------------------------------------------------- - -The menu "Help" speeds up the access to various resources, such as the online -documentation of Matlab functions or an English dictionary. - - Feature Menu Entry Map - ---------------------------------------------------------------------------- - open English dictionary Help.English <LocalLeader>he - open reference for a Help.Matlab function <LocalLeader>hf - function - open plug-in help Help.help (Matlab support) <LocalLeader>hs - ---------------------------------------------------------------------------- - -The online reference can by opened very conveniently for Matlab functions. -Simply place the cursor on the name of a function in your source code, and use -the menu entry or the map to open the online reference for that function. -(See Section |matlabsupport-config-browser| for the configuration.) - -Example: - -Place the cursor on "sin" and invoke the map: > - a = sin ( r * pi ); -The following URL will be opened in your browser: > - http://www.mathworks.de/help/techdoc/ref/sin.html -< -============================================================================== -3. TEMPLATES *matlabsupport-templates* -============================================================================== - -Most of the menu entries insert templates into the current text. Most -templates come with their own map, for fast and convenient access. All maps -start with a mapleader, which can be set to a different value for use within -Matlab Support (see |g:Matlab_MapLeader|). - - Feature Menu Entry Map - ---------------------------------------------------------------------------- - -various templates- (automatically generated) <LocalLeader>... - ---------------------------------------------------------------------------- - -The following sections provide a short overview of the template system. See -the documentation of the template system for a more in-depth discussion: -|templatesupport.txt| - ------------------------------------------------------------------------------- -3.1 INTRODUCTION *matlabsupport-templates-introduction* ------------------------------------------------------------------------------- - -This plug-in makes heavy use of an extendible template library. A template -library can assist in speeding up the writing of code, while at the same time -ensuring a consistent style. The templates are written in an easy to use -markup language, which enables the user to customize templates without much -hassle. - -Templates are short pieces of text which can be included into source code or -text of any other kind. But they are not just plain text, they can be extended -with macros and tags to provide further convenience. Macros can be -automatically replaced with the date or the filename, or they can be replaced -with input from the user, for example the name of a new function. - -While inserting a template, the user will often be ask to enter some -replacement text on the command line, for example the name of a function. The -replacement text will then be used in the template while it is inserted. -Hitting <ESC> or entering an empty text will abort template insertion. - ------------------------------------------------------------------------------- -3.2 JUMP TAGS *matlabsupport-templates-jump-tags* ------------------------------------------------------------------------------- - -Templates can include special tags, which mark positions where text needs to -be added. - - Feature Menu Entry Map - ---------------------------------------------------------------------------- - jump to next tag - <CTRL-J> - ---------------------------------------------------------------------------- - -Use the <CTRL-J> to jump to the next tag. The maps works in normal and insert -mode. - ------------------------------------------------------------------------------- -3.3 SPLIT TAGS *matlabsupport-templates-split-tags* ------------------------------------------------------------------------------- - -Some templates include so-called split tags and therefore can use to surround -some lines of code. - -Example: - -Consider the lines: -> - a = 1; - b = 2; -< -The template "Statements.if, else" contains a split tag between "if" and -"else". After selecting the two lines and inserting the template, the result -looks like this: -> - if <CURSOR IS PLACED HERE> - a = 1; - b = 2; - else - {+ELSE_PART+} - end -< -After adding the condition, use <CTRL-J> to jump to the else-part. - ------------------------------------------------------------------------------- -3.4 AUXILIARY FUNCTIONS *matlabsupport-templates-aux* ------------------------------------------------------------------------------- - -The template system comes with several auxiliary functions. - - Feature Menu Entry Map - ---------------------------------------------------------------------------- - edit the local template Snippets.edit local templates <LocalLeader>ntl - library - edit the global template Snippets.edit global templates <LocalLeader>ntg - library (*1) - reread the templates Snippets.reread templates <LocalLeader>ntr - choose a style Snippets.choose style <LocalLeader>nts - ---------------------------------------------------------------------------- - -"Snippets -> edit templates" will open a file browser in the directory -containing your template library. This feature is merely a fast way to jump to -the files. After the templates have been edited, they need to be read again. - -See the documentation of the template system for a more in-depth discussion: -|templatesupport.txt| - -Note *1: system-wide installation only - -============================================================================== -4. CONFIGURATION *matlabsupport-configuration* -============================================================================== - -The basic configuration is done via a number of global variables, which can be -set in the .vimrc file. - - Variable Default Description - ---------------------------------------------------------------------------- - |g:Matlab_LoadMenus| 'auto' when to load the menus ('startup', - 'auto' or 'manual') - |g:Matlab_RootMenu| '&Matlab' name and shortcut of the root menu - |g:Matlab_MapLeader| '' the |maplocalleader| used for maps - |g:Matlab_LineEndCommentColumn| standard column used for end-of- - 49 line comments - |g:Matlab_SnippetDir| (see below) directory with code snippers - |g:Matlab_SnippetBrowser| 'gui' browser to select code snippets - |g:Matlab_MlintExecutable| 'mlint' the mlint executable - |g:Matlab_LclTemplateFile| (see below) the local top-level template file - |g:Matlab_GlbTemplateFile| (see below) the global top-level template file - ---------------------------------------------------------------------------- - -Further customization is carried out in the template library: -- |matlabsupport-config-template-cstm| -- |matlabsupport-config-browser| - ------------------------------------------------------------------------------- -4.1 MENUS *matlabsupport-config-menus* ------------------------------------------------------------------------------- - *g:Matlab_LoadMenus* -The creation of the menus is controlled by g:Matlab_LoadMenus. The default -setting: > - let g:Matlab_LoadMenus = 'auto' -causes the templates to be loaded and the menus to be created when the first -Matlab file is opened. -The menus appear right away after starting Vim with the setting: > - let g:Matlab_LoadMenus = 'startup' -This has the disadvantage that the templates have to be loaded during the -startup of Vim, which might cause a noticeable slowdown on older systems. -The automatic creation of the menus is prevented by: > - let g:Matlab_LoadMenus = 'manual' -Now the menus can only be loaded by using the tool menu entry "Tools.Load -Matlab Support". - - *g:Matlab_RootMenu* -The name and shortcut of the root menu is set via g:Matlab_RootMenu. The -character prefixed by '&' will be the shortcut. - -Example: > - let g:Matlab_RootMenu = 'Mat&lab' -Sets the shortcut to 'l'. - ------------------------------------------------------------------------------- -4.2 MAPS *matlabsupport-config-maps* ------------------------------------------------------------------------------- - *g:Matlab_MapLeader* -All the maps the plug-in creates use |maplocalleader|. It can be changed by -setting the variable g:Matlab_MapLeader. If it contains the empty string, -Vim's default (backslash) is used. - -Example: > - let g:Matlab_MapLeader = '#' -Sets the mapleader to '#'. - - *Matlab_SetMapLeader()* - *Matlab_ResetMapLeader()* -The configured mapleader can also be used in the ftplugin, by calling the -functions Matlab_SetMapLeader() and Matlab_ResetMapLeader(). The maps created -between the two calls will use |g:Matlab_MapLeader| as the |<LocalLeader>|: -> - call Matlab_SetMapLeader () - - map <buffer> <LocalLeader>eg :echo "Example Map :)"<CR> - - call Matlab_ResetMapLeader () -< ------------------------------------------------------------------------------- -4.3 COMMENTS *matlabsupport-config-comments* ------------------------------------------------------------------------------- - *g:Matlab_LineEndCommentColumn* -The standard column used for end-of-line comments is configured using -g:Matlab_LineEndCommentColumn. The column can then be set individually for -each buffer, using the menu entry "Comments.set end-of-line com. col.". - -Example: > - let g:Matlab_LineEndCommentColumn = 59 -< ------------------------------------------------------------------------------- -4.4 SNIPPETS *matlabsupport-config-snippets* ------------------------------------------------------------------------------- - *g:Matlab_SnippetDir* -The variable g:Matlab_SnippetDir sets the location of the code snippet -directory. The default value depends on the type of installation and the -operating system. - -(Path separators are always written as slashes '/', even for Windows.) - - -For a local installation, the default will be (UNIX/Linux): > - s:Matlab_SnippetDir = $HOME.'/.vim/matlab-support/codesnippets/' -or (Windows): > - s:Matlab_SnippetDir = $HOME.'/vimfiles/matlab-support/codesnippets' -< - -For a sytem-wide installation, the default will be: > - s:Matlab_SnippetDir = $VIM.'/vimfiles/matlab-support/codesnippets' -< - -Example: - -To set a different code snippet directory, add this line to your vimrc: > - let g:Matlab_SnippetDir = $HOME.'/myvim/matlab/codesnippets/' -< - *g:Matlab_SnippetBrowser* -Code snippets can either be selected in a file browser, by setting: > - let g:Matlab_SnippetBrowser = 'gui' -or on the command line by setting: > - let g:Matlab_SnippetBrowser = 'cmd-line' -< ------------------------------------------------------------------------------- -4.5 MLINT *matlabsupport-config-mlint* ------------------------------------------------------------------------------- - *g:Matlab_MlintExecutable* -If mlint can be found on the system path, no further configuration is -necessary. Otherwise the executable must be set via g:Matlab_MlintExecutable. - -Example: > - let g:Matlab_MlintExecutable = '/opt/matlab/bin/glnxa64/mlint' -This is where mlint can be found on the authors system. - ------------------------------------------------------------------------------- -4.6 TEMPLATE LIBRARY *matlabsupport-config-template-lib* ------------------------------------------------------------------------------- - *g:Matlab_LclTemplateFile* - *g:Matlab_GlbTemplateFile* -The variables g:Matlab_LclTemplateFile and g:Matlab_GlbTemplateFile set the -locations and names of the local and global template files, respectively. -The default for the local and global template files depend on the type of the -installation. - -(Path separators are always written as slashes '/', even for Windows.) - - -Local installation: - -If the plug-in matlab-support.vim can be found here: > - <VIMDIR>/plugin/matlab-support.vim -The default for the local template file is: > - g:Matlab_LclTemplateFile - = '<VIMDIR>/matlab-support/templates/Templates' -There is no global template file. - - -System-wide installation: - -The default for the global template file is: > - g:Matlab_GlbTemplateFile - = $VIM.'/vimfiles/matlab-support/templates/Templates' -The default for the local template file is (UNIX/Linux): > - s:Matlab_LclTemplateFile - = $HOME.'/.vim/matlab-support/templates/Templates' -or (Windows): > - s:Matlab_LclTemplateFile - = $HOME.'/vimfiles/matlab-support/templates/Templates' -< - -Example: - -To set a different local template file, add this line to your vimrc: > - let g:Matlab_LclTemplateFile = $HOME.'/myvim/matlab/templates/my.templates' -< ------------------------------------------------------------------------------- -4.7 TEMPLATE CUSTOMIZATION *matlabsupport-config-template-cstm* ------------------------------------------------------------------------------- - -The template library is customized via your local template file. Use the menu -entry "Snippets -> edit local templates" to get there. - -You should fill in your name and other information here: -> - SetMacro( 'AUTHOR', 'Your Name' ) - SetMacro( 'AUTHORREF', 'YN' ) - SetMacro( 'EMAIL', 'your-email@i-use-vim.org' ) - ... -< -The format of the date and time which is inserted in the templates can be -configured as well (using the same format as the C function 'strftime'): -> - SetFormat( 'DATE', '%x' ) - SetFormat( 'TIME', '%H:%M' ) - SetFormat( 'YEAR', '%Y' ) -< -This sets the format for the date to the preferred representation for your -current locale, the time will be inserted as 10:24 and the year will be -represented using four digits. - -Afterwards, use the menu entry "Snippets -> reread templates" to apply the -changes. - ------------------------------------------------------------------------------- -4.8 BROWSER *matlabsupport-config-browser* ------------------------------------------------------------------------------- - -Opening the online reference for various items is a feature of the template -library. The browser has to be configured there, in your local template file -(see |matlabsupport-config-template-lib|), by setting the macro *|HELP_BROWSER|* -(see below). - -The help facility will open the reference with a system call like this: > - |HELP_BROWSER| |URL| -where *|URL|* is replaced with an appropriate URL and *|HELP_BROWSER|* is -replaced with a string set by the user. - -Example: - -By adding this line to your local template file: > - SetMacro( 'HELP_BROWSER', 'firefox -new-tab' ) -The online reference will be opened like this: > - firefox -new-tab http://wiki.awesomematlabwiki.de/wiki/sin -< -Under Windows, the browser for opening the online documentation has to be -configured. To set the executable, the template library has to be modified. -In case of a local installation (the default), choose: - Matlab -> Snippets -> edit local templates -and for a system-wide installation: - Matlab -> Snippets -> edit global templates -Open the main template file 'Templates' and uncomment the line > - §SetMacro( 'HELP_BROWSER', '"C:\Program Files\Mozilla Firefox\firefox.exe"' ) -by removing the leading '§' > - SetMacro( 'HELP_BROWSER', '"C:\Program Files\Mozilla Firefox\firefox.exe"' ) -Then set the right executable. Mind the double quotes which escape the name of -the executable. -Finally, reread the template library using: - Matlab -> Snippets -> reread templates - -============================================================================== -5. SYSTEM-WIDE INSTALLATION *matlabsupport-system-wide* -============================================================================== - -A system-wide installation (one installation for all users) of the plug-in can -be done. This will mean however, that a user can not edit the template -library, for example to set his own name. So in case of a system-wide -installation, every user can have an own set of templates (called local -templates), which are localed in each users' home directory. -Note: As you might have guessed, this behavior is much more inspired by Linux -than Windows. - -A system-wide installation is done as follows. - ------------------------------------------------------------------------------- - -As *** SUPERUSER *** : - -(1) Find the Vim installation directory. -The Vim ex command ':echo $VIM' gives '/usr/local/share/vim' or something -similar. Beyond this directory you will find the Vim installation, e.g. in -'/usr/local/share/vim/vim73' if Vim version 7.3 has been installed (Windows: -'C:\Program Files\Vim'). - -(2) Create a new subdirectory 'vimfiles', e.g. '/usr/local/share/vim/vimfiles' -(Windows: 'C:\Program Files\Vim\vimfiles'). - -(3) Install Matlab Support -Copy the archive matlab-support.zip to this new directory and unpack it: -> - unzip matlab-support.zip -< -(4) Generate the help tags: -> - :helptags $VIM/vimfiles/doc -< -SPECIAL CASES. Some Linux distributions use non-standard names for Vim -directories. SUSE has a directory '/usr/share/vim/site' to put plug-ins in. -These directories will not be found automatically. After installing the -plug-in below '/usr/share/vim/site' the use of the templates will be enabled -by the following line in '~/.vimrc' (see |matlabsupport-config-template-lib|): -> - let g:Matlab_GlbTemplateFile = - \ '/usr/share/vim/site/matlab-support/templates/Templates' -< ------------------------------------------------------------------------------- - -As *** USER *** : - -This plug-in will try to create your private template directory, taking the -path from the setting g:Matlab_LclTemplateFile. The default is: > - ~/.vim/matlab-support/templates -The directory will contain a minimal personal main template file. You should -set some macros in this file with your personal information in order to obtain -personalized comments: -> - SetMacro( 'AUTHOR', 'Your Name' ) - SetMacro( 'AUTHORREF', 'YN' ) - SetMacro( 'EMAIL', 'your-email@i-use-vim.org' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) -< -You can also have local templates which override the global ones. To edit the -file, use the menu entry "Matlab -> Snippets -> edit local templates". - -============================================================================== -A. TROUBLESHOOTING - KNOWN ISSUES *matlabsupport-troubleshooting* -============================================================================== - -* I do not see any new main menu item. - - The menu is only created upon opening the first Matlab file (*.m). - This behavior can be changed: - :help matlabsupport-config-menus - - Was the archive extracted into the right directory? - See the section INSTALLATION in matlab-support/README.md. - - Loading of plug-in files must be enabled. If not use - :filetype plugin on - This is the minimal content of the file '$HOME/.vimrc'. Create one if - there is none, or better use customization.vimrc. - See the section FILES in matlab-support/README.md. - -* How can I see what was loaded? - - Use ':scriptnames' from the Vim command line. - -* mlint is not running. - - Is "mlint" executable from the command line? - - Is the $PATH variable set correctly? - - Are the settings correct? See: - :help matlabsupport-config-mlint - -============================================================================== -B. RELEASE NOTES - CHANGE LOG *matlabsupport-release-notes* -============================================================================== - -See files 'matlab-support/README.md' and 'matlab-support/doc/ChangeLog'. - -============================================================================== -C. CREDITS *matlabsupport-credits* -============================================================================== - -Fritz Mehner (vim.org user name: mehner) for a number of things: -- his plug-ins (bash-support, c-support, perl-support, ...) provided the - inspiration and template for this plug-in and the utilized template system -- parts of the documentation and other material are taken from his plug-ins as - well - -Sameer Sheorey (sameer0s) and Fabrice Guy (Fabrice): -- for demonstrating how to use mlint with Vim - -============================================================================== -vim:tw=78:noet:ts=2:ft=help:norl:expandtab: diff --git a/doc/perlsupport.txt b/doc/perlsupport.txt index 5b750d2..1b5b23d 100644 --- a/doc/perlsupport.txt +++ b/doc/perlsupport.txt @@ -1,8 +1,8 @@ -*perlsupport.txt* Perl Support Feb 12 2017 +*perlsupport.txt* Perl Support Jun 15 2019 Perl Support *perl-support* *perlsupport* - Plug-in version 5.5pre + Plug-in version 5.5alpha for Vim version 7.0 and above Wolfgang Mehner <wolfgang-mehner@web.de> Fritz Mehner <mehner.fritz@web.de> @@ -98,6 +98,7 @@ profiler can be done with a keystroke. 5.3.1 Template definition |perlsupport-templates-definition| 5.3.2 The jump tags |perlsupport-templates-jumptags| 5.3.3 Command Ctrl-j |perlsupport-Ctrl-j| + 5.4 File Skeletons |perlsupport-file-skeleton| 6 Perl::Tags |perlsupport-perltags| 7. Perl Dictionary |perlsupport-dictionary| 8. Optional Dependencies |perlsupport-dependencies| @@ -859,8 +860,8 @@ For convenience consider to use maps like > noremap <silent> <F5> :copen<CR> noremap <silent> <F6> :cclose<CR> - noremap <silent> <F7> :cp<CR> - noremap <silent> <F8> :cn<CR> + noremap <silent> <F7> :cprevious<CR> + noremap <silent> <F8> :cnext<CR> < in your .vimrc file to jump to the error locations (F7,F8) and to open and close the error window (F5,F6). This makes navigation a lot easier (see also @@ -905,10 +906,10 @@ the buffer with the new name. 1.9.5 DEBUG *perlsupport-run-debug* ------------ -Start a debugger from the menu item Run->debug, with hotkey \rd or F9. One of -three debuggers can be started. The preference can be set with the variable -g:Perl_Debugger (possible values: 'perl', 'ptkdb', 'ddd' ). The default is -'perl'). +Start a debugger from the menu item Run->debug, with the map \rd or the +command `:PerlDebug`. One of three debuggers can be started. The preference +can be set with the variable `g:Perl_Debugger`. The possible values are: +"perl" (default), "ptkdb", "ddd" (1) perl The script will be run as 'perl -d my-script.pl my-arguments' in an xterm. @@ -932,8 +933,9 @@ the debugger. Debugging without GUI --------------------- -The hotkey \rd or F9 can be used to start the debugger inside the vim window. -The script will be run with 'perl -d my-script.pl my-arguments'. +The map \rd or command `:PerlDebug` can be used to start the debugger inside +the vim window. The script will be run with: +'perl -d my-script.pl my-arguments'. 1.9.6 READ PERLDOC *perlsupport-perldoc* ------------------- @@ -1663,7 +1665,8 @@ CAVEAT: This setting is global and influences all filetypes. 3. FUNCTION KEYS *perlsupport-function-keys* ============================================================================== -The following function keys are defined in normal, visual and insert mode: +Additional function keys can be defined in the |ftplugin|. The examples in +'perl-support/rc/perl.vim' set the following maps: Shift-F1 read perldoc (for the word under the cursor) F9 start a debugger @@ -1671,7 +1674,7 @@ The following function keys are defined in normal, visual and insert mode: Ctrl-F9 run script Shift-F9 set command line arguments (buffer related) -These function keys are defined in the file type plug-in ~/.vim/ftplugin/perl.vim . +Copy them to your filetype plug-in '~/.vim/ftplugin/perl.vim'. Note for xterm users (Vim without GUI): The function key combinations Shift-Fx, Alt-Fx and Ctrl-Fx do not work. F9 is also not working to prevent @@ -1756,7 +1759,8 @@ global variable default value tag (see below) g:Perl_GlobalTemplateFile root_dir.'perl-support/templates/Templates' g:Perl_LocalTemplateFile $HOME.'/.vim/perl-support/templates/Templates' g:Perl_CustomTemplateFile $HOME.'/.vim/templates/perl.templates' -g:Perl_Ctrl_j 'on' +g:Perl_Ctrl_j 'yes' +g:Perl_Ctrl_d 'yes' g:Perl_CodeSnippets root_dir.'perl-support/codesnippets/' g:Perl_LoadMenus 'yes' @@ -1766,7 +1770,7 @@ g:Perl_InsertFileHeader 'yes' g:Perl_CreateMenusDelayed 'yes' g:Perl_PerlTags 'off' g:Perl_PerltidyBackup 'off' -g:Perl_Executable "/usr/bin/perl" or "C:/Perl/bin/perl.exe" +g:Perl_Executable "perl" or "C:/Perl/bin/perl.exe" g:Perl_DirectRun 'no' g:Perl_PerlModuleList root_dir.'perl-support/modules/perl-modules.list' @@ -1802,7 +1806,8 @@ The variable root_dir will automatically be set to one of the following values: g:Perl_GlobalTemplateFile : sets the global template file (see|perlsupport-templates|) g:Perl_LocalTemplateFile : sets the local template file (see|perlsupport-templates|) g:Perl_CustomTemplateFile : sets the custom template file (see|perlsupport-templates|) - g:Perl_Ctrl_j : hotkey Ctrl-j 'on'/'off' (see|perlsupport-Ctrl-j|) + g:Perl_Ctrl_j : hotkey Ctrl-j 'yes'/'no' (see |perlsupport-Ctrl-j|) + g:Perl_Ctrl_d : hotkey Ctrl-d 'yes'/'no' (see |perlsupport-templates-jumptags|) 2. group: g:Perl_CodeSnippets : The name of the (non-standard) code snippet directory (see below). g:Perl_LoadMenus : Load menus and mappings ("yes", "no") at startup. @@ -1830,7 +1835,7 @@ The variable root_dir will automatically be set to one of the following values: g:Xterm_Options : the xterm options g:Perl_XtermDefaults : the xterm options (included for backwards compatibility only) - g:Perl_Debugger : the debugger called by F9 (perl, ptkdb, ddd). + g:Perl_Debugger : the debugger called by :PerlDebug (perl, ptkdb, ddd). g:Perl_TimestampFormat : trailing time stamp for a file g:Perl_LineEndCommColDefault : default starting column for line end comments g:Perl_PodcheckerWarnings : podchecker warnings on/off @@ -2280,6 +2285,38 @@ you jump to the target <-IF PART-> and deletes it. When the block is written a Ctrl-j leads you to the else-part. The target <+ELSE_PART+> disappears and you can type on. +------------------------------------------------------------------------------ +5.4 FILE SKELETONS *perlsupport-file-skeleton* +------------------------------------------------------------------------------ + *g:Perl_InsertFileHeader* +If g:Perl_InsertFileHeader is set to "yes", a file skeleton is automatically +inserted into new Perl scripts. The list of templates used to create this +skeleton is specified in the template library. For this purpose a property is +used, which can for example be set in the customization file +(see |perlsupport-templates|). + + *Perl::FileSkeleton::Script* *Perl::FileSkeleton::Test* + *Perl::FileSkeleton::Module* *Perl::FileSkeleton::POD* +The file skeletons are controlled via these properties, which can be set in +one of the template files. There are different skeletons for scripts (*.pl), +modules (*.pm), test (*.t), and POD (*.pod): +> + SetProperty ( 'Perl::FileSkeleton::Script', 'Comments.file description pl' ) + SetProperty ( 'Perl::FileSkeleton::Module', 'Comments.file description pm' ) + SetProperty ( 'Perl::FileSkeleton::Test', 'Comments.file description t' ) + SetProperty ( 'Perl::FileSkeleton::POD', '' ) +< +This inserts only a comment boxes to document the files. To disable the +insertion completely, set the property to an empty string: > + SetProperty ( 'Perl::FileSkeleton::Script', '' ) +In general, this property is a semicolon-separated list of templates to be +inserted: > + SetProperty ( 'Perl::FileSkeleton::Script', 'Comments.shebang;Comments.file description pl; ;Skeleton.script-use' ) +This will insert a shebang, a file description, and the default use commands +from the template "Skeleton.script-use". If a space appears as an entry in the +list, an empty line is inserted: > + '...; ;...' +< ============================================================================== 6. Perl::Tags *perlsupport-perltags* ============================================================================== @@ -2397,7 +2434,7 @@ was compiled for your platform. Install it and all is done. COMPILE YOUR OWN VERSION (LINUX/UNIX). -------------------------------------- -(1) Download the sources from http://vim.sourceforge.net/ and extract the +(1) Download the sources from https://www.vim.org/ and extract the sources from the archive (for patches see|perlsupport-compile-vim-patches|). (2) Inspect the current version again. The section 'Compilation' shows how diff --git a/doc/templatesupport.txt b/doc/templatesupport.txt index 75aa83b..021fdd7 100644 --- a/doc/templatesupport.txt +++ b/doc/templatesupport.txt @@ -1,8 +1,8 @@ -*templatesupport.txt* MM Template Support Apr 14 2017 +*templatesupport.txt* MM Template Support Aug 06 2020 MM Template Support *template-support* - Plug-in version 1.1alpha + Plug-in version 1.1beta for Vim version 7.0 and above Wolfgang Mehner <wolfgang-mehner at web.de> @@ -31,9 +31,9 @@ can exist in parallel. This makes it relatively easy to write a plug-in for the programming language of your choice. Here is a list of high profile plug-ins which use the template support: -- Bash-Support (www.vim.org/scripts/script.php?script_id=365) -- C-Support (www.vim.org/scripts/script.php?script_id=213) -- Perl-Support (www.vim.org/scripts/script.php?script_id=556) +- Bash-Support (https://www.vim.org/scripts/script.php?script_id=365) +- C-Support (https://www.vim.org/scripts/script.php?script_id=213) +- Perl-Support (https://www.vim.org/scripts/script.php?script_id=556) ============================================================================== 0. TABLE OF CONTENTS *template-support-contents* @@ -236,7 +236,7 @@ the library, are case sensitive. A template library can be organized in several files. The command: > IncludeFile ( "<path>/<file>" ) -loads templates from another file (|template-support-IncludeFile|). The path +loads templates from another file (|template-support-IncludeFile()|). The path is given relative to the including file. The call: > IncludeFile ( "<path>/<file>", "abs" ) interprets the path as a absolute path instead. @@ -295,7 +295,7 @@ found in |template-support-menus|. ------------------------------------------------------------------------------ A personalization of the template library can be achieved by using macros. The -command 'SetMacro' (|template-support-SetMacro|) is used to set replacements +command 'SetMacro' (|template-support-SetMacro()|) is used to set replacements for various macros (my settings as an example): > SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) @@ -326,7 +326,7 @@ Then the template for the file description may look as follows: == ENDTEMPLATE == < The format of the included dates and times can be set in a similar fashion, -using 'SetFormat' (|template-support-SetFormat|): +using 'SetFormat' (|template-support-SetFormat()|): > SetFormat( 'DATE', '%D' ) SetFormat( 'TIME', '%H:%M' ) @@ -478,7 +478,7 @@ Except for using flags, the user has no further influence on the replacements of these macros, they can not be set via SetMacro(). Dates and timestamps are inserted analogously. Their format can be set via -SetFormat (see |template-support-SetFormat|). +SetFormat (see |template-support-SetFormat()|). *|TIME|* : the current time *|DATE|* : the current date @@ -1154,7 +1154,7 @@ Templates inside nested statements are only associated with the styles listed in the innermost "USE STYLES" statement. When files are included inside a "USE STYLES" statement (see -|template-support-IncludeFile|), the templates inside the file are associated +|template-support-IncludeFile()|), the templates inside the file are associated with the style, as they would if they appeared in the including file itself. The rules for nested "USE STYLES" statements also hold across included files. @@ -1168,7 +1168,7 @@ directory, such the include mechanism of the C preprocessor or LaTeX's support offers so-called file pickers. File pickers are templates which use the command PickFile( <prompt>, <path> ) -(|template-support-PickFile|), which asks the user to interactively select a +(|template-support-PickFile()|), which asks the user to interactively select a file: > SetPath( 'global_include', '/usr/include/' ) @@ -1187,10 +1187,10 @@ beforehand, such as "global_include". After the user selects a file, several macros are created which can be used in the template. *|PICK|* is the path and name of the file, relative to the path given as the second argument. *|FILENAME|* is only the name of the file. For a list of all macros, see -|template-support-PickFile|. +|template-support-PickFile()|. Names for paths are created using the function SetPath( <name>, <path> ) -(see |template-support-SetPath|), which is a lot like SetMacro. +(see |template-support-SetPath()|), which is a lot like SetMacro. For example, if the user picks "/usr/include/GL/gl.h", the first template would result in the line > @@ -1217,7 +1217,7 @@ directory. The template support automatically creates menus for every template. The user has a measure of influence on the result. Some of these options were already -explained in |templates-support-templ-maps|, this chapter will introduce further +explained in |template-support-templ-maps|, this chapter will introduce further capabilities. The menu entries appear in the order the templates have been read. Including a @@ -1326,7 +1326,7 @@ flag is 'W', the |WORD| under the cursor is picked up: > |Word('W')| Otherwise the |word| under the cursor is picked: > |Word('')| -Lastly, the word can be picked using a regular expression (see |regex|): > +Lastly, the word can be picked using a regular expression (see |regexp|): > |Pattern( '[\\@]\w\+' )| This call picks a word prefix by "\" or "@", which in a C comment could be a Doxygen command. @@ -3208,7 +3208,7 @@ Fritz Mehner (vim.org user name: mehner): Jeremy Cantrell (jmcantrell): - the solution for getting the visual area is take from his plug-in "opener.vim", which is distributed under the same licence as Vim itself - ( http://www.vim.org/scripts/script.php?script_id=3543 ) + ( https://www.vim.org/scripts/script.php?script_id=3543 ) Andrew L: - suggested to insert a breakpoint into the undo sequence before inserting diff --git a/doc/toolbox.txt b/doc/toolbox.txt index 4e2c0b8..a15be96 100644 --- a/doc/toolbox.txt +++ b/doc/toolbox.txt @@ -1,8 +1,8 @@ -*toolbox.txt* MM Toolbox Support Oct 23 2014 +*toolbox.txt* MM Toolbox Support Sep 30 2017 MM Toolbox Support *toolbox* - Plug-in version 1.2 + Plug-in version 1.3 for Vim version 7.0 and above Wolfgang Mehner <wolfgang-mehner at web.de> @@ -20,8 +20,8 @@ exist in parallel. This makes it easy to integrate a toolbox into your plug-in. Here is a list of high profile plug-ins which use the toolbox support: -- C-Support (www.vim.org/scripts/script.php?script_id=213) -- Perl-Support (www.vim.org/scripts/script.php?script_id=556) +- C-Support (https://www.vim.org/scripts/script.php?script_id=213) +- Perl-Support (https://www.vim.org/scripts/script.php?script_id=556) ============================================================================== 0. TABLE OF CONTENTS *toolbox-support-contents* @@ -377,6 +377,13 @@ See also |toolbox-support-AddMenu()|. A. CHANGE LOG *toolbox-support-change-log* ============================================================================== +------------------------------------------------------------------------------ + RELEASE NOTES FOR VERSION 1.3 +------------------------------------------------------------------------------ + +- Change path handling to be more flexible with regards to file locations. +- Minor changes. + ------------------------------------------------------------------------------ RELEASE NOTES FOR VERSION 1.2 ------------------------------------------------------------------------------ diff --git a/doc/toolboxcmake.txt b/doc/toolboxcmake.txt index 71d102b..1856f79 100644 --- a/doc/toolboxcmake.txt +++ b/doc/toolboxcmake.txt @@ -1,8 +1,8 @@ -*toolboxcmake.txt* CMake Tool Feb 05 2016 +*toolboxcmake.txt* CMake Tool Oct 16 2017 CMake Tool *toolbox-cmake* - Plug-in version 0.9.2 + Plug-in version 0.9.3 for Vim version 7.0 and above Wolfgang Mehner <wolfgang-mehner at web.de> @@ -385,6 +385,14 @@ value on the command line. A. CHANGE LOG *toolbox-cmake-change-log* ============================================================================== +------------------------------------------------------------------------------ + RELEASE NOTES FOR VERSION 0.9.3 +------------------------------------------------------------------------------ + +- Change: Do not use :lchdir internally, switch to :cd, which has less + side-effects. +- Minor changes and bugfixes. + ------------------------------------------------------------------------------ RELEASE NOTES FOR VERSION 0.9.2 ------------------------------------------------------------------------------ diff --git a/doc/toolboxdoxygen.txt b/doc/toolboxdoxygen.txt index e189a38..8997210 100644 --- a/doc/toolboxdoxygen.txt +++ b/doc/toolboxdoxygen.txt @@ -1,8 +1,8 @@ -*toolboxdoxygen.txt* Doxygen Tool Feb 14 2016 +*toolboxdoxygen.txt* Doxygen Tool Oct 16 2017 Doxygen Tool *toolbox-doxygen* - Plug-in version 0.9.2 + Plug-in version 0.9.3 for Vim version 7.0 and above Wolfgang Mehner <wolfgang-mehner at web.de> @@ -290,6 +290,13 @@ The executable of doxywizard is set by g:Doxygen_WizardExec: > A. CHANGE LOG *toolbox-doxygen-change-log* ============================================================================== +------------------------------------------------------------------------------ + RELEASE NOTES FOR VERSION 0.9.3 +------------------------------------------------------------------------------ + +- Change: Do not use :lchdir internally, switch to :cd, which has less + side-effects. + ------------------------------------------------------------------------------ RELEASE NOTES FOR VERSION 0.9.2 ------------------------------------------------------------------------------ diff --git a/doc/toolboxmake.txt b/doc/toolboxmake.txt index c7ce6bb..883f5e4 100644 --- a/doc/toolboxmake.txt +++ b/doc/toolboxmake.txt @@ -1,4 +1,4 @@ -*toolboxmake.txt* Make Tool Oct 07 2016 +*toolboxmake.txt* Make Tool Oct 16 2017 Make Tool *toolbox-make* @@ -178,6 +178,8 @@ A. CHANGE LOG *toolbox-make-change-log* - Change: If make is not executable, still provide the functionality for finding targets in a Makefile. +- Change: Do not use :lchdir internally, switch to :cd, which has less + side-effects. ------------------------------------------------------------------------------ RELEASE NOTES FOR VERSION 1.1 diff --git a/doc/vimsupport.txt b/doc/vimsupport.txt index 97dad61..2513410 100644 --- a/doc/vimsupport.txt +++ b/doc/vimsupport.txt @@ -1,278 +1,316 @@ -*vimsupport.txt* Vim Support Jul 09 2017 +*vimsupport.txt* Vim Support Feb 10 2018 Vim Support *vim-support* *vimsupport* - Plug-in version 2.4.1beta + Plug-in version 2.5beta for Vim version 7.0 and above Wolfgang Mehner <wolfgang-mehner@web.de> Fritz Mehner <mehner.fritz@web.de> -Vim Support implements a Vim-IDE for Vim/gVim. It is written to considerably -speed up writing Vim script code in a consistent style. This is done by -inserting complete statements, comments, idioms, and code snippets. There -are many additional hints and options which can improve speed and comfort when -writing Vim scripts. - - 1. Usage with GUI |vimsupport-usage-gvim| - 1.1 Menu 'Comments' |vimsupport-comments| - 1.1.1 Append aligned comments |vimsupport-comm-aligned| - 1.1.2 Adjust end-of-line comments |vimsupport-comm-realign| - 1.1.3 Comment / uncomment |vimsupport-comm-uncomm| - 1.1.4 Frame comments, file header, ... |vimsupport-comm-templates| - 1.1.5 Function description (auto) |vimsupport-comm-auto| - 1.1.6 Keyword comment |vimsupport-comm-keywords| - 1.2 Menu 'Statements' |vimsupport-statements| - 1.2.1 Normal mode, insert mode |vimsupport-stat-norm-ins| - 1.2.2 Visual mode |vimsupport-stat-visual| - 1.3 Menu 'Idioms' |vimsupport-idioms| - 1.4 Menu 'Regex' |vimsupport-regex| - 1.5 Menu 'Perl' |vimsupport-perl| - 1.6 Menu 'Documentation' |vimsupport-documentation| - 1.7 Menu 'Snippets' |vimsupport-snippets| - 1.7.1 Code Snippets |vimsupport-snippets-menu| - 1.7.2 Code Templates |vimsupport-templates-menu| - 1.8 Menu 'Run' |vimsupport-run| - 1.8.1 Hardcopy |vimsupport-hardcopy| - 1.8.2 Settings |vimsupport-settings| - 1.9 Menu 'Help' |vimsupport-help| - 2. Usage without GUI |vimsupport-usage-vim| - 3. Customization and configuration |vimsupport-customization| - 3.1 Files |vimsupport-custom-files| - 3.2 Global variables |vimsupport-custom-variables| - 3.3 The root menu |vimsupport-custom-root| - 3.4 System-wide installation |vimsupport-system-wide| - 4. Template files and tags |vimsupport-templates| - 4.1 Template files |vimsupport-templates-files| - 4.2 Macros |vimsupport-templates-macros| - 4.2.1 Formats for date and time |vimsupport-templates-date| - 4.3 Templates |vimsupport-templates-names| - 4.3.1 Template definition |vimsupport-templates-definition| - 4.3.2 The macros <+text+> etc. |vimsupport-templates-jumptags| - 4.3.3 Commands Ctrl-j and Ctrl-d |vimsupport-Ctrl-j| - 5. Windows particularities |vimsupport-windows| - 6. Troubleshooting |vimsupport-troubleshooting| - 7. Release Notes |vimsupport-release-notes| - - How to add this help file to Vim's help |add-local-help| +Vim Support implements a VimL/VimScript-IDE for Vim/gVim/Neovim. It is written +to considerably speed up writing Vim script code in a consistent style. This +is done by inserting complete statements, comments, idioms, and code snippets. +There are many additional hints and options which can improve speed and +comfort when writing Vim scripts. +See the chapter |vimsupport-introduction| for a quick overview and a short +guide to this documentation. +============================================================================== +0. TABLE OF CONTENTS *vimsupport-contents* +============================================================================== + + 1. Introduction |vimsupport-introduction| + + 2. Usage |vimsupport-usage| + 2.1 Comments |vimsupport-usage-comments| + 2.1.1 End-of-Line Comments |vimsupport-usage-comments-eol| + 2.1.2 Toggle Comment Lines |vimsupport-usage-comments-lines| + 2.1.3 Automated Comments |vimsupport-usage-comments-auto| + 2.1.4 Further Comments |vimsupport-usage-comments-other| + 2.1.5 Keyword Comments |vimsupport-usage-comments-keyword| + 2.2 Statements, Idioms, ... |vimsupport-usage-templates| + 2.3 Perl API |vimsupport-usage-api| + 2.4 Documentation |vimsupport-usage-docu| + 2.5 Code Snippets |vimsupport-usage-snippets| + 2.6 Hardcopy |vimsupport-usage-hardcopy| + 2.7 Help |vimsupport-usage-help| + + 3. Templates |vimsupport-templates| + 3.1 Introduction |vimsupport-templates-introduction| + 3.2 Customization |vimsupport-templates-custom| + 3.3 Jump Tags |vimsupport-templates-jump-tags| + 3.4 Split Tags |vimsupport-templates-split-tags| + 3.5 Macros |vimsupport-templates-macros| + 3.6 Template Files |vimsupport-templates-files| + 3.7 Template Libraries |vimsupport-templates-libs| + + 4. Configuration |vimsupport-configuration| + 4.1 Menus |vimsupport-config-menus| + 4.2 Maps |vimsupport-config-maps| + 4.3 Comments |vimsupport-config-comments| + 4.4 Snippets |vimsupport-config-snippets| + 4.5 Hardcopy |vimsupport-config-hardcopy| + 4.6 Windows Particularities |vimsupport-config-windows| + + 5. System-wide Installation |vimsupport-system-wide| + + A. Overview of Mappings |vimsupport-mappings| + B. Files |vimsupport-files| + C. Troubleshooting - Known Issues |vimsupport-troubleshooting| + D. Release Notes - Change Log |vimsupport-release-notes| ============================================================================== -1. USAGE with GUI (gVim) *vimsupport-usage-gvim* +1. INTRODUCTION *vimsupport-introduction* ============================================================================== -If the menus are not visible call them with the entry "Load Vim Support" -in the standard Tools-menu. +After the first VimL/VimScript file (*.vim) has been opened, the menu "Vim" +appears in the menu bar. It holds entries for all the templates (such as +"Statements->for" or "Idioms->function"), as well as some other functionality. +The letters on the right name maps, which can also be used to access all the +capabilities. See |vimsupport-mappings| for an overview. +The menus are also created if a GUI is not running. They can be used via > + :emenu Vim. +(Use the arrow keys for navigation, <Enter> to select an entry and <TAB> for +auto completion.) + +The features of the plug-in are: +- Turn code lines into comments and vice versa. + |vimsupport-usage-comments-lines| +- Automatically add comments for functions and their parameters. + |vimsupport-usage-comments-auto| +- Manage code snippets. |vimsupport-usage-snippets| +- An extendible template library. |vimsupport-templates| + +The usage of most features is described in the chapter |vimsupport-usage|. +The chapter |vimsupport-templates| gives a short introduction to the +template system. Various features may require some configuration, which is +documented in the chapter |vimsupport-configuration|. How to do a system-wide +installation is outlined in |vimsupport-system-wide|. + +The template system comes with its own documentation, which mainly aims at the +advanced user (see |templatesupport.txt|). + +============================================================================== +2. USAGE *vimsupport-usage* +============================================================================== +Features are accessible via menu entries and maps. Most maps are preceded by a +mapleader. The leader is a backslash, if the standard configuration is used. + +If the root menu 'Vim' is not visible you also can load it with the item +"Load Vim Support" from the "Tools" menu. The item "Unload Vim Support" +can be used to unload the Vim root menu. +(Compare |vimsupport-config-menus|.) + +------------------------------------------------------------------------------ +2.1 COMMENTS *vimsupport-usage-comments* ------------------------------------------------------------------------------ -1.1 MENU 'Comments' *vimsupport-comments* + +Besides the templates, there is some other functionality provided in the menu +"Comments". + + Feature Menu Entry Map + ---------------------------------------------------------------------------- + add end-of-line comments Comments.end-of-line comment <LocalLeader>cl + adjust end-of-line com. Comments.adjust end-of-line c. <LocalLeader>cj + set end-of-line column Comments.set end-of-line col. <LocalLeader>cs + + code to comment Comments.comment <LocalLeader>cc + comment to code Comments.uncomment <LocalLeader>co + + automatic function Comments.func. desc. (auto) <LocalLeader>ca + description + ---------------------------------------------------------------------------- + ------------------------------------------------------------------------------ -1.1.1 APPEND ALIGNED COMMENTS TO CONSECUTIVE LINES *vimsupport-comm-aligned* --------------------------------------------------- +2.1.1 End-of-Line Comments *vimsupport-usage-comments-eol* -In NORMAL MODE the menu entry 'end-of-line comments' will append a comment to -the current line. -In VISUAL MODE, this item will append aligned comments to all marked lines. -Marking the 4 lines +In NORMAL MODE the menu item 'end-of-line comments' will append a comment to +the current line. In VISUAL MODE this item will append aligned comments to all +marked lines. Marking the 4 lines +> let x = 33 let y = 44 let z = 55 +< and choosing 'end-of-line comments' will yield +> let x = 33 " | let y = 44 " let z = 55 " +< The cursor position above is marked by '|'. Empty lines will be ignored. -The default starting column is 49 ( = (multiple of 2,4, or 8) + 1 ). This can -be changed by setting a global variable in the file '.vimrc', e.g. : - - let g:Vim_LineEndCommColDefault = 45 - -The starting column can also be set by the menu entry 'Comments->adjust -end-of-line com.' . Just position the cursor in an arbitrary column (normal +The default starting column is 49 ( = (multiple of 2,4, or 8) + 1 ). This can +be changed by setting a global variable in the file '.vimrc', e.g. : > + let g:Vim_LineEndCommColDefault = 65 +The starting column can also be set by the menu entry "Comments -> adjust +end-of-line com.". Just position the cursor in an arbitrary column (normal mode; column number is shown in the Vim status line) and choose this menu -item. This setting is buffer related. +item. This setting is stored individually for each buffer. If the cursor was at the end of a line you will be asked for a column number -because this position is most likely not the desired starting column. Your -choice will be confirmed. +because this position is most likely not the desired starting column. -1.1.2 ADJUST END-OF-LINE COMMENTS *vimsupport-comm-realign* ---------------------------------- +------------------------------------------------------------------------------ After some copy/paste/change actions comments may be misaligned: - - let x = 33 " this is x - let y = 44 " and y - let z = 55 " and now z - +> + let x = 33 " this is x + let y = 44 " and y + let z = 55 " and now z +< Realignment can be achieved with the menu item 'adjust end-of-line com.' In normal mode the comment (if any) in the current line will be aligned to the end-of-line comment column (see above) if possible. In visual mode the comments in the marked block will be aligned: - - let x = 33 " this is x - let y = 44 " and y - let z = 55 " and now z - -Another way is to use the hotkey \cj. In normal and insert mode the current +> + let x = 33 " this is x + let y = 44 " and y + let z = 55 " and now z +< +Another way is to use the hotkey `\cj`. In normal and insert mode the current line will be adjusted. To adjust n lines starting with the current one use -n\cj. +`n\cj`. -1.1.3 COMMENT/UNCOMMENT *vimsupport-comm-uncomm* ------------------------- - -The comment sign " can be set or removed at the beginning of the current line -or for a marked block using the menu items 'comment' (or \cc) and 'uncomment' -(or \co). A single line needs not to be marked (normal mode, insert mode). +------------------------------------------------------------------------------ -A marked block +2.1.2 Toggle Comment Lines *vimsupport-usage-comments-lines* - let x = 33 " this is x - let y = 44 " and y - let z = 55 " and now z +The comment sign " can be inserted or removed at the beginning of the current +line or for a marked block, using the menu items 'comment' (or `\cc`) and +'uncomment' (or `\co`). A single line needs not to be marked (normal mode, +insert mode). +A marked block +> + let x = 33 " this is x + let y = 44 " and y + let z = 55 " and now z +< will be changed into (and vice versa) +> + "let x = 33 " this is x + "let y = 44 " and y + "let z = 55 " and now z +< +------------------------------------------------------------------------------ - "let x = 33 " this is x - "let y = 44 " and y - "let z = 55 " and now z - -1.1.4 FRAME COMMENTS, FILE HEADER, ... *vimsupport-comm-templates* --------------------------------------- - -Frame comments, function descriptions and file header comments are read as -templates from the appropriate files (see |vimsupport-templates|). - -1.1.5 FUNCTION DESCRIPTION (AUTO) *vimsupport-comm-auto* ---------------------------------- +2.1.3 Automated Comments *vimsupport-usage-comments-auto* The menu item 'function description (auto)' generates a function description -from the function head in the current line. The line - - function! s:fct77 ( a, b, c ) - ... - +from the function head in the current line. The function: +> + function! s:fct77 ( a, b, c ) + ... +< will be augmented by the following comment +> + "=== FUNCTION ============================================================= + " NAME: s:fct77 {{{1 + " DESCRIPTION: + " PARAMETERS: a - {+DESCRIPTION+} + " b - {+DESCRIPTION+} + " c - {+DESCRIPTION+} + " RETURNS: + "============================================================================ + function! s:fct77 ( a, b, c ) + ... +< +The template Comments.function will be used. After typing a brief description, +use <CTRL-J> to jump to the various tags: > + {+TAG+} +and fill in the information (see Sec. |vimsupport-templates-jump-tags|). - "=== FUNCTION ============================================================= - " NAME: s:fct77 {{{1 - " DESCRIPTION: - " PARAMETERS: a - {+DESCRIPTION+} - " b - {+DESCRIPTION+} - " c - {+DESCRIPTION+} - " RETURNS: - "============================================================================ - function! s:fct77 ( a, b, c ) - ... +------------------------------------------------------------------------------ -The template Comments.function will be used. +2.1.4 Further Comments *vimsupport-usage-comments-other* -1.1.6 KEYWORD COMMENT *vimsupport-comm-keywords* ---------------------- +Frame comments, function descriptions and file header comments are read as +templates from the appropriate files (see |vimsupport-templates|). -Preliminary end-of-line comments to document (and find again!) places where -work will be resumed shortly, like +------------------------------------------------------------------------------ - " :BUG:08.02.2012 12:29:: ... your comment +2.1.5 Keyword Comments *vimsupport-usage-comments-keyword* +Preliminary end-of-line comments to document (and find again!) places where +work will be resumed shortly, like: +> + " :BUG:08.02.2012 12:29:: ... your comment +< Usually these comments are not meant for the final documentation. ------------------------------------------------------------------------------ -1.2 MENU 'Statements' *vimsupport-statements* +2.2 STATEMENTS, IDIOMS, ... *vimsupport-usage-templates* ------------------------------------------------------------------------------ -1.2.1 NORMAL MODE, INSERT MODE *vimsupport-stat-norm-ins* +The 'Statement' and 'Idioms' menus contain the most frequently used templates. +The menu entries insert some code into the buffer. Almost all menu entries +also have a map, making the same behavior accessible more quickly. E.g. the +menu entry "Idioms -> function" has the map `\if`. + +NORMAL MODE, INSERT MODE ------------------------------- -An empty statement will be inserted and properly indented. The entry 'if, end' -will insert an if-statement: +If you choose "Idioms -> function" you will be prompted for the name of the +new function. Enter it, then hit <Enter>. An empty function will be inserted: +> + function! s:MyFunc ( | ) + <-FUNCTION_BODY-> + return + endfunction " ---------- end of function s:MyFunc ---------- +< +The inserted lines will be indented. The character '|' marks the cursor +position after insertion. + +VISUAL MODE +------------------------------- +Select the following lines: +> + echohl WarningMsg + echo msg + echohl None +< +If you now use the menu entry "Statements -> if, end", the lines will be +surrounded by the statement: +> if | - <-IF_PART-> + echohl WarningMsg + echo msg + echohl None endif - -The statement will be indented. - -1.2.2 VISUAL MODE *vimsupport-stat-visual* ------------------- - -The highlighted area - - xxxxx - xxxxx - -can be surrounded by one of the following statements ( '|' -marks the cursor position after insertion): - - +--------------------------------------------------+ - | for | in <+LIST+> | - | xxxxx | - | xxxxx | - | endfor | - +--------------------------------------------------+ - | if | | - | xxxxx | - | xxxxx | - | endif | - +--------------------------------------------------+ - | if | | - | xxxxx | - | xxxxx | - | else | - | <+ELSE_PART+> | - | endif | - +--------------------------------------------------+ - | while | - | xxxxx | - | xxxxx | - | endwhile | - +--------------------------------------------------+ - | try | - | xxxxx | - | xxxxx | - | catch // | - | catch /.*/ | - | echo "Internal error (" . v:exception . ")" | - | echo " - occurred at " . v:throwpoint | - | finally | - | endtry | - +--------------------------------------------------+ - -The whole statement will be indented after insertion. - ------------------------------------------------------------------------------- -1.3 MENU 'Idioms' *vimsupport-idioms* ------------------------------------------------------------------------------- - -Often used programming idioms other than the basic language statements. - ------------------------------------------------------------------------------- -1.4 MENU 'Regex' *vimsupport-regex* ------------------------------------------------------------------------------- - -This menu can be used to compose regular expressions with a few keystrokes. -In normal mode the entries insert the shown constructs after the cursor. Some -of them can enclose a marked text. The marked text - xxxxx -will be changed into - \(xxxxx\|\) -by the menu item 'branch'. - +< +This "split mode" works for many of the menu entries. With the pattern '\w\+' +selected, the map `\xc` or the menu entry "Regex -> capture" will surround it +with a capture: > + matchlist ( str, '\s\+\w\+' ) +will be changed into: > + matchlist ( str, '\s\+\(\w\+\)' ) +< +Lots of submenus are only associated with one map. E.g. all the entries in +"Idiom -> iterators -> ..." can be accessed via the map `\ii`. You will be +prompted for your choice. Use tab-expansion to display the choices and the +arrow keys to select an item: +> + dict, keys dict, key+val dict, values file list + iterator over : dict, keys +> ------------------------------------------------------------------------------ -1.5 MENU 'Perl' *vimsupport-perl* +2.3 PERL API *vimsupport-usage-api* ------------------------------------------------------------------------------ -This submenu supplies support for the Perl interface of Vim. +This sub-menu supplies support for the Perl interface of Vim. For more information please see |if_perl.txt|. ------------------------------------------------------------------------------ -1.6 MENU 'Documentation' *vimsupport-documentation* +2.4 DOCUMENTATION *vimsupport-usage-docu* ------------------------------------------------------------------------------ -This submenu supplies support for writing Vim help-files in an easy an -consistent way. Example: insert a chapter header with 'chapter, text'. +This sub-menu supplies support for writing Vim help-files in an easy and +consistent way. You can insert a chapter header with 'chapter, text'. You will be asked for number, name, and tag: > ============================================================================ @@ -280,115 +318,92 @@ You will be asked for number, name, and tag: ============================================================================ < Now generate a line for the table of content using 'chapter, ToC': -Example: > 3 Documentation |xxxx| < The number, name, and tag is taken from the last chapter header inserted. For using the maps while editing help-files set the variable -g:Vim_CreateMapsForHelp in ~/.vimrc to 'yes' (default 'no'): -> +|g:Vim_CreateMapsForHelp| in ~/.vimrc to 'yes' (default 'no'): > let g:Vim_CreateMapsForHelp = 'yes' -< +Now the maps are created for filetype "help", but only if the buffer is +modifiable. This way, the maps are not created for help buffers when you look +up documentation. + ------------------------------------------------------------------------------ -1.7 MENU 'SNIPPETS' *vimsupport-snippets* +2.5 CODE SNIPPETS *vimsupport-usage-snippets* ------------------------------------------------------------------------------ -1.7.1 Code Snippets *vimsupport-snippets-menu* --------------------- - -Code snippets are pieces of code which are kept in separate files in a special -directory. File names are used to identify the snippets. The default snippet -directory is '$HOME/.vim/vim-support/codesnippets'. Snippets are managed -with the 3 entries +Useful code snippets can be kept in a central place. This way, they can +quickly be inserted into the code, using "Snippets -> read code snippet". +New snippets can be created from existing lines of code by selecting them in +visual mode and saving them using "Snippets -> write code snippet". - vim -> Snippets -> read code snippet - vim -> Snippets -> write code snippet - vim -> Snippets -> edit code snippet +Code snippets are kept in a directory which can be changed using the setting +|g:Vim_CodeSnippets|. -from the Statements submenu. + Feature Menu Entry Map + ---------------------------------------------------------------------------- + insert code snippet Snippets.read code snippet <LocalLeader>nr + view code snippet Snippets.view code snippet <LocalLeader>nv + create code snippet Snippets.write code snippet <LocalLeader>nw + edit code snippet Snippets.edit code snippet <LocalLeader>ne + ---------------------------------------------------------------------------- -Creating a new snippet: ------------------------ -When nothing is marked, 'write code snippet' will write the whole buffer -to a snippet file, otherwise the marked area will be written to a file. +Creating a new snippet +---------------------- +When nothing is marked, "write code snippet" will write the whole buffer to a +snippet file. Otherwise the marked area will be written to a file. -Insert a snippet: ------------------ -Select the appropriate file from the snippet directory ('read code snippet'). +Insert a snippet +---------------- +Select the appropriate file from the snippet directory via "read code snippet". The inserted lines will be indented. Indentation / no indentation ---------------------------- Code snippets are normally indented after insertion. To suppress indentation add the file extension "ni" or "noindent" to the snippet file name, e.g. - +> parameter_handling.vim.noindent - +< Snippet browser --------------- Under a GUI a file requester will be put up. Without GUI the filename will be read from the command line. You can change this behavior by setting a global -variable in your $HOME/.vimrc : - - let g:Vim_GuiSnippetBrowser = 'commandline' - +variable in your $HOME/.vimrc : > + let g:Vim_GuiSnippetBrowser = 'commandline' The default value is 'gui'. -1.7.2 Code Templates *vimsupport-templates-menu* ---------------------- - -Nearly all menu entries insert code snippets or comments. All of these are -contained within template files and can be changed by the user to meet their -requirements (see|vimsupport-templates|on how to use the template system). - -The menu items 'edit ... templates' open various template files. The stock -templates are usually located in the "local" template file: > - ~/.vim/perl-support/templates/Templates -The template files named "custom" and "personal" can be used for -customization, which avoids editing the stock templates. -There may be dependent files loaded from the main files. Change whatever file -you want, save it, and click on the menu item 'reread templates' to read in -the file(s) and to rebuild the internal representation of the templates. - ------------------------------------------------------------------------------ -1.8 MENU 'Run' *vimsupport-run* +2.6 HARDCOPY *vimsupport-usage-hardcopy* ------------------------------------------------------------------------------ -1.8.1 Hardcopy *vimsupport-hardcopy* --------------- - -Generates a PostScript file from the whole buffer or from a marked region. The -hardcopy is written to the current working directory. If the buffer contains -documentation or other material from non-writable directories the hardcopy -goes to the HOME directory. The output destination will be shown in a message. +The current buffer, or a range in it, can be quickly printed into a file, +using the menu entry "Run -> hardcopy to filename.ps". -The print header contains date and time according the current locale. The -definition used is: -> - let g:Vim_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" -< -The current locale can be overwritten by changing the language, e.g. : -> - :language C -< -or by setting a global variable in the file '.vimrc', e.g. : -> - let g:Vim_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} SEITE %N" -< -See |printheader| and |strftime()| for more details. + Feature Menu Entry Map + ---------------------------------------------------------------------------- + hardcopy to postscript Run.hardcopy to ... <LocalLeader>rh + ---------------------------------------------------------------------------- -1.8.2 Settings *vimsupport-settings* --------------- +The file will be put into the current working directory. If the user can not +write there, it is put into the home directory instead. -Displays some Vim Support plugin settings. +The printheader on top of each page can be set via |g:Vim_Printheader|. ------------------------------------------------------------------------------ -1.9 MENU 'Help' *vimsupport-help* +2.7 HELP *vimsupport-usage-help* ------------------------------------------------------------------------------ -This submenu offers convenient access to various documentations. +This sub-menu offers convenient access to various documentations. + + Feature Menu Entry Map + ---------------------------------------------------------------------------- + open English dictionary Help.English <LocalLeader>he + view help for keyword Help.keyword help <LocalLeader>hk + open plug-in help Help.help (Vim-Support) <LocalLeader>hp + ---------------------------------------------------------------------------- The entry 'keyword' looks up Vim help for the word (function name, keyword) under the cursor. If there is no word under the cursor the functions list @@ -396,277 +411,516 @@ will be displayed. The entry 'English' opens an online dictionary for the word under the cursor. ------------------------------------------------------------------------------- - -The browser for opening the online documentation, or the English dictionary, +The browser for opening online documentation, such as the English dictionary, can be configured by setting a global variable in your ~/.vimrc (see -|g:Templates_InternetBrowserExec| and |g:Templates_InternetBrowserFlags|): -> +|g:Templates_InternetBrowserExec| and |g:Templates_InternetBrowserFlags|): > let g:Templates_InternetBrowserExec = 'firefox' < + *<Plug>VimSupportKeywordHelp* +The keyword help can be mapped to an additional key by the user, using the +mapping `<Plug>VimSupportKeywordHelp`. To map the <F1> key to bring up the +help for the keyword under the cursor, add this to your vim filetype plug-in: +> + nmap <buffer> <F1> <Plug>VimSupportKeywordHelp + imap <buffer> <F1> <Plug>VimSupportKeywordHelp +< +See 'vim-support/rc/vim.vim' for an example filetype plug-in. + ============================================================================== -2. USAGE without GUI (Vim) *vimsupport-usage-vim* +3. TEMPLATES *vimsupport-templates* ============================================================================== -The frequently used constructs can be inserted via key mappings. The mappings -are also described in the document 'vim-hotkeys.pdf' (reference card, part of -this package). +Most of the menu entries insert templates into the current text. Most +templates come with their own map, for fast and convenient access. All maps +start with a mapleader, which can be set to a different value for use within +Vim Support (see |g:Vim_MapLeader|). -All mappings are filetype specific: they are only defined for buffers with -filetype 'vim' to minimize conflicts with mappings from other plugins. + Feature Menu Entry Map + ---------------------------------------------------------------------------- + -various templates- (automatically generated) <LocalLeader>... + ---------------------------------------------------------------------------- -Hint: Typing speed matters. The combination of a leader ('\') and the -following character(s) will only be recognized for a short time. +The following sections provide a short overview of the template system. See +the documentation of the template system for a more in-depth discussion: +|templatesupport.txt|, particularly |template-support-basics| -Some mappings can be used with range (of lines). In normal mode - \cl -appends a end-of-line comment to the current line, whereas - 4\cl -appends end-of-line comments to the 4 lines starting with the current line. +------------------------------------------------------------------------------ +3.1 INTRODUCTION *vimsupport-templates-introduction* +------------------------------------------------------------------------------ -Legend: (i) insert mode, (n) normal mode, (v) visual mode - [n] range +This plug-in makes heavy use of an extendible template library. A template +library can assist in speeding up the writing of code, while at the same time +ensuring a consistent style. The templates are written in an easy to use +markup language, which enables the user to customize templates without much +hassle. The menu shortcuts (e.g. 'c' for the Comments menu) and the maps +(e.g. `\ct` to insert date and time) are also defined in the template library. - -- Help ---------------------------------------------- +Templates are short pieces of text which can be included into source code or +text of any other kind. But they are not just plain text, they can be extended +with macros and tags to provide further convenience. Macros can be +automatically replaced with the date or the filename, or they can be replaced +with input from the user, for example the name of a new function. - \he open an English dictionary for the (n, i) - word under the cursor - \hk displays help for the function name (n, i) - under the cursor (Vim help) - \hp displays plugin help (n, i) +While inserting a template, the user will often be asked to enter some +replacement text on the command line, for example the name of a function. The +replacement text will then be used in the template while it is inserted. +Hitting <ESC> or entering an empty text will abort template insertion. - -- Comments ------------------------------------------ +------------------------------------------------------------------------------ +3.2 CUSTOMIZATION *vimsupport-templates-custom* +------------------------------------------------------------------------------ - [n]\cl end-of-line comment (n, i, v) - [n]\cj adjust end-of-line comments (n, i, v) - \cs set end-of-line comment column (n) - [n]\cc comment code (n, i, v) - [n]\co uncomment code (n, i, v) - \ca function description (auto) (n, i, v) - \cfr frame comment (n, i) - \cfu function description (n, i) - \ch file header (n, i) - \cd date (n, i) - \ct date & time (n, i) - \ck keyword comments (n, i) - \cma plugin macros (n, i) +The master template file is `$HOME/.vim/vim-support/templates/Templates` for +a user installation and `$VIM/vimfiles/vim-support/templates/Templates` for +a system-wide installation (see |vimsupport-system-wide|). - -- Statements ----------------------------------------- +The template library is customized via your local template files. Use the menu +entries "Snippets -> edit local templates", "Snippets -> edit custom +templates", or "Snippets -> edit personal templates" to get there. - \sv let variable (n, i) - \sl let list (n, i) - \sd let dictionary (n, i) - \sf for (n, i, v) - \sif if ... endif (n, i, v) - \sie if ... else ... endif (n, i, v) - \sei elseif (n, i) - \sel else (n, i) - \sw while (n, i, v) - \st try ... catch (n, i, v) +The master template file can be edited itself to adapt the templates/menus to +the users need. Alternatively, a custom template file can be added (see +|g:Vim_CustomTemplateFile|), which eliminates the need to edit stock +templates. - -- Idioms ---------------------------------------------- +The personalization (name, email, ..., date and time format) can be done in a +special personalization template file (see |g:Templates_PersonalizationFile|). +It will be read by all plug-ins which support this feature, so it should only +contain basic information not pertaining to a specific programming language. +It can be set up using a wizard, which is run by the map `\ntw` or the menu +entry "Snippets -> template setup wizard". Afterwards, use the menu entry +"Snippets -> reread templates" to apply the changes. - \ii iterators (n, i, v ) - \if function (n, i, v ) +Further template files can be added using the call: > + call mmtemplates#config#Add ( 'vim', '<PATH>/some.templates', 'example', 'nte' ) +The first parameter adds the file to your Vim templates, the second is the +path. The remaining two optional parameters specify the symbolic name for +these templates and the map to edit them. The map is `\nte` in this example, +if the standard mapleader is set. - -- Regular Expression ---------------------------------- +------------------------------------------------------------------------------ +3.3 JUMP TAGS *vimsupport-templates-jump-tags* +------------------------------------------------------------------------------ - \xc capture (n, i, v ) - \xbc branch (n, i, v ) - \xbn branch, no capture (n, i, v ) - \xw word (n, i ) - \xpc POSIX character classes (n, i ) - \xs switches (n, i ) +Templates can include special tags, which mark positions where text needs to +be added: > + {+TAGNAME+} {-TAGNAME-} + <+TAGNAME+> <-TAGNAME-> + [+TAGNAME+] [-TAGNAME-] +< + Feature Menu Entry Map + ---------------------------------------------------------------------------- + jump to next tag - <CTRL-J> + delete optional tag - <CTRL-D> + ---------------------------------------------------------------------------- - -- Perl ------------------------------------------------ +Use the <CTRL-J> to jump to the next tag. The maps works in normal and insert +mode. Use <CTRL-D> to delete optional tags on the same line, for example: > + strpart ( <+src+>, <+start+>, [+len+] ) +The optional argument "len" can be written down after jumping to the tag +using <CTRL-J> or deleted together with the comma using <CTRL-D>. The optional +tags are: `[+TAGNAME+]` `[-TAGNAME-]` - \ps Perl snippet (n, i) - \pd Vim::DoCommand() (n, i) - \pe Vim::Eval() (n, i) - \pm Vim::Msg( "" ) (n, i) - \pmc Vim::Msg( "", "Comment" ) (n, i) - \pme Vim::Msg( "", "Warning" ) (n, i) - \pmw Vim::Msg( "", "ErrorMsg" ) (n, i) +The tags written with minus signs are removed when the template is used in +visual mode, compare the next section: `{-TAGNAME-}` `<-TAGNAME->` `[-TAGNAME-]` - -- Documentation --------------------------------------- +------------------------------------------------------------------------------ +3.4 SPLIT TAGS *vimsupport-templates-split-tags* +------------------------------------------------------------------------------ - \dcc chapter, contents (n, i) - \dcs section, contents (n, i) - \dcu subsection, contents (n, i) - \dtc chapter, text (n, i) - \dts section, text (n, i) - \dtu subsection, text (n, i) - \df function description (n, i) - \de example (n, i, v) - \dl list item (n, i) +Some templates include so-called split tags and can use to surround some lines +of code, or to surround a part of the current line. - -- Snippets -------------------------------------------- +Example: - \nr read code snippet (n, i) - \nw write code snippet (n, i, v) - \ne edit code snippet (n, i) +The template "Statements.if, else" contains a split tag for the if-branch: +> + == Statements.if, else == map:sie, sc:i == + if <CURSOR> + <SPLIT><-IF_PART-> + else + <+ELSE_PART+> + endif + == ENDTEMPLATE == +< +Consider the lines: +> + echohl WarningMsg + echo msg + echohl None +< +After selecting these three lines and inserting the template, the result looks +like this: +> + if | + echohl WarningMsg + echo msg + echohl None + else + <+ELSE_PART+> + endif +< +The tag `<-IF_PART->`is removed because it is written with a minus signs. The +cursor is placed where the condition must go. Use <CTRL-J> to jump to the +else-branch. - \ntg edit global template file (n, i) - \ntl edit local template file (n, i) - \ntc edit custom template file (n, i) - \ntp edit personal template file (n, i) - \ntr reread template file (n, i) - \ntw template setup wizard (n, i) - \nts choose template style (n, i) +------------------------------------------------------------------------------ +3.5 MACROS *vimsupport-templates-macros* +------------------------------------------------------------------------------ - -- Run ------------------------------------------------- +Macros are placeholders which get replace while a template is inserted. The +template library defines several macros used for personalization: +> + SetMacro( 'AUTHOR', 'YOUR NAME' ) + SetMacro( 'AUTHORREF', '' ) + SetMacro( 'EMAIL', '' ) + SetMacro( 'ORGANIZATION', '' ) + SetMacro( 'COMPANY', '' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) + SetMacro( 'LICENSE', 'GNU General Public License' ) +< +These macros are used by some templates, e.g. the file prolog. Arbitrary +user-defined macros are possible. The macro name must follows the rules for a +C language identifier: first character letter or underscore; case matters; +digits are allowed beginning with the second character. +> +Some predefined macros can help make comments much richer: +> + |BASENAME| filename without path and suffix + |FILENAME| filename without path + |PATH| path without filename + |SUFFIX| filename suffix + + |DATE| the date + |TIME| the time + |YEAR| the year +< +The date and time formats can be set in the template library, see |strftime()| +for the format specifiers: +> + SetFormat( 'DATE', '%D' ) + SetFormat( 'TIME', '%H:%M' ) + SetFormat( 'YEAR', 'year %Y' ) +< +This sets the format for the date to the preferred representation for your +current locale, the time will be inserted as 10:24 and the year will be +represented using four digits. - \rh hardcopy buffer to FILENAME.ps (n, i) - \rs settings and hot keys (n, i) +------------------------------------------------------------------------------ +3.6 TEMPLATE FILES *vimsupport-templates-files* +------------------------------------------------------------------------------ -File 'vim-hotkeys.pdf' contains a reference card for these key mappings. -Multiline inserts and code snippets will be indented after insertion. +The template definitions are spread out over several template files. These can +contain comments, lines starting with a section sign (§) are ignored. -Changing the default map leader '\' ------------------------------------ -The map leader can be changed by the user by setting a global variable in the -file .vimrc +Template files can include several further files: > + IncludeFile( 'comments.templates' ) +An included file will be processed before the remainder of the including file. - let g:Vim_MapLeader = ',' +The template behind a menu item is identified by a given name. The first part +of the name identifies the menu name, the second part identifies the item. +A template definition starts with a template header with the following syntax: -The map leader is now a comma. The 'end-of-line comment' command is now -defined as ',cl'. This setting will be used as a so called local leader and -influences only files with filetype 'vim'. + == menu_name.template_name == options == -============================================================================== -3.0 CUSTOMIZATION *vimsupport-customization* -============================================================================== +The options are described here: |template-support-options| ------------------------------------------------------------------------------ -3.1 FILES (after installation) *vimsupport-custom-files* +3.7 TEMPLATE LIBRARIES *vimsupport-templates-libs* ------------------------------------------------------------------------------ -vim-support/README.md Release notes, installation description. +The template system comes with several auxiliary functions. + + Feature Menu Entry Map + ---------------------------------------------------------------------------- + edit the global template Snippets.edit global templates <LocalLeader>ntg + library (^1) + edit the local template Snippets.edit local templates <LocalLeader>ntl + library + edit the custom template Snippets.edit custom templates <LocalLeader>ntc + library + edit the personal templ. Snippets.edit personal templ. <LocalLeader>ntp + library + reread the templates Snippets.reread templates <LocalLeader>ntr + setup wizard Snippets.template setup wizard <LocalLeader>ntw + choose a style Snippets.choose style <LocalLeader>nts + ---------------------------------------------------------------------------- + +(^1) system-wide installation only + +The menu items "Snippets -> edit ... templates" open various template files. The +stock templates are usually located in the "local" template file: > + ~/.vim/vim-support/templates/Templates +The template files named "custom" and "personal" can be used for +customization, which avoids editing the stock templates. +There may be dependent files loaded from the main files. Change whatever file +you want, save it, and click on the menu item "reread templates" to read in +the file(s) and to rebuild the internal representation of the templates. + +For how to use these files to configure and personalize the template library, +see |vimsupport-templates-custom|. For help with setting up the template +library, use the setup wizard: + Vim -> Snippets -> template setup wizard + +Template Browser +---------------- +When editing a template file, it is selected via |:Explore|. You can change +this behavior by setting a global variable in your ~/.vimrc (see +|g:Templates_TemplateBrowser|): +> + let g:Templates_TemplateBrowser = 'browse' +< +Template Style +-------------- +The template system supports different template styles. If there are more than +one style the menu item "choose style" let you choose a style on the fly. + +Template Locations +------------------ + *g:Vim_LocalTemplateFile* *g:Vim_GlobalTemplateFile* + *g:Vim_CustomTemplateFile* +The variables `g:Vim_LocalTemplateFile` and `g:Vim_GlobalTemplateFile` set the +locations and names of the local and global template files, respectively. +The standard locations of the template files can be changed via these +configuration variables, e.g.: > + let g:Vim_CustomTemplateFile = $HOME.'/.vim/my-templates/vim.templates' +< + Variable Default Linux + ---------------------------------------------------------------------------- + g:Vim_CustomTemplateFile $HOME/.vim/templates/vim.templates + g:Vim_GlobalTemplateFile $VIMRUNTIME/vim-support/templates/Templates + g:Vim_LocalTemplateFile $HOME/.vim/vim-support/templates/Templates + ---------------------------------------------------------------------------- -plugin/vim-support.vim The vim plugin for Vim/gVim. + Variable Default Windows + ---------------------------------------------------------------------------- + g:Vim_CustomTemplateFile $HOME/vimfiles/templates/vim.templates + g:Vim_GlobalTemplateFile $VIMRUNTIME/vim-support/templates/Templates + g:Vim_LocalTemplateFile $HOME/vimfiles/vim-support/templates/Templates + ---------------------------------------------------------------------------- -doc/vimsupport.txt The help file for the local online help. +The personalization file is located in a directory relative to |runtimepath|: > + <RUNTIMEPATH>/templates/personal.templates +For configuring the personalization file, see |g:Templates_PersonalizationFile|. -vim-support/codesnippets/* Some code snippets as a starting point. +============================================================================== +4. CONFIGURATION *vimsupport-configuration* +============================================================================== -vim-support/templates/* Vim template files - (see |vimsupport-comm-templates|). +The basic configuration is done via a number of global variables, which can be +set in the `.vimrc` file. -autoload/mmtemplates/* The template engine. + Variable Default Description + ---------------------------------------------------------------------------- + |g:Vim_CreateMapsForHelp| 'no' create the mappings in modifiable + help buffers -The following files and extensions are for convenience only. vim-support.vim -will work without them. + |g:Vim_LoadMenus| 'auto' when to load the menus ('startup', + 'auto' or 'manual') + |g:Vim_RootMenu| '&Vim' name and shortcut of the root menu + |g:Vim_MapLeader| '' the |maplocalleader| used for maps + |g:Vim_Ctrl_j| 'yes' generate the <CTRL-J> map + |g:Vim_Ctrl_d| 'yes' generate the <CTRL-D> map -vim-support/doc/* Hotkey reference card (PDF), changelog. + |g:Vim_LineEndCommColDefault| standard column used for end-of- + 49 line comments -vim-support/rc/customization.vimrc Additional settings I use in '.vimrc': - incremental search, tabstop, hot keys, - font, use of dictionaries, ... The file - is commented. Append it to your '.vimrc' - if you like. + |g:Vim_CodeSnippets| (see below) directory with code snippers + |g:Vim_GuiSnippetBrowser| 'gui' browser to select code snippets -vim-support/rc/customization.gvimrc Additional settings I use in '.gvimrc': - hot keys, mouse settings, ... The file is - commented. Append it to your '.gvimrc' if - you like. + |g:Vim_LocalTemplateFile| (see Chp. 3) the local top-level template file + |g:Vim_GlobalTemplateFile| (see Chp. 3) the global top-level template file + |g:Vim_CustomTemplateFile| (see Chp. 3) the optional custom template file + |g:Templates_PersonalizationFile| + (see Chp. 3) the personalization template file + + |g:Vim_Printheader| '...' printheader used for hardcopy + + |g:Templates_InternetBrowserExec| the browser executable + |g:Templates_InternetBrowserFlags| additional browser flags + ---------------------------------------------------------------------------- + +Further customization is carried out in the template library, see +|vimsupport-templates-custom|. ------------------------------------------------------------------------------ -3.2 GLOBAL VARIABLES *vimsupport-custom-variables* ------------------------------------------------------------------------------- + *g:Vim_CreateMapsForHelp* +In order to use the mappings for the templates listed in "Documentation" while +writing helpfiles, the creation of these maps has to be allowed explicitly by +the user. (compare |vimsupport-usage-docu|) -Several global variables are checked by the plugin to customize it: +Add this line to your .vimrc: > + let g:Vim_CreateMapsForHelp = 'yes' +Now the maps are created for filetype "help", but only if the buffer is +modifiable. This way, the maps are not created for help buffers when you look +up documentation. ------------------------------------------------------------------------------ -Global Variable Default Value +4.1 MENUS *vimsupport-config-menus* ------------------------------------------------------------------------------ -g:Vim_CreateMapsForHelp 'no' -g:Vim_GlobalTemplateFile $VIM.'/vimfiles/vim-support/templates/Templates' -g:Vim_LocalTemplateFile $HOME.'/.vim/vim-support/templates/Templates' -g:Vim_CustomTemplateFile $HOME.'/.vim/templates/vim.templates' -g:Vim_CodeSnippets $HOME.'/.vim/vim-support/codesnippets' (Linux/U**X) - $VIM.'\vimfiles\vim-support/codesnippets/'(Windows) -g:Vim_LoadMenus 'yes' -g:Vim_CreateMenusDelayed 'no' -g:Vim_RootMenu '&Vim' -g:Vim_GuiSnippetBrowser 'gui' -g:Vim_Ctrl_j 'yes' -g:Vim_Ctrl_d 'yes' -g:Vim_LineEndCommColDefault 49 -g:Vim_Printheader '%<%f%h%m%< %=%{strftime('%x %X')} Page %N' - 'vim.exe' (Windows) -g:Vim_MapLeader '\' + *g:Vim_LoadMenus* +The creation of the menus is controlled by `g:Vim_LoadMenus`. The default +setting: > + let g:Vim_LoadMenus = 'auto' +causes the templates to be loaded and the menus to be created when the first +VimL file is opened. +The menus appear right away after starting Vim with the setting: > + let g:Vim_LoadMenus = 'startup' +This has the disadvantage that the templates have to be loaded during the +startup of Vim, which might cause a noticeable slowdown on older systems. +The automatic creation of the menus is prevented by: > + let g:Vim_LoadMenus = 'manual' +Now the menus can only be loaded by using the tool menu entry "Tools -> Load +Vim Support". + + *g:Vim_CreateMenusDelayed* +The old setting `g:Vim_CreateMenusDelayed` still works for backwards +compatibility, use the above values for |g:Vim_LoadMenus| instead. + + *g:Vim_RootMenu* +The name and shortcut of the root menu is set via `g:Vim_RootMenu`. The +character prefixed by '&' will be the shortcut. +> +Example: > + let g:Vim_RootMenu = '&Plugin.&Vim' +Creates the Vim menu as a submenu of "Plugin", and sets the shortcut to 'l'. ------------------------------------------------------------------------------ -Global Variable Description +4.2 MAPS *vimsupport-config-maps* ------------------------------------------------------------------------------ -g:Vim_CreateMapsForHelp Create maps for modifiable help buffers ("yes", "no"). -g:Vim_GlobalTemplateFile sets the global template file (see|vimsupport-templates|) -g:Vim_LocalTemplateFile sets the local template file (see|vimsupport-templates|) -g:Vim_CustomTemplateFile sets the custom template file (see|vimsupport-templates|) -g:Vim_CodeSnippets set the personal code snippet directory -g:Vim_LoadMenus Load menus and mappings ("yes", "no") at start up. -g:Vim_CreateMenusDelayed Load menus only with filetype 'vim' -g:Vim_RootMenu The name of the root menu entry of this plugin - (see |vimsupport-custom-root|). -g:Vim_GuiSnippetBrowser code snippet browser: 'gui', 'commandline' -g:Vim_Ctrl_j hotkey Ctrl-J 'yes'/'no' (see |vimsupport-Ctrl-j|) -g:Vim_Ctrl_d hotkey Ctrl-D 'yes'/'no' (see |vimsupport-Ctrl-j|) - -g:Vim_LineEndCommColDefault default starting column for line end comments -g:Vim_Printheader hardcopy header format -g:Vim_MapLeader the map leader for hotkeys (see|vimsupport-usage-vim|) + *g:Vim_MapLeader* +All the maps the plug-in creates use |maplocalleader|. It can be changed by +setting the variable `g:Vim_MapLeader`. If it contains the empty string, +Vim's default (backslash) is used. + +Example: > + let g:Vim_MapLeader = '#' +Sets the mapleader to '#'. + + *Vim_SetMapLeader()* + *Vim_ResetMapLeader()* +The configured mapleader can also be used in the ftplugin, by calling the +functions `Vim_SetMapLeader()` and `Vim_ResetMapLeader()`. The maps created +between the two calls will use |g:Vim_MapLeader| as the |<LocalLeader>|: +> + call Vim_SetMapLeader () -To override the defaults add appropriate assignments in '.vimrc', e.g. - let g:Vim_MapLeader = ',' + map <buffer> <LocalLeader>eg :echo "Example Map :)"<CR> + call Vim_ResetMapLeader () +< + *g:Vim_Ctrl_j* *g:Vim_Ctrl_d* +The creation of the <CTRL-J> and <CTRL-D> maps is controlled by the variables +`g:Vim_Ctrl_j` and `g:Vim_Ctrl_d`, respectively. To disable <CTRL-D>, set the +variable to "no": > + let g:Vim_Ctrl_d = 'no' +< ------------------------------------------------------------------------------ -3.3 THE ROOT MENU *vimsupport-custom-root* +4.3 COMMENTS *vimsupport-config-comments* ------------------------------------------------------------------------------ + *g:Vim_LineEndCommColDefault* +The standard column used for end-of-line comments is configured using +`g:Vim_LineEndCommentColumn`. The column can then be set individually for each +buffer, using the menu entry "Comments -> set end-of-line com. col.". -The variable g:Vim_RootMenu, if set (in '.vimrc' or in '.gvimrc'), sets the -name of the single gVim root menu item in which the Vim submenus will be -appear. The default is +Example: > + g:Vim_LineEndCommColDefault = 59 +< +------------------------------------------------------------------------------ +4.4 SNIPPETS *vimsupport-config-snippets* +------------------------------------------------------------------------------ + *g:Vim_CodeSnippets* +The variable `g:Vim_Snippets` sets the location of the code snippet directory. +The default value depends on the type of installation and the operating +system. - '&Vim' +(Path separators are always written as slashes '/', even for Windows.) -If you want to set the plugin root menu into another menu, e.g. 'Plugin', -this is done by the following line in '.vimrc' +For a local installation, the default will be (UNIX/Linux): > + s:Vim_Snippets = $HOME.'/.vim/vim-support/codesnippets/' +or (Windows): > + s:Vim_Snippets = $HOME.'/vimfiles/vim-support/codesnippets' +< +For a sytem-wide installation, the default will be: > + s:Vim_Snippets = $VIM.'/vimfiles/vim-support/codesnippets' +< +Example: - let g:Vim_RootMenu = "&Plugin" +To set a different code snippet directory, add this line to your vimrc: > + let g:Vim_Snippets = $HOME.'/myvim/vimscript/codesnippets/' +< + *g:Vim_GuiSnippetBrowser* +Code snippets can either be selected in a file browser, by setting: > + let g:Vim_GuiSnippetBrowser = 'gui' +or on the command line by setting: > + let g:Vim_GuiSnippetBrowser = 'commandline' +< +------------------------------------------------------------------------------ +4.5 HARDCOPY *vimsupport-config-hardcopy* +------------------------------------------------------------------------------ + *g:Vim_Printheader* +The printheader used by "Run -> hardcopy to filename.ps" is set via the +variable `g:Vim_Printheader`. It is temporarily set as the value of +'printheader' while printing the hardcopy. See the documentation of the +option 'printheader' for the possible contents of `g:Vim_Printheader`. The +default is: > + let g:Vim_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" +< +The behavior can be changed on the fly by settings the variable to a different +value on the command line. ------------------------------------------------------------------------------ -3.4 System-wide installation *vimsupport-system-wide* +4.6 WINDOWS PARTICULARITIES *vimsupport-config-windows* ------------------------------------------------------------------------------ +For a user installation the plug-in should go into the directory structure +below the folder: > + $HOME/vimfiles/ +for a system installation below: > + $VIM/vimfiles/ +< +The values of the two variables can be found from inside Vim: > + :echo $HOME +and > + :echo $VIM +< +The configuration files for the user are `$HOME/_vimrc` and `$HOME/_gvimrc`, +and for the system `$VIM/_vimrc` and `$VIM/_gvimrc`. + +============================================================================== +5. SYSTEM-WIDE INSTALLATION *vimsupport-system-wide* +============================================================================== + A system-wide installation (one installation for all users) is done as follows. -As ****** SUPERUSER ****** : +As *** SUPERUSER *** : (1) Find the Vim installation directory. -The Vim ex command ':echo $VIM' gives '/usr/local/share/vim' or something like -that. Beyond this directory you will find the Vim installation, e.g. in +The Vim ex-command `:echo $VIM` gives '/usr/local/share/vim' or something like +that. Beyond this directory you will find the Vim installation, e.g. in '/usr/local/share/vim/vim73' if Vim version 7.3 has been installed. (2) Create a new subdirectory 'vimfiles', e.g. '/usr/local/share/vim/vimfiles'. (3) Install Vim Support -Copy the archive 'vim-support.zip' to this new directory and unpack it: +Copy the archive 'vim-support.zip' to this new directory and unpack it: > unzip vim-support.zip - -(4) Generate the help tags: +< +(4) Generate the help tags: > :helptags $VIM/vimfiles/doc - +< SPECIAL CASES. Some Linux distributions use non-standard names for Vim -directories. SUSE has a directory '/usr/share/vim/site' to put plugins in. -These directories will not be found automatically. After installing the -plugin below '/usr/share/vim/site' the use of the templates will be enabled by -the following line in '$HOME/.vimrc': - +directories. SUSE has a directory '/usr/share/vim/site' to put plug-ins in. +These directories will not be found automatically. After installing the +plug-in below '/usr/share/vim/site' the use of the templates will be enabled +by the following line in '$HOME/.vimrc': +> let g:Vim_GlobalTemplateFile = '/usr/share/vim/site/vim-support/templates/Templates' +< +------------------------------------------------------------------------------ - -As ****** USER ****** : +As *** USER *** : Use the template setup wizard: Vim -> Snippets -> template setup wizard @@ -677,10 +931,10 @@ and should contain only information relevant for all template libraries. You can set some macros in this file with your personal information in order to obtain personalized comments, e.g. something like this: > - SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) - SetMacro( 'AUTHORREF', 'fgm' ) - SetMacro( 'EMAIL', 'mehner.fritz@web.de' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) + SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) + SetMacro( 'AUTHORREF', 'WM' ) + SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) < Use the custom template file for Vim templates which override the global templates or to add new ones. @@ -691,241 +945,177 @@ is still supported for backwards compatibility. Create your private snippet directory: > mkdir --parents $HOME/.vim/vim-support/codesnippets -You may want to copy the snippets coming with this plugin (in +You may want to copy the snippets coming with this plug-in (in $VIM/vimfiles/vim-support/codesnippets) into the new directory or to set a link to the global directory. ============================================================================== -4. TEMPLATE FILES AND TAGS *vimsupport-templates* +A. OVERVIEW OF MAPPINGS *vimsupport-mappings* ============================================================================== -Nearly all menu items insert code snippets or comments. All of these are -contained within template files and can be changed by the user to meet their -requirements. The menu shortcuts (e.g. 'c' for the Comments menu) and the -menu item hotkeys (e.g. '\ct' insert date and time) are also defined in the -templates. -The template engine comes as a separate plugin contributed by Wolfgang Mehner. -This section is a short introduction to this template system. Please see -|templatesupport.txt| for more information. +Almost all functionality is accessible using key mappings. These mappings are +also described in the reference card 'vim-support/doc/vim-hotkeys.pdf'. -The master template file can be edited itself to adapt the templates/menus to -the users need. Alternatively, a custom template file can be added (see -g:Vim_CustomTemplateFile), which eliminates the need to edit stock templates. -The personalization (name, email, ..., date and time format) can be done in a -special personalization template file. It will be read by all plug-ins which -support this feature, so it should only contain basic information not -pertaining to a specific programming language. It can be set up using a -wizard, which is run by the map \ntw or the menu entry: - Vim -> Snippets -> template setup wizard +All mappings are filetype specific; they are only defined for buffers with +filetype 'vim' to minimize conflicts with mappings from other plug-ins. +Furthermore, the mapleader can be changed using the setting |g:Vim_MapLeader|. -Further template files can be added using the call: > - call mmtemplates#config#Add ( 'vim', '<PATH>/some.templates', 'example', 'nte' ) -The first parameter adds the file to your VimL templates, the second is the -path. The remaining two optional parameters specify the symbolic name for -these templates and the map to edit them. The map is '\nte' in this example, -if the standard mapleader is set. +All maps work in normal and insert mode. Additionally some mappings can be +used with a range (of lines). In normal mode > + \cl +appends a end-of-line comment to the current line, whereas > + 4\cl +appends end-of-line comments to the 4 lines starting with the current line. ------------------------------------------------------------------------------- -4.1 TEMPLATE FILES *vimsupport-templates-files* ------------------------------------------------------------------------------- +Hint: Typing speed matters. The combination of a leader ('\') and the +following character(s) will only be recognized for a short time. -The master template file starts with various settings followed by templates -for single menu items or better by including other template files grouping the -templates according to the menu structure of this plugin. The master file -usually looks like this: -> - § ============================================================= - § Settings - § ============================================================= - - SetMacro( 'AUTHOR', 'YOUR NAME' ) - SetMacro( 'AUTHORREF', '' ) - SetMacro( 'EMAIL', '' ) - SetMacro( 'ORGANIZATION', '' ) - SetMacro( 'COMPANY', '' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - SetMacro( 'LICENSE', 'GNU General Public License' ) - - SetStyle( 'default' ) - - § ============================================================= - § File Includes and Shortcuts - § ============================================================= - - MenuShortcut( 'Comments', 'c' ) - MenuShortcut( 'Statements', 's' ) - MenuShortcut( 'Idioms', 'i' ) - MenuShortcut( 'Regex', 'x' ) - MenuShortcut( 'Perl', 'p' ) - MenuShortcut( 'Documentation', 'd' ) - - IncludeFile( 'comments.templates' ) - IncludeFile( 'statements.templates' ) - IncludeFile( 'idioms.templates' ) - IncludeFile( 'regex.templates' ) - IncludeFile( 'perl.templates' ) - IncludeFile( 'docu.templates' ) -< -Lines starting with a paragraph sign are comments. The section starting with -> - SetMacro( 'AUTHOR', 'YOUR NAME' ) -< -assigns values to predefined tags (macros). Arbitrary user-defined macros are -possible. The macro name must follows the rules for a C language identifier: -first character letter or underscore; case matters; digits are allowed -beginning with the second character. -Some of the macros assigned here are placeholders, they will be overwritten by -template files read later on, which contain the user's configuration. +Legend: visual mode: (v) use range, (s) surround content, + [n] range + tab-completion: (T) specialized, (F) filenames -The statement -> - IncludeFile( 'comments.templates' ) -< -includes the templates from the file 'comments.templates' (in the same -directory). An absolute path would also be possible. The statement -> - MenuShortcut( 'Comments', 'c' ) -< -sets 'c' as the shortcut for the Comments menu. + -- Jump Tags ----------------------------------------- ------------------------------------------------------------------------------- -4.2 MACROS *vimsupport-templates-macros* ------------------------------------------------------------------------------- + <CTRL-J> jump to next tag + <CTRL-D> delete an optional tag -The following macro names are predefined. The first group is used to -personalize templates. + -- Help ---------------------------------------------- - ---------------------------------------------------------------------------- - PREDEFINED MACROS DEFAULT VALUE - ---------------------------------------------------------------------------- + for the word under the cursor ... + \he open an English dictionary + \hk display help -*|BASENAME|* filename without path and suffix -*|DATE|* the preferred date representation for the current locale - without the time -*|FILENAME|* filename without path -*|PATH|* path without filename -*|SUFFIX|* filename suffix -*|TIME|* the preferred time representation for the current locale - without the date and the time zone or name or abbreviation -*|YEAR|* the year as a decimal number including the century + \hp display plug-in help - ---------------------------------------------------------------------------- - PREDEFINED TAGS USED IN TEMPLATES - ---------------------------------------------------------------------------- - <CURSOR> The cursor position after insertion of a template. - <+text+>,<-text-> See |vimsupport-templates-jumptags|. - {+text+},{-text-} - [+text+],[-text-] - - <SPLIT> The split point when inserting in visual mode - (see|vimsupport-templates|) - -A dependent template file can start with its own command section. There is no -need to have all user defined macros in the master file. - -4.2.1 User Defined Formats for Date and Time *vimsupport-templates-date* --------------------------------------------- - -The format for *|DATE|* ,*|TIME|* , and*|YEAR|* can be set by the user. The -defaults are - *|DATE|* '%x' - *|TIME|* '%X' - *|YEAR|* '%Y' -See the manual page of the C function strftime() for the format. The accepted -format depends on your system, thus this is not portable! The maximum length -of the result is 80 characters. - -User defined formats can be set using the following function calls in the -master template file is '$HOME/.vim/vim-support/templates/Templates', e.g. -> - SetFormat( 'DATE', '%D' ) - SetFormat( 'TIME', '%H:%M' ) - SetFormat( 'YEAR', 'year %Y' ) -< ------------------------------------------------------------------------------- -4.3 TEMPLATES *vimsupport-templates-names* ------------------------------------------------------------------------------- + -- Comments ------------------------------------------ -4.3.1 Template definition *vimsupport-templates-definition* -------------------------- + [n]\cl end-of-line comment (v) + [n]\cj adjust end-of-line comments (v) + \cs set end-of-line comment column + [n]\cc comment code (v) + [n]\co uncomment code (v) + \ca function description (auto) (v) + \cfr frame comment + \cfu function description + \ch file header + \cd date + \ct date & time + \ck keyword comments (T) + \cma plug-in macros (T) -The template behind a menu entry is identified by a given name. The first part -of the name identifies the menu name, the second part identifies the item. -A template definition starts with a template header with the following syntax: + -- Statements ----------------------------------------- + + \sv let variable + \sl let list + \sd let dictionary + \sf for (s) + \sif if ... endif (s) + \sie if ... else ... endif (s) + \sei elseif + \sel else + \sw while (s) + \st try ... catch (s) + + -- Idioms ---------------------------------------------- + + \ib built-in functions (T) + \ii iterators (s, T) + \if function (s, T) - == menu_name.template_name == options == + -- Regular Expression ---------------------------------- -The options are described here: |template-support-options|. + \xc capture (s) + \xbc branch (s) + \xbn branch, no capture (s) + \xw word (s) + \xcc POSIX character classes (T) + \xs switches (T) -4.3.2 The jump tags <+text+> etc. *vimsupport-templates-jumptags* ----------------------------------- + -- Perl ------------------------------------------------ -There are four jump tag types which can be used as jump targets in templates: + \ps Perl snippet + \pd Vim::DoCommand() + \pe Vim::Eval() + \pm Vim::Msg( "" ) + \pmc Vim::Msg( "", "Comment" ) + \pme Vim::Msg( "", "Warning" ) + \pmw Vim::Msg( "", "ErrorMsg" ) - <+text+> Can be jumped to by hitting Ctrl-j. - {+text+} Same as <+text+>. Used in cases where indentation gives unwanted - results with the first one. - - <-text-> Same as the two above. Will be removed if the template is used - {-text-} in visual mode. + -- Documentation --------------------------------------- - [+text+] The "optional" tag. Serves as a jump tag, but can be deleted using - Ctrl-d. - [-text-] Same as above, removed in visual mode. + \dcc chapter, contents + \dcs section, contents + \dcu subsection, contents + \dtc chapter, text + \dts section, text + \dtu subsection, text + \df function description + \de example (s) -The text inside the brackets is userdefined and can be empty. The text can be -composed from letters (uppercase and lowercase), digits, and underscores. -After the insertion of an template these jump targets will be highlighted. + -- Snippets -------------------------------------------- -4.3.3 Commands Ctrl-j and Ctrl-d *vimsupport-Ctrl-j* ---------------------------------- + \nr read code snippet + \nw write code snippet (v) + \nv view code snippet + \ne edit code snippet -Use the command Ctrl-j to jump to the next target. The target will be removed -and the mode will switched to insertion. Ctrl-j works in normal and in insert -mode. The template for an if-else-statement can be written as follows: -> - == Statements.if, else == map:sie, sc:i == - if <CURSOR> - <SPLIT><-IF_PART-> - else - <+ELSE_PART+> - endif -< -The cursor will be set as shown. When the condition is specified a Ctrl-j let -you jump to the target <-IF PART-> and deletes it. When the block is written -a Ctrl-j leads you to the else-part. The target <+ELSE_PART+> disappears and -you can type on. + \ntg edit global template file + \ntl edit local template file + \ntc edit custom template file + \ntp edit personal template file + \ntr reread template file + \ntw template setup wizard + \nts choose template style (T) + + -- Run ------------------------------------------------- -Use <CTRL-D> to delete optional tags on the same line, for example: > - strpart ( <+src+>, <+start+>, [+len+] ) -The optional argument "len" can be written down after jumping to the tag using -<CTRL-J> or deleted together with the comma using <CTRL-D>. + \rh hardcopy buffer to FILENAME.ps (v) + \rs settings and hot keys ============================================================================== -5. WINDOWS PARTICULARITIES *vimsupport-windows* +B. FILES *vimsupport-files* ============================================================================== -For a user installation the plugin should go into the directory structure -below - $HOME/vimfiles/ -for a system installation below - $VIM/vimfiles/ +vim-support/README.md Release notes, installation description. + +autoload/mmtemplates/* The template system. -The values of the two variables can be found from inside Vim: - :echo $VIM -or - :echo $HOME +doc/vimsupport.txt The help file for Vim Support. +doc/templatesupport.txt The help file for the template system. -The configuration files for a user are +plugin/vim-support.vim The VimL plug-in for Vim/gVim/Neovim. - $HOME/_vimrc and $HOME/_gvimrc +vim-support/codesnippets/ Some code snippets as a starting point. -for the system +vim-support/templates/* The template files. + +-------------------------------------------------------------- + The following files and extensions are for convenience only. + `vim-support.vim` will work without them. +-------------------------------------------------------------- + +ftdetect/template.vim +ftplugin/template.vim +syntax/template.vim Additional files for working with templates. + +vim-support/... + .../doc/vim-hotkeys.pdf Reference card for the key mappings. + .../doc/ChangeLog The change log. + +vim-support/... + .../rc/customization.gvimrc Additional settings for use in .gvimrc. + .../rc/customization.vimrc Additional settings for use in .vimrc: + incremental search, tabstop, hot keys, + font, use of dictionaries, ... + The file is commented. Append it to your + .vimrc if you like. - $VIM/_vimrc and $VIM/_gvimrc + .../rc/vim.vim Suggestion for a filetype plug-in. + .../rc/*.templates Sample template files for customization. + Used by the customization template setup wizard. ============================================================================== -6. TROUBLESHOOTING *vimsupport-troubleshooting* +C. TROUBLESHOOTING - KNOWN ISSUES *vimsupport-troubleshooting* ============================================================================== * I do not see any new main menu item. @@ -945,10 +1135,10 @@ for the system settings can usually be redefined. ============================================================================== -7. Release Notes *vimsupport-release-notes* +D. RELEASE NOTES - CHANGE LOG *vimsupport-release-notes* ============================================================================== -See file 'README.md'. +See files 'vim-support/README.md' and 'vim-support/doc/ChangeLog'. ============================================================================== vim:tw=78:expandtab:ts=2:ft=help:norl: diff --git a/ftplugin/bashhelp.vim b/ftplugin/bashhelp.vim new file mode 100644 index 0000000..ede7329 --- /dev/null +++ b/ftplugin/bashhelp.vim @@ -0,0 +1,34 @@ +"=============================================================================== +" +" File: bashhelp.vim +" +" Description: Filetype plugin for Bash's built-in help. +" +" Some settings have been taken from Neovim's filetype plug-in +" for 'man'. +" +" VIM Version: 7.4+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Organization: +" Version: 1.0 +" Created: 16.11.2017 +" Revision: --- +"=============================================================================== + +" only do this when not done yet for this buffer +if exists("b:did_BashHelp_ftplugin") + finish +endif +let b:did_BashHelp_ftplugin = 1 + +setlocal noexpandtab +setlocal tabstop=8 +setlocal softtabstop=8 +setlocal shiftwidth=8 + +setlocal nonumber +setlocal norelativenumber +setlocal foldcolumn=0 +setlocal colorcolumn=0 +setlocal nolist +setlocal nofoldenable diff --git a/ftplugin/c.vim b/ftplugin/c.vim deleted file mode 100644 index 1ecc7e6..0000000 --- a/ftplugin/c.vim +++ /dev/null @@ -1,60 +0,0 @@ -" ------------------------------------------------------------------------------ -" -" Vim filetype plugin file -" -" Language : C -" Plugin : c.vim -" Revision : 15.04.2017 -" Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> -" (formerly Fritz Mehner <mehner.fritz@web.de>) -" -" ------------------------------------------------------------------------------ - -" Only do this when not done yet for this buffer -if exists("b:did_c_support_ftplugin") - finish -endif -let b:did_c_support_ftplugin = 1 - -"------------------------------------------------------------------------------- -" additional mapping : complete a classical C comment: '/*' => '/* | */' -"------------------------------------------------------------------------------- -inoremap <buffer> /* /*<Space><Space>*/<Left><Left><Left> -vnoremap <buffer> /* s/*<Space><Space>*/<Left><Left><Left><Esc>p -" -"------------------------------------------------------------------------------- -" additional mapping : complete a classical C multi-line comment: -" '/*<CR>' => /* -" * | -" */ -"------------------------------------------------------------------------------- -inoremap <buffer> /*<CR> /*<CR><CR>/<Esc>kA<Space> -" -"------------------------------------------------------------------------------- -" additional mapping : {<CR> always opens a block -"------------------------------------------------------------------------------- -inoremap <buffer> {<CR> {<CR>}<Esc>O -vnoremap <buffer> {<CR> S{<CR>}<Esc>Pk=iB -" -"------------------------------------------------------------------------------- -" set "maplocalleader" as configured using "g:C_MapLeader" -"------------------------------------------------------------------------------- -call C_SetMapLeader () -" -"------------------------------------------------------------------------------- -" additional mapping : Make tool -"------------------------------------------------------------------------------- - noremap <buffer> <silent> <LocalLeader>rm :Make<CR> -inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> - noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> -inoremap <buffer> <silent> <LocalLeader>rmc <C-C>:Make clean<CR> - noremap <buffer> <LocalLeader>rma :MakeCmdlineArgs<space> -inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> - noremap <buffer> <LocalLeader>rcm :MakeFile<space> -inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> -" -"------------------------------------------------------------------------------- -" reset "maplocalleader" -"------------------------------------------------------------------------------- -call C_ResetMapLeader () -" diff --git a/ftplugin/matlab.vim b/ftplugin/matlab.vim deleted file mode 100644 index 280a59b..0000000 --- a/ftplugin/matlab.vim +++ /dev/null @@ -1,51 +0,0 @@ -"=============================================================================== -" -" File: matlab.vim -" -" Description: Filetype plugin for MATLAB. -" -" VIM Version: 7.0+ -" Author: Wolfgang Mehner, wolfgang-mehner@web.de -" Organization: -" Version: 1.0 -" Created: 11.04.2010 -" Revision: 24.11.2013 -" License: Copyright (c) 2012-2014, Wolfgang Mehner -" This program is free software; you can redistribute it and/or -" modify it under the terms of the GNU General Public License as -" published by the Free Software Foundation, version 2 of the -" License. -" This program is distributed in the hope that it will be -" useful, but WITHOUT ANY WARRANTY; without even the implied -" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -" PURPOSE. -" See the GNU General Public License version 2 for more details. -"=============================================================================== -" -" Only do this when not done yet for this buffer -if exists("b:did_Matlab_ftplugin") - finish -endif -let b:did_Matlab_ftplugin = 1 -" -"------------------------------------------------------------------------------- -" settings - tabs + shift -"------------------------------------------------------------------------------- -setlocal tabstop=4 -setlocal shiftwidth=4 -setlocal expandtab -" -"------------------------------------------------------------------------------- -" set "maplocalleader" as configured using "g:Matlab_MapLeader" -"------------------------------------------------------------------------------- -call Matlab_SetMapLeader () -" -" maps defined here will use "g:Matlab_MapLeader" as <LocalLeader> -" example: -"map <buffer> <LocalLeader>eg :echo "Example Map :)"<CR> -" -"------------------------------------------------------------------------------- -" reset "maplocalleader" -"------------------------------------------------------------------------------- -call Matlab_ResetMapLeader () -" diff --git a/ftplugin/sh.vim b/ftplugin/sh.vim deleted file mode 100644 index 7176231..0000000 --- a/ftplugin/sh.vim +++ /dev/null @@ -1,46 +0,0 @@ -" ------------------------------------------------------------------------------ -" -" Vim filetype plugin file -" -" Language : Bash -" Plugin : bash-support.vim -" Revision : 15.04.2017 -" Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> -" (formerly Fritz Mehner <mehner.fritz@web.de>) -" -" ----------------------------------------------------------------- - -" Only do this when not done yet for this buffer -if exists("b:did_bash_support_ftplugin") - finish -endif -let b:did_bash_support_ftplugin = 1 - -"------------------------------------------------------------------------------ -" Avoid a wrong syntax highlighting for $(..) and $((..)) -"------------------------------------------------------------------------------ -let b:is_bash = 1 -" -"------------------------------------------------------------------------------- -" additional mapping : single quotes around a Word (non-whitespaces) -" masks the normal mode command '' (jump to the position -" before the latest jump) -" additional mapping : double quotes around a Word (non-whitespaces) -"------------------------------------------------------------------------------- -nnoremap <buffer> '' ciW''<Esc>P -nnoremap <buffer> "" ciW""<Esc>P -" -"------------------------------------------------------------------------------- -" set "maplocalleader" as configured using "g:BASH_MapLeader" -"------------------------------------------------------------------------------- -call Bash_SetMapLeader () -" -" maps defined here will use "g:BASH_MapLeader" as <LocalLeader> -" example: -"map <buffer> <LocalLeader>eg :echo "Example Map :)"<CR> -" -"------------------------------------------------------------------------------- -" reset "maplocalleader" -"------------------------------------------------------------------------------- -call Bash_ResetMapLeader () -" diff --git a/git-support/README.md b/git-support/README.md deleted file mode 100644 index fc7ab08..0000000 --- a/git-support/README.md +++ /dev/null @@ -1,218 +0,0 @@ -README for git-support.vim (Version 0.9.3) / July 23 2016 -================================================================================ - - * INSTALLATION - * RELEASE NOTES - * FILES - * CREDITS - - -Integration of Git for Vim/gVim. The plug-in at hand allows to use Git from -within Vim, eliminating the need for context switches. The output of commands -like "git status" is written into buffers, and the commit can be manipulated -from right there. Further commands allow to quickly add the file in the -current buffer or show its diff. -Please read the documentation. - -This plug-in can be used with Vim version 7.x. - - --------------------------------------------------------------------------------- - -INSTALLATION -================================================================================ - -(1) LINUX ----------------------------------------------------------------------- - -The subdirectories in the zip archive git-support.zip mirror the directory -structure which is needed below the local installation directory - - $HOME/.vim/ - -(find the value of $HOME with `:echo $HOME` from inside Vim). - -(1.1) Copy the zip archive git-support.zip to $HOME/.vim and run - - unzip git-support.zip - -(1.2) Loading of plug-in files must be enabled. If not use - - :filetype plugin on - - This is the minimal content of the file '$HOME/.vimrc'. Create one if there - is none or use the file in $HOME/.vim/git-support/rc as a starting point. - -(1.3) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME/.vim/doc/ - -(1.4) To get a syntax highlighting closer to the one Git uses, take a look at - the suggestions in git-support/rc/additions.vimrc, which offers example - settings for bright and dark backgrounds. - -(1.5) Consider additional settings in the file '$HOME/.vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your .vimrc and .gvimrc. You may want to use parts of them. The files - are documented. - -(2) WINDOWS ----------------------------------------------------------------------- - -The subdirectories in the zip archive git-support.zip mirror the directory -structure which is needed below the local installation directory - - $HOME/vimfiles/ - -(find the value of $HOME with `:echo $HOME` from inside Vim). - -(2.1) Copy the zip archive git-support.zip to $HOME/vimfiles and run - - unzip git-support.zip - -(2.2) Loading of plug-in files must be enabled. If not use - - :filetype plugin on - - This is the minimal content of the file '$HOME/_vimrc'. Create one if there - is none or use the file in $HOME/vimfiles/git-support/rc as a starting point. - -(2.3) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME\vimfiles\doc\ - -(2.4) Set the correct executable. This is not necessary if 'git' is already on - your path. See :help g:Git_Executable . - -(2.5) To get a syntax highlighting closer to the one Git uses, take a look at - the suggestions in git-support\rc\additions.vimrc, which offers example - settings for bright and dark backgrounds. - -(2.6) Consider additional settings in the file '$HOME/_vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your _vimrc and _gvimrc. You may want to use parts of them. The files - are documented. - - -(3) ADDITIONAL REMARKS ----------------------------------------------------------------------- - -There are a lot of features and options which can be used and influenced: - - * the Git executable - * removing the Git menu - * the syntax highlighting - * the behavior of various commands - -Look at the Git-Support help with: - - :help gitsupport - - +-----------------------------------------------+ - | +-------------------------------------------+ | - | | ** PLEASE READ THE DOCUMENTATION ** | | - | +-------------------------------------------+ | - +-----------------------------------------------+ - -Any problems? See the TROUBLESHOOTING section at the end of the help file -'doc/gitsupport.txt'. - - --------------------------------------------------------------------------------- - -RELEASE NOTES -================================================================================ - -RELEASE NOTES FOR VERSION 0.9.3 ----------------------------------------------------------------------- -- Add: The diff buffer can be use to add/reset chunks, added new maps. -- Add: Extended command-line completion to handle options for Git commands. -- Add: New maps for the buffer: log -- Add: Command :GitEdit to quickly jump to configuration files. -- Change: The status buffer can handle renamed files. -- Improve syntax highlighting. -- Minor changes. - - -RELEASE NOTES FOR OLDER VERSIONS ----------------------------------------------------------------------- --> see file 'git-support/doc/ChangeLog' - - --------------------------------------------------------------------------------- - -KNOWN ISSUES -================================================================================ - -* Windows: When entered on the Vim command line, commands containing filenames - as parameters cause errors such as "... file not found ...". - - This may happen if filenames contain special characters such as spaces. The - Vim command line escapes those differently then Windows expects then to be - escaped. - - However, a filename containing spaces can always be escape using quotes: - :GitAdd "help 1.txt" - - If you already are in the corresponding buffer, simply use: - :GitAdd - - --------------------------------------------------------------------------------- - -FILES -================================================================================ - - README.md - This file. - - doc/gitsupport.txt - The help file for Git Support. - - plugin/git-support.vim - The Git plug-in for Vim/gVim. - - syntax/gitsbranch.vim - syntax/gitscommit.vim - syntax/gitsdiff.vim - syntax/gitslog.vim - syntax/gitssshort.vim - syntax/gitsstatus.vim - The syntax files used by Git Support. gitssshort.vim - is used for the output of "git status --short". - gitscommit.vim is used for commit messages. - -___The following files and extensions are for convenience only.___ -___git-support.vim will work without them.___ -___The settings are explained in the files themselves.___ - - git-support/doc/ChangeLog - Complete change log. - - git-support/rc/additions.gvimrc - Additional settings for use in .gvimrc: - hot keys, mouse settings, fonts, ... - - git-support/rc/additions.vimrc - Example settings for use in .vimrc: - setup of the plug-in, syntax highlighting - - git-support/rc/customization.gvimrc - Suggestion for the configuration file .gvimrc: - hot keys, mouse settings, fonts, ... - - git-support/rc/customization.vimrc - Suggestion for the configuration file .vimrc: - hot keys, tabstop, use of dictionaries, - the setup of the plug-in, ... - - --------------------------------------------------------------------------------- - -CREDITS -================================================================================ - -For a complete list of people who made contributions to this plug-in, -please be so kind as to take a look at the credits: - - :help gitsupport-credits - diff --git a/git-support/README.standalone.md b/git-support/README.standalone.md deleted file mode 100644 index fb54a6c..0000000 --- a/git-support/README.standalone.md +++ /dev/null @@ -1,11 +0,0 @@ -Preface -================================================================================ - -This repository is mainly for the use with plug-in managers. - -The development happens here: -[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) - - --------------------------------------------------------------------------------- - diff --git a/git-support/data/options.txt b/git-support/data/options.txt deleted file mode 100644 index c6f3500..0000000 --- a/git-support/data/options.txt +++ /dev/null @@ -1,214 +0,0 @@ -branch - --abbrev= - --all - --contains - -D - --delete - --edit-description - --force - --list - -M - --merged - --move - --no-abbrev - --no-merged - --no-track - --remotes - --set-upstream - --track - --verbose -commit - --all - --allow-empty - --allow-empty-message - --amend - --author - --cleanup - --date - --dry-run - --edit - --file - --include - --message - --no-status - --no-verify - --only - --quiet - --reedit-message - --reset-author - --reuse-message - --signoff - --status - --template - --untracked-files - --verbose -diff - --abbrev= - --binary - --break-rewrites - --cached - --check - --color-words - --diff-filter= - --dirstat - --find-copies - --find-copies-harder - --find-renames - --full-index - --function-context - --histogram - --ignore-all-space - --ignore-space-at-eol - --ignore-space-change - --ignore-submodules - --inter-hunk-context= - --irreversible-delete - --minimal - --name-only - --name-status - --no-renames - --numstat - --patch - --patch-with-raw - --patch-with-stat - --patience - --pickaxe-all - --pickaxe-regex - --raw - --relative - --shortstat - --stat - --submodule - --summary - --unified= -log - --abbrev-commit - --after - --all - --all-match - --author - --before - --bisect - --boundary - --branches - --cherry - --cherry-mark - --cherry-pick - --children - --committer - --date - --date-order - --decorate - --encoding - --extended-regexp - --first-parent - --fixed-strings - --follow - --full-diff - --glob - --graph - --grep - --ignore-missing - --left-only - --left-right - --max-count - --max-parents - --merge - --merges - --min-parents - --no-abbrev-commit - --no-decorate - --no-max-parents - --no-merges - --no-min-parents - --no-notes - --not - --notes - --oneline - --parents - --pretty=email - --pretty=format: - --pretty=full - --pretty=fuller - --pretty=medium - --pretty=oneline - --pretty=raw - --pretty=short - --regexp-ignore-case - --relative-date - --remotes - --remove-empty - --reverse - --right-only - --show-notes - --since - --skip - --source - --stat - --tags - --topo-order - --until - --walk-reflogs -remote - add - prune - rename - rm - set-branches - set-head - set-url - show - update - --no-tags - --tags - --verbose -show - --abbrev-commit - --encoding - --no-abbrev-commit - --no-notes - --notes - --oneline - --pretty=email - --pretty=format: - --pretty=full - --pretty=fuller - --pretty=medium - --pretty=oneline - --pretty=raw - --pretty=short - --show-notes - --stat -stash - apply - branch - clear - create - drop - list - pop - save - show - --all - --include-untracked - --index - --keep-index - --no-keep-index - --patch -tag - --annotate - --contains - --delete - --file - --force - --list - --local-user - --sign - --verify -k - --all - --max-count= - --merge - --select-commit= - --since= - --until= diff --git a/git-support/doc/ChangeLog b/git-support/doc/ChangeLog deleted file mode 100644 index b0b7280..0000000 --- a/git-support/doc/ChangeLog +++ /dev/null @@ -1,61 +0,0 @@ --------------------------------------------------------------------------------- - RELEASE NOTES FOR VERSION 0.9.3 --------------------------------------------------------------------------------- -- Add: The diff buffer can be use to add/reset chunks, added new maps. -- Add: Extended command-line completion to handle options for Git commands. -- Add: New maps for the buffer: log -- Add: Command :GitEdit to quickly jump to configuration files. -- Change: The status buffer can handle renamed files. -- Improve syntax highlighting. -- Minor changes. - --------------------------------------------------------------------------------- - RELEASE NOTES FOR VERSION 0.9.2 --------------------------------------------------------------------------------- -- Added: Command :GitBash for running interactive Git commands. -- Added: Command :GitSlist as a shorthand for ":GitStash list". -- Added: New maps for the buffers: branch, remote, stash, tag -- Added: New maps for the buffer: status -- Added: New setting g:Git_BinPath, to set the path to the executables. -- Added: Command-line completion for subcommands, branches, remotes, tags. -- Changed: :GitShow shows different objects in an according way. -- Changed: :GitCommitFile updates the file before committing. -- Changed: :GitHelp shows man page text with appropriate width. -- Changed: :GitStatus can be restricted to a path by passing it as an argument. -- Changed: :GitStatus respects the option 'status.relativePaths'. -- Changed: :GitStatus can work with changes introduced by Git version 1.8.5. -- Changed: Calling :GitCheckout and :GitReset without arguments - (see g:Git_CheckoutExpandEmpty and g:Git_ResetExpandEmpty). -- Fixed: Jumping to files was still not working correctly. -- Fixed: Better compatibility with custom mappings - (use "normal!", "noremap" and "noremenu" consistently). -- Improved syntax highlighting. -- Minor changes. - --------------------------------------------------------------------------------- - RELEASE NOTES FOR VERSION 0.9.1 --------------------------------------------------------------------------------- -- Added: New maps for the buffers: blame, diff and status -- Changed: Commands which open a file will jump to its window, if one exists. -- Changed: Opening a diff in the status buffer (see g:Git_StatusStagedOpenDiff). -- Changed: Calling :GitDiff without arguments (see g:Git_DiffExpandEmpty). -- Added: Command :GitGrep and :GitGrepTop. -- Added: Command :GitMergeUpstream. -- Added: Custom menu (see g:Git_CustomMenu). -- Added: Cmd. line completion for :GitHelp. -- Added: Command :GitBlame supports ranges. -- Fixed: Jumping from the status buffer to a file did not work when the working - directory changed. -- Changed: After jumping to a file/buffer, open all folds under the cursor (see - g:Git_OpenFoldAfterJump). -- Changed: Default executables for Windows. -- Added: Command :GitK. -- Added: Settings g:Git_GitKExecutable and g:Git_GitKScript. -- Improved syntax highlighting. -- Minor bugfixes and improvements. - --------------------------------------------------------------------------------- - RELEASE NOTES FOR VERSION 0.9 --------------------------------------------------------------------------------- -- Initial release. - diff --git a/git-support/git-doc/commands.txt b/git-support/git-doc/commands.txt deleted file mode 100644 index 4568064..0000000 --- a/git-support/git-doc/commands.txt +++ /dev/null @@ -1,147 +0,0 @@ -add -add--interactive -am -annotate -apply -archive -bisect -bisect--helper -blame -branch -bundle -cat-file -check-attr -checkout -checkout-index -check-ref-format -cherry -cherry-pick -citool -clean -clone -commit -commit-tree -config -count-objects -credential-cache -credential-cache--daemon -credential-store -daemon -describe -diff -diff-files -diff-index -difftool -difftool--helper -diff-tree -fast-export -fast-import -fetch -fetch-pack -filter-branch -fmt-merge-msg -for-each-ref -format-patch -fsck -fsck-objects -gc -get-tar-commit-id -grep -gui -gui--askpass -hash-object -help -http-backend -http-fetch -http-push -imap-send -index-pack -init -init-db -instaweb -log -lost-found -ls-files -ls-remote -ls-tree -mailinfo -mailsplit -merge -merge-base -merge-file -merge-index -merge-octopus -merge-one-file -merge-ours -merge-recursive -merge-resolve -merge-subtree -mergetool -merge-tree -mktag -mktree -mv -name-rev -notes -pack-objects -pack-redundant -pack-refs -patch-id -peek-remote -prune -prune-packed -pull -push -quiltimport -read-tree -rebase -receive-pack -reflog -relink -remote -remote-ext -remote-fd -remote-ftp -remote-ftps -remote-http -remote-https -remote-testgit -repack -replace -repo-config -request-pull -rerere -reset -revert -rev-list -rev-parse -rm -send-pack -shell -sh-i18n--envsubst -shortlog -show -show-branch -show-index -show-ref -stage -stash -status -stripspace -submodule -symbolic-ref -tag -tar-tree -unpack-file -unpack-objects -update-index -update-ref -update-server-info -upload-archive -upload-pack -var -verify-pack -verify-tag -web--browse -whatchanged -write-tree diff --git a/git-support/git-doc/compile_changelog.lua b/git-support/git-doc/compile_changelog.lua deleted file mode 100644 index caaa748..0000000 --- a/git-support/git-doc/compile_changelog.lua +++ /dev/null @@ -1,28 +0,0 @@ --- --------------------------------------------------------------------------------- --- FILE: compile_changelog.lua --- USAGE: lua compile_changelog.lua --- DESCRIPTION: --- OPTIONS: --- --- REQUIREMENTS: --- --- BUGS: --- --- NOTES: --- --- AUTHOR: Wolfgang Mehner (WM), <wolfgang-mehner@web.de> --- COMPANY: --- VERSION: 1.0 --- CREATED: 2012-10-13 14:49:54 CEST --- REVISION: --- --------------------------------------------------------------------------------- --- - -local ifs = io.popen ( 'ls -v /usr/share/doc/git/RelNotes/*.txt' ) - -local filename = 'changelog.txt' - -for file in ifs:lines() do - os.execute ( 'cat '..file..' >> '..filename ) - os.execute ( 'echo "" >> '..filename ) -end - -os.execute ( 'gzip '..filename ) - diff --git a/git-support/git-doc/help_topics.txt b/git-support/git-doc/help_topics.txt deleted file mode 100644 index a3fb219..0000000 --- a/git-support/git-doc/help_topics.txt +++ /dev/null @@ -1,155 +0,0 @@ -add -am -annotate -apply -archive -attributes -bisect -blame -branch -bundle -cat-file -check-attr -checkout -checkout-index -check-ref-format -cherry -cherry-pick -citool -clean -cli -clone -commit -commit-tree -config -core-tutorial -count-objects -credential-cache -credential-store -cvs-migration -daemon -describe -diff -diffcore -diff-files -diff-index -difftool -diff-tree -fast-export -fast-import -fetch -fetch-pack -filter-branch -fmt-merge-msg -for-each-ref -format-patch -fsck -fsck-objects -gc -get-tar-commit-id -gitk -glossary -grep -gui -hash-object -help -hooks -http-backend -http-fetch -http-push -ignore -imap-send -index-pack -init -init-db -instaweb -log -lost-found -ls-files -ls-remote -ls-tree -mailinfo -mailsplit -merge -merge-base -merge-file -merge-index -merge-octopus -merge-one-file -merge-ours -merge-recursive -merge-resolve -merge-subtree -mergetool -merge-tree -mktag -mktree -modules -mv -name-rev -namespaces -notes -pack-objects -pack-redundant -pack-refs -patch-id -peek-remote -prune -prune-packed -pull -push -quiltimport -read-tree -rebase -receive-pack -reflog -relink -remote -remote-ext -remote-fd -remote-ftp -remote-ftps -remote-http -remote-https -remote-testgit -repack -replace -repo-config -repository-layout -request-pull -rerere -reset -revert -rev-list -rev-parse -rm -send-pack -shell -shortlog -show -show-branch -show-index -show-ref -stage -stash -status -stripspace -submodule -symbolic-ref -tag -tar-tree -tutorial -tutorial-2 -unpack-file -unpack-objects -update-index -update-ref -update-server-info -upload-archive -upload-pack -var -verify-pack -verify-tag -whatchanged -workflows -write-tree diff --git a/git-support/rc/additions.gvimrc b/git-support/rc/additions.gvimrc deleted file mode 100644 index 0e96202..0000000 --- a/git-support/rc/additions.gvimrc +++ /dev/null @@ -1,31 +0,0 @@ -"------------------------------------------------------------------------------- -" Moving cursor to other windows: -" shift-down : change window focus to lower one (cyclic) -" shift-up : change window focus to upper one (cyclic) -" shift-left : change window focus to one on left -" shift-right : change window focus to one on right -"------------------------------------------------------------------------------- -nnoremap <s-down> <c-w>w -nnoremap <s-up> <c-w>W -nnoremap <s-left> <c-w>h -nnoremap <s-right> <c-w>l -" -"------------------------------------------------------------------------------- -" Some additional hot keys: -" shift-F3 : call gvim file browser -"------------------------------------------------------------------------------- - noremap <silent> <s-F3> :silent browse confirm e<CR> -inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" -"------------------------------------------------------------------------------- -" toggle insert mode <--> normal mode with the <RightMouse>-key -"------------------------------------------------------------------------------- -nnoremap <RightMouse> <Insert> -inoremap <RightMouse> <ESC> -" -"------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets: ()[]{} -"------------------------------------------------------------------------------- -set guifont=Monospace\ 11 -"set guifont=Luxi\ Mono\ 14 -" diff --git a/git-support/rc/additions.vimrc b/git-support/rc/additions.vimrc deleted file mode 100644 index c3ad4a4..0000000 --- a/git-support/rc/additions.vimrc +++ /dev/null @@ -1,66 +0,0 @@ -"------------------------------------------------------------------------------- -" Git-Support -"------------------------------------------------------------------------------- -" -" the settings are documented here: -" :help gitsupport-configuration -" the syntax highlighting is documented here: -" :help gitsupport-syntax -" -"------------------------------------------------------------------------------- -" -"let g:Git_Executable = 'LANG=en_US git' -" -"let g:Git_LoadMenus = 'yes' -"let g:Git_RootMenu = '&Git' -" -"" open the status window -" noremap <silent> <F10> :GitStatus<CR> -"inoremap <silent> <F10> <C-C>:GitStatus<CR> -" -"" cmd-line completion -"" (use ctrl+s for commands, since we do not want to remap ctrl+c, -"" "s" stands for Git 's'ubcommands) -"let g:Git_MapCompleteBranch = '<c-b>' -"let g:Git_MapCompleteCommand = '<c-s>' -"let g:Git_MapCompleteRemote = '<c-r>' -"let g:Git_MapCompleteTag = '<c-t>' -" -" syntax highlighting (bright background) -" -"highlight GitComment -highlight GitHeading cterm=bold gui=bold -highlight GitHighlight1 ctermfg=Green guifg=DarkGreen -highlight GitHighlight2 ctermfg=DarkYellow guifg=DarkYellow -highlight GitHighlight3 cterm=bold ctermfg=Cyan gui=bold guifg=DarkCyan -"highlight GitWarning -highlight GitAdd ctermfg=Green guifg=SeaGreen -highlight GitRemove ctermfg=Red guifg=Red -highlight GitConflict cterm=bold ctermfg=White ctermbg=Red gui=bold guifg=White guibg=Red -" -"" syntax highlighting (dark background) -"" -""highlight GitComment -"highlight GitHeading cterm=bold gui=bold -"highlight GitHighlight1 ctermfg=Green guifg=Green -"highlight GitHighlight2 ctermfg=Yellow guifg=Yellow -"highlight GitHighlight3 cterm=bold ctermfg=Cyan gui=bold guifg=Cyan -""highlight GitWarning -"highlight GitAdd ctermfg=Green guifg=Green -"highlight GitRemove ctermfg=Red guifg=Red -"highlight GitConflict cterm=bold ctermfg=White ctermbg=Red gui=bold guifg=White guibg=Red -" -"" custom menu -"let g:Git_CustomMenu = [ -" \ [ '&grep, word under cursor', ':GitGrepTop', ':GitGrepTop <WORD><EXECUTE>' ], -" \ [ '&grep, version x..y', ':GitGrepTop', ':GitGrepTop -i "Version[^[:digit:]]\+<CURSOR>"' ], -" \ [ '-SEP1-', '', '' ], -" \ [ '&log, grep commit msg..', ':GitLog', ':GitLog -i --grep="<CURSOR>"' ], -" \ [ '&log, grep diff word', ':GitLog', ':GitLog -p -S "<CURSOR>"' ], -" \ [ '&log, grep diff line', ':GitLog', ':GitLog -p -G "<CURSOR>"' ], -" \ [ '-SEP2-', '', '' ], -" \ [ '&merge, fast-forward only', ':GitMerge', ':GitMerge --ff-only <CURSOR>' ], -" \ [ '&merge, no commit', ':GitMerge', ':GitMerge --no-commit <CURSOR>' ], -" \ [ '&merge, abort', ':GitMerge', ':GitMerge --abort<EXECUTE>' ], -" \ ] -" diff --git a/git-support/rc/customization.gvimrc b/git-support/rc/customization.gvimrc deleted file mode 100644 index d0794a5..0000000 --- a/git-support/rc/customization.gvimrc +++ /dev/null @@ -1,54 +0,0 @@ -"=================================================================================== -" FILE: .gvimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc -" AUTHOR: Wolfgang Mehner -" VERSION: 1.0 -" CREATED: 20.03.2013 -" REVISION: -"=================================================================================== -" -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== -" -set cmdheight=2 " make command line two lines high -set mousehide " hide the mouse when typing text -" -highlight Normal guibg=grey90 -highlight Cursor guibg=Blue guifg=NONE -highlight lCursor guibg=Cyan guifg=NONE -highlight NonText guibg=grey80 -highlight Constant gui=NONE guibg=grey95 -highlight Special gui=NONE guibg=grey95 -" -"------------------------------------------------------------------------------- -" Moving cursor to other windows: -" shift-down : change window focus to lower one (cyclic) -" shift-up : change window focus to upper one (cyclic) -" shift-left : change window focus to one on left -" shift-right : change window focus to one on right -"------------------------------------------------------------------------------- -nnoremap <s-down> <c-w>w -nnoremap <s-up> <c-w>W -nnoremap <s-left> <c-w>h -nnoremap <s-right> <c-w>l -" -"------------------------------------------------------------------------------- -" Some additional hot keys: -" shift-F3 : call gvim file browser -"------------------------------------------------------------------------------- - noremap <silent> <s-F3> :silent browse confirm e<CR> -inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" -"------------------------------------------------------------------------------- -" toggle insert mode <--> normal mode with the <RightMouse>-key -"------------------------------------------------------------------------------- -nnoremap <RightMouse> <Insert> -inoremap <RightMouse> <ESC> -" -"------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets: ()[]{} -"------------------------------------------------------------------------------- -set guifont=Monospace\ 11 -"set guifont=Luxi\ Mono\ 14 -" diff --git a/git-support/rc/customization.vimrc b/git-support/rc/customization.vimrc deleted file mode 100644 index fab0a7e..0000000 --- a/git-support/rc/customization.vimrc +++ /dev/null @@ -1,240 +0,0 @@ -"=================================================================================== -" FILE: .vimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc -" AUTHOR: Wolfgang Mehner -" VERSION: 1.0 -" CREATED: 20.03.2013 -" REVISION: -"=================================================================================== -" -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" Use Vim settings, rather then Vi settings. -" This must be first, because it changes other options as a side effect. -"------------------------------------------------------------------------------- -set nocompatible -" -"------------------------------------------------------------------------------- -" Enable file type detection. Use the default filetype settings. -" Also load indent files, to automatically do language-dependent indenting. -"------------------------------------------------------------------------------- -filetype plugin on -filetype indent on -" -"------------------------------------------------------------------------------- -" Switch syntax highlighting on. -"------------------------------------------------------------------------------- -syntax on -" -"------------------------------------------------------------------------------- -" Platform specific items: -" - central backup directory (has to be created) -" - default dictionary -" Uncomment your choice. -" -" Using a backupdir under UNIX/Linux: you may want to include a line similar to: -" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; -" in one of your shell startup files (e.g. $HOME/.profile). -"------------------------------------------------------------------------------- -if has("win16") || has("win32") || has("win64") || - \ has("win95") || has("win32unix") -" runtime mswin.vim -" set backupdir =$VIM\vimfiles\backupdir -" set dictionary=$VIM\vimfiles\wordlists/german.list -else -" set backupdir =$HOME/.vim.backupdir -" set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list -endif -" -"------------------------------------------------------------------------------- -" Various settings -"------------------------------------------------------------------------------- -set autoindent " copy indent from current line -set autoread " read open files again when changed outside Vim -set autowrite " write a modified buffer on each :next , ... -set backspace=indent,eol,start " backspacing over everything in insert mode -set backup " keep a backup file -set browsedir=current " which directory to use for the file browser -set complete+=k " scan the files given with the 'dictionary' option -set history=50 " keep 50 lines of command line history -set hlsearch " highlight the last used search pattern -set incsearch " do incremental searching -set listchars=tab:>.,eol:\$ " strings to use in 'list' mode -set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines -set popt=left:8pc,right:3pc " print options -set ruler " show the cursor position all the time -set shiftwidth=2 " number of spaces to use for each step of indent -set showcmd " display incomplete commands -set smartindent " smart autoindenting when starting a new line -set tabstop=2 " number of spaces that a <Tab> counts for -set visualbell " visual bell instead of beeping -set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions -set wildmenu " command-line completion in an enhanced mode -" -"------------------------------------------------------------------------------- -" Highlight paired brackets -"------------------------------------------------------------------------------- -highlight MatchParen ctermbg=blue guibg=lightyellow -" -"=================================================================================== -" BUFFERS and WINDOWS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" Change the working directory to the directory containing the current file -"------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufEnter * :lchdir %:p:h -endif -" -"------------------------------------------------------------------------------- -" Fast switching between buffers -" The current buffer will be saved before switching to the next one. -" Choose :bprevious or :bnext -"------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" -"------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q: Write all changed buffers and exit Vim -"------------------------------------------------------------------------------- -nnoremap <C-q> :wqall<CR> -" -"=================================================================================== -" HOT KEYS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" F2 - write file without confirmation -" F3 - call file explorer Ex -" F4 - show tag under curser in the preview window (tagfile must exist!) -" F5 - show the current list of errors -" F6 - close the quickfix window (error list) -" F7 - display previous error -" F8 - display next error -" F12 - list buffers and edit n-th buffer -"------------------------------------------------------------------------------- -" -noremap <silent> <F2> :write<CR> -noremap <silent> <F3> :Explore<CR> -noremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> -noremap <silent> <F5> :copen<CR> -noremap <silent> <F6> :cclose<CR> -noremap <silent> <F7> :cprevious<CR> -noremap <silent> <F8> :cnext<CR> -noremap <F12> :ls<CR>:edit # -" -inoremap <silent> <F2> <C-C>:write<CR> -inoremap <silent> <F3> <C-C>:Explore<CR> -inoremap <silent> <F4> <C-C>:execute ":ptag ".expand("<cword>")<CR> -inoremap <silent> <F5> <C-C>:copen<CR> -inoremap <silent> <F6> <C-C>:cclose<CR> -inoremap <silent> <F7> <C-C>:cprevious<CR> -inoremap <silent> <F8> <C-C>:cnext<CR> -inoremap <F12> <C-C>:ls<CR>:edit # -" -"------------------------------------------------------------------------------- -" autocomplete parenthesis, brackets and braces -"------------------------------------------------------------------------------- -inoremap ( ()<Left> -inoremap [ []<Left> -inoremap { {}<Left> -" -" surround content -vnoremap ( s()<Esc>P<Right>% -vnoremap [ s[]<Esc>P<Right>% -vnoremap { s{}<Esc>P<Right>% -" -" surround content with additional spaces -vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% -vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% -vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% -" -"------------------------------------------------------------------------------- -" autocomplete quotes -"------------------------------------------------------------------------------- -" -inoremap '' ''<Left> -inoremap "" ""<Left> -" -" surround content (visual and select mode) -xnoremap ' s''<Esc>P<Right> -xnoremap " s""<Esc>P<Right> -xnoremap ` s``<Esc>P<Right> -" -"=================================================================================== -" VARIOUS PLUGIN CONFIGURATIONS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" Git-Support -"------------------------------------------------------------------------------- -" -" the settings are documented here: -" :help gitsupport-configuration -" the syntax highlighting is documented here: -" :help gitsupport-syntax -" -"------------------------------------------------------------------------------- -" -"let g:Git_Executable = 'LANG=en_US git' -" -"let g:Git_LoadMenus = 'yes' -"let g:Git_RootMenu = '&Git' -" -"" open the status window -" noremap <silent> <F10> :GitStatus<CR> -"inoremap <silent> <F10> <C-C>:GitStatus<CR> -" -"" cmd-line completion -"" (use ctrl+s for commands, since we do not want to remap ctrl+c, -"" "s" stands for Git 's'ubcommands) -"let g:Git_MapCompleteBranch = '<c-b>' -"let g:Git_MapCompleteCommand = '<c-s>' -"let g:Git_MapCompleteRemote = '<c-r>' -"let g:Git_MapCompleteTag = '<c-t>' -" -" syntax highlighting (bright background) -" -"highlight GitComment -highlight GitHeading cterm=bold gui=bold -highlight GitHighlight1 ctermfg=Green guifg=DarkGreen -highlight GitHighlight2 ctermfg=DarkYellow guifg=DarkYellow -highlight GitHighlight3 cterm=bold ctermfg=Cyan gui=bold guifg=DarkCyan -"highlight GitWarning -highlight GitAdd ctermfg=Green guifg=SeaGreen -highlight GitRemove ctermfg=Red guifg=Red -highlight GitConflict cterm=bold ctermfg=White ctermbg=Red gui=bold guifg=White guibg=Red -" -"" syntax highlighting (dark background) -"" -""highlight GitComment -"highlight GitHeading cterm=bold gui=bold -"highlight GitHighlight1 ctermfg=Green guifg=Green -"highlight GitHighlight2 ctermfg=Yellow guifg=Yellow -"highlight GitHighlight3 cterm=bold ctermfg=Cyan gui=bold guifg=Cyan -""highlight GitWarning -"highlight GitAdd ctermfg=Green guifg=Green -"highlight GitRemove ctermfg=Red guifg=Red -"highlight GitConflict cterm=bold ctermfg=White ctermbg=Red gui=bold guifg=White guibg=Red -" -"" custom menu -"let g:Git_CustomMenu = [ -" \ [ '&grep, word under cursor', ':GitGrepTop', ':GitGrepTop <WORD><EXECUTE>' ], -" \ [ '&grep, version x..y', ':GitGrepTop', ':GitGrepTop -i "Version[^[:digit:]]\+<CURSOR>"' ], -" \ [ '-SEP1-', '', '' ], -" \ [ '&log, grep commit msg..', ':GitLog', ':GitLog -i --grep="<CURSOR>"' ], -" \ [ '&log, grep diff word', ':GitLog', ':GitLog -p -S "<CURSOR>"' ], -" \ [ '&log, grep diff line', ':GitLog', ':GitLog -p -G "<CURSOR>"' ], -" \ [ '-SEP2-', '', '' ], -" \ [ '&merge, fast-forward only', ':GitMerge', ':GitMerge --ff-only <CURSOR>' ], -" \ [ '&merge, no commit', ':GitMerge', ':GitMerge --no-commit <CURSOR>' ], -" \ [ '&merge, abort', ':GitMerge', ':GitMerge --abort<EXECUTE>' ], -" \ ] -" diff --git a/latex-support/README.md b/latex-support/README.md index 5dea02c..382767f 100644 --- a/latex-support/README.md +++ b/latex-support/README.md @@ -1,4 +1,4 @@ -README for latex-support.vim (Version 1.3alpha) / July 28 2017 +README for latex-support.vim (Version 2.0beta) / November 22 2020 ================================================================================ * INSTALLATION @@ -7,14 +7,14 @@ README for latex-support.vim (Version 1.3alpha) / July 28 2017 * ADDITIONAL TIPS * CREDITS -LaTeX Support implements an LaTeX-IDE for Vim/gVim. It has been written to -considerably speed up writing code in a consistent style. This is done by +LaTeX Support implements an LaTeX-IDE for Vim/gVim/Neovim. It has been written +to considerably speed up writing code in a consistent style. This is done by inserting complete statements, comments, idioms, and code snippets. There are many additional hints and options which can improve speed and comfort when writing LaTeX. See the help file latexsupport.txt for more information. -This plugin can be used with Vim version 7.x. +This plug-in can be used with Vim version 7.4+ and Neovim 0.2.1+. -------------------------------------------------------------------------------- @@ -25,7 +25,7 @@ INSTALLATION A system-wide installation for all users can also be done. This will have further effects on how the plug-in works. For a step-by-step instruction, as well as an explanation of the other consequences, please see the help file -'doc/latexsupport.txt' or look up the documentation via: +`doc/latexsupport.txt` or look up the documentation via: :help latexsupport-system-wide @@ -33,14 +33,14 @@ well as an explanation of the other consequences, please see the help file (1) LINUX ---------------------------------------------------------------------- -The subdirectories in the zip archive latex-support.zip mirror the directory -structure which is needed below the local installation directory $HOME/.vim/ -(find the value of $HOME with `:echo $HOME` from inside Vim). +The subdirectories in the zip archive `latex-support.zip` mirror the directory +structure which is needed below the local installation directory `$HOME/.vim/` +(find the value of `$HOME` with `:echo $HOME` from inside Vim). -(1.0) Save the template files in '$HOME/.vim/latex-support/templates/Templates' if - you have changed any of them. +(1.0) Save the template files in `$HOME/.vim/latex-support/templates/Templates` + if you have changed any of them. -(1.1) Copy the zip archive latex-support.zip to $HOME/.vim and run +(1.1) Copy the zip archive `latex-support.zip` to `$HOME/.vim` and run unzip latex-support.zip @@ -50,19 +50,24 @@ structure which is needed below the local installation directory $HOME/.vim/ $HOME/.vim/doc/... $HOME/.vim/plugin/latex-support.vim -(1.2) Loading of plugin files must be enabled. If not use +(1.2) Loading of plug-in files must be enabled. If not use :filetype plugin on - This is the minimal content of the file '$HOME/.vimrc'. Create one if there - is none or use the files in $HOME/.vim/latex-support/rc as a starting point. + This is the minimal content of the file `$HOME/.vimrc`. Create one if there + is none or use the files in `$HOME/.vim/latex-support/rc` as a starting point. -(1.3) Set at least some personal details. Use the map \ntw inside a LaTeX buffer +(1.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME/.vim/doc/ + +(1.4) Set at least some personal details. Use the map \ntw inside a LaTeX buffer or the menu entry: LaTeX -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): @@ -71,33 +76,28 @@ structure which is needed below the local installation directory $HOME/.vim/ SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/.vim/templates/latex.templates to customize or add to your - LaTeX template library. It can also be set up via the wizard. - - (Read more about the template system in the plugin documentation) - -(1.4) Make the plugin help accessible by typing the following command on the - Vim command line: + Use the file `$HOME/.vim/templates/latex.templates` to customize or add to + your LaTeX template library. It can also be set up via the wizard. - :helptags $HOME/.vim/doc/ + (Read more about the template system in the plug-in documentation) -(1.5) Consider additional settings in the file '$HOME/.vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your .vimrc and .gvimrc. You may want to use parts of them. The files - are documented. +(1.5) Consider additional settings in the file `$HOME/.vimrc`. The files + `customization.vimrc` and `customization.gvimrc` are replacements or + extensions for your `.vimrc` and `.gvimrc`. You may want to use parts of + them. The files are documented. (2) WINDOWS ---------------------------------------------------------------------- -The subdirectories in the zip archive latex-support.zip mirror the directory -structure which is needed below the local installation directory $HOME/vimfiles/ -(find the value of $HOME with ":echo $HOME" from inside Vim). +The subdirectories in the zip archive `latex-support.zip` mirror the directory +structure which is needed below the local installation directory `$HOME/vimfiles/` +(find the value of `$HOME` with `:echo $HOME` from inside Vim). -(2.0) Save the template files in '$HOME/vimfiles/latex-support/templates/Templates' if - you have changed any of them. +(2.0) Save the template files in `$HOME/vimfiles/latex-support/templates/Templates` + if you have changed any of them. -(2.1) Copy the zip archive latex-support.zip to $HOME/vimfiles and run +(2.1) Copy the zip archive `latex-support.zip` to `$HOME/vimfiles` and run unzip latex-support.zip @@ -107,19 +107,24 @@ structure which is needed below the local installation directory $HOME/vimfiles/ $HOME/vimfiles/doc/... $HOME/vimfiles/plugin/latex-support.vim -(2.2) Loading of plugin files must be enabled. If not use +(2.2) Loading of plug-in files must be enabled. If not use :filetype plugin on - This is the minimal content of the file '$HOME/_vimrc'. Create one if there - is none or use the files in $HOME/vimfiles/latex-support/rc as a starting point. + This is the minimal content of the file `$HOME/_vimrc`. Create one if there + is none or use the files in `$HOME/vimfiles/latex-support/rc` as a starting point. -(2.3) Set at least some personal details. Use the map \ntw inside a LaTeX buffer +(2.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME\vimfiles\doc\ + +(2.4) Set at least some personal details. Use the map \ntw inside a LaTeX buffer or the menu entry: LaTeX -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): @@ -128,20 +133,15 @@ structure which is needed below the local installation directory $HOME/vimfiles/ SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/vimfiles/templates/latex.templates to customize or add to + Use the file `$HOME/vimfiles/templates/latex.templates` to customize or add to your LaTeX template library. It can also be set up via the wizard. - (Read more about the template system in the plugin documentation) - -(2.4) Make the plugin help accessible by typing the following command on the - Vim command line: - - :helptags $HOME\vimfiles\doc\ + (Read more about the template system in the plug-in documentation) -(2.5) Consider additional settings in the file '$HOME/_vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your _vimrc and _gvimrc. You may want to use parts of them. The files - are documented. +(2.5) Consider additional settings in the file `$HOME/_vimrc`. The files + `customization.vimrc` and `customization.gvimrc` are replacements or + extensions for your `_vimrc` and `_gvimrc`. You may want to use parts of + them. The files are documented. (3) ADDITIONAL REMARKS @@ -151,21 +151,14 @@ There are a lot of features and options which can be used and influenced: * use of template files and macros * using and managing personal code snippets - * using additional plugins + * using additional plug-ins -Look at the LaTeX-Support help with: +Actions differ for different modes. Please read the documentation: :help latexsupport - +-----------------------------------------------+ - | +-------------------------------------------+ | - | | ** PLEASE READ THE DOCUMENTATION ** | | - | | Actions differ for different modes! | | - | +-------------------------------------------+ | - +-----------------------------------------------+ - Any problems? See the TROUBLESHOOTING section at the end of the help file -'doc/latexsupport.txt'. +`doc/latexsupport.txt`. -------------------------------------------------------------------------------- @@ -173,11 +166,12 @@ Any problems? See the TROUBLESHOOTING section at the end of the help file RELEASE NOTES ================================================================================ -RELEASE NOTES FOR VERSION 1.3alpha +RELEASE NOTES FOR VERSION 2.0beta ---------------------------------------------------------------------- +- Adapt for running under Neovim more smoothly. - Add commands :Latex, :LatexCheck, :LatexMakeindex, and :LatexBibtex to run the external commands. -- Add command :LatexMakeglossaries to run 'makeglossaries'. +- Add command :LatexMakeglossaries to run `makeglossaries`. - Add command :LatexView to start external viewers. - Add command :LatexConvert to convert documents. - Add command :LatexMainDoc to set the document for typesetting, viewing, ... @@ -187,26 +181,27 @@ RELEASE NOTES FOR VERSION 1.3alpha - Add command :LatexErrors and map ´re to view errors from background processing in quickfix. - BibTeX errors are recognized by quickfix. -- Add a converter 'eps-pdf'. +- Add a conversion 'eps-pdf'. - The templates which are inserted into new files as file skeletons can be specified in the templates library, via the property: - Latex::FileSkeleton::Script -- Add configuration variables 'g:Latex_Ctrl_j' and 'g:Latex_Ctrl_d' to control - the creation of the CTRL+J and CTRL+D maps. + `Latex::FileSkeleton::Script` +- Add configuration variables `g:Latex_Ctrl_j` and `g:Latex_Ctrl_d` to control + the creation of the `CTRL+J` and `CTRL+D` maps. +- Remove `g:Latex_CreateMenusDelayed`, use `g:Latex_LoadMenus` instead. - Improve templates. (Includes the removal of some templates!) -- Move the filetype plug-ins for tex and make to 'latex-support/rc'. -- Remove the definition of the maps 'CTRL+F9' and 'ALT+F9'. Add them to your +- Move the filetype plug-ins for tex and make to `latex-support/rc`. +- Remove the definition of the maps `CTRL+F9` and `ALT+F9`. Add them to your filetype plug-ins if you want to use them. - Minor bugfixes. Note: The filetype plug-ins have been moved, and are thus not loaded -automatically anymore. Copy them from 'latex-support/rc' to 'ftplugin' or add -the commands there to your own filetype plug-ins. +automatically anymore. Copy them from `latex-support/rc` to `ftplugin`, +or add the commands there to your own filetype plug-ins. RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- --> see file 'latex-support/doc/ChangeLog' +-> see file `latex-support/doc/ChangeLog` -------------------------------------------------------------------------------- @@ -230,7 +225,7 @@ FILES The help files for the toolbox. plugin/latex-support.vim - The LaTeX plug-in for Vim/gVim. + The LaTeX plug-in for Vim/gVim/Neovim. latex-support/codesnippets/* Some LaTeX code snippets as a starting point. @@ -288,14 +283,6 @@ ___The settings are explained in the files themselves.___ CREDITS ================================================================================ -Fritz Mehner thanks: ----------------------------------------------------------------------- - -Many thanks to Wolfgang Mehner (wolfgang-mehner at web.de) for is template -engine Template Support. - -Wolfgang Mehner thanks: ----------------------------------------------------------------------- - -This plug-in has been developed by Fritz Mehner, who maintained it until 2015. +__We thank:__ +* Fritz Mehner for developed this plug-in and maintained it until 2015. diff --git a/latex-support/README.standalone.md b/latex-support/README.standalone.md index 7e2d62e..142b786 100644 --- a/latex-support/README.standalone.md +++ b/latex-support/README.standalone.md @@ -3,8 +3,9 @@ Preface This repository is mainly for the use with plug-in managers. -The development happens here: -[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) +Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/latexsupport.html). + +The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins). Preview Version diff --git a/latex-support/doc/latex-hotkeys.tex b/latex-support/doc/latex-hotkeys.tex index d986391..f93dde1 100644 --- a/latex-support/doc/latex-hotkeys.tex +++ b/latex-support/doc/latex-hotkeys.tex @@ -6,12 +6,12 @@ %% %% Version: see \Pluginversion %% Created: 02.01.2013 -%% Revision: 27.01.2017 +%% Revision: 12.02.2018 %% %% Author: Wolfgang Mehner (WM), wolfgang-mehner@web.de %% Dr. Fritz Mehner (fgm), mehner.fritz@web.de %% Copyright: Copyright (c) 2013-2015, Dr. Fritz Mehner -%% Copyright (c) 2016-2017, Wolfgang Mehner +%% Copyright (c) 2016-2018, Wolfgang Mehner %% %%===================================================================================== @@ -30,7 +30,7 @@ \setlength\parindent{0pt} -\newcommand{\Pluginversion}{1.3alpha} +\newcommand{\Pluginversion}{2.0} \newcommand{\ReleaseDate}{\today} \newcommand{\Rep}{{\scriptsize{[n]}}} \newcommand{\Map}[1] {\textbf{\textasciiacute}\texttt{#1}} @@ -77,11 +77,8 @@ \vspace{1mm}% \textbf{\textsc{\Huge{Hot keys}}}\\ \vspace{1mm}% -Key mappings for Vim and gVim\\ -{\tiny \texttt{http://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ -\vspace{1.0mm} -{\normalsize (i)} insert mode, {\normalsize (n)} normal mode, {\normalsize (v)} visual mode,\\ -{\normalsize (T)} tab-completion +Key mappings for Vim/gVim/Neovim\\ +{\tiny \texttt{https://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ \vspace{1.0mm} % %%====================================================================== @@ -90,53 +87,54 @@ %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{60mm}|} %%---------------------------------------------------------------------- -%% Help +%% Help [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{H}elp}}\\[1.0ex] -\hline \Map{he} & English dictionary \hfill (n,i)\\ -\hline \Map{ht} & start \texttt{texdoc} \hfill (n,i)\\ -\hline \Map{hp} & help (plug-in) \hfill (n,i)\\ +\hline \Map{he} & English dictionary \\ +\hline \Map{ht} & start \texttt{texdoc} \\ +\hline \Map{hp} & help (plug-in) \\ \hline %%---------------------------------------------------------------------- -%% Comments +%% Comments [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{C}omments}} \\[1.0ex] -\hline \Rep\Map{cl} & end-of-line comment \hfill (n, i, v)\\ -\hline \Rep\Map{cj} & adjust end-of-line comments \hfill (n, i, v)\\ -\hline \Map{cs} & set end-of-line comment col.\hfill (n) \\ +\hline \Rep\Map{cl} & end-of-line comment \hfill (v)\\ +\hline \Rep\Map{cj} & adjust end-of-line comments \hfill (v)\\ +\hline \Map{cs} & set end-of-line comment col.\\ % -\hline \Rep\Map{cc} & toggle code comment \hfill (n, i, v)\\ +\hline \Rep\Map{cc} & toggle code comment \hfill (v)\\ % -\hline \Map{cfr1} & frame comment, type 1 \hfill (n, i) \\ -\hline \Map{cfr2} & frame comment, type 2 \hfill (n, i) \\ -\hline \Map{cfr3} & frame comment, type 3 \hfill (n, i) \\ -\hline \Map{cp} & file prolog \hfill (n, i) \\ -\hline \Map{cm} & plug-in macros \hfill (n, i, T)\\ -\hline \Map{cd} & date \hfill (n, i) \\ -\hline \Map{ct} & date \& time \hfill (n, i) \\ +\hline \Map{cfr1} & frame comment, type 1 \\ +\hline \Map{cfr2} & frame comment, type 2 \\ +\hline \Map{cfr3} & frame comment, type 3 \\ +\hline \Map{cp} & file prolog \\ +\hline \Map{cm} & plug-in macros \hfill (T)\\ +\hline \Map{cd} & date \\ +\hline \Map{ct} & date \& time \\ \hline %%---------------------------------------------------------------------- -%% Document +%% Document [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{D}ocument}} \\[1.0ex] -\hline \Map{dc} & documentclass \hfill (n, i, T)\\ -\hline \Map{di} & indices \hfill (n, i, T)\\ -\hline \Map{dti} & title \hfill (n, i)\\ -\hline \Map{dbi} & bibliography \hfill (n, i)\\ -\hline \Map{dac} & addcontentsline \hfill (n, i)\\ +\hline \Map{dc} & documentclass \hfill (T)\\ +\hline \Map{di} & indices \hfill (T)\\ +\hline \Map{dti} & title \\ +\hline \Map{dbi} & bibliography \hfill (T)\\ +\hline \Map{dac} & addcontentsline \\ \hline -\hline \Map{dln} & newlength \hfill (n, i)\\ -\hline \Map{dls} & setlength \hfill (n, i)\\ -\hline \Map{dla} & addtolength \hfill (n, i)\\ -\hline \Map{dlp} & print length \hfill (n, i)\\ -\hline \Map{dlt} & set length to \hfill (n, i)\\ +\hline \Map{dln} & newlength \\ +\hline \Map{dls} & setlength \\ +\hline \Map{dla} & addtolength \\ +\hline \Map{dlp} & print length \\ +\hline \Map{dlt} & set length to \\ \hline % \end{tabular}\\ %%~~~~~ TABULAR : end ~~~~~~~~~~ +% ]]]2 % %%====================================================================== %% page 1 / table, middle part [[[1 @@ -144,42 +142,43 @@ %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{60mm}|} %%---------------------------------------------------------------------- -%% Text +%% Text [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{T}ext}} \\[1.0ex] -\hline \Map{e} & environment \hfill (n, i, v, T)\\ -\hline \Map{to} & organization \hfill (n, i, T)\\ -\hline \Map{ts} & section \hfill (n, i, T)\\ -\hline \Map{tld} & list environment, description \hfill (n, i)\\ -\hline \Map{tle} & list environment, enumerate \hfill (n, i)\\ -\hline \Map{tli} & list environment, itemize \hfill (n, i)\\ -\hline \Map{tll} & list environment, list \hfill (n, i)\\ -\hline \Map{tlit} & list environment, item \hfill (n, i)\\ -\hline \Map{tlil} & list environment, item+labels \hfill (n, i)\\ -\hline \Map{tf} & font style \hfill (n, i, v, T)\\ -\hline \Map{tfs} & font size \hfill (n, i, v, T)\\ -\hline \Map{tq} & quotes \hfill (n, i, v, T)\\ -\hline \Map{tsp} & spacing \hfill (n, i, T)\\ -\hline \Map{tal} & line alignment + spacing \hfill (n, i, v, T)\\ -\hline \Map{tac} & accents \hfill (n, i, T)\\ -\hline \Map{ttc} & textcomp characters \hfill (n, i, T)\\ +\hline \Map{e} & environment \hfill (s, T)\\ +\hline \Map{to} & organization \hfill (T)\\ +\hline \Map{ts} & section \hfill (T)\\ +\hline \Map{tld} & list environment, description \\ +\hline \Map{tle} & list environment, enumerate \\ +\hline \Map{tli} & list environment, itemize \\ +\hline \Map{tll} & list environment, list \\ +\hline \Map{tlit} & list environment, item \\ +\hline \Map{tlil} & list environment, item+labels \\ +\hline \Map{tf} & font style \hfill (s, T)\\ +\hline \Map{tfs} & font size \hfill (s, T)\\ +\hline \Map{tq} & quotes \hfill (s, T)\\ +\hline \Map{tsp} & spacing \hfill (T)\\ +\hline \Map{tal} & line alignment + spacing \hfill (s, T)\\ +\hline \Map{tac} & accents \hfill (T)\\ +\hline \Map{ttc} & textcomp characters \hfill (T)\\ \hline -\hline \Map{tbi} & bibitem \hfill (n, i)\\ -\hline \Map{tci} & cite \hfill (n, i)\\ -\hline \Map{tfo} & footnote \hfill (n, i)\\ -\hline \Map{tin} & index \hfill (n, i)\\ -\hline \Map{tla} & label \hfill (n, i)\\ -\hline \Map{tma} & marginpar \hfill (n, i)\\ -\hline \Map{tco} & newcommand \hfill (n, i)\\ -\hline \Map{tnc} & nocite \hfill (n, i)\\ -\hline \Map{tpa} & pageref \hfill (n, i)\\ -\hline \Map{tre} & ref \hfill (n, i)\\ -\hline \Map{tur} & url \hfill (n, i, v)\\ +\hline \Map{tbi} & bibitem \\ +\hline \Map{tci} & cite \\ +\hline \Map{tfo} & footnote \\ +\hline \Map{tin} & index \\ +\hline \Map{tla} & label \\ +\hline \Map{tma} & marginpar \\ +\hline \Map{tco} & newcommand \\ +\hline \Map{tnc} & nocite \\ +\hline \Map{tpa} & pageref \\ +\hline \Map{tre} & ref \\ +\hline \Map{tur} & url \hfill (s)\\ \hline % \end{tabular}\\ %%~~~~~ TABULAR : end ~~~~~~~~~~ +% ]]]2 % %%====================================================================== %% page 1 / table, right part [[[1 @@ -187,41 +186,55 @@ %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{62mm}|} %%---------------------------------------------------------------------- -%% Math +%% Math [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{M}ath}} \\[1.0ex] -\hline \Map{msp} & spaces \hfill (n, i, T)\\ -\hline \Map{mac} & accents \hfill (n, i, T)\\ -\hline \Map{mfs} & font styles \hfill (n, i, T)\\ -\hline \Map{md} & delimiter \hfill (n, i, T)\\ -\hline \Map{mf} & functions \hfill (n, i, T)\\ -\hline \Map{mgl} & lowercase greek \hfill (n, i, T)\\ -\hline \Map{mgu} & uppercase greek \hfill (n, i, T)\\ -\hline \Map{mo} & operators \hfill (n, i, T)\\ -\hline \Map{mr} & relations \hfill (n, i, T)\\ -\hline \Map{mar} & arrows \hfill (n, i, T)\\ +\hline \Map{msp} & spaces \hfill (T)\\ +\hline \Map{mac} & accents \hfill (T)\\ +\hline \Map{mfs} & font styles \hfill (T)\\ +\hline \Map{md} & delimiter \hfill (T)\\ +\hline \Map{mf} & functions \hfill (T)\\ +\hline \Map{mgl} & lowercase greek \hfill (T)\\ +\hline \Map{mgu} & uppercase greek \hfill (T)\\ +\hline \Map{mo} & operators \hfill (T)\\ +\hline \Map{mr} & relations \hfill (T)\\ +\hline \Map{mar} & arrows \hfill (T)\\ \hline -\hline \Map{me} & equation+label \hfill (n, i, v)\\ -\hline \Map{mea} & eqnarray+label \hfill (n, i, v)\\ +\hline \Map{me} & equation+label \hfill (s)\\ +\hline \Map{mea} & eqnarray+label \hfill (s)\\ \hline -\hline \Map{mca} & cases \hfill (n, i, v)\\ -\hline \Map{mch} & choose \hfill (n, i, v)\\ -\hline \Map{mfr} & frac \hfill (n, i, v)\\ -\hline \Map{mma} & matrix \hfill (n, i)\\ -\hline \Map{mnr} & \textit{n}th root \hfill (n, i, v)\\ -\hline \Map{mon} & operatorname \hfill (n, i, v)\\ -\hline \Map{mov} & overset \hfill (n, i, v)\\ -\hline \Map{mpr} & prod \hfill (n, i, v)\\ -\hline \Map{msi} & sideset \hfill (n, i, v)\\ -\hline \Map{msq} & sqrt \hfill (n, i, v)\\ -\hline \Map{msu} & sum \hfill (n, i, v)\\ -\hline \Map{mun} & underset \hfill (n, i, v)\\ +\hline \Map{mca} & cases \\ +\hline \Map{mch} & choose \hfill (s)\\ +\hline \Map{mfr} & frac \hfill (s)\\ +\hline \Map{mma} & matrix \\ +\hline \Map{mnr} & \textit{n}th root \hfill (s)\\ +\hline \Map{mon} & operatorname \hfill (s)\\ +\hline \Map{mov} & overset \hfill (s)\\ +\hline \Map{mpr} & prod \hfill (s)\\ +\hline \Map{msi} & sideset \hfill (s)\\ +\hline \Map{msq} & sqrt \hfill (s)\\ +\hline \Map{msu} & sum \hfill (s)\\ +\hline \Map{mun} & underset \hfill (s)\\ \hline % -\end{tabular}\\ +\end{tabular}\\[1.0ex] %%~~~~~ TABULAR : end ~~~~~~~~~~ % +%%---------------------------------------------------------------------- +%% box Footnotes [[[2 +%%---------------------------------------------------------------------- +\begin{minipage}[b]{72mm}% +\scriptsize{% +all hotkeys work in normal and insert mode \\ +visual mode: {\normalsize (v)} use the range, +{\normalsize (s)} surround range \\ +tab-completion: {\normalsize (T)} specialized, +{\normalsize (F)} filenames +}% +\end{minipage} +% ]]]2 +% \newpage % %%====================================================================== @@ -230,63 +243,68 @@ %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{60mm}|} %%---------------------------------------------------------------------- -%% Beamer +%% Beamer [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{B\textbf{e}amer}}\\[1.0ex] -\hline \Map{bf} & frame \hfill (n, i, v)\\ -\hline \Map{bc} & columns \hfill (n, i, v, T)\\ -\hline \Map{bi} & itemize \hfill (n, i, v)\\ -\hline \Map{bo} & overprint \hfill (n, i, v)\\ -\hline \Map{bg} & includegraphics \hfill (n, i)\\ -\hline \Map{bbl} & block \hfill (n, i, v)\\ +\hline \Map{but} & usetheme \hfill (T)\\ +\hline \Map{bf} & frame \hfill (s)\\ +\hline \Map{bco} & columns \hfill (s, T)\\ +\hline \Map{bit} & itemize \hfill (s)\\ +\hline \Map{bov} & overprint \hfill (s)\\ +\hline \Map{bpa} & pause \\ +\hline \Map{bgr} & includegraphics \hfill (F)\\ +\hline \Map{bal} & alert \hfill (s)\\ +\hline \Map{bbl} & block \hfill (s)\\ +\hline \Map{btc} & textcolor \hfill (s, T)\\ \hline %%---------------------------------------------------------------------- -%% Wizard +%% Wizard [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{W}izard}}\\[1.0ex] -\hline \Map{wll} & lstlisting \hfill (n, i, v)\\ -\hline \Map{wlil} & lstinputlisting \hfill (n, i)\\ -\hline \Map{wlin} & lstinline \hfill (n, i, v)\\ -\hline \Map{wls} & lstset \hfill (n, i, T)\\ +\hline \Map{wll} & lstlisting \hfill (s)\\ +\hline \Map{wlil} & lstinputlisting \\ +\hline \Map{wlin} & lstinline \hfill (s)\\ +\hline \Map{wls} & lstset \hfill (T)\\ \hline -\hline \Map{wtt} & table \hfill (n, i, v)\\ -\hline \Map{wtf} & table, floating \hfill (n, i, v)\\ -\hline \Map{wtg} & tabbing \hfill (n, i)\\ -\hline \Map{wtr} & tabular \hfill (n, i)\\ +\hline \Map{wtt} & table \hfill (s)\\ +\hline \Map{wtf} & table, floating \hfill (s)\\ +\hline \Map{wtg} & tabbing \\ +\hline \Map{wtr} & tabular \\ \hline -\hline \Map{wf} & figure \hfill (n, i)\\ -\hline \Map{wff} & floatingfigure \hfill (n, i)\\ -\hline \Map{wwf} & wrapfigure \hfill (n, i)\\ +\hline \Map{wf} & figure \\ +\hline \Map{wff} & floatingfigure \\ +\hline \Map{wwf} & wrapfigure \\ \hline -\hline \Map{wbf} & fbox \hfill (n, i, v)\\ -\hline \Map{wbfr} & framebox \hfill (n, i, v)\\ -\hline \Map{wbm} & mbox \hfill (n, i, v)\\ -\hline \Map{wbmb} & makebox \hfill (n, i, v)\\ -\hline \Map{wmp} & minipage \hfill (n, i, v)\\ -\hline \Map{wbp} & parbox \hfill (n, i, v)\\ +\hline \Map{wbf} & fbox \hfill (s)\\ +\hline \Map{wbfr} & framebox \hfill (s)\\ +\hline \Map{wbm} & mbox \hfill (s)\\ +\hline \Map{wbmb} & makebox \hfill (s)\\ +\hline \Map{wmp} & minipage \hfill (s)\\ +\hline \Map{wbp} & parbox \hfill (s)\\ \hline %%---------------------------------------------------------------------- -%% Snippets +%% Snippets [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{S\textbf{n}ippets}} \\[1.0ex] -\hline \Map{nr} & read code snippet \hfill (n, i) \\ -\hline \Map{nw} & write code snippet \hfill (n, i, v)\\ -\hline \Map{nv} & view code snippet \hfill (n, i) \\ -\hline \Map{ne} & edit code snippet \hfill (n, i) \\ +\hline \Map{nr} & read code snippet \\ +\hline \Map{nw} & write code snippet \hfill (v)\\ +\hline \Map{nv} & view code snippet \\ +\hline \Map{ne} & edit code snippet \\ \hline -\hline \Map{ntl} & edit local templates \hfill (n, i) \\ -\hline \Map{ntc} & edit custom templates \hfill (n, i) \\ -\hline \Map{ntp} & edit personal templates \hfill (n, i) \\ -\hline \Map{ntr} & reread the templates \hfill (n, i) \\ -\hline \Map{ntw} & template setup wizard \hfill (n, i) \\ -\hline \Map{nts} & choose template style \hfill (n, i, T)\\ +\hline \Map{ntl} & edit local templates \\ +\hline \Map{ntc} & edit custom templates \\ +\hline \Map{ntp} & edit personal templates \\ +\hline \Map{ntr} & reread the templates \\ +\hline \Map{ntw} & template setup wizard \\ +\hline \Map{nts} & choose template style \hfill (T)\\ \hline % \end{tabular}\\ %%~~~~~ TABULAR : end ~~~~~~~~~~ +% ]]]2 % %%====================================================================== %% page 2 / table, middle part [[[1 @@ -294,37 +312,36 @@ %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{62mm}|} %%---------------------------------------------------------------------- -%% menu run +%% menu run [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\textbf{R}un}} \\[1.0ex] -\hline \Map{rr} & save + run typesetter \hfill (n, i)\\ -\hline \Map{rla} & save + run \texttt{lacheck} \hfill (n, i)\\ -\hline \Map{rsd} & set the main document \hfill (n, i)\\ -\hline \Map{re} & errors from last bg.\ process \hfill (n, i)\\ -\hline \Map{rdvi} & view DVI \hfill (n, i)\\ -\hline \Map{rpdf} & view PDF \hfill (n, i)\\ -\hline \Map{rps} & view PS \hfill (n, i)\\ -\hline \Map{rc} & run a converter \hfill (n, i)\\ +\hline \Map{rr} & save + run typesetter \\ +\hline \Map{rla} & save + run \texttt{lacheck} \\ +\hline \Map{rmd} & set the main document \hfill (F)\\ +\hline \Map{re} & errors from last bg.\ process \\ +\hline \Map{rdvi} & view DVI \\ +\hline \Map{rpdf} & view PDF \\ +\hline \Map{rps} & view PS \\ +\hline \Map{rc} & run a converter \hfill (T)\\ \hline -\hline \Map{rmg} & run \texttt{makeglossaries} \hfill (n, i)\\ -\hline \Map{rmi} & run \texttt{makeindex} \hfill (n, i)\\ -\hline \Map{rbi} & run \texttt{bibtex} \hfill (n, i)\\ +\hline \Map{rmg} & run \texttt{makeglossaries} \\ +\hline \Map{rmi} & run \texttt{makeindex} \\ +\hline \Map{rbi} & run \texttt{bibtex} \\ \hline -\hline \Map{rt} & choose the typesetter \hfill (n, i, T)\\ -\hline \Map{rp} & method for external processing \hfill (n, i, T)\\ +\hline \Map{rt} & choose the typesetter \hfill (T)\\ +\hline \Map{rp} & method for external processing \hfill (T)\\ \hline -\hline \Map{rh} & hardcopy buffer to postscript \hfill (n, i, v)\\ -\hline \Map{rse} & show plug-in settings \hfill (n, i)\\ +\hline \Map{rh} & hardcopy buffer to postscript \hfill (v)\\ +\hline \Map{rs} & show plug-in settings \\ \hline \end{tabular}\\[2.5ex] %%~~~~~ TABULAR : end ~~~~~~~~~~ % -\parbox[t][80mm][t]{70mm}{% -% %%---------------------------------------------------------------------- -%% External Programs +%% External Programs [[[2 %%---------------------------------------------------------------------- +\begin{minipage}[b]{70mm}% \large{\textbf{Run}}\\[1.0ex] Run the typesetter or \texttt{lacheck} : \\[1.0ex] \texttt{:Latex [<tex-file>]} \\[1.0ex] @@ -337,18 +354,18 @@ Set the main document: \\[1.0ex] \texttt{:LatexMainDoc <tex-file>} \\[1.0ex] View the errors of the last background process: \\[1.0ex] -\texttt{:LatexErrors} \\[2.5ex] -} +\texttt{:LatexErrors} +\end{minipage} +% ]]]2 % %%====================================================================== %% page 2 / table, right part [[[1 %%====================================================================== % -\parbox[t][130mm][t]{70mm}{% -% %%---------------------------------------------------------------------- -%% View & Convert +%% View & Convert [[[2 %%---------------------------------------------------------------------- +\begin{minipage}[b]{70mm}% \large{\textbf{View \& Convert}}\\[1.0ex] View a document of the specified format (supports \texttt{dvi}, \texttt{pdf}, and \texttt{ps}): \\[1.0ex] @@ -357,21 +374,27 @@ \texttt{:LatexView <file> [<format>]} \\[1.0ex] Convert a document: \\[1.0ex] \texttt{:LatexConvert [<file>]} \\[1.0ex] -(the default filename is derived from the name of the current buffer) \\[2.5ex] +(the default filename is derived from the name of the current buffer) +\end{minipage} +\\[2.5ex] % %%---------------------------------------------------------------------- -%% Options +%% Options [[[2 %%---------------------------------------------------------------------- +\begin{minipage}[b]{70mm}% \large{\textbf{Options}}\\[1.0ex] Print or set the typesetter: \\[1.0ex] \texttt{:LatexTypesetter [<typesetter>]} \\[1.0ex] Print or set the processing method: \\[1.0ex] \texttt{:LatexProcessing [<method>]} \\[1.0ex] -(both commands support tab-compl.) \\[2.5ex] +(both commands support tab-compl.) +\end{minipage} +\\[2.5ex] % %%---------------------------------------------------------------------- -%% Make +%% Make [[[2 %%---------------------------------------------------------------------- +\begin{minipage}[b]{70mm}% \large{\textbf{Make}}\\[1.0ex] Run \texttt{make} : \\[1.0ex] \texttt{:Make [<args>]} \\[1.0ex] @@ -380,7 +403,8 @@ (both commands support tab-compl.) \\[1.0ex] Help for the Make Tool: \\[1.0ex] \texttt{:MakeHelp} \\[2.5ex] -} +\end{minipage} +% ]]]2 % \end{center}% \end{multicols}% diff --git a/latex-support/rc/customization.gvimrc b/latex-support/rc/customization.gvimrc index c5a0d19..aeb0055 100644 --- a/latex-support/rc/customization.gvimrc +++ b/latex-support/rc/customization.gvimrc @@ -1,17 +1,23 @@ -"=================================================================================== -" FILE: .gvimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" VERSION: 1.0 -" CREATED: 12.01.2013 -"=================================================================================== +"=============================================================================== " -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== +" File: customization.gvimrc " -set cmdheight=2 " Make command line two lines high -set mousehide " Hide the mouse when typing text +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.4+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 16.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== +" GENERAL SETTINGS +"=============================================================================== + +set cmdheight=2 " Make command line two lines high +set mousehide " Hide the mouse when typing text highlight Normal guibg=grey90 highlight Cursor guibg=Blue guifg=NONE @@ -20,34 +26,37 @@ highlight NonText guibg=grey80 highlight Constant gui=NONE guibg=grey95 highlight Special gui=NONE guibg=grey95 -" +let c_comment_strings=1 " highlight strings inside C comments + "------------------------------------------------------------------------------- -" Moving cursor to other windows: -" shift down : change window focus to lower one (cyclic) -" shift up : change window focus to upper one (cyclic) -" shift left : change window focus to one on left -" shift right : change window focus to one on right +" Moving cursor to other windows +" +" shift-down : change window focus to lower one (cyclic) +" shift-up : change window focus to upper one (cyclic) +" shift-left : change window focus to one on left +" shift-right : change window focus to one on right "------------------------------------------------------------------------------- nnoremap <s-down> <c-w>w nnoremap <s-up> <c-w>W nnoremap <s-left> <c-w>h nnoremap <s-right> <c-w>l -" + "------------------------------------------------------------------------------- -" Some additional hot keys: -" S-F3 - call gvim file browser +" Some additional hot keys +" +" shift-F3 : call gvim file browser "------------------------------------------------------------------------------- noremap <silent> <s-F3> :silent browse confirm e<CR> inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" + "------------------------------------------------------------------------------- -" toggle insert mode <--> 'normal mode with the <RightMouse>-key +" toggle insert mode <--> normal mode with the <RightMouse>-key "------------------------------------------------------------------------------- + nnoremap <RightMouse> <Insert> inoremap <RightMouse> <ESC> -" + "------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets : ()[]{} +" use font with clearly distinguishable brackets: ()[]{} "------------------------------------------------------------------------------- -set guifont=Luxi\ Mono\ 14 -" +"set guifont=Luxi\ Mono\ 14 diff --git a/latex-support/rc/customization.vimrc b/latex-support/rc/customization.vimrc index 20f9676..942d1c0 100644 --- a/latex-support/rc/customization.vimrc +++ b/latex-support/rc/customization.vimrc @@ -1,33 +1,59 @@ -"=================================================================================== -" FILE: .vimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" VERSION: 1.0 -" CREATED: 12.01.2013 -"=================================================================================== +"=============================================================================== " -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== +" File: customization.vimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc " +" VIM Version: 7.4+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 15.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== +" GENERAL SETTINGS +"=============================================================================== + "------------------------------------------------------------------------------- " Use Vim settings, rather then Vi settings. " This must be first, because it changes other options as a side effect. "------------------------------------------------------------------------------- set nocompatible -" + "------------------------------------------------------------------------------- " Enable file type detection. Use the default filetype settings. " Also load indent files, to automatically do language-dependent indenting. "------------------------------------------------------------------------------- filetype plugin on filetype indent on -" + "------------------------------------------------------------------------------- " Switch syntax highlighting on. "------------------------------------------------------------------------------- syntax on -" + +"------------------------------------------------------------------------------- +" Platform specific items: +" - central backup directory (has to be created) +" - default dictionary +" Uncomment your choice. +" +" Using a backupdir under UNIX/Linux: you may want to include a line similar to: +" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; +" in one of your shell startup files (e.g. $HOME/.profile). +"------------------------------------------------------------------------------- +if has("win16") || has("win32") || has("win64") || + \ has("win95") || has("win32unix") +" runtime mswin.vim +" set backupdir =$VIM\vimfiles\backupdir +" set dictionary=$VIM\vimfiles\wordlists/german.list +else +" set backupdir =$HOME/.vim.backupdir +" set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list +endif + "------------------------------------------------------------------------------- " Various settings "------------------------------------------------------------------------------- @@ -39,12 +65,12 @@ set backup " keep a backup file set browsedir=current " which directory to use for the file browser set complete+=k " scan the files given with the 'dictionary' option set encoding=utf-8 " sets the character encoding used inside Vim +set formatoptions+=j " remove comment leader when joining lines set history=50 " keep 50 lines of command line history -set hlsearch " highlightthe last used search pattern +set hlsearch " highlight the last used search pattern set incsearch " do incremental searching set listchars=tab:>.,eol:\$ " strings to use in 'list' mode set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines set popt=left:8pc,right:3pc " print options set ruler " show the cursor position all the time set shiftwidth=2 " number of spaces to use for each step of indent @@ -54,97 +80,149 @@ set tabstop=2 " number of spaces that a <Tab> counts for set visualbell " visual bell instead of beeping set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions set wildmenu " command-line completion in an enhanced mode -" -"------------------------------------------------------------------------------- -" highlight paired brackets -"------------------------------------------------------------------------------- -highlight MatchParen ctermbg=blue guibg=lightyellow -" -"------------------------------------------------------------------------------- -" some additional hot keys -"------------------------------------------------------------------------------- -" F2 - write file without confirmation -" F3 - call file explorer Ex -" F5 - close open list all errors -" F6 - open list all errors -" F7 - display previous error -" F8 - display next error -"------------------------------------------------------------------------------- -noremap <silent> <F2> :write<CR> -noremap <silent> <F3> :Explore<CR> -noremap <silent> <F5> :copen<CR> -noremap <silent> <F6> :cclose<CR> -noremap <silent> <F7> :cprevious<CR> -noremap <silent> <F8> :cnext<CR> -" -inoremap <silent> <F2> <C-C>:write<CR> -inoremap <silent> <F3> <C-C>:Explore<CR> -inoremap <silent> <F5> <C-C>:copen<CR> -inoremap <silent> <F6> <C-C>:cclose<CR> -inoremap <silent> <F7> <C-C>:cprevious<CR> -inoremap <silent> <F8> <C-C>:cnext<CR> -" -"------------------------------------------------------------------------------- -" comma always followed by a space -"------------------------------------------------------------------------------- -inoremap , ,<Space> -" +set nowrap " do not wrap lines + "------------------------------------------------------------------------------- -" autocomplete parenthesis, (brackets) and braces +" Highlight paired brackets "------------------------------------------------------------------------------- -inoremap ( ()<Left> -inoremap [ []<Left> -inoremap { {}<Left> -" -vnoremap ( s()<Esc>P<Right>% -vnoremap [ s[]<Esc>P<Right>% -vnoremap { s{}<Esc>P<Right>% -" -" surround content with additional spaces -" -vnoremap ) s( )<Esc><Left>P<Right><Right>% -vnoremap ] s[ ]<Esc><Left>P<Right><Right>% -vnoremap } s{ }<Esc><Left>P<Right><Right>% -" +"highlight MatchParen ctermbg=blue guibg=lightyellow + +"=============================================================================== +" BUFFERS, WINDOWS +"=============================================================================== + "------------------------------------------------------------------------------- -" autocomplete quotes (visual and select mode) +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). "------------------------------------------------------------------------------- -xnoremap ' s''<Esc>P<Right> -xnoremap " s""<Esc>P<Right> -xnoremap ` s``<Esc>P<Right> -" +if has("autocmd") + augroup MyResetCursor + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + augroup END +endif + "------------------------------------------------------------------------------- -" The current directory is the directory of the file in the current window. +" Change the working directory to the directory containing the current file "------------------------------------------------------------------------------- if has("autocmd") - autocmd BufEnter * :lchdir %:p:h + augroup MySetLocalDir + autocmd BufEnter * :lchdir %:p:h + augroup END endif -" + "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" +"nnoremap <silent> <s-tab> :if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> +"inoremap <silent> <s-tab> <C-C>:if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> + "------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q (KDE): Write all changed buffers and exit Vim +" Leave the editor with Ctrl-q: Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nnoremap <C-q> :wqall<CR> -" -"=================================================================================== + +"------------------------------------------------------------------------------- +" Some additional hot keys +" +" F2 - write file without confirmation +" F3 - call file explorer Ex +" F4 - show tag under cursor in the preview window (tagfile must exist!) +" F5 - open quickfix error window +" F6 - close quickfix error window +" F7 - display previous error +" F8 - display next error +" F12 - list buffers and prompt for a buffer name +"------------------------------------------------------------------------------- + +noremap <silent> <F2> :write<CR> +noremap <silent> <F3> :Explore<CR> +nnoremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> +noremap <silent> <F5> :copen<CR> +noremap <silent> <F6> :cclose<CR> +noremap <silent> <F7> :cprevious<CR> +noremap <silent> <F8> :cnext<CR> +noremap <F12> :buffer <C-D> +noremap <S-F12> :sbuffer <C-D> + +inoremap <silent> <F2> <Esc>:write<CR> +inoremap <silent> <F3> <Esc>:Explore<CR> +inoremap <silent> <F4> <Esc>:execute ":ptag ".expand("<cword>")<CR> +inoremap <silent> <F5> <Esc>:copen<CR> +inoremap <silent> <F6> <Esc>:cclose<CR> +inoremap <silent> <F7> <Esc>:cprevious<CR> +inoremap <silent> <F8> <Esc>:cnext<CR> +inoremap <F12> <C-C>:buffer <C-D> +inoremap <S-F12> <C-C>:sbuffer <C-D> + +"------------------------------------------------------------------------------- +" Always wrap lines in the quickfix buffer +"------------------------------------------------------------------------------- +"autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak + +"=============================================================================== +" AUTOCOMPLETE BRACKETS, QUOTES +"=============================================================================== + +"------------------------------------------------------------------------------- +" Autocomplete parenthesis, brackets and braces +"------------------------------------------------------------------------------- + +inoremap ( ()<Left> +inoremap [ []<Left> +inoremap { {}<Left> + +" surround content +vnoremap ( s()<Esc>P<Right>% +vnoremap [ s[]<Esc>P<Right>% +vnoremap { s{}<Esc>P<Right>% + +" surround content with additional spaces +vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% +vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% +vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% + +"------------------------------------------------------------------------------- +" Autocomplete quotes +"------------------------------------------------------------------------------- + +" surround content (visual and select mode) +vnoremap ' s''<Esc>P<Right> +vnoremap " s""<Esc>P<Right> +vnoremap ` s``<Esc>P<Right> + +"=============================================================================== " VARIOUS PLUGIN CONFIGURATIONS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" plugin taglist.vim : toggle the taglist window -"------------------------------------------------------------------------------- - noremap <silent> <F11> :TlistToggle<CR> -inoremap <silent> <F11> <C-C>:TlistToggle<CR> -" +"=============================================================================== + +"------------------------------------------------------------------------------- +" Latex-Support +" +" the settings are documented here: +" :help latexsupport-configuration +"------------------------------------------------------------------------------- + +"let g:Latex_LoadMenus = 'auto' +"let g:Latex_RootMenu = '&LaTeX' +"let g:Latex_MapLeader = '´' + +"let g:Latex_InsertFileProlog = 'no' + +"let g:Latex_Typesetter = 'lualatex' +"let g:Latex_Processing = 'background' + +"------------------------------------------------------------------------------- +" taglist.vim : toggle the taglist window +"------------------------------------------------------------------------------- + noremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> +inoremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> + let Tlist_Close_On_Select = 1 let tlist_tex_settings = 'latex;s:Contents;g:Graphics;i:Listings;l:\label;r:\ref;p:\pageref;b:\bibitem' -" diff --git a/latex-support/rc/make.vim b/latex-support/rc/make.vim index cd275fd..a1afd27 100644 --- a/latex-support/rc/make.vim +++ b/latex-support/rc/make.vim @@ -3,8 +3,8 @@ " Vim filetype plugin file " " Language : Make -" Plugin : c.vim / latex.vim / ... -" Revision : 15.04.2017 +" Plugin : c.vim / latex-support.vim / ... +" Revision : 03.10.2017 " Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> " (formerly Fritz Mehner <mehner.fritz@web.de>) " @@ -16,8 +16,10 @@ if exists("b:did_c_support_make") endif let b:did_c_support_make = 1 -" ---------- Maps for the Make tool ------------------------------------------ +" ---------- Set "maplocalleader" as configured using "g:C_MapLeader" -------- +"call C_SetMapLeader () +" ---------- Maps for the Make tool ------------------------------------------ noremap <buffer> <silent> <LocalLeader>rm :Make<CR> inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> @@ -28,3 +30,7 @@ inoremap <buffer> <silent> <LocalLeader>rmd <C-C>:Make doc<CR> inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> noremap <buffer> <LocalLeader>rcm :MakeFile<space> inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> + +" ---------- Reset "maplocalleader" ------------------------------------------ +"call C_ResetMapLeader () + diff --git a/latex-support/rc/tex.vim b/latex-support/rc/tex.vim index e0c9088..c5da9b9 100644 --- a/latex-support/rc/tex.vim +++ b/latex-support/rc/tex.vim @@ -17,22 +17,18 @@ let b:did_latex_support_ftplugin = 1 " ---------- Add to the keyword characters ----------------------------------- " useful for searching labels which use special characters - "setlocal iskeyword+=_ "setlocal iskeyword+=: " ---------- Key mappings --------------------------------------------------- " double '$', surround marked expression with '$ ... $' - "inoremap <buffer> $ $$<Left> "vnoremap <buffer> $ s$$<Esc>P<Right> " ---------- Set "maplocalleader" as configured using "g:Latex_MapLeader" ---- - call Latex_SetMapLeader () " ---------- Maps for running Latex et al. ----------------------------------- - nnoremap <buffer> <F9> :Latex<CR> inoremap <buffer> <F9> <Esc>:Latex<CR> vnoremap <buffer> <F9> <Esc>:Latex<CR> @@ -41,17 +37,17 @@ inoremap <buffer> <C-F9> <Esc>:LatexView<CR> vnoremap <buffer> <C-F9> <Esc>:LatexView<CR> " ---------- Maps for the Make tool ------------------------------------------ - noremap <buffer> <silent> <LocalLeader>rm :Make<CR> inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> inoremap <buffer> <silent> <LocalLeader>rmc <C-C>:Make clean<CR> + noremap <buffer> <silent> <LocalLeader>rmd :Make doc<CR> +inoremap <buffer> <silent> <LocalLeader>rmd <C-C>:Make doc<CR> noremap <buffer> <LocalLeader>rma :MakeCmdlineArgs<space> inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> noremap <buffer> <LocalLeader>rcm :MakeFile<space> inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> " ---------- Reset "maplocalleader" ------------------------------------------ - call Latex_ResetMapLeader () diff --git a/latex-support/templates/beamer.templates b/latex-support/templates/beamer.templates index c1931a9..2e8525c 100644 --- a/latex-support/templates/beamer.templates +++ b/latex-support/templates/beamer.templates @@ -34,7 +34,7 @@ default == ENDLIST == -== Beamer.usetheme == expandmenu, below, sc:u == +== Beamer.usetheme == expandmenu, below, map:but, sc:u == |PickList( 'theme', 'beamer_themes' )| \usetheme<CURSOR>{|PICK|} == ENDTEMPLATE == @@ -56,7 +56,7 @@ \begin{frame}<CURSOR>{<+TITLE+>}{<+SUBTITLE+>} <SPLIT> \end{frame} -== Beamer.columns == expandmenu, below, map:bc, sc:c == +== Beamer.columns == expandmenu, below, map:bco, sc:c == |PickList( 'alignment', 'beamer_col_align' )| \begin{columns}[|VALUE|<CURSOR>] \begin{column}{<+WIDTH+>|BEAMER_UNIT|} @@ -74,20 +74,20 @@ == SEP: Beamer.sep-overlay == -== Beamer.itemize == below, map:bi, sc:i == +== Beamer.itemize == below, map:bit, sc:i == \begin{itemize} \item<1-> <CURSOR><SPLIT> \item<2-> <+ITEM+> \item<3-> <+ITEM+> \end{itemize} -== Beamer.overprint == below, map:bo, sc:o == +== Beamer.overprint == below, map:bov, sc:o == \begin{overprint} \onslide<1> <CURSOR><SPLIT> \onslide<2> <+SLIDE+> \end{overprint} -== Beamer.pause == below, sc:p == +== Beamer.pause == below, map:bpa, sc:p == \pause[<CURSOR>] == ENDTEMPLATE == @@ -114,7 +114,7 @@ == Beamer.graphicspath == below, sc:p == \graphicspath{{<CURSOR>}} -== Beamer.includegraphics == below, map:bg, sc:g == +== Beamer.includegraphics == below, map:bgr, sc:g == |PickFile( 'image', 'graphics_path' )| \includegraphics[width=<CURSOR>|BEAMER_UNIT|]{|PICK|} == ENDTEMPLATE == @@ -136,13 +136,13 @@ magenta yellow == ENDLIST == -== Beamer.alert == insert == +== Beamer.alert == insert, map:bal == \alert<CURSOR><<+ON_SLIDES+>>{<SPLIT><-TEXT->} -== Beamer.block == below, map:bbl, sc:b == +== Beamer.block == below, map:bbl == \begin{block}{<CURSOR>} <SPLIT><-CONTENT-> \end{block} -== Beamer.textcolor == insert == +== Beamer.textcolor == insert, map:btc == |PickList( 'color name', 'textcolors' )| \textcolor{|PICK|}{<CURSOR><SPLIT><-TEXT->} == ENDTEMPLATE == diff --git a/latex-support/templates/environments.templates b/latex-support/templates/environments.templates index 5b091c8..0b3b464 100644 --- a/latex-support/templates/environments.templates +++ b/latex-support/templates/environments.templates @@ -4,6 +4,7 @@ == LIST: environment_list == list, bare == align +aligned array center description diff --git a/latex-support/templates/text.templates b/latex-support/templates/text.templates index fdc9a45..e8346b4 100644 --- a/latex-support/templates/text.templates +++ b/latex-support/templates/text.templates @@ -210,6 +210,8 @@ SetExpansion ( 'Text.accents', '\|KEY:T|', '|VALUE|' ) § ------------------------------------------------------------- == LIST: textcomp == dict == 'asciiacute' : '´', + 'asciitilde' : '~', + 'backslash' : '\', 'bullet' : '•', 'celsius' : '℃', 'copyright' : '©', @@ -223,6 +225,7 @@ SetExpansion ( 'Text.accents', '\|KEY:T|', '|VALUE|' ) 'pm' : '±', 'registered' : '®', 'section' : '§', + 'tildelow' : '~', 'times' : '⨉', 'trademark' : '™', == ENDTEMPLATE == diff --git a/lua-support/README.md b/lua-support/README.md index a3a5a1a..a6df6b5 100644 --- a/lua-support/README.md +++ b/lua-support/README.md @@ -1,4 +1,4 @@ -README for lua-support.vim (Version 1.0.1pre) / July 02 2017 +README for lua-support.vim (Version 1.1alpha) / November 22 2020 ================================================================================ * INSTALLATION @@ -8,15 +8,15 @@ README for lua-support.vim (Version 1.0.1pre) / July 02 2017 * CREDITS -Lua-IDE for Vim/gVim. It is written to considerably speed up writing code in -a consistent style. This is done by inserting complete statements, idioms and +Lua-IDE for Vim/gVim/Neovim. It is written to considerably speed up writing code +in a consistent style. This is done by inserting complete statements, idioms and comments. These code fragments are provided in an extendible template library. This plug-in helps with running and compiling Lua scripts, applying the code checker, and provides quick access to the online documentation of the Lua functions. Please read the documentation. -This plug-in can be used with Vim version 7.x. +This plug-in can be used with Vim version 7.3+ and Neovim 0.2.1+. Lua is: Copyright 1994-2016 Lua.org, PUC-Rio. @@ -29,7 +29,7 @@ INSTALLATION A system-wide installation for all users can also be done. This will have further effects on how the plug-in works. For a step-by-step instruction, as well as an explanation of the other consequences, please see the help file -'doc/luasupport.txt' or look up the documentation via: +`doc/luasupport.txt` or look up the documentation via: :help luasupport-system-wide @@ -37,17 +37,14 @@ well as an explanation of the other consequences, please see the help file (1) LINUX ---------------------------------------------------------------------- -The subdirectories in the zip archive lua-support.zip mirror the directory -structure which is needed below the local installation directory +The subdirectories in the zip archive `lua-support.zip` mirror the directory +structure which is needed below the local installation directory `$HOME/.vim/` +(find the value of `$HOME` with `:echo $HOME` from inside Vim). - $HOME/.vim/ - -(find the value of $HOME with `:echo $HOME` from inside Vim). - -(1.0) Save the template files in '$HOME/.vim/lua-support/templates/' if you +(1.0) Save the template files in `$HOME/.vim/lua-support/templates/` if you have changed any of them. -(1.1) Copy the zip archive lua-support.zip to $HOME/.vim and run +(1.1) Copy the zip archive `lua-support.zip` to `$HOME/.vim` and run unzip lua-support.zip @@ -61,8 +58,8 @@ structure which is needed below the local installation directory :filetype plugin on - This is the minimal content of the file '$HOME/.vimrc'. Create one if there - is none or use the file in $HOME/.vim/lua-support/rc as a starting point. + This is the minimal content of the file `$HOME/.vimrc`. Create one if there + is none or use the file in `$HOME/.vim/lua-support/rc` as a starting point. (1.3) Make the plug-in help accessible by typing the following command on the Vim command line: @@ -74,7 +71,7 @@ structure which is needed below the local installation directory Lua -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): @@ -84,7 +81,7 @@ structure which is needed below the local installation directory SetMacro( 'ORGANIZATION', '' ) SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/.vim/templates/lua.templates to customize or add to your + Use the file `$HOME/.vim/templates/lua.templates` to customize or add to your Lua template library. It can also be set up via the wizard. This plug-in ships with templates for Lua's C-API. If you want to use them, @@ -92,26 +89,28 @@ structure which is needed below the local installation directory (Read more about the template system in the plug-in documentation.) -(1.5) Consider additional settings in the file '$HOME/.vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your .vimrc and .gvimrc. You may want to use parts of them. The files - are documented. +(1.5) Consider additional settings in the file `$HOME/.vimrc`. The files + `customization.vimrc` and `customization.gvimrc` are replacements or + extensions for your `.vimrc` and `.gvimrc`. You may want to use parts of + them. The files are documented. + + Some settings are specifically for Lua buffers and should be placed in the + filetype plug-in. You may copy the file `lua-support/rc/lua.vim` into the + directory `$HOME/.vim/ftplugin/`, or use the settings there as additions to + your own filetype plug-in. (2) WINDOWS ---------------------------------------------------------------------- -The subdirectories in the zip archive lua-support.zip mirror the directory -structure which is needed below the local installation directory - - $HOME/vimfiles/ - -(find the value of $HOME with `:echo $HOME` from inside Vim). +The subdirectories in the zip archive `lua-support.zip` mirror the directory +structure which is needed below the local installation directory `$HOME/vimfiles/` +(find the value of `$HOME` with `:echo $HOME` from inside Vim). -(2.0) Save the template files in '$HOME/vimfiles/lua-support/templates/' if you +(2.0) Save the template files in `$HOME/vimfiles/lua-support/templates/` if you have changed any of them. -(2.1) Copy the zip archive lua-support.zip to $HOME/vimfiles and run +(2.1) Copy the zip archive `lua-support.zip` to `$HOME/vimfiles` and run unzip lua-support.zip @@ -125,9 +124,8 @@ structure which is needed below the local installation directory :filetype plugin on - This is the minimal content of the file '$HOME/_vimrc'. Create one if there - is none or use the file in $HOME/vimfiles/lua-support/rc as a starting - point. + This is the minimal content of the file `$HOME/_vimrc`. Create one if there + is none or use the file in `$HOME/vimfiles/lua-support/rc` as a starting point. (2.3) Make the plug-in help accessible by typing the following command on the Vim command line: @@ -139,7 +137,7 @@ structure which is needed below the local installation directory Lua -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): @@ -149,7 +147,7 @@ structure which is needed below the local installation directory SetMacro( 'ORGANIZATION', '' ) SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/vimfiles/templates/lua.templates to customize or add to + Use the file `$HOME/vimfiles/templates/lua.templates` to customize or add to your Lua template library. It can also be set up via the wizard. This plug-in ships with templates for Lua's C-API. If you want to use them, @@ -157,13 +155,18 @@ structure which is needed below the local installation directory (Read more about the template system in the plug-in documentation.) -(2.5) Consider additional settings in the file '$HOME/_vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your _vimrc and _gvimrc. You may want to use parts of them. The files - are documented. +(2.5) Consider additional settings in the file `$HOME/_vimrc`. The files + `customization.vimrc` and `customization.gvimrc` are replacements or + extensions for your `_vimrc` and `_gvimrc`. You may want to use parts of + them. The files are documented. -(2.6) Make sure the shell is set up correctly. The options 'shell', - 'shellcmdflag', 'shellquote', and 'shellxquote' must be set consistently. + Some settings are specifically for Lua buffers and should be placed in the + filetype plug-in. You may copy the file `lua-support/rc/lua.vim` into the + directory `$HOME/vimfiles/ftplugin/`, or use the settings there as additions + to your own filetype plug-in. + +(2.6) Make sure the shell is set up correctly. The options `shell`, + `shellcmdflag`, `shellquote`, and `shellxquote` must be set consistently. Compare `:help luasupport-troubleshooting`. @@ -178,19 +181,12 @@ There are a lot of features and options which can be used and influenced: * quick access to the online documentation * removing the Lua menu -Look at the Lua-Support help with: +Actions differ for different modes. Please read the documentation: :help luasupport - +-----------------------------------------------+ - | +-------------------------------------------+ | - | | ** PLEASE READ THE DOCUMENTATION ** | | - | | Actions differ for different modes! | | - | +-------------------------------------------+ | - +-----------------------------------------------+ - Any problems? See the TROUBLESHOOTING section at the end of the help file -'doc/luasupport.txt'. +`doc/luasupport.txt`. -------------------------------------------------------------------------------- @@ -198,25 +194,30 @@ Any problems? See the TROUBLESHOOTING section at the end of the help file RELEASE NOTES ================================================================================ -RELEASE NOTES FOR VERSION 1.0.1pre +RELEASE NOTES FOR VERSION 1.1alpha ---------------------------------------------------------------------- +- Adapt for running under Neovim more smoothly. +- Add output method 'terminal' for running scripts in a terminal window + (requires +terminal). +- Rename output methods 'vim-io' to 'cmd-line', and 'vim-qf' to 'quickfix', + for more consistency (old settings will still work). - The templates which are inserted into new files as file skeletons can be specified in the templates library, via the property: - Lua::FileSkeleton::Script -- Add configuration variables 'g:Lua_Ctrl_j' and 'g:Lua_Ctrl_d' to control the - creation of the CTRL+J and CTRL+D maps. -- Update Lua's reference manual to 5.3.4. -- Move the filetype plug-in for lua to 'lua-support/rc'. + `Lua::FileSkeleton::Script` +- Add configuration variables `g:Lua_Ctrl_j` and `g:Lua_Ctrl_d` to control the + creation of the `CTRL+J` and `CTRL+D` maps. +- Update Lua's reference manual to 5.3.6. +- Move the filetype plug-in for lua to `lua-support/rc`. - Minor changes and bugfixes. Note: The filetype plug-in has been moved, and is thus not loaded automatically -anymore. Copy it from 'lua-support/rc/' to 'ftplugin' or add the commands there +anymore. Copy it from `lua-support/rc/` to `ftplugin`, or add the commands there to your own filetype plug-in. RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- --> see file 'lua-support/doc/ChangeLog' +-> see file `lua-support/doc/ChangeLog` -------------------------------------------------------------------------------- @@ -240,7 +241,7 @@ FILES The help files for the toolbox. plugin/lua-support.vim - The Lua plug-in for Vim/gVim. + The Lua plug-in for Vim/gVim/Neovim. lua-support/templates/Templates Lua main template file. @@ -325,6 +326,8 @@ ADDITIONAL TIPS CREDITS ================================================================================ +__We thank:__ + * Fritz Mehner (vim.org user name: mehner) for a number of things: - his plug-ins (bash-support, c-support, perl-support, ...) provided the inspiration and model for this plug-in and the utilized template support @@ -335,11 +338,10 @@ CREDITS - the idea for suppling Lua's reference manual in Vim's help format is taken from his plug-in "luarefvim", which contains previous versions of the reference manual - ( http://vim.sourceforge.net/scripts/script.php?script_id=1291 ) + ( https://www.vim.org/scripts/script.php?script_id=1291 ) For a complete list of people who made contributions to this plug-in, please be so kind as to take a look at the credits: :help luasupport-credits - diff --git a/lua-support/README.standalone.md b/lua-support/README.standalone.md index fb54a6c..1b48f9f 100644 --- a/lua-support/README.standalone.md +++ b/lua-support/README.standalone.md @@ -3,8 +3,25 @@ Preface This repository is mainly for the use with plug-in managers. -The development happens here: -[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) +Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/luasupport.html). + +The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins). + + +Preview Version +================================================================================ + +___This is a preview version!___ + +Notable new feature: + +- Run Lua in a terminal window directly inside the editor. +- Fully enabled for Neovim. + +The terminal window relies on the new `+terminal` feature, which becomes +available with a patch level of approx. `8.0.1000`. + +_Please read the release notes below._ -------------------------------------------------------------------------------- diff --git a/lua-support/codesnippets/script_with_options.lua b/lua-support/codesnippets/script_with_options.lua index 03054a4..8dc08aa 100644 --- a/lua-support/codesnippets/script_with_options.lua +++ b/lua-support/codesnippets/script_with_options.lua @@ -1,5 +1,3 @@ -local args = { ... } - -- script name, version and help text local script_name = 'TODO' local script_version = '1.0' @@ -17,7 +15,7 @@ Options: ]] -- check for "--help" and "--version", exit -for idx, arg in ipairs ( args ) do +for idx, arg in ipairs ( arg ) do if arg == '-h' or arg == '--help' then print ( help_text ) return @@ -35,19 +33,19 @@ local options = { -- go through arguments local idx = 1 -while idx <= #args do +while idx <= #arg do - if args[idx] == '--lit' then + if arg[idx] == '--lit' then options.lit = true idx = idx + 1 - elseif args[idx] == '--str' then - options.str = args[idx+1] + elseif arg[idx] == '--str' then + options.str = arg[idx+1] idx = idx + 2 - elseif args[idx] == '-h' or args[idx] == '--help' or args[idx] == '-v' or args[idx] == '--version' then + elseif arg[idx] == '-h' or arg[idx] == '--help' or arg[idx] == '-v' or arg[idx] == '--version' then -- noop idx = idx + 1 else - print ( 'Unknown option: '..args[idx] ) + print ( 'Unknown option: '..arg[idx] ) print ( '' ) return end diff --git a/lua-support/html2doc/html2vim.lua b/lua-support/html2doc/html2vim.lua index fe62d0a..98301e6 100644 --- a/lua-support/html2doc/html2vim.lua +++ b/lua-support/html2doc/html2vim.lua @@ -24,40 +24,46 @@ os.setlocale ( 'C' ) -- settings for Lua 5.1.5 ------------------------------------------------------------------------ ---local lua_major = 5 ---local lua_minor = 1 ---local lua_release = 5 ---local lua_date = 'Feb 13 2012' ---local lua_copyright = '2006 - 2012' ---local doc_filename = os.getenv ( 'HOME' ) .. '/Programme/VimPlugins/doc/luaref51.txt' ---local link_main_component = 'lua51' ---local html_filename = '/home/wolfgang/Software/lua-5.1.5/doc/manual.html' +--[[ -- BlockCommentNo_1 -- +local lua_major = 5 +local lua_minor = 1 +local lua_release = 5 +local lua_date = 'Feb 13 2012' +local lua_copyright = '2006 - 2012' +local doc_filename = os.getenv ( 'HOME' ) .. '/Programme/VimPlugins/doc/luaref51.txt' +local link_main_component = 'lua51' +local html_filename = '/home/wolfgang/Software/lua-5.1.5/doc/manual.html' +--]] -- BlockCommentNo_1 -- ------------------------------------------------------------------------ -- settings for Lua 5.2.4 ------------------------------------------------------------------------ ---local lua_major = 5 ---local lua_minor = 2 ---local lua_release = 4 ---local lua_date = 'Feb 23 2015' ---local lua_copyright = '2011 - 2015' ---local doc_filename = os.getenv ( 'HOME' ) .. '/Programme/VimPlugins/doc/luaref52.txt' ---local link_main_component = 'lua52' ---local html_filename = '/home/wolfgang/Software/lua-5.2.4/doc/manual.html' +--[[ -- BlockCommentNo_2 -- +local lua_major = 5 +local lua_minor = 2 +local lua_release = 4 +local lua_date = 'Feb 23 2015' +local lua_copyright = '2011 - 2015' +local doc_filename = os.getenv ( 'HOME' ) .. '/Programme/VimPlugins/doc/luaref52.txt' +local link_main_component = 'lua52' +local html_filename = '/home/wolfgang/Software/lua-5.2.4/doc/manual.html' +--]] -- BlockCommentNo_2 -- ------------------------------------------------------------------------ --- settings for Lua 5.3.4 +-- settings for Lua 5.3.6 ------------------------------------------------------------------------ +--[ [ -- BlockCommentNo_3 -- local lua_major = 5 local lua_minor = 3 -local lua_release = 4 -local lua_date = 'May 30 2016' -local lua_copyright = '2015 - 2016' +local lua_release = 6 +local lua_date = 'Jul 14 2020' +local lua_copyright = '2015 - 2020' local doc_filename = os.getenv ( 'HOME' ) .. '/Programme/VimPlugins/doc/luaref53.txt' local link_main_component = 'lua53' -local html_filename = '/home/wolfgang/Software/lua-5.3.4/doc/manual.html' +local html_filename = '/home/wolfgang/Software/lua-5.3.6/doc/manual.html' +--]] -- BlockCommentNo_3 -- ------------------------------------------------------------------------ -- links to all versions (since Lua 5.3.1) @@ -208,7 +214,7 @@ local function t_add_anchor ( anchor ) local data = ANCHOR_DATA local pos = data[ANCHOR_POS] - text = t_rightalign ( data, anchor ) + local text = t_rightalign ( data, anchor ) table.insert ( data.text, pos, text ) @@ -1001,6 +1007,7 @@ function parse_matching_tag ( str_html, tag ) local options local tag_end = string.find ( str_html, '>', 1, true ) local tag_compl = string.sub ( str_html, 1, tag_end ) + local text_end if string.match ( tag_compl, '<'..tag_pat..'%s' ) then options = string.match ( tag_compl, '<'..tag_pat..'%s+(%S.*)>' ) @@ -1165,10 +1172,8 @@ end ----- end of function parse_html ----- -- }}}1 ------------------------------------------------------------------------ ---print ( string.format ( '"%s" "%s" "%s" "%s"', parse_matching_tag ( '<em class="id">opening long bracket of level <em class="blah">n</em></em> ', 'em' ) ) ) - -- header inserted before the generated documentation to make the format Vim compatible -header_txt = [[ +local header_txt = [[ *luaref%MAJOR%%MINOR%.txt* Lua %MAJOR%.%MINOR% Reference Manual %DATE% Lua %MAJOR%.%MINOR%.%RELEASE% Reference Manual *%LINKMAIN%* *luaref%MAJOR%%MINOR%* @@ -1187,7 +1192,7 @@ Formated for Vim help by ]] -- footer inserted after the generated documentation -footer_txt = [[ +local footer_txt = [[ Formated for Vim help: ]] .. os.date ( '%a %b %d %H:%M:%S %Z %Y' ) .. '\n' .. [[ diff --git a/lua-support/rc/additions.gvimrc b/lua-support/rc/additions.gvimrc index 0e96202..b8839a3 100644 --- a/lua-support/rc/additions.gvimrc +++ b/lua-support/rc/additions.gvimrc @@ -1,31 +1,32 @@ "------------------------------------------------------------------------------- -" Moving cursor to other windows: -" shift-down : change window focus to lower one (cyclic) -" shift-up : change window focus to upper one (cyclic) -" shift-left : change window focus to one on left -" shift-right : change window focus to one on right -"------------------------------------------------------------------------------- -nnoremap <s-down> <c-w>w -nnoremap <s-up> <c-w>W -nnoremap <s-left> <c-w>h -nnoremap <s-right> <c-w>l +" Moving cursor to other windows " -"------------------------------------------------------------------------------- -" Some additional hot keys: -" shift-F3 : call gvim file browser +" shift-down : change window focus to lower one (cyclic) +" shift-up : change window focus to upper one (cyclic) +" shift-left : change window focus to one on left +" shift-right : change window focus to one on right +"------------------------------------------------------------------------------- +nnoremap <s-down> <c-w>w +nnoremap <s-up> <c-w>W +nnoremap <s-left> <c-w>h +nnoremap <s-right> <c-w>l + +"------------------------------------------------------------------------------- +" Some additional hot keys +" +" shift-F3 : call gvim file browser "------------------------------------------------------------------------------- noremap <silent> <s-F3> :silent browse confirm e<CR> inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" + "------------------------------------------------------------------------------- " toggle insert mode <--> normal mode with the <RightMouse>-key "------------------------------------------------------------------------------- -nnoremap <RightMouse> <Insert> -inoremap <RightMouse> <ESC> -" + +nnoremap <RightMouse> <Insert> +inoremap <RightMouse> <ESC> + "------------------------------------------------------------------------------- " use font with clearly distinguishable brackets: ()[]{} "------------------------------------------------------------------------------- -set guifont=Monospace\ 11 "set guifont=Luxi\ Mono\ 14 -" diff --git a/lua-support/rc/additions.vimrc b/lua-support/rc/additions.vimrc index 7bca9dd..f95e515 100644 --- a/lua-support/rc/additions.vimrc +++ b/lua-support/rc/additions.vimrc @@ -1,20 +1,19 @@ "------------------------------------------------------------------------------- " Lua-Support -"------------------------------------------------------------------------------- " " the settings are documented here: -" :help lua-configuration -" +" :help luasupport-configuration "------------------------------------------------------------------------------- -" + "let g:Lua_LoadMenus = 'auto' "let g:Lua_RootMenu = '&Lua' -" "let g:Lua_MapLeader = '\' -" + +"let g:Lua_InsertFileHeader = 'no' + +"let g:Lua_OutputMethod = 'terminal' + +"let g:Lua_BinPath = '/path/to/lua/exe' "let g:Lua_Executable = 'lua' "let g:Lua_CompilerExec = 'luac' "let g:Lua_CompiledExtension = 'luac' -" -"let g:Lua_LclTemplateFile = '~/ TODO /Templates' -" diff --git a/lua-support/rc/customization.gvimrc b/lua-support/rc/customization.gvimrc index d0794a5..73ff4d7 100644 --- a/lua-support/rc/customization.gvimrc +++ b/lua-support/rc/customization.gvimrc @@ -1,54 +1,62 @@ -"=================================================================================== -" FILE: .gvimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc -" AUTHOR: Wolfgang Mehner -" VERSION: 1.0 -" CREATED: 20.03.2013 -" REVISION: -"=================================================================================== -" -"=================================================================================== +"=============================================================================== +" +" File: customization.gvimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 16.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== " GENERAL SETTINGS -"=================================================================================== -" -set cmdheight=2 " make command line two lines high -set mousehide " hide the mouse when typing text -" +"=============================================================================== + +set cmdheight=2 " Make command line two lines high +set mousehide " Hide the mouse when typing text + highlight Normal guibg=grey90 highlight Cursor guibg=Blue guifg=NONE highlight lCursor guibg=Cyan guifg=NONE highlight NonText guibg=grey80 highlight Constant gui=NONE guibg=grey95 highlight Special gui=NONE guibg=grey95 + +let c_comment_strings=1 " highlight strings inside C comments + +"------------------------------------------------------------------------------- +" Moving cursor to other windows " +" shift-down : change window focus to lower one (cyclic) +" shift-up : change window focus to upper one (cyclic) +" shift-left : change window focus to one on left +" shift-right : change window focus to one on right "------------------------------------------------------------------------------- -" Moving cursor to other windows: -" shift-down : change window focus to lower one (cyclic) -" shift-up : change window focus to upper one (cyclic) -" shift-left : change window focus to one on left -" shift-right : change window focus to one on right +nnoremap <s-down> <c-w>w +nnoremap <s-up> <c-w>W +nnoremap <s-left> <c-w>h +nnoremap <s-right> <c-w>l + "------------------------------------------------------------------------------- -nnoremap <s-down> <c-w>w -nnoremap <s-up> <c-w>W -nnoremap <s-left> <c-w>h -nnoremap <s-right> <c-w>l +" Some additional hot keys " -"------------------------------------------------------------------------------- -" Some additional hot keys: -" shift-F3 : call gvim file browser +" shift-F3 : call gvim file browser "------------------------------------------------------------------------------- noremap <silent> <s-F3> :silent browse confirm e<CR> inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" + "------------------------------------------------------------------------------- " toggle insert mode <--> normal mode with the <RightMouse>-key "------------------------------------------------------------------------------- -nnoremap <RightMouse> <Insert> -inoremap <RightMouse> <ESC> -" + +nnoremap <RightMouse> <Insert> +inoremap <RightMouse> <ESC> + "------------------------------------------------------------------------------- " use font with clearly distinguishable brackets: ()[]{} "------------------------------------------------------------------------------- -set guifont=Monospace\ 11 "set guifont=Luxi\ Mono\ 14 -" diff --git a/lua-support/rc/customization.vimrc b/lua-support/rc/customization.vimrc index 5da133a..cf47c20 100644 --- a/lua-support/rc/customization.vimrc +++ b/lua-support/rc/customization.vimrc @@ -1,34 +1,39 @@ -"=================================================================================== -" FILE: .vimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc -" AUTHOR: Wolfgang Mehner -" VERSION: 1.0 -" CREATED: 17.06.2012 -" REVISION: -"=================================================================================== +"=============================================================================== " -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== +" File: customization.vimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc " +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 15.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== +" GENERAL SETTINGS +"=============================================================================== + "------------------------------------------------------------------------------- " Use Vim settings, rather then Vi settings. " This must be first, because it changes other options as a side effect. "------------------------------------------------------------------------------- set nocompatible -" + "------------------------------------------------------------------------------- " Enable file type detection. Use the default filetype settings. " Also load indent files, to automatically do language-dependent indenting. "------------------------------------------------------------------------------- filetype plugin on filetype indent on -" + "------------------------------------------------------------------------------- " Switch syntax highlighting on. "------------------------------------------------------------------------------- syntax on -" + "------------------------------------------------------------------------------- " Platform specific items: " - central backup directory (has to be created) @@ -48,7 +53,7 @@ else " set backupdir =$HOME/.vim.backupdir " set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list endif -" + "------------------------------------------------------------------------------- " Various settings "------------------------------------------------------------------------------- @@ -59,12 +64,12 @@ set backspace=indent,eol,start " backspacing over everything in insert mode set backup " keep a backup file set browsedir=current " which directory to use for the file browser set complete+=k " scan the files given with the 'dictionary' option +set formatoptions+=j " remove comment leader when joining lines set history=50 " keep 50 lines of command line history set hlsearch " highlight the last used search pattern set incsearch " do incremental searching set listchars=tab:>.,eol:\$ " strings to use in 'list' mode set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines set popt=left:8pc,right:3pc " print options set ruler " show the cursor position all the time set shiftwidth=2 " number of spaces to use for each step of indent @@ -74,121 +79,144 @@ set tabstop=2 " number of spaces that a <Tab> counts for set visualbell " visual bell instead of beeping set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions set wildmenu " command-line completion in an enhanced mode -" +set nowrap " do not wrap lines + "------------------------------------------------------------------------------- " Highlight paired brackets "------------------------------------------------------------------------------- -highlight MatchParen ctermbg=blue guibg=lightyellow -" -"=================================================================================== -" BUFFERS and WINDOWS -"=================================================================================== -" +"highlight MatchParen ctermbg=blue guibg=lightyellow + +"=============================================================================== +" BUFFERS, WINDOWS +"=============================================================================== + +"------------------------------------------------------------------------------- +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). +"------------------------------------------------------------------------------- +if has("autocmd") + augroup MyResetCursor + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + augroup END +endif + "------------------------------------------------------------------------------- " Change the working directory to the directory containing the current file "------------------------------------------------------------------------------- if has("autocmd") - autocmd BufEnter * :lchdir %:p:h + augroup MySetLocalDir + autocmd BufEnter * :lchdir %:p:h + augroup END endif -" + "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" +"nnoremap <silent> <s-tab> :if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> +"inoremap <silent> <s-tab> <C-C>:if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> + "------------------------------------------------------------------------------- " Leave the editor with Ctrl-q: Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nnoremap <C-q> :wqall<CR> -" -"=================================================================================== -" HOT KEYS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" F2 - write file without confirmation -" F3 - call file explorer Ex -" F4 - show tag under curser in the preview window (tagfile must exist!) -" F5 - show the current list of errors -" F6 - close the quickfix window (error list) -" F7 - display previous error -" F8 - display next error -" F12 - list buffers and edit n-th buffer + "------------------------------------------------------------------------------- +" Some additional hot keys " +" F2 - write file without confirmation +" F3 - call file explorer Ex +" F4 - show tag under cursor in the preview window (tagfile must exist!) +" F5 - open quickfix error window +" F6 - close quickfix error window +" F7 - display previous error +" F8 - display next error +" F12 - list buffers and prompt for a buffer name +"------------------------------------------------------------------------------- + noremap <silent> <F2> :write<CR> noremap <silent> <F3> :Explore<CR> -noremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> +nnoremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> noremap <silent> <F5> :copen<CR> noremap <silent> <F6> :cclose<CR> noremap <silent> <F7> :cprevious<CR> noremap <silent> <F8> :cnext<CR> -noremap <F12> :ls<CR>:edit # -" -inoremap <silent> <F2> <C-C>:write<CR> -inoremap <silent> <F3> <C-C>:Explore<CR> -inoremap <silent> <F4> <C-C>:execute ":ptag ".expand("<cword>")<CR> -inoremap <silent> <F5> <C-C>:copen<CR> -inoremap <silent> <F6> <C-C>:cclose<CR> -inoremap <silent> <F7> <C-C>:cprevious<CR> -inoremap <silent> <F8> <C-C>:cnext<CR> -inoremap <F12> <C-C>:ls<CR>:edit # -" -"------------------------------------------------------------------------------- -" autocomplete parenthesis, brackets and braces -"------------------------------------------------------------------------------- +noremap <F12> :buffer <C-D> +noremap <S-F12> :sbuffer <C-D> + +inoremap <silent> <F2> <Esc>:write<CR> +inoremap <silent> <F3> <Esc>:Explore<CR> +inoremap <silent> <F4> <Esc>:execute ":ptag ".expand("<cword>")<CR> +inoremap <silent> <F5> <Esc>:copen<CR> +inoremap <silent> <F6> <Esc>:cclose<CR> +inoremap <silent> <F7> <Esc>:cprevious<CR> +inoremap <silent> <F8> <Esc>:cnext<CR> +inoremap <F12> <C-C>:buffer <C-D> +inoremap <S-F12> <C-C>:sbuffer <C-D> + +"------------------------------------------------------------------------------- +" Always wrap lines in the quickfix buffer +"------------------------------------------------------------------------------- +"autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak + +"=============================================================================== +" AUTOCOMPLETE BRACKETS, QUOTES +"=============================================================================== + +"------------------------------------------------------------------------------- +" Autocomplete parenthesis, brackets and braces +"------------------------------------------------------------------------------- + inoremap ( ()<Left> inoremap [ []<Left> inoremap { {}<Left> -" + " surround content vnoremap ( s()<Esc>P<Right>% vnoremap [ s[]<Esc>P<Right>% vnoremap { s{}<Esc>P<Right>% -" + " surround content with additional spaces vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% -" + "------------------------------------------------------------------------------- -" autocomplete quotes +" Autocomplete quotes "------------------------------------------------------------------------------- -" -inoremap '' ''<Left> -inoremap "" ""<Left> -" + " surround content (visual and select mode) -xnoremap ' s''<Esc>P<Right> -xnoremap " s""<Esc>P<Right> -xnoremap ` s``<Esc>P<Right> -" -"=================================================================================== +vnoremap ' s''<Esc>P<Right> +vnoremap " s""<Esc>P<Right> +vnoremap ` s``<Esc>P<Right> + +"=============================================================================== " VARIOUS PLUGIN CONFIGURATIONS -"=================================================================================== -" +"=============================================================================== + "------------------------------------------------------------------------------- " Lua-Support -"------------------------------------------------------------------------------- " " the settings are documented here: -" :help lua-configuration -" +" :help luasupport-configuration "------------------------------------------------------------------------------- -" + "let g:Lua_LoadMenus = 'auto' "let g:Lua_RootMenu = '&Lua' -" "let g:Lua_MapLeader = '\' -" + +"let g:Lua_InsertFileHeader = 'no' + +"let g:Lua_OutputMethod = 'terminal' + +"let g:Lua_BinPath = '/path/to/lua/exe' "let g:Lua_Executable = 'lua' "let g:Lua_CompilerExec = 'luac' "let g:Lua_CompiledExtension = 'luac' -" -"let g:Lua_LclTemplateFile = '~/ TODO /Templates' -" diff --git a/lua-support/templates/comments.templates b/lua-support/templates/comments.templates index bb7427e..d1ed1c9 100644 --- a/lua-support/templates/comments.templates +++ b/lua-support/templates/comments.templates @@ -59,6 +59,8 @@ -- Returns: {+RETURNS+} ------------------------------------------------------------------------ +== Comments.shebang == start, map:cb == +#!|LUA_INTERPRETER|<CURSOR> == ENDTEMPLATE == § ------------------------------------------------------------- @@ -106,11 +108,3 @@ |DATE| |TIME|<CURSOR> == ENDTEMPLATE == -§ ------------------------------------------------------------- -§ Interpreter -§ ------------------------------------------------------------- - -== Comments.shebang == start == -#!|LUA_INTERPRETER|<CURSOR> -== ENDTEMPLATE == - diff --git a/lua-support/templates/files.templates b/lua-support/templates/files.templates index 665937b..8331f59 100644 --- a/lua-support/templates/files.templates +++ b/lua-support/templates/files.templates @@ -9,10 +9,6 @@ local module_name = ... module ( module_name, package.seeall ) -<CURSOR> -== Files.script == below, map:fs, sc:s == -local args = { ... } - <CURSOR> == ENDTEMPLATE == @@ -28,10 +24,6 @@ local |BASENAME| = {} <CURSOR> return |BASENAME| -== Files.script == below, map:fs, sc:s == -local args = { ... } - -<CURSOR> == ENDTEMPLATE == == ENDSTYLES == diff --git a/lua-support/templates/statements.templates b/lua-support/templates/statements.templates index 917891f..948aa62 100644 --- a/lua-support/templates/statements.templates +++ b/lua-support/templates/statements.templates @@ -47,3 +47,15 @@ elseif <CURSOR> then else <CURSOR> == ENDTEMPLATE == + +§ ------------------------------------------------------------- +§ Block +§ ------------------------------------------------------------- + +== SEP: Statements.sep_block == + +== Statements.do block == below, map:sb, sc:b == +do + <CURSOR><SPLIT> +end +== ENDTEMPLATE == diff --git a/matlab-support/README.md b/matlab-support/README.md deleted file mode 100644 index fd2a409..0000000 --- a/matlab-support/README.md +++ /dev/null @@ -1,284 +0,0 @@ -README for matlab-support.vim (Version 0.8rc2) / Mar 25 2014 -================================================================================ - - * INSTALLATION - * RELEASE NOTES - * FILES - * ADDITIONAL TIPS - * CREDITS - - -MATLAB-IDE for Vim/gVim. It is written to considerably speed up writing code in -a consistent style. This is done by inserting complete statements, idioms and -comments. These code fragments are provided in an extendible template library. -This plug-in also supports the use of the MATLAB code checker "mlint", and -provides quick access to the online documentation of the Matlab functions. -Please read the documentation. -This plug-in can be used with Vim version 7.x . - -This software is not part of MATLAB. Neither the author nor the provided -software are associated with MathWorks, Inc in any way. - -The MathWorks, Inc and MATLAB are registered trademarks of The MathWorks, Inc. - - --------------------------------------------------------------------------------- - - INSTALLATION -================================================================================ - -A system-wide installation for all users can also be done. This will have -further effects on how the plug-in works. For a step-by-step instruction, as -well as an explanation of the other consequences, please see the help file -'doc/matlabsupport.txt' or look up the documentation via: - - :help matlabsupport-system-wide - - (1) LINUX ----------------------------------------------------------------------- - -The subdirectories in the zip archive matlab-support.zip mirror the directory -structure which is needed below the local installation directory - - $HOME/.vim/ - -(find the value of $HOME with ":echo $HOME" from inside Vim). - -(1.0) Save the template files in '$HOME/.vim/matlab-support/templates/' if - you have changed any of them. - -(1.1) Copy the zip archive matlab-support.zip to $HOME/.vim and run - - unzip matlab-support.zip - -(1.2) Loading of plug-in files must be enabled. If not use - - :filetype plugin on - - This is the minimal content of the file '$HOME/.vimrc'. Create one if there - is none or use the file in $HOME/.vim/matlab-support/rc as a starting point. - -(1.3) Set at least some personal details in the file - - '$HOME/.vim/matlab-support/templates/Templates' - - Here is the minimal personalization (my settings as an example): - - SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) - SetMacro( 'AUTHORREF', 'WM' ) - SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) - SetMacro( 'ORGANIZATION', '' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - - (Read more about the template system in the plug-in documentation) - -(1.4) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME/.vim/doc/ - -(1.5) Consider additional settings in the file '$HOME/.vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your .vimrc and .gvimrc. You may want to use parts of them. The files - are documented. - - (2) WINDOWS ----------------------------------------------------------------------- - -The subdirectories in the zip archive matlab-support.zip mirror the directory -structure which is needed below the local installation directory - - $HOME/vimfiles/ - -(find the value of $HOME with ":echo $HOME" from inside Vim). - -(2.0) Save the template files in '$HOME/vimfiles/matlab-support/templates/' - if you have changed any of them. - -(2.1) Copy the zip archive matlab-support.zip to $HOME/vimfiles and run - - unzip matlab-support.zip - -(2.2) Loading of plug-in files must be enabled. If not use - - :filetype plugin on - - This is the minimal content of the file '$HOME/_vimrc'. Create one if there - is none or use the file in $HOME/vimfiles/matlab-support/rc as a starting - point. - -(2.3) Set at least some personal details in the file - - '$HOME/vimfiles/matlab-support/templates/Templates' - - Here is the minimal personalization (my settings as an example): - - SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) - SetMacro( 'AUTHORREF', 'WM' ) - SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) - SetMacro( 'ORGANIZATION', '' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - - (Read more about the template system in the plug-in documentation) - -(2.4) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME\vimfiles\doc\ - -(2.5) Consider additional settings in the file '$HOME/_vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your _vimrc and _gvimrc. You may want to use parts of them. The files - are documented. - - (3) ADDITIONAL REMARKS ----------------------------------------------------------------------- - -There are a lot of features and options which can be used and influenced: - - * use of the extendible template library - * automated generation of comments for functions - * use of the MATLAB code checker mlint - * quick access to the online documentation - * removing the Matlab menu - -Look at the Matlab-Support help with: - - :help matlabsupport - - +-----------------------------------------------+ - | +-------------------------------------------+ | - | | ** PLEASE READ THE DOCUMENTATION ** | | - | | Actions differ for different modes! | | - | +-------------------------------------------+ | - +-----------------------------------------------+ - -Any problems? See the TROUBLESHOOTING section at the end of the help file -'doc/matlabsupport.txt'. - - --------------------------------------------------------------------------------- - - RELEASE NOTES -================================================================================ - - RELEASE NOTES FOR VERSION 0.8 ----------------------------------------------------------------------- -- Initial release. - - RELEASE NOTES FOR OLDER VERSIONS ----------------------------------------------------------------------- --> see file 'matlab-support/doc/ChangeLog' - - --------------------------------------------------------------------------------- - - FILES -================================================================================ - - README.md - This file. - - autoload/mmtemplates/* - The template system. - - doc/matlabsupport.txt - The help file for Matlab support. - - doc/templatesupport.txt - The help file for the template system. - - plugin/matlab-support.vim - The Matlab plug-in for Vim/gVim. - - matlab-support/templates/Templates - Matlab main template files. - - matlab-support/templates/*.templates - Several dependent template files. - -___The following files and extensions are for convenience only.___ -___matlab-support.vim will work without them.___ -___The settings are explained in the files themselves.___ - - ftplugin/matlab.vim - Example filetype plug-in for Matlab: - modifies tabs according to Matlab standard - - matlab-support/doc/ChangeLog - Complete change log. - - matlab-support/rc/additions.gvimrc - Additional settings for use in .gvimrc: - hot keys, mouse settings, fonts, ... - matlab-support/rc/additions.vimrc - Example settings for use in .vimrc: - setup of the plug-in - - matlab-support/rc/customization.gvimrc - Suggestion for the configuration file .gvimrc: - hot keys, mouse settings, fonts, ... - matlab-support/rc/customization.vimrc - Suggestion for the configuration file .vimrc: - hot keys, tabstop, use of dictionaries, - the setup of the plug-in, ... - - matlab-support/rc/sample_template_file - Sample template file for personalization, when using a - system-wide installation. - - --------------------------------------------------------------------------------- - - ADDITIONAL TIPS -================================================================================ - -(1) You may want to use a central hidden directory for all your backup files: - - 1.1 Add the following line to .vimrc: - - set backupdir=$HOME/.vim.backupdir - - 1.2 Create $HOME/.vim.backupdir . - - 1.3 Add the following line to your shell initialization file ~/.profile : - - find $HOME/.vim.backupdir/ -name "*" -type f -mtime +60 -exec rm -f {} \; - - When you are logging in all files in the backup directory older then 60 - days (-mtime +60) will be removed (60 days is a suggestion, of course). - Be sure to backup in shorter terms ! - -(2) gVim. Toggle 'insert mode' <--> 'normal mode' with the right mouse button - (see mapping in file customization.gvimrc). - -(3) gVim. Use tear off menus. - -(4) Try 'Focus under mouse' as window behavior (No mouse click when the mouse - pointer is back from the menu entry). - -(5) Use Emulate3Buttons "on" (X11) even for a 3-button mouse. Pressing left and - right button simultaneously without moving your fingers is faster than - moving a finger to the middle button (which is often a wheel). - - --------------------------------------------------------------------------------- - - CREDITS -================================================================================ - -* Fritz Mehner (vim.org user name: mehner) for a number of things: - - his plug-ins (bash-support, c-support, perl-support, ...) provided the - inspiration and model for this plug-in and the utilized template support - - parts of the documentation and other material (including the 'ADDITIONAL TIPS' - above) are taken from his plug-ins as well - -* Sameer Sheorey (sameer0s) and Fabrice Guy (Fabrice): - - for demonstrating how to use mlint with Vim - - -For a complete list of people who made contributions to this plug-in, -please be so kind as to take a look at the credits: - - :help matlabsupport-credits - diff --git a/matlab-support/README.standalone.md b/matlab-support/README.standalone.md deleted file mode 100644 index 375d7e7..0000000 --- a/matlab-support/README.standalone.md +++ /dev/null @@ -1,11 +0,0 @@ -Preface -================================================================================ - -This repository is mainly for the use with plug-in managers. - -The development happens here: -([WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins)) - - --------------------------------------------------------------------------------- - diff --git a/matlab-support/codesnippets/textscan.m b/matlab-support/codesnippets/textscan.m deleted file mode 100644 index 5c6e965..0000000 --- a/matlab-support/codesnippets/textscan.m +++ /dev/null @@ -1,12 +0,0 @@ -filename = 'TODO'; - -fid = fopen ( filename, 'r' ); - -if fid ~= -1 - C = textscan ( fid, '%f %f %f', 'commentstyle', '#', 'delimiter', '', 'collectoutput', false ); - - fclose ( fid ); -else - error ( 'Could not open the file "%s" for reading.', filename ); -end - diff --git a/matlab-support/doc/ChangeLog b/matlab-support/doc/ChangeLog deleted file mode 100644 index 2f954f9..0000000 --- a/matlab-support/doc/ChangeLog +++ /dev/null @@ -1,5 +0,0 @@ ---------------------------------------------------------------------------------------- - RELEASE NOTES FOR VERSION 0.8 ---------------------------------------------------------------------------------------- -- Initial release. - diff --git a/matlab-support/rc/additions.gvimrc b/matlab-support/rc/additions.gvimrc deleted file mode 100644 index 0e96202..0000000 --- a/matlab-support/rc/additions.gvimrc +++ /dev/null @@ -1,31 +0,0 @@ -"------------------------------------------------------------------------------- -" Moving cursor to other windows: -" shift-down : change window focus to lower one (cyclic) -" shift-up : change window focus to upper one (cyclic) -" shift-left : change window focus to one on left -" shift-right : change window focus to one on right -"------------------------------------------------------------------------------- -nnoremap <s-down> <c-w>w -nnoremap <s-up> <c-w>W -nnoremap <s-left> <c-w>h -nnoremap <s-right> <c-w>l -" -"------------------------------------------------------------------------------- -" Some additional hot keys: -" shift-F3 : call gvim file browser -"------------------------------------------------------------------------------- - noremap <silent> <s-F3> :silent browse confirm e<CR> -inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" -"------------------------------------------------------------------------------- -" toggle insert mode <--> normal mode with the <RightMouse>-key -"------------------------------------------------------------------------------- -nnoremap <RightMouse> <Insert> -inoremap <RightMouse> <ESC> -" -"------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets: ()[]{} -"------------------------------------------------------------------------------- -set guifont=Monospace\ 11 -"set guifont=Luxi\ Mono\ 14 -" diff --git a/matlab-support/rc/additions.vimrc b/matlab-support/rc/additions.vimrc deleted file mode 100644 index ba1fd16..0000000 --- a/matlab-support/rc/additions.vimrc +++ /dev/null @@ -1,18 +0,0 @@ -"------------------------------------------------------------------------------- -" Matlab-Support -"------------------------------------------------------------------------------- -" -" the settings are documented here: -" :help matlabsupport-configuration -" -"------------------------------------------------------------------------------- -" -"let g:Matlab_LoadMenus = 'auto' -"let g:Matlab_RootMenu = '&Matlab' -" -"let g:Matlab_MapLeader = '\' -" -"let g:Matlab_MlintExecutable = '/opt/matlab/ TODO /mlint' -" -"let g:Matlab_LclTemplateFile = '~/ TODO /Templates' -" diff --git a/matlab-support/rc/customization.gvimrc b/matlab-support/rc/customization.gvimrc deleted file mode 100644 index d0794a5..0000000 --- a/matlab-support/rc/customization.gvimrc +++ /dev/null @@ -1,54 +0,0 @@ -"=================================================================================== -" FILE: .gvimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc -" AUTHOR: Wolfgang Mehner -" VERSION: 1.0 -" CREATED: 20.03.2013 -" REVISION: -"=================================================================================== -" -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== -" -set cmdheight=2 " make command line two lines high -set mousehide " hide the mouse when typing text -" -highlight Normal guibg=grey90 -highlight Cursor guibg=Blue guifg=NONE -highlight lCursor guibg=Cyan guifg=NONE -highlight NonText guibg=grey80 -highlight Constant gui=NONE guibg=grey95 -highlight Special gui=NONE guibg=grey95 -" -"------------------------------------------------------------------------------- -" Moving cursor to other windows: -" shift-down : change window focus to lower one (cyclic) -" shift-up : change window focus to upper one (cyclic) -" shift-left : change window focus to one on left -" shift-right : change window focus to one on right -"------------------------------------------------------------------------------- -nnoremap <s-down> <c-w>w -nnoremap <s-up> <c-w>W -nnoremap <s-left> <c-w>h -nnoremap <s-right> <c-w>l -" -"------------------------------------------------------------------------------- -" Some additional hot keys: -" shift-F3 : call gvim file browser -"------------------------------------------------------------------------------- - noremap <silent> <s-F3> :silent browse confirm e<CR> -inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" -"------------------------------------------------------------------------------- -" toggle insert mode <--> normal mode with the <RightMouse>-key -"------------------------------------------------------------------------------- -nnoremap <RightMouse> <Insert> -inoremap <RightMouse> <ESC> -" -"------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets: ()[]{} -"------------------------------------------------------------------------------- -set guifont=Monospace\ 11 -"set guifont=Luxi\ Mono\ 14 -" diff --git a/matlab-support/rc/customization.vimrc b/matlab-support/rc/customization.vimrc deleted file mode 100644 index c1abc41..0000000 --- a/matlab-support/rc/customization.vimrc +++ /dev/null @@ -1,192 +0,0 @@ -"=================================================================================== -" FILE: .vimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc -" AUTHOR: Wolfgang Mehner -" VERSION: 1.0 -" CREATED: 17.06.2012 -" REVISION: -"=================================================================================== -" -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" Use Vim settings, rather then Vi settings. -" This must be first, because it changes other options as a side effect. -"------------------------------------------------------------------------------- -set nocompatible -" -"------------------------------------------------------------------------------- -" Enable file type detection. Use the default filetype settings. -" Also load indent files, to automatically do language-dependent indenting. -"------------------------------------------------------------------------------- -filetype plugin on -filetype indent on -" -"------------------------------------------------------------------------------- -" Switch syntax highlighting on. -"------------------------------------------------------------------------------- -syntax on -" -"------------------------------------------------------------------------------- -" Platform specific items: -" - central backup directory (has to be created) -" - default dictionary -" Uncomment your choice. -" -" Using a backupdir under UNIX/Linux: you may want to include a line similar to: -" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; -" in one of your shell startup files (e.g. $HOME/.profile). -"------------------------------------------------------------------------------- -if has("win16") || has("win32") || has("win64") || - \ has("win95") || has("win32unix") -" runtime mswin.vim -" set backupdir =$VIM\vimfiles\backupdir -" set dictionary=$VIM\vimfiles\wordlists/german.list -else -" set backupdir =$HOME/.vim.backupdir -" set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list -endif -" -"------------------------------------------------------------------------------- -" Various settings -"------------------------------------------------------------------------------- -set autoindent " copy indent from current line -set autoread " read open files again when changed outside Vim -set autowrite " write a modified buffer on each :next , ... -set backspace=indent,eol,start " backspacing over everything in insert mode -set backup " keep a backup file -set browsedir=current " which directory to use for the file browser -set complete+=k " scan the files given with the 'dictionary' option -set history=50 " keep 50 lines of command line history -set hlsearch " highlight the last used search pattern -set incsearch " do incremental searching -set listchars=tab:>.,eol:\$ " strings to use in 'list' mode -set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines -set popt=left:8pc,right:3pc " print options -set ruler " show the cursor position all the time -set shiftwidth=2 " number of spaces to use for each step of indent -set showcmd " display incomplete commands -set smartindent " smart autoindenting when starting a new line -set tabstop=2 " number of spaces that a <Tab> counts for -set visualbell " visual bell instead of beeping -set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions -set wildmenu " command-line completion in an enhanced mode -" -"------------------------------------------------------------------------------- -" Highlight paired brackets -"------------------------------------------------------------------------------- -highlight MatchParen ctermbg=blue guibg=lightyellow -" -"=================================================================================== -" BUFFERS and WINDOWS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" Change the working directory to the directory containing the current file -"------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufEnter * :lchdir %:p:h -endif -" -"------------------------------------------------------------------------------- -" Fast switching between buffers -" The current buffer will be saved before switching to the next one. -" Choose :bprevious or :bnext -"------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" -"------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q: Write all changed buffers and exit Vim -"------------------------------------------------------------------------------- -nnoremap <C-q> :wqall<CR> -" -"=================================================================================== -" HOT KEYS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" F2 - write file without confirmation -" F3 - call file explorer Ex -" F4 - show tag under curser in the preview window (tagfile must exist!) -" F5 - show the current list of errors -" F6 - close the quickfix window (error list) -" F7 - display previous error -" F8 - display next error -" F12 - list buffers and edit n-th buffer -"------------------------------------------------------------------------------- -" -noremap <silent> <F2> :write<CR> -noremap <silent> <F3> :Explore<CR> -noremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> -noremap <silent> <F5> :copen<CR> -noremap <silent> <F6> :cclose<CR> -noremap <silent> <F7> :cprevious<CR> -noremap <silent> <F8> :cnext<CR> -noremap <F12> :ls<CR>:edit # -" -inoremap <silent> <F2> <C-C>:write<CR> -inoremap <silent> <F3> <C-C>:Explore<CR> -inoremap <silent> <F4> <C-C>:execute ":ptag ".expand("<cword>")<CR> -inoremap <silent> <F5> <C-C>:copen<CR> -inoremap <silent> <F6> <C-C>:cclose<CR> -inoremap <silent> <F7> <C-C>:cprevious<CR> -inoremap <silent> <F8> <C-C>:cnext<CR> -inoremap <F12> <C-C>:ls<CR>:edit # -" -"------------------------------------------------------------------------------- -" autocomplete parenthesis, brackets and braces -"------------------------------------------------------------------------------- -inoremap ( ()<Left> -inoremap [ []<Left> -inoremap { {}<Left> -" -" surround content -vnoremap ( s()<Esc>P<Right>% -vnoremap [ s[]<Esc>P<Right>% -vnoremap { s{}<Esc>P<Right>% -" -" surround content with additional spaces -vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% -vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% -vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% -" -"------------------------------------------------------------------------------- -" autocomplete quotes -"------------------------------------------------------------------------------- -" -inoremap '' ''<Left> -inoremap "" ""<Left> -" -" surround content (visual and select mode) -xnoremap ' s''<Esc>P<Right> -xnoremap " s""<Esc>P<Right> -xnoremap ` s``<Esc>P<Right> -" -"=================================================================================== -" VARIOUS PLUGIN CONFIGURATIONS -"=================================================================================== -" -"------------------------------------------------------------------------------- -" Matlab-Support -"------------------------------------------------------------------------------- -" -" the settings are documented here: -" :help matlabsupport-configuration -" -"------------------------------------------------------------------------------- -" -"let g:Matlab_LoadMenus = 'auto' -"let g:Matlab_RootMenu = '&Matlab' -" -"let g:Matlab_MapLeader = '\' -" -"let g:Matlab_MlintExecutable = '/opt/matlab/ TODO /mlint' -" -"let g:Matlab_LclTemplateFile = '~/ TODO /Templates' -" diff --git a/matlab-support/rc/sample_template_file b/matlab-support/rc/sample_template_file deleted file mode 100644 index 940420b..0000000 --- a/matlab-support/rc/sample_template_file +++ /dev/null @@ -1,16 +0,0 @@ -§ ============================================================= -§ User Macros -§ ============================================================= - -SetMacro( 'AUTHOR', 'YOUR NAME' ) -SetMacro( 'AUTHORREF', '' ) -SetMacro( 'EMAIL', '' ) -SetMacro( 'ORGANIZATION', '' ) -SetMacro( 'COMPANY', '' ) -SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) -SetMacro( 'LICENSE', 'GNU General Public License' ) - -§ ============================================================= -§ File Includes -§ ============================================================= - diff --git a/matlab-support/release.lua b/matlab-support/release.lua deleted file mode 100644 index bc78767..0000000 --- a/matlab-support/release.lua +++ /dev/null @@ -1,154 +0,0 @@ --- --------------------------------------------------------------------------------- --- FILE: release.lua --- USAGE: lua matlab-support/release.lua <mode> [<options>] --- DESCRIPTION: Run from the project's top-level directory. --- OPTIONS: The mode is either "check", "zip", "cp-repo" or "help". --- REQUIREMENTS: --- --- BUGS: --- --- NOTES: --- --- AUTHOR: Wolfgang Mehner, <wolfgang-mehner@web.de> --- COMPANY: --- VERSION: 1.0 --- CREATED: 14.09.11 --- REVISION: 01.03.14 --------------------------------------------------------------------------------- --- - -function escape_shell ( text ) - return string.gsub ( text, '[%(%);&=\' ]', function ( m ) return '\\' .. m end ) -end ---------- end of function escape_shell ---------- - -local args = { ... } - -local outfile = 'matlab-support.zip' - -local filelist = { - 'autoload/mmtemplates/', - 'doc/matlabsupport.txt', - 'doc/templatesupport.txt', - 'ftplugin/matlab.vim', - 'plugin/matlab-support.vim', - 'syntax/template.vim', - 'matlab-support/codesnippets/', - 'matlab-support/doc/', - 'matlab-support/rc/', - 'matlab-support/templates/', - 'matlab-support/README.md', -} - -local filelist_repo = { - 'matlab-support/release.lua', -} - -outfile = escape_shell ( outfile ) -for idx, val in ipairs ( filelist ) do - filelist[ idx ] = escape_shell ( val ) -end - -local print_help = false - -if #args == 0 then - - print ( '\n=== failed: mode missing ===\n' ) - - print_help = true - -elseif args[1] == 'check' then - - local cmd = 'grep -nH ":[[:upper:]]\\+:\\|[Tt][Oo][Dd][Oo]" '..table.concat ( filelist, ' ' ) - - print ( '\n=== checking ===\n' ) - - local success, res_reason, res_status = os.execute ( cmd ) - - if success then - print ( '\n=== done ===\n' ) - else - print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' ) - end - -elseif args[1] == 'zip' then - - local cmd = 'zip -r '..outfile..' '..table.concat ( filelist, ' ' ) - - print ( '\n=== executing: '..outfile..' ===\n' ) - - local success, res_reason, res_status = os.execute ( cmd ) - - if success then - print ( '\n=== successful ===\n' ) - else - print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' ) - end - -elseif args[1] == 'cp-repo' then - - if #args >= 2 then - - filelist_compl = {} - - for key, val in pairs ( filelist ) do - table.insert ( filelist_compl, val ) - end - - for key, val in pairs ( filelist_repo ) do - table.insert ( filelist_compl, val ) - end - - os.execute ( 'mkdir -p '..args[2] ) - - local cmd = 'cp --parents -r '..table.concat ( filelist_compl, ' ' )..' '..args[2] - - print ( '\n=== copying: '..args[2]..' ===\n' ) - - local success, res_reason, res_status = os.execute ( cmd ) - - if success then - cmd = 'cat matlab-support/README.standalone.md matlab-support/README.md > '..args[2]..'/README.md' - - success, res_reason, res_status = os.execute ( cmd ) - end - - if success then - cmd = 'echo "\\ntaken from WolfgangMehner/vim-plugins, revision\\nhttps://github.com/WolfgangMehner/vim-plugins/commit/$(git rev-parse HEAD)" >> '..args[2]..'/project/commit.txt' - - success, res_reason, res_status = os.execute ( cmd ) - end - - if success then - print ( '\n=== successful ===\n' ) - else - print ( '\n=== failed: '..res_reason..' '..res_status..' ===\n' ) - end - - else - - print ( '\n=== failed: no destination given: release.lua cp-repo <dest> ===\n' ) - - end - -elseif args[1] == 'help' then - - print_help = true - -else - - print ( '\n=== failed: unknown mode "'..args[1]..'" ===\n' ) - - print_help = true - -end - -if print_help then - - print ( '' ) - print ( 'release <mode>' ) - print ( '' ) - print ( '\tcheck - check the release' ) - print ( '\tzip - create archive' ) - print ( '\tcp-repo <dest> - copy the repository' ) - print ( '\thelp - print help' ) - print ( '' ) - -end diff --git a/matlab-support/templates/Templates b/matlab-support/templates/Templates deleted file mode 100644 index f153f93..0000000 --- a/matlab-support/templates/Templates +++ /dev/null @@ -1,54 +0,0 @@ -§ ============================================================= -§ User Macros -§ ============================================================= - -SetMacro( 'AUTHOR', 'YOUR NAME' ) -SetMacro( 'AUTHORREF', '' ) -SetMacro( 'EMAIL', '' ) -SetMacro( 'ORGANIZATION', '' ) -SetMacro( 'COMPANY', '' ) -SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) -SetMacro( 'LICENSE', 'GNU General Public License' ) - -SetFormat( 'DATE', '%x' ) -SetFormat( 'TIME', '%H:%M' ) -SetFormat( 'YEAR', '%Y' ) - -§ browser for help templates (UNIX) -SetMacro( 'HELP_BROWSER', 'firefox' ) - -§ browser for help templates (Windows) -§SetMacro( 'HELP_BROWSER', '"C:\Program Files\Mozilla Firefox\firefox.exe"' ) - -§ ============================================================= -§ File Includes -§ ============================================================= - -MenuShortcut( 'Comments', 'c' ) -MenuShortcut( 'Statements', 's' ) -MenuShortcut( 'Idioms', 'i' ) -MenuShortcut( 'Classes', 'l' ) -MenuShortcut( 'Help', 'h' ) - -IncludeFile( 'comments.templates' ) -IncludeFile( 'statements.templates' ) -IncludeFile( 'idioms.templates' ) -IncludeFile( 'classes.templates' ) - -§ ============================================================= -§ Help -§ ============================================================= - -SetMacro( 'HelpPathEnglish', 'http://en.wiktionary.org/wiki/' ) -SetMacro( 'HelpPathMathWorks', 'http://www.mathworks.de/help/techdoc/' ) - -== HELP: Help.English == map:he, sc:e == -|Word( '' )| -|Substitute( '\W', '', 'g' )| -|System( '|HELP_BROWSER| |HelpPathEnglish||PICK:l|' )| -== HELP: Help.Matlab function == map:hf, sc:f == -|Word( '' )| -|Substitute( '\W', '', 'g' )| -|System( '|HELP_BROWSER| |HelpPathMathWorks|ref/|PICK|.html' )| -|Default( '|HELP_BROWSER| |HelpPathMathWorks|' )| -== ENDTEMPLATE == diff --git a/matlab-support/templates/classes.templates b/matlab-support/templates/classes.templates deleted file mode 100644 index 9e68fdf..0000000 --- a/matlab-support/templates/classes.templates +++ /dev/null @@ -1,71 +0,0 @@ -§ ============================================================= -§ Classes -§ ============================================================= - -MenuShortcut( 'Classes.Properties', 'p' ) -MenuShortcut( 'Classes.Method', 'm' ) - -§ ------------------------------------------------------------- -§ Properties -§ ------------------------------------------------------------- - -== Classes.Properties.normal == below, sc:n == -properties ( GetAccess=public, SetAccess=public ) - <SPLIT> -end - -== Classes.Properties.dependent == below, sc:d == -properties ( GetAccess=public, SetAccess=public, Dependent ) - <SPLIT> -end - -== ENDTEMPLATE == - -§ ------------------------------------------------------------- -§ Methods -§ ------------------------------------------------------------- - -== Classes.Method.static object == below, sc:s == -function out = |?FUNCTION_NAME| ( obj, varargin ) - <SPLIT> -end - -== Classes.Method.change object == below, sc:c == -function obj = |?FUNCTION_NAME| ( obj, varargin ) - <SPLIT> -end - -== ENDTEMPLATE == - -§ ------------------------------------------------------------- -§ Definition -§ ------------------------------------------------------------- - -== Classes.definition == start, noindent, sc:d == -classdef |BASENAME| -%|BASENAME:u| Summary. -% Details. - - properties ( GetAccess=public, SetAccess=public ) - end - - methods ( Access=public ) - - function |BASENAME| = |BASENAME| ( varargin ) - %|BASENAME:u| Constructs a |BASENAME| object. - % - % Parameters: - % property, value, ... - Options. - % Returns: |BASENAME| - The new object. - - - end - - end - -end - -== ENDTEMPLATE == - -§-------------------------------------------------------------- -§ vim:et:sw=4:ts=4: diff --git a/matlab-support/templates/comments.templates b/matlab-support/templates/comments.templates deleted file mode 100644 index c0ed97d..0000000 --- a/matlab-support/templates/comments.templates +++ /dev/null @@ -1,107 +0,0 @@ -§ ============================================================= -§ Comments -§ ============================================================= - -MenuShortcut( 'Comments.Lists', 'l' ) - -== Comments.end-of-line comment == append, nomenu == -% <CURSOR> -== Comments.frame comment == below, map:cfr, sc:r == -%----------------------------------------------------------------------- -% <CURSOR> -%----------------------------------------------------------------------- -== ENDTEMPLATE == - -§ ------------------------------------------------------------- -§ Description -§ -§ Usage: -§ 'Comments.file description' and 'Comments.function description' -§ are used for the automated function description. Their names -§ should remain unchanged. The macro names 'FUNCTION_NAME', -§ 'PARAMETERS' and 'RETURNS' are fixed as well. -§ ------------------------------------------------------------- - -== Comments.file description == start, map:cfi, sc:f == -%|BASENAME:u| <CURSOR>. -% {+DETAILS+} -% -% Parameters: -|PARAMETERS:EMPTY| -% Parameters: |PARAMETERS:FIRST| - {+DESCRIPTION+} ({+TYPE+}) -% |PARAMETERS:ENTRY| - {+DESCRIPTION+} ({+TYPE+}) -% Returns: -|RETURNS:EMPTY| -% Returns: |RETURNS:FIRST| - {+DESCRIPTION+} ({+TYPE+}) -% |RETURNS:ENTRY| - {+DESCRIPTION+} ({+TYPE+}) -% -% See also: TODO - -== Comments.function description == below, map:cfu, sc:f == -%|?FUNCTION_NAME:u| <CURSOR>. -% {+DETAILS+} -% -% Parameters: -|PARAMETERS:EMPTY| -% Parameters: |PARAMETERS:FIRST| - {+DESCRIPTION+} ({+TYPE+}) -% |PARAMETERS:ENTRY| - {+DESCRIPTION+} ({+TYPE+}) -% Returns: -|RETURNS:EMPTY| -% Returns: |RETURNS:FIRST| - {+DESCRIPTION+} ({+TYPE+}) -% |RETURNS:ENTRY| - {+DESCRIPTION+} ({+TYPE+}) -== Comments.parameter description == below, map:cpa, sc:p == -% <CURSOR> - {+DESCRIPTION+} ({+TYPE+}) -== ENDTEMPLATE == - -§ ------------------------------------------------------------- -§ Keywords, Special and Macros -§ ------------------------------------------------------------- - -== LIST: comments_keywords == hash == - 'bug' : ':BUG:|DATE| |TIME|:|AUTHORREF|: <CURSOR>', - 'todo' : ':TODO:|DATE| |TIME|:|AUTHORREF|: <CURSOR>', - 'tricky' : ':TRICKY:|DATE| |TIME|:|AUTHORREF|: <CURSOR>', - 'warning' : ':WARNING:|DATE| |TIME|:|AUTHORREF|: <CURSOR>', - 'workaround' : ':WORKAROUND:|DATE| |TIME|:|AUTHORREF|: <CURSOR>', - 'new keyword' : ':<CURSOR>:|DATE| |TIME|:|AUTHORREF|: {+COMMENT+}', -== LIST: comments_special == list == - 'EMPTY', - 'FALL THROUGH', - 'NO RETURN', - 'NOT REACHED', - 'REMAINS TO BE IMPLEMENTED', -== LIST: comments_macros == hash == - 'author' : '|AUTHOR|', - 'authorRef' : '|AUTHORREF|', - 'organization' : '|ORGANIZATION|', - 'copyright' : '|COPYRIGHT|', - 'email' : '|EMAIL|', - - 'path' : '|PATH|', - 'filename' : '|FILENAME|', - 'basename' : '|BASENAME|', - 'basename:u' : '|BASENAME:u|', - 'suffix' : '|SUFFIX|', - - 'date' : '|DATE|', - 'time' : '|TIME|', - 'year' : '|YEAR|', -== ENDLIST == - -§ ------------------------------------------------------------- - -== SEP: Comments.sep1 == - -== Comments.keyword comment == expandmenu, append, map:cke, sc:k == -|PickList( 'keyword', 'comments_keywords' )| - % |PICK| -== Comments.special comments == expandmenu, append, map:csp, sc:s == -|PickList( 'special comment', 'comments_special' )| - % |PICK|<CURSOR> -== Comments.macros == expandmenu, insert, map:cma, sc:m == -|PickList( 'macro', 'comments_macros' )| -|PICK|<CURSOR> -== Comments.date == insert, map:cd, sc:d == -|DATE|<CURSOR> -== Comments.date time == insert, sc:t == -|DATE| |TIME|<CURSOR> -== ENDTEMPLATE == - -§-------------------------------------------------------------- -§ vim:et:sw=4:ts=4: diff --git a/matlab-support/templates/idioms.templates b/matlab-support/templates/idioms.templates deleted file mode 100644 index 857f941..0000000 --- a/matlab-support/templates/idioms.templates +++ /dev/null @@ -1,80 +0,0 @@ -§ ============================================================= -§ Idioms -§ ============================================================= - -MenuShortcut( 'Idioms.Exceptions', 'x' ) - -§ ------------------------------------------------------------- -§ Exception Object -§ ------------------------------------------------------------- - -== LIST: exception_properties == hash == - 'cause{}' : 'cause{<CURSOR>}', - 'identifier' : 'identifier<CURSOR>', - 'message' : 'message<CURSOR>', - 'stack' : 'stack<CURSOR>', - 'stack().file' : 'stack(<CURSOR>).file', - 'stack().line' : 'stack(<CURSOR>).line', - 'stack().name' : 'stack(<CURSOR>).name', -== ENDLIST == - -== LIST: exception_methods == hash == - 'MException' : '', - 'addCause' : ', {+CAUSE_EXCEPTION+}', - 'getReport' : '', - 'rethrow' : '', - 'throw' : '', - 'throwAsCaller' : '', -== ENDLIST == - -== Idioms.Exceptions.property == insert, expandmenu, map:xp, sc:p == -|Prompt( 'EXCEPTION_OBJ', '' )| -|PickList( 'property', 'exception_properties' )| -|EXCEPTION_OBJ|.|VALUE| -== Idioms.Exceptions.method == insert, expandmenu, map:xm, sc:m == -|Prompt( 'EXCEPTION_OBJ', '' )| -|PickList( 'method', 'exception_methods' )| -|KEY| ( |EXCEPTION_OBJ|<CURSOR>|VALUE| ) -== Idioms.Exceptions.last exception == insert, map:xl, sc:l == -MException.last<CURSOR> -== ENDTEMPLATE == - -§ ------------------------------------------------------------- -§ Try-Catch Block -§ ------------------------------------------------------------- - -== Idioms.Exceptions.try == below, map:xt, sc:t == -|Prompt( 'EXCEPTION_OBJ', '' )| -try - <CURSOR><SPLIT> -catch |EXCEPTION_OBJ| - {+EXC_HANDLING+} -end -== ENDTEMPLATE == - -§ ------------------------------------------------------------- -§ Try-Catch Block -§ ------------------------------------------------------------- - -== SEP: Idioms.sep_functions == - -== Idioms.primary function == start, map:ip, sc:p == -function <CURSOR> = |BASENAME| ( {+ARGUMENTS+} ) - <SPLIT>{-FUNCTION_BODY-} -end - -== Idioms.function == below, map:if, sc:f == -function <CURSOR> = |?FUNCTION_NAME| ( {+ARGUMENTS+} ) - <SPLIT>{-FUNCTION_BODY-} -end - -== ENDTEMPLATE == - -SetPath( 'matlab_path', './' ) - -== Idioms.add to MATLAB path == below, map:im, sc:m == -path ( path, '<CURSOR>' ); -== ENDTEMPLATE == - -§-------------------------------------------------------------- -§ vim:et:sw=4:ts=4: diff --git a/matlab-support/templates/statements.templates b/matlab-support/templates/statements.templates deleted file mode 100644 index ea7c192..0000000 --- a/matlab-support/templates/statements.templates +++ /dev/null @@ -1,70 +0,0 @@ -§ ============================================================= -§ Statements -§ ============================================================= - -§ ------------------------------------------------------------- -§ Loops -§ ------------------------------------------------------------- - -== Statements.for == below, map:sf, sc:f == -for i = <CURSOR> - <SPLIT>{-LOOP_BODY-} -end -== Statements.for, vector == below, map:sv, sc:v == -for i = 1:length ( <CURSOR> ) - <SPLIT>{-LOOP_BODY-} -end -== Statements.while == below, map:sw, sc:w == -while <CURSOR> - <SPLIT>{-LOOP_BODY-} -end -== ENDTEMPLATE == - -§ ------------------------------------------------------------- -§ If-Then-Else -§ ------------------------------------------------------------- - -== SEP: Statements.sep_if == - -== Statements.if, end == below, map:sif, sc:i == -if <CURSOR> - <SPLIT>{-IF_PART-} -end -== Statements.if, else == below, map:sie, sc:i == -if <CURSOR> - <SPLIT>{-IF_PART-} -else - {+ELSE_PART+} -end -== Statements.elseif == below, map:sei, sc:e == -elseif <CURSOR> - {+ELSEIF_PART+} -== Statements.else == below, map:sel, sc:e == -else - <CURSOR> -== ENDTEMPLATE == - -§ ------------------------------------------------------------- -§ Switch -§ ------------------------------------------------------------- - -== SEP: Statements.sep_switch == - -== Statements.switch == below, map:ss, sc:s == -switch <CURSOR> - case {+CASE+} - {+CODE+} - - otherwise - {+OTHERWISE+} -end -== Statements.case == below, map:sc, sc:c == -case <CURSOR> - {+CODE+} -== Statements.otherwise == below, map:so, sc:o == -otherwise - <CURSOR> -== ENDTEMPLATE == - -§-------------------------------------------------------------- -§ vim:et:sw=4:ts=4: diff --git a/perl-support/README.md b/perl-support/README.md index df17c7e..3853270 100644 --- a/perl-support/README.md +++ b/perl-support/README.md @@ -1,4 +1,4 @@ -README for perl-support.vim (Version 5.5pre) / February 12 2017 +README for perl-support.vim (Version 5.5alpha) / August 06 2020 ================================================================================ * INSTALLATION @@ -59,7 +59,12 @@ structure which is needed below the local installation directory `$HOME/.vim/` This is the minimal content of the file `$HOME/.vimrc`. Create one if there is none or use the files in `$HOME/.vim/perl-support/rc` as a starting point. -(1.3) Set at least some personal details. Use the map `\ntw` inside a Perl buffer +(1.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME/.vim/doc/ + +(1.4) Set at least some personal details. Use the map `\ntw` inside a Perl buffer or the menu entry: Perl -> Snippets -> template setup wizard @@ -78,11 +83,6 @@ structure which is needed below the local installation directory `$HOME/.vim/` (Read more about the template system in the plug-in documentation) -(1.4) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME/.vim/doc/ - (1.5) Consider additional settings in the file `$HOME/.vimrc`. The files `customization.vimrc` and `customization.gvimrc` are replacements or extensions for your `.vimrc` and `.gvimrc`. You may want to use parts of @@ -116,7 +116,12 @@ structure which is needed below the local installation directory This is the minimal content of the file `$HOME/_vimrc`. Create one if there is none or use the files in `$HOME/vimfiles/perl-support/rc` as a starting point. -(2.3) Set at least some personal details. Use the map `\ntw` inside a Perl buffer +(2.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME\vimfiles\doc\ + +(2.4) Set at least some personal details. Use the map `\ntw` inside a Perl buffer or the menu entry: Perl -> Snippets -> template setup wizard @@ -135,11 +140,6 @@ structure which is needed below the local installation directory (Read more about the template system in the plug-in documentation) -(2.4) Make the plug-in help accessible by typing the following command on the - Vim command line: - - :helptags $HOME\vimfiles\doc\ - (2.5) Consider additional settings in the file `$HOME/_vimrc`. The files `customization.vimrc` and `customization.gvimrc` are replacements or extensions for your `_vimrc` and `_gvimrc`. You may want to use parts of @@ -163,17 +163,10 @@ There are a lot of features and options which can be used and influenced: * removing the root menu * using additional plug-ins -Look at the Perl Support help with: +Actions differ for different modes. Please read the documentation: :help perlsupport - +-----------------------------------------------+ - | +-------------------------------------------+ | - | | ** PLEASE READ THE DOCUMENTATION ** | | - | | Actions differ for different modes! | | - | +-------------------------------------------+ | - +-----------------------------------------------+ - Any problems? See the TROUBLESHOOTING section at the end of the help file `doc/perlsupport.txt`. @@ -183,10 +176,33 @@ Any problems? See the TROUBLESHOOTING section at the end of the help file RELEASE NOTES ================================================================================ -RELEASE NOTES FOR VERSION 5.5pre +RELEASE NOTES FOR VERSION 5.5alpha ---------------------------------------------------------------------- +- Add command `:Perl [<args>]` to run the interpreter with arguments. +- Add command `:PerlDebug [<args>]` to run the debugger with arguments. +- Add command `:PerlCheck` to run the syntax checker. +- Add command `:PerlDoc [<item>]` to look up help. +- Set default for `g:Perl_Executable` to `perl` when running under Linux, + instead of a hardcoded path. +- The templates which are inserted into new files as file skeletons can be + specified in the templates library, via the properties: + `Perl::FileSkeleton::Script`, `Perl::FileSkeleton::Module`, + `Perl::FileSkeleton::Test`, `Perl::FileSkeleton::POD` +- Add configuration variable `g:Perl_Ctrl_d` to control the creation + of the `CTRL+D` map. +- Remove the definition of the maps `F9`. `CTRL+F9`, `SHIFT+F9`, `ALT+F9`, and + `SHIFT+F1`. Add them to your filetype plug-in if you want to use them. - Minor changes. +Note: The filetype plug-ins have been moved, and are thus not loaded +automatically anymore. Copy them from `perl-support/rc` to `ftplugin`, +or add the commands there to your own filetype plug-ins. + +Note: Some configuration for `*.t` and `*.pod` files has been removed. +See `perl-support/rc/customization.vimrc` for how to add them to your +configuration files. + + RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- -> see file `perl-support/doc/ChangeLog` @@ -241,16 +257,6 @@ ___The following files and extensions are for convenience only.___ ___perl-support.vim will work without them.___ ___The settings are explained in the files themselves.___ - ftplugin/make.vim - Access hotkeys for make(1) in makefiles. - ftplugin/perl.vim - A filetype plugin. Define hotkeys, create a local - dictionary for each Perl file. - ftplugin/pod.vim - A filetype plugin. Define hotkeys for filetype 'pod'. - ftplugin/qf.vim - A filetype plugin used by the profilers. - ftdetect/template.vim ftplugin/template.vim syntax/template.vim @@ -277,6 +283,17 @@ ___The settings are explained in the files themselves.___ The file is commented. Append it to your .vimrc if you like. + perl-support/rc/make.vim + Access hotkeys for make(1) in makefiles. + perl-support/rc/perl.vim + perl-support/rc/pod.vim + Example filetype plug-ins for Perl and POD: + defines additional maps, + set tabs according to Perl Style Guide + expands keyword characters for better support of tokens, + perl-support/rc/qf.vim + Some maps to help with the profilers' output. + perl-support/rc/*.templates Sample template files for customization. Used by the template setup wizard. diff --git a/perl-support/README.standalone.md b/perl-support/README.standalone.md index fb54a6c..96f04db 100644 --- a/perl-support/README.standalone.md +++ b/perl-support/README.standalone.md @@ -3,8 +3,9 @@ Preface This repository is mainly for the use with plug-in managers. -The development happens here: -[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) +Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/perlsupport.html). + +The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins). -------------------------------------------------------------------------------- diff --git a/perl-support/doc/ChangeLog b/perl-support/doc/ChangeLog index 733f270..830f870 100644 --- a/perl-support/doc/ChangeLog +++ b/perl-support/doc/ChangeLog @@ -1,3 +1,29 @@ +--------------------------------------------------------------------------------------- + RELEASE NOTES FOR VERSION 5.5 +--------------------------------------------------------------------------------------- +- Add command ':Perl [<args>]' to run the interpreter with arguments. +- Add command ':PerlDebug [<args>]' to run the debugger with arguments. +- Add command ':PerlCheck' to run the syntax checker. +- Add command ':PerlDoc [<item>]' to look up help. +- Set default for 'g:Perl_Executable' to 'perl' when running under Linux, + instead of a hardcoded path. +- The templates which are inserted into new files as file skeletons can be + specified in the templates library, via the properties: + 'Perl::FileSkeleton::Script', 'Perl::FileSkeleton::Module', + 'Perl::FileSkeleton::Test', 'Perl::FileSkeleton::POD' +- Add configuration variable 'g:Perl_Ctrl_d' to control the creation + of the 'CTRL+D' map. +- Remove the definition of the maps 'F9'. 'CTRL+F9', 'SHIFT+F9', 'ALT+F9', and + 'SHIFT+F1'. Add them to your filetype plug-in if you want to use them. +- Minor changes. + +Note: The filetype plug-ins have been moved, and are thus not loaded +automatically anymore. Copy them from 'perl-support/rc' to 'ftplugin', +or add the commands there to your own filetype plug-ins. +Note: Some configuration for '*.t' and '*.pod' files has been removed. +See 'perl-support/rc/customization.vimrc' for how to add them to your +configuration files. + --------------------------------------------------------------------------------------- RELEASE NOTES FOR VERSION 5.4 --------------------------------------------------------------------------------------- diff --git a/perl-support/doc/perl-hot-keys.tex b/perl-support/doc/perl-hot-keys.tex index f0220be..4f3dda4 100644 --- a/perl-support/doc/perl-hot-keys.tex +++ b/perl-support/doc/perl-hot-keys.tex @@ -30,7 +30,7 @@ \setlength\parindent{0pt} -\newcommand{\Pluginversion}{5.5pre} +\newcommand{\Pluginversion}{5.5} \newcommand{\ReleaseDate}{\today} \newcommand{\Rep}{{\scriptsize{[n]}}} @@ -78,7 +78,7 @@ \textbf{\textsc{\Huge{Hot keys}}}\\ \vspace{1mm}% Key mappings for Vim and gVim\\ -{\tiny \texttt{http://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ +{\tiny \texttt{https://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ \vspace{1.0mm} {\normalsize (i)} insert mode, {\normalsize (n)} normal mode, {\normalsize (v)} visual mode\\ \vspace{1.0mm} diff --git a/perl-support/doc/pmdesc3.text b/perl-support/doc/pmdesc3.text index e0ddadc..9444335 100644 --- a/perl-support/doc/pmdesc3.text +++ b/perl-support/doc/pmdesc3.text @@ -49,12 +49,12 @@ BUGS AND LIMITATIONS There are no known bugs in this module. - Please report problems to Fritz Mehner, mehner@web.de . + Please report problems to Fritz Mehner, mehner.fritz@web.de . AUTHORS Tom Christiansen, tchrist@perl.com (pmdesc) Aristotle, http://qs321.pair.com/~monkads/ (pmdesc2) - Fritz Mehner, mehner@web.de (pmdesc3.pl) + Fritz Mehner, mehner.fritz@web.de (pmdesc3.pl) NOTES pmdesc3.pl is based on pmdesc2 (Aristotle, diff --git a/perl-support/rc/custom.templates b/perl-support/rc/custom.templates index 0642d73..db8e179 100644 --- a/perl-support/rc/custom.templates +++ b/perl-support/rc/custom.templates @@ -5,9 +5,27 @@ § set the template style used after loading the library SetStyle( 'default' ) +§ date format: +§SetFormat ( "TIME_LOCALE", "en_US.UTF-8" ) + +§ pretty dates: +§ - DATE_PRETTY1 is a nicer date formatting, such as "January 06 2016" +§ - DATE_PRETTY2 is a shorter version, such as "Jan 06 2016" +SetFormat( 'DATE_PRETTY1', '%B %d %Y' ) +SetFormat( 'DATE_PRETTY2', '%b %d %Y' ) + § used by the template "Comments.file description pl": SetMacro( 'PERL_INTERPRETER', '/usr/bin/env perl' ) +§ templates automatically included into new files +§ set the property to an empty string to disable the insertion +§SetProperty ( 'Perl::FileSkeleton::Script', 'Comments.shebang;Comments.file description pl; ;Skeleton.script-use' ) +§SetProperty ( 'Perl::FileSkeleton::Module', 'Comments.file description pm; ;Skeleton.module-use' ) +§SetProperty ( 'Perl::FileSkeleton::Module', 'Comments.file description pm; ;Skeleton.module-pod; ;Skeleton.module-use' ) +§SetProperty ( 'Perl::FileSkeleton::Test', 'Comments.file description t; ;Skeleton.test-use' ) +§SetProperty ( 'Perl::FileSkeleton::POD', '' ) +§SetProperty ( 'Perl::FileSkeleton::POD', 'Comments.file description pod' ) + § ------------------------------------------------------------- § A template definition is build like this: § == Menu.some name == <options> == @@ -19,6 +37,57 @@ SetMacro( 'PERL_INTERPRETER', '/usr/bin/env perl' ) § the start of a new template. § ------------------------------------------------------------- +§ ------------------------------------------------------------- +§ Inserted when creating a new script. +§ See configuration variable 'g:Perl_InsertFileHeader' +§ and template properties: +§ - Perl::FileSkeleton::Script +§ - Perl::FileSkeleton::Module +§ - Perl::FileSkeleton::Test +§ - Perl::FileSkeleton::POD +§ +§ - option 'nomenu': this will not create a menu entry +§ ------------------------------------------------------------- + +§ uncomment and edit to customize + +§== Skeleton.script-use == nomenu, below == +§use strict; +§use warnings; +§use utf8; +§== ENDTEMPLATE == + +§== Skeleton.module-use == nomenu, below == +§use strict; +§use warnings; +§== ENDTEMPLATE == + +§== Skeleton.test-use == nomenu, below == +§use strict; +§use warnings; +§ +§use Test::More tests => 1; # last test to print +§== ENDTEMPLATE == + +§== Skeleton.module-pod == nomenu, below == +§=pod +§ +§=head2 SYNOPSIS +§ +§PACKAGE NAME: |BASENAME| +§ +§AUTHOR: |AUTHOR| +§ +§DATE: |DATE_PRETTY1| +§ +§DESCRIPTION: +§Version: +§ +§=head2 USE +§ +§=cut +§== ENDTEMPLATE == + § ------------------------------------------------------------- § Statements § ------------------------------------------------------------- diff --git a/perl-support/rc/custom_with_personal.templates b/perl-support/rc/custom_with_personal.templates index b9b1b4a..6d9cedd 100644 --- a/perl-support/rc/custom_with_personal.templates +++ b/perl-support/rc/custom_with_personal.templates @@ -32,9 +32,27 @@ SetMacro( 'LICENSE', 'GNU General Public License' ) § set the template style used after loading the library SetStyle( 'default' ) +§ date format: +§SetFormat ( "TIME_LOCALE", "en_US.UTF-8" ) + +§ pretty dates: +§ - DATE_PRETTY1 is a nicer date formatting, such as "January 06 2016" +§ - DATE_PRETTY2 is a shorter version, such as "Jan 06 2016" +SetFormat( 'DATE_PRETTY1', '%B %d %Y' ) +SetFormat( 'DATE_PRETTY2', '%b %d %Y' ) + § used by the template "Comments.file description pl": SetMacro( 'PERL_INTERPRETER', '/usr/bin/env perl' ) +§ templates automatically included into new files +§ set the property to an empty string to disable the insertion +§SetProperty ( 'Perl::FileSkeleton::Script', 'Comments.shebang;Comments.file description pl; ;Skeleton.script-use' ) +§SetProperty ( 'Perl::FileSkeleton::Module', 'Comments.file description pm; ;Skeleton.module-use' ) +§SetProperty ( 'Perl::FileSkeleton::Module', 'Comments.file description pm; ;Skeleton.module-pod; ;Skeleton.module-use' ) +§SetProperty ( 'Perl::FileSkeleton::Test', 'Comments.file description t; ;Skeleton.test-use' ) +§SetProperty ( 'Perl::FileSkeleton::POD', '' ) +§SetProperty ( 'Perl::FileSkeleton::POD', 'Comments.file description pod' ) + § ------------------------------------------------------------- § A template definition is build like this: § == Menu.some name == <options> == @@ -46,6 +64,57 @@ SetMacro( 'PERL_INTERPRETER', '/usr/bin/env perl' ) § the start of a new template. § ------------------------------------------------------------- +§ ------------------------------------------------------------- +§ Inserted when creating a new script. +§ See configuration variable 'g:Perl_InsertFileHeader' +§ and template properties: +§ - Perl::FileSkeleton::Script +§ - Perl::FileSkeleton::Module +§ - Perl::FileSkeleton::Test +§ - Perl::FileSkeleton::POD +§ +§ - option 'nomenu': this will not create a menu entry +§ ------------------------------------------------------------- + +§ uncomment and edit to customize + +§== Skeleton.script-use == nomenu, below == +§use strict; +§use warnings; +§use utf8; +§== ENDTEMPLATE == + +§== Skeleton.module-use == nomenu, below == +§use strict; +§use warnings; +§== ENDTEMPLATE == + +§== Skeleton.test-use == nomenu, below == +§use strict; +§use warnings; +§ +§use Test::More tests => 1; # last test to print +§== ENDTEMPLATE == + +§== Skeleton.module-pod == nomenu, below == +§=pod +§ +§=head2 SYNOPSIS +§ +§PACKAGE NAME: |BASENAME| +§ +§AUTHOR: |AUTHOR| +§ +§DATE: |DATE_PRETTY1| +§ +§DESCRIPTION: +§Version: +§ +§=head2 USE +§ +§=cut +§== ENDTEMPLATE == + § ------------------------------------------------------------- § Statements § ------------------------------------------------------------- diff --git a/perl-support/rc/customization.gvimrc b/perl-support/rc/customization.gvimrc index 026a2b2..73ff4d7 100644 --- a/perl-support/rc/customization.gvimrc +++ b/perl-support/rc/customization.gvimrc @@ -1,17 +1,23 @@ -"=================================================================================== -" FILE: .gvimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" VERSION: 1.0 -" CREATED: 23.05.2008 -"=================================================================================== +"=============================================================================== " -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== +" File: customization.gvimrc " -set cmdheight=2 " Make command line two lines high -set mousehide " Hide the mouse when typing text +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 16.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== +" GENERAL SETTINGS +"=============================================================================== + +set cmdheight=2 " Make command line two lines high +set mousehide " Hide the mouse when typing text highlight Normal guibg=grey90 highlight Cursor guibg=Blue guifg=NONE @@ -20,34 +26,37 @@ highlight NonText guibg=grey80 highlight Constant gui=NONE guibg=grey95 highlight Special gui=NONE guibg=grey95 -" +let c_comment_strings=1 " highlight strings inside C comments + "------------------------------------------------------------------------------- -" Moving cursor to other windows: -" shift down : change window focus to lower one (cyclic) -" shift up : change window focus to upper one (cyclic) -" shift left : change window focus to one on left -" shift right : change window focus to one on right +" Moving cursor to other windows +" +" shift-down : change window focus to lower one (cyclic) +" shift-up : change window focus to upper one (cyclic) +" shift-left : change window focus to one on left +" shift-right : change window focus to one on right "------------------------------------------------------------------------------- nnoremap <s-down> <c-w>w nnoremap <s-up> <c-w>W nnoremap <s-left> <c-w>h nnoremap <s-right> <c-w>l -" + "------------------------------------------------------------------------------- -" Some additional hot keys: -" S-F3 - call gvim file browser +" Some additional hot keys +" +" shift-F3 : call gvim file browser "------------------------------------------------------------------------------- noremap <silent> <s-F3> :silent browse confirm e<CR> inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> -" + "------------------------------------------------------------------------------- -" toggle insert mode <--> 'normal mode with the <RightMouse>-key +" toggle insert mode <--> normal mode with the <RightMouse>-key "------------------------------------------------------------------------------- + nnoremap <RightMouse> <Insert> inoremap <RightMouse> <ESC> -" + "------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets : ()[]{} +" use font with clearly distinguishable brackets: ()[]{} "------------------------------------------------------------------------------- -set guifont=Luxi\ Mono\ 14 -" +"set guifont=Luxi\ Mono\ 14 diff --git a/perl-support/rc/customization.vimrc b/perl-support/rc/customization.vimrc index 0de5cd8..686a305 100644 --- a/perl-support/rc/customization.vimrc +++ b/perl-support/rc/customization.vimrc @@ -1,47 +1,59 @@ -"=================================================================================== -" FILE: .vimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" VERSION: 1.0 -" CREATED: 23.05.2008 -"=================================================================================== +"=============================================================================== " -"=================================================================================== -" GENERAL SETTINGS -"=================================================================================== +" File: customization.vimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc " +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 15.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== +" GENERAL SETTINGS +"=============================================================================== + "------------------------------------------------------------------------------- " Use Vim settings, rather then Vi settings. " This must be first, because it changes other options as a side effect. "------------------------------------------------------------------------------- set nocompatible -" + "------------------------------------------------------------------------------- " Enable file type detection. Use the default filetype settings. " Also load indent files, to automatically do language-dependent indenting. "------------------------------------------------------------------------------- filetype plugin on filetype indent on -" + "------------------------------------------------------------------------------- " Switch syntax highlighting on. "------------------------------------------------------------------------------- -syntax on -" +syntax on + +"------------------------------------------------------------------------------- " Platform specific items: " - central backup directory (has to be created) " - default dictionary -" Uncomment your choice. -if has("win16") || has("win32") || has("win64") || has("win95") +" Uncomment your choice. " +" Using a backupdir under UNIX/Linux: you may want to include a line similar to: +" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; +" in one of your shell startup files (e.g. $HOME/.profile). +"------------------------------------------------------------------------------- +if has("win16") || has("win32") || has("win64") || + \ has("win95") || has("win32unix") " runtime mswin.vim " set backupdir =$VIM\vimfiles\backupdir " set dictionary=$VIM\vimfiles\wordlists/german.list else - set backupdir =$HOME/.vim.backupdir - set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list +" set backupdir =$HOME/.vim.backupdir +" set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list endif -" + "------------------------------------------------------------------------------- " Various settings "------------------------------------------------------------------------------- @@ -52,12 +64,12 @@ set backspace=indent,eol,start " backspacing over everything in insert mode set backup " keep a backup file set browsedir=current " which directory to use for the file browser set complete+=k " scan the files given with the 'dictionary' option +set formatoptions+=j " remove comment leader when joining lines set history=50 " keep 50 lines of command line history -set hlsearch " highlightthe last used search pattern +set hlsearch " highlight the last used search pattern set incsearch " do incremental searching set listchars=tab:>.,eol:\$ " strings to use in 'list' mode set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines set popt=left:8pc,right:3pc " print options set ruler " show the cursor position all the time set shiftwidth=2 " number of spaces to use for each step of indent @@ -67,110 +79,154 @@ set tabstop=2 " number of spaces that a <Tab> counts for set visualbell " visual bell instead of beeping set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions set wildmenu " command-line completion in an enhanced mode -" -"------------------------------------------------------------------------------- -" highlight paired brackets -"------------------------------------------------------------------------------- -highlight MatchParen ctermbg=blue guibg=lightyellow -" -"------------------------------------------------------------------------------- -" some additional hot keys -"------------------------------------------------------------------------------- -" F2 - write file without confirmation -" F3 - call file explorer Ex -" F4 - show tag under curser in the preview window (tagfile must exist!) -" F6 - list all errors -" F7 - display previous error -" F8 - display next error -" F12 - list buffers and edit n-th buffer -"------------------------------------------------------------------------------- -noremap <silent> <F2> :write<CR> -noremap <silent> <F3> :Explore<CR> -noremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> -noremap <silent> <F5> :copen<CR> -noremap <silent> <F6> :cclose<CR> -noremap <silent> <F7> :cprevious<CR> -noremap <silent> <F8> :cnext<CR> -noremap <F12> :ls<CR>:edit # -" -inoremap <silent> <F2> <C-C>:write<CR> -inoremap <silent> <F3> <C-C>:Explore<CR> -inoremap <silent> <F4> <C-C>:execute ":ptag ".expand("<cword>")<CR> -inoremap <silent> <F5> <C-C>:copen<CR> -inoremap <silent> <F6> <C-C>:cclose<CR> -inoremap <silent> <F7> <C-C>:cprevious<CR> -inoremap <silent> <F8> <C-C>:cnext<CR> -inoremap <F12> <C-C>:ls<CR>:edit # -" -"------------------------------------------------------------------------------- -" comma always followed by a space -"------------------------------------------------------------------------------- -inoremap , ,<Space> -" +set nowrap " do not wrap lines + "------------------------------------------------------------------------------- -" autocomplete parenthesis, (brackets) and braces +" Highlight paired brackets "------------------------------------------------------------------------------- -inoremap ( ()<Left> -inoremap [ []<Left> -inoremap { {}<Left> -" -vnoremap ( s()<Esc>P<Right>% -vnoremap [ s[]<Esc>P<Right>% -vnoremap { s{}<Esc>P<Right>% -" -" surround content with additional spaces -" -vnoremap ) s( )<Esc><Left>P<Right><Right>% -vnoremap ] s[ ]<Esc><Left>P<Right><Right>% -vnoremap } s{ }<Esc><Left>P<Right><Right>% -" +"highlight MatchParen ctermbg=blue guibg=lightyellow + +"=============================================================================== +" BUFFERS, WINDOWS +"=============================================================================== + "------------------------------------------------------------------------------- -" autocomplete quotes (visual and select mode) +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). "------------------------------------------------------------------------------- -xnoremap ' s''<Esc>P<Right> -xnoremap " s""<Esc>P<Right> -xnoremap ` s``<Esc>P<Right> -" +if has("autocmd") + augroup MyResetCursor + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + augroup END +endif + "------------------------------------------------------------------------------- -" The current directory is the directory of the file in the current window. +" Change the working directory to the directory containing the current file "------------------------------------------------------------------------------- if has("autocmd") - autocmd BufEnter * :lchdir %:p:h + augroup MySetLocalDir + autocmd BufEnter * :lchdir %:p:h + augroup END endif -" + "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" +"nnoremap <silent> <s-tab> :if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> +"inoremap <silent> <s-tab> <C-C>:if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> + "------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q (KDE): Write all changed buffers and exit Vim +" Leave the editor with Ctrl-q: Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nnoremap <C-q> :wqall<CR> -" -" -"=================================================================================== -" VARIOUS PLUGIN CONFIGURATIONS -"=================================================================================== -" + "------------------------------------------------------------------------------- -" perl-support.vim -"------------------------------------------------------------------------------- -" -" --empty -- +" Some additional hot keys " +" F2 - write file without confirmation +" F3 - call file explorer Ex +" F4 - show tag under cursor in the preview window (tagfile must exist!) +" F5 - open quickfix error window +" F6 - close quickfix error window +" F7 - display previous error +" F8 - display next error +" F12 - list buffers and prompt for a buffer name "------------------------------------------------------------------------------- -" plugin taglist.vim : toggle the taglist window -" plugin taglist.vim : define the tag file entry for Perl -"------------------------------------------------------------------------------- -"------------------------------------------------------------------------------- - noremap <silent> <F11> :TlistToggle<CR> -inoremap <silent> <F11> <C-C>:TlistToggle<CR> -" + +noremap <silent> <F2> :write<CR> +noremap <silent> <F3> :Explore<CR> +nnoremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> +noremap <silent> <F5> :copen<CR> +noremap <silent> <F6> :cclose<CR> +noremap <silent> <F7> :cprevious<CR> +noremap <silent> <F8> :cnext<CR> +noremap <F12> :buffer <C-D> +noremap <S-F12> :sbuffer <C-D> + +inoremap <silent> <F2> <Esc>:write<CR> +inoremap <silent> <F3> <Esc>:Explore<CR> +inoremap <silent> <F4> <Esc>:execute ":ptag ".expand("<cword>")<CR> +inoremap <silent> <F5> <Esc>:copen<CR> +inoremap <silent> <F6> <Esc>:cclose<CR> +inoremap <silent> <F7> <Esc>:cprevious<CR> +inoremap <silent> <F8> <Esc>:cnext<CR> +inoremap <F12> <C-C>:buffer <C-D> +inoremap <S-F12> <C-C>:sbuffer <C-D> + +"------------------------------------------------------------------------------- +" Always wrap lines in the quickfix buffer +"------------------------------------------------------------------------------- +"autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak + +"=============================================================================== +" AUTOCOMPLETE BRACKETS, QUOTES +"=============================================================================== + +"------------------------------------------------------------------------------- +" Autocomplete parenthesis, brackets and braces +"------------------------------------------------------------------------------- + +inoremap ( ()<Left> +inoremap [ []<Left> +inoremap { {}<Left> + +" surround content +vnoremap ( s()<Esc>P<Right>% +vnoremap [ s[]<Esc>P<Right>% +vnoremap { s{}<Esc>P<Right>% + +" surround content with additional spaces +vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% +vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% +vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% + +"------------------------------------------------------------------------------- +" Autocomplete quotes +"------------------------------------------------------------------------------- + +" surround content (visual and select mode) +vnoremap ' s''<Esc>P<Right> +vnoremap " s""<Esc>P<Right> +vnoremap ` s``<Esc>P<Right> + +"=============================================================================== +" VARIOUS PLUGIN CONFIGURATIONS +"=============================================================================== + +"------------------------------------------------------------------------------- +" Perl-Support +" +" the settings are documented here: +" :help perlsupport-custom-variables +"------------------------------------------------------------------------------- + +" use Perl syntax highlighting for POD +" always use filetype 'perl' for files *.t +"augroup MyFiletypeAdjust +"autocmd BufNewFile,BufReadPost *.pod setlocal syntax=perl +"autocmd BufNewFile,BufReadPost *.t setlocal filetype=perl +"augroup END + +"let g:Perl_LoadMenus = 'yes' +"let g:Perl_CreateMenusDelayed = 'no' +"let g:Perl_RootMenu = '&Perl' +"let g:Perl_MapLeader = '\' + +"let g:Perl_InsertFileHeader = 'no' + +"------------------------------------------------------------------------------- +" taglist.vim : toggle the taglist window +" taglist.vim : define the tag file entry for Perl +"------------------------------------------------------------------------------- + noremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> +inoremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> + let tlist_perl_settings = 'perl;c:constants;f:formats;l:labels;p:packages;s:subroutines;d:subroutines;o:POD;k:comments' -" diff --git a/perl-support/rc/make.vim b/perl-support/rc/make.vim new file mode 100644 index 0000000..a1afd27 --- /dev/null +++ b/perl-support/rc/make.vim @@ -0,0 +1,36 @@ +" ------------------------------------------------------------------------------ +" +" Vim filetype plugin file +" +" Language : Make +" Plugin : c.vim / latex-support.vim / ... +" Revision : 03.10.2017 +" Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> +" (formerly Fritz Mehner <mehner.fritz@web.de>) +" +" ------------------------------------------------------------------------------ + +" Only do this when not done yet for this buffer +if exists("b:did_c_support_make") + finish +endif +let b:did_c_support_make = 1 + +" ---------- Set "maplocalleader" as configured using "g:C_MapLeader" -------- +"call C_SetMapLeader () + +" ---------- Maps for the Make tool ------------------------------------------ + noremap <buffer> <silent> <LocalLeader>rm :Make<CR> +inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> + noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> +inoremap <buffer> <silent> <LocalLeader>rmc <C-C>:Make clean<CR> + noremap <buffer> <silent> <LocalLeader>rmd :Make doc<CR> +inoremap <buffer> <silent> <LocalLeader>rmd <C-C>:Make doc<CR> + noremap <buffer> <LocalLeader>rma :MakeCmdlineArgs<space> +inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> + noremap <buffer> <LocalLeader>rcm :MakeFile<space> +inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> + +" ---------- Reset "maplocalleader" ------------------------------------------ +"call C_ResetMapLeader () + diff --git a/ftplugin/perl.vim b/perl-support/rc/perl.vim similarity index 61% rename from ftplugin/perl.vim rename to perl-support/rc/perl.vim index cf13931..4e5bf4d 100644 --- a/ftplugin/perl.vim +++ b/perl-support/rc/perl.vim @@ -4,7 +4,7 @@ " " Language : Perl " Plugin : perl-support.vim -" Revision : 15.04.2017 +" Revision : 26.06.2019 " Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> " (formerly Fritz Mehner <mehner.fritz@web.de>) " @@ -20,27 +20,49 @@ let b:did_perl_support_ftplugin = 1 " Set tabulator and shift width to 4 conforming to the Perl Style Guide. " Uncomment the next two lines to force these settings for all files with " filetype 'perl' . -" setlocal tabstop=4 setlocal shiftwidth=4 -" + " ---------- Add ':' to the keyword characters ------------------------------- " Tokens like 'File::Find' are recognized as " one keyword -" setlocal iskeyword+=: -" + " ---------- additional mapping : {<CR> always opens a block ----------------- -" inoremap <buffer> {<CR> {<CR>}<Esc>O vnoremap <buffer> {<CR> s{<CR>}<Esc>kp=iB -" + " ---------- Set "maplocalleader" as configured using "g:Perl_MapLeader" ----- -" call Perl_SetMapLeader () -" + +" Ctrl-F9: run script (alt 1: run it straight away) + noremap <buffer> <silent> <C-F9> :Perl<CR> +inoremap <buffer> <silent> <C-F9> <C-C>:Perl<CR> +"" Ctrl-F9: run script (alt 2: add cmd.-line arguments, then press <Enter> to run) +" noremap <buffer> <C-F9> :Perl<Space> +"inoremap <buffer> <C-F9> <C-C>:Perl<Space> + +" F9: run debugger (alt 1: run it straight away) + noremap <buffer> <silent> <F9> :PerlDebug<CR> +inoremap <buffer> <silent> <F9> <C-C>:PerlDebug<CR> + +"" F9: run debugger (alt 2: add cmd.-line arguments, then press <Enter> to run) +" noremap <buffer> <F9> :PerlDebug<Space> +"inoremap <buffer> <F9> <C-C>:PerlDebug<Space> + +" Alt-F9: run syntax check + noremap <buffer> <silent> <A-F9> :PerlCheck<CR> +inoremap <buffer> <silent> <A-F9> <C-C>:PerlCheck<CR> + +" Shift-F9: set command line arguments + noremap <buffer> <S-F9> :PerlScriptArguments<Space> +inoremap <buffer> <S-F9> <C-C>:PerlScriptArguments<Space> + +" Shift-F1: read Perl documentation + noremap <buffer> <silent> <S-F1> :PerlDoc<CR> +inoremap <buffer> <silent> <S-F1> <C-C>:PerlDoc<CR> + " ---------- Maps for the Make tool ------------------------------------------ -" noremap <buffer> <silent> <LocalLeader>rm :Make<CR> inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> @@ -49,8 +71,7 @@ inoremap <buffer> <silent> <LocalLeader>rmc <C-C>:Make clean<CR> inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> noremap <buffer> <LocalLeader>rcm :MakeFile<space> inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> -" + " ---------- Reset "maplocalleader" ------------------------------------------ -" call Perl_ResetMapLeader () -" + diff --git a/ftplugin/pod.vim b/perl-support/rc/pod.vim similarity index 84% rename from ftplugin/pod.vim rename to perl-support/rc/pod.vim index 43ead99..82f4307 100644 --- a/ftplugin/pod.vim +++ b/perl-support/rc/pod.vim @@ -4,7 +4,7 @@ " " Language : Perl (POD) " Plugin : perl-support.vim -" Revision : 15.04.2017 +" Revision : 26.06.2019 " Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> " (formerly Fritz Mehner <mehner.fritz@web.de>) " @@ -20,22 +20,26 @@ let b:did_perl_support_pod = 1 " Set tabulator and shift width to 4 conforming to the Perl Style Guide. " Uncomment the next two lines to force these settings for all files with " filetype 'perl' . -" setlocal tabstop=4 setlocal shiftwidth=4 -" + " ---------- Add ':' to the keyword characters ------------------------------- " Tokens like 'File::Find' are recognized as " one keyword -" setlocal iskeyword+=: -" + " ---------- Set "maplocalleader" as configured using "g:Perl_MapLeader" ----- -" call Perl_SetMapLeader () -" + +" Alt-F9: run syntax check + noremap <buffer> <silent> <A-F9> :PerlCheck<CR> +inoremap <buffer> <silent> <A-F9> <C-C>:PerlCheck<CR> + +" Shift-F1: read Perl documentation + noremap <buffer> <silent> <S-F1> :PerlDoc<CR> +inoremap <buffer> <silent> <S-F1> <C-C>:PerlDoc<CR> + " ---------- Maps for the Make tool ------------------------------------------ -" noremap <buffer> <silent> <LocalLeader>rm :Make<CR> inoremap <buffer> <silent> <LocalLeader>rm <C-C>:Make<CR> noremap <buffer> <silent> <LocalLeader>rmc :Make clean<CR> @@ -44,8 +48,7 @@ inoremap <buffer> <silent> <LocalLeader>rmc <C-C>:Make clean<CR> inoremap <buffer> <LocalLeader>rma <C-C>:MakeCmdlineArgs<space> noremap <buffer> <LocalLeader>rcm :MakeFile<space> inoremap <buffer> <LocalLeader>rcm <C-C>:MakeFile<space> -" + " ---------- Reset "maplocalleader" ------------------------------------------ -" call Perl_ResetMapLeader () -" + diff --git a/ftplugin/qf.vim b/perl-support/rc/qf.vim similarity index 100% rename from ftplugin/qf.vim rename to perl-support/rc/qf.vim diff --git a/perl-support/scripts/csv2err.pl b/perl-support/scripts/csv2err.pl index 0443e87..498b3d3 100755 --- a/perl-support/scripts/csv2err.pl +++ b/perl-support/scripts/csv2err.pl @@ -13,7 +13,7 @@ # REQUIREMENTS: --- # BUGS: --- # NOTES: --- -# AUTHOR: Dr. Fritz Mehner (fgm), mehner@web.de +# AUTHOR: Dr. Fritz Mehner (fgm), mehner.fritz@web.de # VERSION: 2.0 # CREATED: 13.02.2009 17:04:00 #=============================================================================== diff --git a/perl-support/scripts/pmdesc3.pl b/perl-support/scripts/pmdesc3.pl index 338434c..b3c9697 100755 --- a/perl-support/scripts/pmdesc3.pl +++ b/perl-support/scripts/pmdesc3.pl @@ -353,13 +353,13 @@ =head1 BUGS AND LIMITATIONS There are no known bugs in this module. -Please report problems to Fritz Mehner, mehner@web.de . +Please report problems to Fritz Mehner, mehner.fritz@web.de . =head1 AUTHORS Tom Christiansen, tchrist@perl.com (pmdesc) Aristotle, http://qs321.pair.com/~monkads/ (pmdesc2) - Fritz Mehner, mehner@web.de (pmdesc3.pl) + Fritz Mehner, mehner.fritz@web.de (pmdesc3.pl) =head1 NOTES diff --git a/perl-support/templates/Templates b/perl-support/templates/Templates index b551953..c7cdd0a 100644 --- a/perl-support/templates/Templates +++ b/perl-support/templates/Templates @@ -27,6 +27,13 @@ SetStyle( 'default' ) § used by the template "Comments.file description pl": SetMacro( 'PERL_INTERPRETER', '/usr/bin/env perl' ) +§ templates automatically included into new files +§ set the property to an empty string to disable the insertion +SetProperty ( 'Perl::FileSkeleton::Script', 'Comments.shebang;Comments.file description pl; ;Skeleton.script-use' ) +SetProperty ( 'Perl::FileSkeleton::Module', 'Comments.file description pm; ;Skeleton.module-use' ) +SetProperty ( 'Perl::FileSkeleton::Test', 'Comments.file description t; ;Skeleton.test-use' ) +SetProperty ( 'Perl::FileSkeleton::POD', '' ) + § ========================================================== § File Includes and Shortcuts § ========================================================== @@ -50,6 +57,32 @@ IncludeFile( 'pod.templates' ) IncludeFile( 'snippets.templates' ) IncludeFile( 'filetests.templates' ) +§ ============================================================= +§ Inserted when creating a new script. +§ See configuration variable 'g:Perl_InsertFileHeader' +§ and template properties: +§ - Perl::FileSkeleton::Script +§ - Perl::FileSkeleton::Module +§ - Perl::FileSkeleton::Test +§ - Perl::FileSkeleton::POD +§ +§ - option 'nomenu': this will not create a menu entry +§ ============================================================= + +== Skeleton.script-use == nomenu, below == +use strict; +use warnings; +use utf8; +== Skeleton.module-use == nomenu, below == +use strict; +use warnings; +== Skeleton.test-use == nomenu, below == +use strict; +use warnings; + +use Test::More tests => 1; # last test to print +== ENDTEMPLATE == + § ============================================================= § Help § diff --git a/perl-support/templates/comments.templates b/perl-support/templates/comments.templates index ccbbd36..f0aa77a 100644 --- a/perl-support/templates/comments.templates +++ b/perl-support/templates/comments.templates @@ -47,7 +47,6 @@ # SEE ALSO: n/a #=============================================================================== == Comments.file description pl == map:chpl, sc:d, start, noindent == -#!|PERL_INTERPRETER| #=============================================================================== # # FILE: |FILENAME| @@ -66,11 +65,6 @@ # CREATED: |DATE| |TIME| # REVISION: --- #=============================================================================== - -use strict; -use warnings; -use utf8; - == Comments.file description pm == map:chpm, sc:d, start, noindent == # #=============================================================================== @@ -88,10 +82,6 @@ use utf8; # CREATED: |DATE| |TIME| # REVISION: --- #=============================================================================== - -use strict; -use warnings; - == Comments.file description t == map:cht, sc:d, start, noindent == # #=============================================================================== @@ -109,13 +99,6 @@ use warnings; # CREATED: |DATE| |TIME| # REVISION: --- #=============================================================================== - -use strict; -use warnings; - -use Test::More tests => 1; # last test to print - - == Comments.file description pod == map:chpo, sc:d, start == # #=============================================================================== @@ -129,7 +112,13 @@ use Test::More tests => 1; # last test to print # CREATED: |DATE| # REVISION: --- #=============================================================================== +== Comments.shebang == start, map:csh == +#!|PERL_INTERPRETER| +== ENDTEMPLATE == + +§ ------------------------------------------------------------- +== SEP: Comments.sep-date-time == == Comments.date == insert, map:cd, sc:d == |DATE|<CURSOR> diff --git a/plugin/awk-support.vim b/plugin/awk-support.vim index ea11cde..523c224 100644 --- a/plugin/awk-support.vim +++ b/plugin/awk-support.vim @@ -12,9 +12,9 @@ " Fritz Mehner <mehner.fritz@web.de> " Version: see g:AwkSupportVersion below " Created: 14.01.2012 -" Revision: 28.06.2017 +" Revision: 22.11.2020 " License: Copyright (c) 2001-2015, Dr. Fritz Mehner -" Copyright (c) 2016-2017, Wolfgang Mehner +" Copyright (c) 2016-2020, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the @@ -64,10 +64,10 @@ let g:AwkSupportVersion= "1.4pre" " version number of this scri "------------------------------------------------------------------------------- function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - let { 'g:'.a:varname } = a:value + if ! exists( 'g:'.a:varname ) + let {'g:'.a:varname} = a:value endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ErrorMsg : Print an error message. {{{2 @@ -86,7 +86,7 @@ function! s:ErrorMsg ( ... ) echomsg line endfor echohl None -endfunction " ---------- end of function s:ErrorMsg ---------- +endfunction "------------------------------------------------------------------------------- " s:GetGlobalSetting : Get a setting from a global variable. {{{2 @@ -107,10 +107,10 @@ endfunction " ---------- end of function s:ErrorMsg ---------- function! s:GetGlobalSetting ( varname, ... ) let lname = a:varname let gname = a:0 >= 1 ? a:1 : lname - if exists ( 'g:'.gname ) - let { 's:'.lname } = { 'g:'.gname } + if exists( 'g:'.gname ) + let {'s:'.lname} = {'g:'.gname} endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ImportantMsg : Print an important message. {{{2 @@ -442,6 +442,25 @@ function! s:MakeExecutable () endfunction " ---------- end of function s:MakeExecutable ---------- +"------------------------------------------------------------------------------- +" s:XtermSize : Set xterm size. {{{2 +"------------------------------------------------------------------------------- +function! s:XtermSize () + let regex = '-geometry\s\+\zs\d\+x\d\+' + let geom = matchstr ( g:Xterm_Options, regex ) + let geom = substitute ( geom, 'x', ' ', "" ) + + let answer = s:UserInput ( " xterm size (COLUMNS LINES) : ", geom, '' ) + while match( answer, '^\s*\d\+\s\+\d\+\s*$' ) < 0 + let answer = s:UserInput ( " + xterm size (COLUMNS LINES) : ", geom, '' ) + endwhile + + let answer = substitute ( answer, '^\s\+', '', '' ) " remove leading whitespaces + let answer = substitute ( answer, '\s\+$', '', '' ) " remove trailing whitespaces + let answer = substitute ( answer, '\s\+', 'x', '' ) " replace inner whitespaces + let g:Xterm_Options = substitute ( g:Xterm_Options, regex, answer , 'g' ) +endfunction " ---------- end of function s:XtermSize ---------- + " }}}2 "------------------------------------------------------------------------------- @@ -456,13 +475,14 @@ endfunction " ---------- end of function s:MakeExecutable ---------- let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") +let s:NEOVIM = has("nvim") + let s:installation = '*undefined*' let s:plugin_dir = '' let s:Awk_GlobalTemplateFile = '' let s:Awk_LocalTemplateFile = '' let s:Awk_CustomTemplateFile = '' " the custom templates let s:Awk_FilenameEscChar = '' -let s:Awk_XtermDefaults = '-fa courier -fs 12 -geometry 80x24' if s:MSWIN " ========== MS Windows ====================================================== @@ -572,7 +592,6 @@ call s:GetGlobalSetting ( 'Awk_LoadMenus' ) call s:GetGlobalSetting ( 'Awk_RootMenu' ) call s:GetGlobalSetting ( 'Awk_ManualReader' ) call s:GetGlobalSetting ( 'Awk_OutputGvim' ) -call s:GetGlobalSetting ( 'Awk_XtermDefaults' ) call s:GetGlobalSetting ( 'Awk_GlobalTemplateFile' ) call s:GetGlobalSetting ( 'Awk_LocalTemplateFile' ) call s:GetGlobalSetting ( 'Awk_CustomTemplateFile' ) @@ -586,11 +605,21 @@ call s:ApplyDefaultSetting ( 'Awk_Printheader', "%<%f%h%m%< %=%{strftime('%x %X " Xterm {{{3 "------------------------------------------------------------------------------- -" set default geometry if not specified -if match( s:Awk_XtermDefaults, "-geometry\\s\\+\\d\\+x\\d\\+" ) < 0 - let s:Awk_XtermDefaults = s:Awk_XtermDefaults." -geometry 80x24" +let s:Xterm_Executable = 'xterm' +let s:Awk_XtermDefaults = '-fa courier -fs 12 -geometry 80x24' + +" check 'g:Awk_XtermDefaults' for backwards compatibility +if ! exists ( 'g:Xterm_Options' ) + call s:GetGlobalSetting ( 'Awk_XtermDefaults' ) + " set default geometry if not specified + if match( s:Awk_XtermDefaults, "-geometry\\s\\+\\d\\+x\\d\\+" ) < 0 + let s:Awk_XtermDefaults = s:Awk_XtermDefaults." -geometry 80x24" + endif endif +call s:GetGlobalSetting ( 'Xterm_Executable' ) +call s:ApplyDefaultSetting ( 'Xterm_Options', s:Awk_XtermDefaults ) + " }}}3 "------------------------------------------------------------------------------- @@ -832,11 +861,11 @@ function! s:HelpManual( topic ) endfunction " ---------- end of function s:HelpManual ---------- "------------------------------------------------------------------------------- -" s:RemoveSpecialCharacters : Clean CYGWIN output {{{1 +" s:RemoveSpecialCharacters : Clean CYGWIN output. {{{1 " " Clean CYGWIN man(1) output: +" remove _<backspace> " remove <backspace><any character> -" remove _<any character> "------------------------------------------------------------------------------- function! s:RemoveSpecialCharacters ( ) let patternunderline = '_\%x08' @@ -897,8 +926,8 @@ function! s:RereadTemplates () " syntax: comments call mmtemplates#core#ChangeSyntax ( g:Awk_Templates, 'comment', '§' ) - " property: file skeletons - call mmtemplates#core#Resource ( g:Awk_Templates, 'add', 'property', 'Awk::FileSkeleton::Script', 'Comments.shebang;Comments.file description' ) + " property: file skeletons (use a safe default here, more sensible settings are applied in the template library) + call mmtemplates#core#Resource ( g:Awk_Templates, 'add', 'property', 'Awk::FileSkeleton::Script', 'Comments.file description' ) "------------------------------------------------------------------------------- " load template library @@ -1025,12 +1054,9 @@ function! s:JumpForward () return '' endfunction " ---------- end of function s:JumpForward ---------- -"=== FUNCTION ================================================================ -" NAME: InitMenus {{{1 -" DESCRIPTION: Initialize menus. -" PARAMETERS: - -" RETURNS: -"=============================================================================== +"------------------------------------------------------------------------------- +" s:InitMenus : Initialize menus. {{{1 +"------------------------------------------------------------------------------- function! s:InitMenus() " if ! has ( 'menu' ) @@ -1112,7 +1138,11 @@ function! s:InitMenus() "------------------------------------------------------------------------------- " run "------------------------------------------------------------------------------- - " + + let ahead = 'anoremenu <silent> '.s:Awk_RootMenu.'.Run.' + let vhead = 'vnoremenu <silent> '.s:Awk_RootMenu.'.Run.' + let ihead = 'inoremenu <silent> '.s:Awk_RootMenu.'.Run.' + exe " menu <silent> ".s:Awk_RootMenu.'.&Run.save\ +\ &run\ script<Tab>'.esc_mapl.'rr\ \ <C-F9> :call Awk_Run("n")<CR>' exe "imenu <silent> ".s:Awk_RootMenu.'.&Run.save\ +\ &run\ script<Tab>'.esc_mapl.'rr\ \ <C-F9> <C-C>:call Awk_Run("n")<CR>' exe " menu <silent> ".s:Awk_RootMenu.'.&Run.update,\ check\ &syntax<Tab>'.esc_mapl.'rs\ \ <A-F9> :call Awk_SyntaxCheck("syntax")<CR>' @@ -1125,31 +1155,28 @@ function! s:InitMenus() " exe " menu ".s:Awk_RootMenu.'.&Run.AWK\ cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'raa :AwkArguments<Space>' exe "imenu ".s:Awk_RootMenu.'.&Run.AWK\ cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'raa <C-C>:AwkArguments<Space>' - " - let ahead = 'amenu <silent> '.s:Awk_RootMenu.'.Run.' - let vhead = 'vmenu <silent> '.s:Awk_RootMenu.'.Run.' - - if !s:MSWIN - exe ahead.'make\ script\ &exec\./not\ exec\.<Tab>'.esc_mapl.'re :call <SID>MakeExecutable()<CR>' - endif exe ahead.'-SEP1- :' if s:MSWIN - exe ahead.'&hardcopy\ to\ printer<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("n")<CR>' + exe ahead.'&hardcopy\ to\ printer<Tab>'.esc_mapl.'rh :call <SID>Hardcopy("n")<CR>' exe vhead.'&hardcopy\ to\ printer<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' + exe ihead.'&hardcopy\ to\ printer<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' else - exe ahead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("n")<CR>' + exe ahead.'make\ script\ &exec\./not\ exec\.<Tab>'.esc_mapl.'re :call <SID>MakeExecutable()<CR>' + exe ihead.'make\ script\ &exec\./not\ exec\.<Tab>'.esc_mapl.'re <C-C>:call <SID>MakeExecutable()<CR>' + exe ahead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh :call <SID>Hardcopy("n")<CR>' exe vhead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' + exe ihead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' endif - " + exe ahead.'-SEP2- :' exe ahead.'plugin\ &settings<Tab>'.esc_mapl.'rse :call Awk_Settings(0)<CR>' " if !s:MSWIN - exe " menu <silent> ".s:Awk_RootMenu.'.&Run.x&term\ size<Tab>'.esc_mapl.'rx :call Awk_XtermSize()<CR>' - exe "imenu <silent> ".s:Awk_RootMenu.'.&Run.x&term\ size<Tab>'.esc_mapl.'rx <C-C>:call Awk_XtermSize()<CR>' + exe ahead.'&xterm\ size<Tab>'.esc_mapl.'rx :call <SID>XtermSize()<CR>' + exe ihead.'&xterm\ size<Tab>'.esc_mapl.'rx <C-C>:call <SID>XtermSize()<CR>' endif - " + if s:MSWIN if s:Awk_OutputGvim == "buffer" exe " menu <silent> ".s:Awk_RootMenu.'.&Run.&output:\ BUFFER->term<Tab>'.esc_mapl.'ro :call Awk_Toggle_Gvim_Xterm_MS()<CR>' @@ -1172,40 +1199,44 @@ function! s:InitMenus() endif endif endif - " - "------------------------------------------------------------------------------- - " help - "------------------------------------------------------------------------------- - " - let ahead = 'amenu <silent> '.s:Awk_RootMenu.'.Help.' - let ihead = 'imenu <silent> '.s:Awk_RootMenu.'.Help.' - exe ahead.'&AWK\ manual<Tab>'.esc_mapl.'hm :call <SID>HelpManual("awk")<CR>' - exe ihead.'&AWK\ manual<Tab>'.esc_mapl.'hm <C-C>:call <SID>HelpManual("awk")<CR>' + "------------------------------------------------------------------------------- + " help + "------------------------------------------------------------------------------- + + let ahead = 'anoremenu <silent> '.s:Awk_RootMenu.'.Help.' + let ihead = 'inoremenu <silent> '.s:Awk_RootMenu.'.Help.' + + if s:NEOVIM + exe ahead.'&AWK\ manual<Tab>'.esc_mapl.'hm :Man awk(1)<CR>' + exe ihead.'&AWK\ manual<Tab>'.esc_mapl.'hm <C-C>:Man awk(1)<CR>' + else + exe ahead.'&AWK\ manual<Tab>'.esc_mapl.'hm :call <SID>HelpManual("awk")<CR>' + exe ihead.'&AWK\ manual<Tab>'.esc_mapl.'hm <C-C>:call <SID>HelpManual("awk")<CR>' + endif exe ahead.'-SEP1- :' exe ahead.'&help\ (Awk-Support)<Tab>'.esc_mapl.'hp :call <SID>HelpPlugin()<CR>' exe ihead.'&help\ (Awk-Support)<Tab>'.esc_mapl.'hp <C-C>:call <SID>HelpPlugin()<CR>' endfunction " ---------- end of function s:InitMenus ---------- -"=== FUNCTION ================================================================ -" NAME: s:CreateAdditionalMaps {{{1 -" DESCRIPTION: create additional maps -" PARAMETERS: - -" RETURNS: -"=============================================================================== +"------------------------------------------------------------------------------- +" s:CreateAdditionalMaps : Create additional maps. {{{1 +"------------------------------------------------------------------------------- function! s:CreateAdditionalMaps () + + "------------------------------------------------------------------------------- + " AWK dictionary " - " ---------- Awk dictionary ------------------------------------------------- " This will enable keyword completion for Awk " using Vim's dictionary feature |i_CTRL-X_CTRL-K|. - " + "------------------------------------------------------------------------------- if exists("g:Awk_Dictionary_File") silent! exe 'setlocal dictionary+='.g:Awk_Dictionary_File endif - " + "------------------------------------------------------------------------------- - " USER DEFINED COMMANDS + " user defined commands (only working in AWK buffers) "------------------------------------------------------------------------------- command! -buffer -nargs=* -complete=file AwkScriptArguments call Awk_ScriptCmdLineArguments(<q-args>) command! -buffer -nargs=* -complete=file AwkArguments call Awk_AwkCmdLineArguments(<q-args>) @@ -1285,8 +1316,8 @@ function! s:CreateAdditionalMaps () nnoremap <buffer> <silent> <LocalLeader>rh :call <SID>Hardcopy("n")<CR> vnoremap <buffer> <silent> <LocalLeader>rh <C-C>:call <SID>Hardcopy("v")<CR> - nnoremap <buffer> <silent> <LocalLeader>rx :call Awk_XtermSize()<CR> - vnoremap <buffer> <silent> <LocalLeader>rx <C-C>:call Awk_XtermSize()<CR> + nnoremap <buffer> <silent> <LocalLeader>rx :call <SID>XtermSize()<CR> + inoremap <buffer> <silent> <LocalLeader>rx <C-C>:call <SID>XtermSize()<CR> noremap <buffer> <silent> <C-F9> :call Awk_Run("n")<CR> inoremap <buffer> <silent> <C-F9> <C-C>:call Awk_Run("n")<CR> @@ -1310,9 +1341,17 @@ function! s:CreateAdditionalMaps () "------------------------------------------------------------------------------- nnoremap <buffer> <silent> <LocalLeader>rse :call Awk_Settings(0)<CR> - noremap <buffer> <silent> <LocalLeader>hm :call <SID>HelpManual('awk')<CR> - inoremap <buffer> <silent> <LocalLeader>hm <Esc>:call <SID>HelpManual('awk')<CR> - noremap <buffer> <silent> <LocalLeader>hp :call <SID>HelpPlugin()<CR> + if s:NEOVIM + nnoremap <buffer> <silent> <LocalLeader>hm :Man awk(1)<CR> + vnoremap <buffer> <silent> <LocalLeader>hm <Esc>:Man awk(1)<CR> + inoremap <buffer> <silent> <LocalLeader>hm <Esc>:Man awk(1)<CR> + else + nnoremap <buffer> <silent> <LocalLeader>hm :call <SID>HelpManual('awk')<CR> + vnoremap <buffer> <silent> <LocalLeader>hm <Esc>:call <SID>HelpManual('awk')<CR> + inoremap <buffer> <silent> <LocalLeader>hm <Esc>:call <SID>HelpManual('awk')<CR> + endif + nnoremap <buffer> <silent> <LocalLeader>hp :call <SID>HelpPlugin()<CR> + vnoremap <buffer> <silent> <LocalLeader>hp <C-C>:call <SID>HelpPlugin()<CR> inoremap <buffer> <silent> <LocalLeader>hp <C-C>:call <SID>HelpPlugin()<CR> "------------------------------------------------------------------------------- @@ -1353,6 +1392,8 @@ function! Awk_Settings ( verbose ) if s:MSWIN | let sys_name = 'Windows' elseif s:UNIX | let sys_name = 'UN*X' else | let sys_name = 'unknown' | endif + if s:NEOVIM | let vim_name = 'nvim' + else | let vim_name = has('gui_running') ? 'gvim' : 'vim' | endif let txt = " Awk-Support settings\n\n" " template settings: macros, style, ... @@ -1369,7 +1410,7 @@ function! Awk_Settings ( verbose ) let txt .= " templates : -not loaded-\n\n" endif " plug-in installation - let txt .= ' plugin installation : '.s:installation.' on '.sys_name."\n" + let txt .= ' plugin installation : '.s:installation.' in '.vim_name.' on '.sys_name."\n" let txt .= "\n" " templates, snippets if exists ( 'g:Awk_Templates' ) @@ -1408,7 +1449,8 @@ function! Awk_Settings ( verbose ) " ----- output ------------------------------ let txt = txt.' current output dest. : '.s:Awk_OutputGvim."\n" if !s:MSWIN - let txt = txt.' xterm defaults : '.s:Awk_XtermDefaults."\n" + let txt = txt.' xterm executable : '.s:Xterm_Executable."\n" + let txt = txt.' xterm options : '.g:Xterm_Options."\n" endif let txt = txt."__________________________________________________________________________\n" let txt = txt." Awk-Support, Version ".g:AwkSupportVersion." / Wolfgang Mehner / wolfgang-mehner@web.de\n\n" @@ -1477,24 +1519,6 @@ function! Awk_Toggle_Gvim_Xterm_MS () endif endif endfunction " ---------- end of function Awk_Toggle_Gvim_Xterm_MS ---------- -" -"------------------------------------------------------------------------------ -" Run : xterm geometry {{{1 -"------------------------------------------------------------------------------ -function! Awk_XtermSize () - let regex = '-geometry\s\+\d\+x\d\+' - let geom = matchstr( s:Awk_XtermDefaults, regex ) - let geom = matchstr( geom, '\d\+x\d\+' ) - let geom = substitute( geom, 'x', ' ', "" ) - let answer = s:UserInput(" xterm size (COLUMNS LINES) : ", geom, '' ) - while match(answer, '^\s*\d\+\s\+\d\+\s*$' ) < 0 - let answer = s:UserInput(" + xterm size (COLUMNS LINES) : ", geom, '' ) - endwhile - let answer = substitute( answer, '^\s\+', "", "" ) " remove leading whitespaces - let answer = substitute( answer, '\s\+$', "", "" ) " remove trailing whitespaces - let answer = substitute( answer, '\s\+', "x", "" ) " replace inner whitespaces - let s:Awk_XtermDefaults = substitute( s:Awk_XtermDefaults, regex, "-geometry ".answer , "" ) -endfunction " ---------- end of function Awk_XtermSize ---------- "------------------------------------------------------------------------------ " Run : Command line arguments {{{1 @@ -1611,7 +1635,7 @@ function! Awk_Run ( mode ) range if s:MSWIN exe ':!'.s:Awk_Executable.l:awkCmdLineArgs.' -f "'.l:fullname.'" '.l:arguments else - silent exe '!xterm -title '.l:fullnameesc.' '.s:Awk_XtermDefaults + silent exe '!xterm -title '.l:fullnameesc.' '.g:Xterm_Options \ .' -e '.s:Awk_Wrapper.' '.l:awkCmdLineArgs.l:fullnameesc.l:arguments.' &' endif " @@ -1742,9 +1766,22 @@ function! s:RemoveMenus() endif endfunction " ---------- end of function s:RemoveMenus ---------- -"---------------------------------------------------------------------- +"------------------------------------------------------------------------------- +" s:Initialize : Initialize templates, menus, and maps. {{{1 +"------------------------------------------------------------------------------- +function! s:Initialize ( ftype ) + if ! exists( 'g:Awk_Templates' ) + if s:Awk_LoadMenus == 'yes' | call s:AddMenus() + else | call s:RereadTemplates() + endif + endif + call s:CreateAdditionalMaps() + call s:CheckTemplatePersonalization() +endfunction " ---------- end of function s:Initialize ---------- + +"------------------------------------------------------------------------------- " === Setup: Templates and menus === {{{1 -"---------------------------------------------------------------------- +"------------------------------------------------------------------------------- " tool menu entry call s:ToolMenu ( 'setup' ) @@ -1754,24 +1791,15 @@ if s:Awk_LoadMenus == 'yes' && s:Awk_CreateMenusDelayed == 'no' endif if has( 'autocmd' ) + augroup AwkSupport - " create menues and maps - autocmd FileType * - \ if &filetype == 'awk' | - \ if ! exists( 'g:Awk_Templates' ) | - \ if s:Awk_LoadMenus == 'yes' | call s:AddMenus () | - \ else | call s:RereadTemplates () | - \ endif | - \ endif | - \ call s:CreateAdditionalMaps () | - \ call s:CheckTemplatePersonalization() | - \ endif + " create menus and maps + autocmd FileType awk call s:Initialize('awk') " insert file header - if s:Awk_InsertFileHeader == 'yes' - autocmd BufNewFile *.awk call s:InsertFileHeader() - endif + autocmd BufNewFile *.awk call s:InsertFileHeader() + augroup END endif " }}}1 "------------------------------------------------------------------------------- diff --git a/plugin/bash-support.vim b/plugin/bash-support.vim index 92ccf69..6be2680 100644 --- a/plugin/bash-support.vim +++ b/plugin/bash-support.vim @@ -7,14 +7,14 @@ " Write Bash scripts by inserting comments, statements, " variables and builtins. " -" VIM Version: 7.0+ +" VIM Version: 7.4+ " Author: Wolfgang Mehner <wolfgang-mehner@web.de> " Fritz Mehner <mehner.fritz@web.de> " Version: see g:BASH_Version below " Created: 26.02.2001 -" Revision: 22.06.2017 +" Revision: 22.11.2020 " License: Copyright (c) 2001-2015, Dr. Fritz Mehner -" Copyright (c) 2016-2017, Wolfgang Mehner +" Copyright (c) 2016-2020, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the @@ -30,10 +30,10 @@ " === Basic checks === {{{1 "------------------------------------------------------------------------------- -" need at least 7.0 -if v:version < 700 +" need at least 7.4 +if v:version < 740 echohl WarningMsg - echo 'The plugin bash-support.vim needs Vim version >= 7.' + echo 'The plugin bash-support.vim needs Vim version >= 7.4' echohl None finish endif @@ -44,7 +44,7 @@ if exists("g:BASH_Version") || &cp finish endif -let g:BASH_Version= "4.4pre" " version number of this script; do not change +let g:BASH_Version = "5.0beta" " version number of this script; do not change "------------------------------------------------------------------------------- " === Auxiliary functions === {{{1 @@ -64,10 +64,10 @@ let g:BASH_Version= "4.4pre" " version number of this script; d "------------------------------------------------------------------------------- function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - let { 'g:'.a:varname } = a:value + if ! exists( 'g:'.a:varname ) + let {'g:'.a:varname} = a:value endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ErrorMsg : Print an error message. {{{2 @@ -86,7 +86,7 @@ function! s:ErrorMsg ( ... ) echomsg line endfor echohl None -endfunction " ---------- end of function s:ErrorMsg ---------- +endfunction "------------------------------------------------------------------------------- " s:GetGlobalSetting : Get a setting from a global variable. {{{2 @@ -107,10 +107,10 @@ endfunction " ---------- end of function s:ErrorMsg ---------- function! s:GetGlobalSetting ( varname, ... ) let lname = a:varname let gname = a:0 >= 1 ? a:1 : lname - if exists ( 'g:'.gname ) - let { 's:'.lname } = { 'g:'.gname } + if exists( 'g:'.gname ) + let {'s:'.lname} = {'g:'.gname} endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ImportantMsg : Print an important message. {{{2 @@ -129,6 +129,217 @@ function! s:ImportantMsg ( ... ) echohl None endfunction " ---------- end of function s:ImportantMsg ---------- +"------------------------------------------------------------------------------- +" s:OpenBuffer : Open a scratch buffer. {{{2 +" +" If a buffer called 'name' already exists, jump to that buffer. Otherwise, +" open a buffer of the given name an set it up as a scratch buffer. It is +" deleted after the window is closed. +" +" Options: +" - showdir: the directory will be shown in the buffer list (set buf=nowrite) +" - reuse_ontab: reuse a buffer of the same name on this tab page +" - reuse_other: reuse a buffer of the same name from another tab page +" - topic <tname>: set a topic name +" +" Settings: +" - buftype=nofile/nowrite (depending on the option 'showdir') +" - bufhidden=wipe +" - swapfile=0 +" - tabstop=8 +" +" Parameters: +" name - name of the buffer (string) +" ... - options (string) +" Returns: +" opened - true, if a new buffer was opened (integer) +"------------------------------------------------------------------------------- + +function! s:OpenBuffer ( name, ... ) + + " options + let btype = 'nofile' + let reuse_ontab = 1 + let reuse_other = 0 + let topic = '' + + let idx = 0 + while idx < a:0 + let val = a:000[idx] + if val == 'showdir' + let btype = 'nowrite' " like 'nofile', but the directory is shown in the buffer list + let idx += 1 + elseif val == 'reuse_ontab' + let reuse_ontab = a:000[idx+1] + let idx += 2 + elseif val == 'reuse_other' + let reuse_other = a:000[idx+1] + let idx += 2 + elseif val == 'topic' + let topic = a:000[idx+1] + let idx += 2 + else + call s:ErrorMsg ( 'Unknown buffer option: '.val ) + endif + endwhile + + let buf_name = a:name + let buf_regex = a:name + if topic != '' + let buf_name .= ' ('.topic.')' + let buf_regex .= ' ([a-zA-Z0-9 :_-]\+)' + endif + let buf_regex = '{'.buf_regex.','.buf_regex.' -[0-9]\+-'.'}' + + " a buffer like this already opened on the current tab page? + if reuse_ontab && bufwinnr ( buf_regex ) != -1 + " yes -> go to the window containing the buffer + exe bufwinnr( buf_regex ).'wincmd w' + call s:RenameBuffer( buf_name, 1 ) + return 0 + endif + + " no -> open a new window + aboveleft new + + " buffer exists elsewhere? + if reuse_other && bufnr ( buf_regex ) != -1 + " yes -> reuse it + silent exe 'edit #'.bufnr( buf_regex ) + call s:RenameBuffer( buf_name, 1 ) + return 0 + endif + + " no -> settings of the new buffer + let &l:buftype = btype + let &l:bufhidden = 'wipe' + let &l:swapfile = 0 + let &l:tabstop = 8 + call s:RenameBuffer( buf_name, 1 ) + + return 1 +endfunction + +"------------------------------------------------------------------------------- +" s:RenameBuffer : Rename a scratch buffer. {{{2 +" +" Parameters: +" name - the new name (string) +" unique - make the name unique (boolean, optional) +" Returns: +" - +"------------------------------------------------------------------------------- + +function! s:RenameBuffer ( name, ... ) + if bufname ( '%' ) =~# '\V'.a:name.'\$' + return + elseif bufname ( '%' ) =~# '\V'.a:name.' -\[0-9]\+-\$' + return + endif + + let buf_name = a:name + if a:0 >= 1 && a:1 && bufnr ( buf_name ) != -1 + let nr = 2 + while bufnr ( buf_name.' -'.nr.'-' ) != -1 + let nr += 1 + endwhile + let buf_name = buf_name.' -'.nr.'-' + endif + silent exe 'keepalt file '.fnameescape( buf_name ) +endfunction " ---------- end of function s:RenameBuffer ---------- + +"------------------------------------------------------------------------------- +" s:Redraw : Redraw depending on whether a GUI is running. {{{2 +" +" Example: +" call s:Redraw ( 'r!', '' ) +" Clear the screen and redraw in a terminal, do nothing when a GUI is running. +" +" Parameters: +" cmd_term - redraw command in terminal mode (string) +" cmd_gui - redraw command in GUI mode (string) +" Returns: +" - +"------------------------------------------------------------------------------- + +function! s:Redraw ( cmd_term, cmd_gui ) + if has('gui_running') + let cmd = a:cmd_gui + else + let cmd = a:cmd_term + endif + + let cmd = substitute ( cmd, 'r\%[edraw]', 'redraw', '' ) + if cmd != '' + silent exe cmd + endif +endfunction " ---------- end of function s:Redraw ---------- + +"------------------------------------------------------------------------------- +" s:ShellParseArgs : Turn cmd.-line arguments into a list. {{{2 +" +" Parameters: +" line - the command-line arguments to parse (string) +" Returns: +" list - the arguments as a list (list) +"------------------------------------------------------------------------------- + +function! s:ShellParseArgs ( line ) + + let list = [] + let curr = '' + + let line = a:line + + while line != '' + + if match ( line, '^\s' ) != -1 + " non-escaped space -> finishes current argument + let line = matchstr ( line, '^\s\+\zs.*' ) + if curr != '' + call add ( list, curr ) + let curr = '' + endif + elseif match ( line, "^'" ) != -1 + " start of a single-quoted string, parse past next single quote + let mlist = matchlist ( line, "^'\\([^']*\\)'\\(.*\\)" ) + if empty ( mlist ) + throw "ShellParseArgs:Syntax:no matching quote '" + endif + let curr .= mlist[1] + let line = mlist[2] + elseif match ( line, '^"' ) != -1 + " start of a double-quoted string, parse past next double quote + let mlist = matchlist ( line, '^"\(\%([^\"]\|\\.\)*\)"\(.*\)' ) + if empty ( mlist ) + throw 'ShellParseArgs:Syntax:no matching quote "' + endif + let curr .= substitute ( mlist[1], '\\\([\"]\)', '\1', 'g' ) + let line = mlist[2] + elseif match ( line, '^\\' ) != -1 + " escape sequence outside of a string, parse one additional character + let mlist = matchlist ( line, '^\\\(.\)\(.*\)' ) + if empty ( mlist ) + throw 'ShellParseArgs:Syntax:single backspace \' + endif + let curr .= mlist[1] + let line = mlist[2] + else + " otherwise parse up to next special char.: space, backslash, quote + let mlist = matchlist ( line, '^\([^[:space:]\\''"]\+\)\(.*\)' ) + let curr .= mlist[1] + let line = mlist[2] + endif + endwhile + + " add last argument + if curr != '' + call add ( list, curr ) + endif + + return list +endfunction " ---------- end of function s:ShellParseArgs ---------- + "------------------------------------------------------------------------------- " s:SID : Return the <SID>. {{{2 " @@ -442,6 +653,25 @@ function! s:MakeExecutable () endfunction " ---------- end of function s:MakeExecutable ---------- +"------------------------------------------------------------------------------- +" s:XtermSize : Set xterm size. {{{2 +"------------------------------------------------------------------------------- +function! s:XtermSize () + let regex = '-geometry\s\+\zs\d\+x\d\+' + let geom = matchstr ( g:Xterm_Options, regex ) + let geom = substitute ( geom, 'x', ' ', "" ) + + let answer = s:UserInput ( " xterm size (COLUMNS LINES) : ", geom, '' ) + while match( answer, '^\s*\d\+\s\+\d\+\s*$' ) < 0 + let answer = s:UserInput ( " + xterm size (COLUMNS LINES) : ", geom, '' ) + endwhile + + let answer = substitute ( answer, '^\s\+', '', '' ) " remove leading whitespaces + let answer = substitute ( answer, '\s\+$', '', '' ) " remove trailing whitespaces + let answer = substitute ( answer, '\s\+', 'x', '' ) " replace inner whitespaces + let g:Xterm_Options = substitute ( g:Xterm_Options, regex, answer , 'g' ) +endfunction " ---------- end of function s:XtermSize ---------- + " }}}2 "------------------------------------------------------------------------------- @@ -456,13 +686,16 @@ endfunction " ---------- end of function s:MakeExecutable ---------- let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") +let s:NEOVIM = has("nvim") + let s:installation = '*undefined*' let s:plugin_dir = '' let s:BASH_GlobalTemplateFile = '' let s:BASH_LocalTemplateFile = '' let s:BASH_CustomTemplateFile = '' " the custom templates let s:BASH_FilenameEscChar = '' -let s:BASH_XtermDefaults = '-fa courier -fs 12 -geometry 80x24' + +let s:BASH_ToolboxDir = [] if s:MSWIN " ========== MS Windows ====================================================== @@ -477,6 +710,9 @@ if s:MSWIN let s:installation = 'local' let s:BASH_LocalTemplateFile = s:plugin_dir.'/bash-support/templates/Templates' let s:BASH_CustomTemplateFile = $HOME.'/vimfiles/templates/bash.templates' + let s:BASH_ToolboxDir += [ + \ s:plugin_dir.'/autoload/mmtoolbox/bash/', + \ s:plugin_dir.'/autoload/mmtoolbox/' ] else " " SYSTEM WIDE INSTALLATION @@ -484,13 +720,16 @@ if s:MSWIN let s:BASH_GlobalTemplateFile = s:plugin_dir.'/bash-support/templates/Templates' let s:BASH_LocalTemplateFile = $HOME.'/vimfiles/bash-support/templates/Templates' let s:BASH_CustomTemplateFile = $HOME.'/vimfiles/templates/bash.templates' + let s:BASH_ToolboxDir += [ + \ s:plugin_dir.'/autoload/mmtoolbox/bash/', + \ s:plugin_dir.'/autoload/mmtoolbox/', + \ $HOME.'/vimfiles/autoload/mmtoolbox/' ] endif let s:BASH_FilenameEscChar = '' let s:BASH_Display = '' let s:BASH_ManualReader = 'man.exe' let s:BASH_Executable = 'bash.exe' - let s:BASH_OutputGvim = 'xterm' else " ========== Linux/Unix ====================================================== @@ -502,6 +741,9 @@ else let s:installation = 'local' let s:BASH_LocalTemplateFile = s:plugin_dir.'/bash-support/templates/Templates' let s:BASH_CustomTemplateFile = $HOME.'/.vim/templates/bash.templates' + let s:BASH_ToolboxDir += [ + \ s:plugin_dir.'/autoload/mmtoolbox/bash/', + \ s:plugin_dir.'/autoload/mmtoolbox/' ] else " " SYSTEM WIDE INSTALLATION @@ -509,13 +751,16 @@ else let s:BASH_GlobalTemplateFile = s:plugin_dir.'/bash-support/templates/Templates' let s:BASH_LocalTemplateFile = $HOME.'/.vim/bash-support/templates/Templates' let s:BASH_CustomTemplateFile = $HOME.'/.vim/templates/bash.templates' + let s:BASH_ToolboxDir += [ + \ s:plugin_dir.'/autoload/mmtoolbox/bash/', + \ s:plugin_dir.'/autoload/mmtoolbox/', + \ $HOME.'/.vim/autoload/mmtoolbox/' ] endif let s:BASH_Executable = $SHELL let s:BASH_FilenameEscChar = ' \%#[]' let s:BASH_Display = $DISPLAY let s:BASH_ManualReader = '/usr/bin/man' - let s:BASH_OutputGvim = 'vim' endif let s:BASH_AdditionalTemplates = mmtemplates#config#GetFt ( 'bash' ) @@ -543,13 +788,28 @@ let s:BASH_CreateMenusDelayed = 'yes' let s:BASH_GuiSnippetBrowser = 'gui' " gui / commandline let s:BASH_LoadMenus = 'yes' " load the menus? let s:BASH_RootMenu = '&Bash' " name of the root menu -let s:BASH_Debugger = 'term' -let s:BASH_bashdb = 'bashdb' -" +let s:BASH_UseToolbox = 'yes' + +if s:NEOVIM + " can not use 'cmd-line' in Neovim, since :! is not interactive + let s:BASH_OutputMethodList = [ 'quickfix', 'buffer', 'terminal' ] + let s:BASH_OutputMethod = 'terminal' " one of 's:BASH_OutputMethodList' +else + let s:BASH_OutputMethodList = [ 'cmd-line', 'quickfix', 'buffer' ] + let s:BASH_OutputMethod = 'cmd-line' " one of 's:BASH_OutputMethodList' + " :TODO:28.09.2017 18:33:WM: Windows defaults (was 'xterm', ran shell in a separate window!?), check running under Windows, +endif +if ! s:MSWIN + let s:BASH_OutputMethodList += [ 'xterm' ] +endif +if has ( 'terminal' ) && ! s:MSWIN " :TODO:25.09.2017 16:16:WM: enable Windows, check how to start jobs with arguments under Windows + let s:BASH_OutputMethodList += [ 'terminal' ] +endif +call sort ( s:BASH_OutputMethodList ) +let s:BASH_DirectRun = 'no' " 'yes' or 'no' let s:BASH_LineEndCommColDefault = 49 let s:BASH_TemplateJumpTarget = '' let s:BASH_Errorformat = '%f: %[%^0-9]%# %l:%m,%f: %l:%m,%f:%l:%m,%f[%l]:%m' -let s:BASH_Wrapper = s:plugin_dir.'/bash-support/scripts/wrapper.sh' let s:BASH_InsertFileHeader = 'yes' let s:BASH_Ctrl_j = 'yes' let s:BASH_Ctrl_d = 'yes' @@ -563,8 +823,6 @@ endif " Get user configuration {{{3 "------------------------------------------------------------------------------- -call s:GetGlobalSetting ( 'BASH_Debugger' ) -call s:GetGlobalSetting ( 'BASH_bashdb' ) call s:GetGlobalSetting ( 'BASH_SyntaxCheckOptionsGlob' ) call s:GetGlobalSetting ( 'BASH_Executable' ) call s:GetGlobalSetting ( 'BASH_InsertFileHeader' ) @@ -575,8 +833,8 @@ call s:GetGlobalSetting ( 'BASH_GuiSnippetBrowser' ) call s:GetGlobalSetting ( 'BASH_LoadMenus' ) call s:GetGlobalSetting ( 'BASH_RootMenu' ) call s:GetGlobalSetting ( 'BASH_ManualReader' ) -call s:GetGlobalSetting ( 'BASH_OutputGvim' ) -call s:GetGlobalSetting ( 'BASH_XtermDefaults' ) +call s:GetGlobalSetting ( 'BASH_OutputMethod', 'BASH_OutputGvim' ) +call s:GetGlobalSetting ( 'BASH_OutputMethod' ) call s:GetGlobalSetting ( 'BASH_GlobalTemplateFile' ) call s:GetGlobalSetting ( 'BASH_LocalTemplateFile' ) call s:GetGlobalSetting ( 'BASH_CustomTemplateFile' ) @@ -586,15 +844,33 @@ call s:GetGlobalSetting ( 'BASH_LineEndCommColDefault' ) call s:ApplyDefaultSetting ( 'BASH_MapLeader', '' ) " default: do not overwrite 'maplocalleader' call s:ApplyDefaultSetting ( 'BASH_Printheader', "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" ) +call s:GetGlobalSetting ( 'BASH_UseToolbox' ) +call s:ApplyDefaultSetting ( 'Bash_UseTool_bashdb', 'yes' ) + +" adapt for backwards compatibility +if s:BASH_OutputMethod == 'vim' + let s:BASH_OutputMethod = 'quickfix' +endif + "------------------------------------------------------------------------------- " Xterm {{{3 "------------------------------------------------------------------------------- -" set default geometry if not specified -if match( s:BASH_XtermDefaults, "-geometry\\s\\+\\d\\+x\\d\\+" ) < 0 - let s:BASH_XtermDefaults = s:BASH_XtermDefaults." -geometry 80x24" +let s:Xterm_Executable = 'xterm' +let s:BASH_XtermDefaults = '-fa courier -fs 12 -geometry 80x24' + +" check 'g:BASH_XtermDefaults' for backwards compatibility +if ! exists ( 'g:Xterm_Options' ) + call s:GetGlobalSetting ( 'BASH_XtermDefaults' ) + " set default geometry if not specified + if match( s:BASH_XtermDefaults, "-geometry\\s\\+\\d\\+x\\d\\+" ) < 0 + let s:BASH_XtermDefaults = s:BASH_XtermDefaults." -geometry 80x24" + endif endif +call s:GetGlobalSetting ( 'Xterm_Executable' ) +call s:ApplyDefaultSetting ( 'Xterm_Options', s:BASH_XtermDefaults ) + " }}}3 "------------------------------------------------------------------------------- @@ -617,7 +893,7 @@ let s:AlignRegex = [ function! s:AdjustLineEndComm ( ) range " comment character (for use in regular expression) - let cc = '#' " start of a Perl comment + let cc = '#' " start of a Bash comment " " patterns to ignore when adjusting line-end comments (maybe incomplete): let align_regex = join( s:AlignRegex, '\|' ) @@ -804,174 +1080,844 @@ function! s:RemoveEcho () endfunction " ---------- end of function s:RemoveEcho ---------- "------------------------------------------------------------------------------- -" s:HelpPlugin : Plug-in help. {{{1 +" s:OutputBufferErrors : Load the "Bash Output" buffer into quickfix. {{{1 +" +" Parameters: +" jump - if non-zero, also jump to the first error (integer) "------------------------------------------------------------------------------- -function! s:HelpPlugin () - try - help bashsupport - catch - exe 'helptags '.s:plugin_dir.'/doc' - help bashsupport - endtry -endfunction " ---------- end of function s:HelpPlugin ---------- -"------------------------------------------------------------------------------ -" === Templates API === {{{1 -"------------------------------------------------------------------------------ -" -"------------------------------------------------------------------------------ -" Bash_SetMapLeader {{{2 -"------------------------------------------------------------------------------ -function! Bash_SetMapLeader () - if exists ( 'g:BASH_MapLeader' ) - call mmtemplates#core#SetMapleader ( g:BASH_MapLeader ) +function! s:OutputBufferErrors ( jump ) + + if bufname('%') !~# 'Bash Output' && bufname('%') !~# 'Bash Terminal' + return s:ImportantMsg ( 'not inside a Bash output buffer' ) endif -endfunction " ---------- end of function Bash_SetMapLeader ---------- -" -"------------------------------------------------------------------------------ -" Bash_ResetMapLeader {{{2 -"------------------------------------------------------------------------------ -function! Bash_ResetMapLeader () - if exists ( 'g:BASH_MapLeader' ) - call mmtemplates#core#ResetMapleader () + + cclose + + " save current settings + let errorf_saved = &l:errorformat + + " run code checker + let &l:errorformat = s:BASH_Errorformat + + silent exe 'cgetbuffer' + + " restore current settings + let &l:errorformat = errorf_saved + + botright cwindow + + if a:jump != 0 + cc endif -endfunction " ---------- end of function Bash_ResetMapLeader ---------- -" }}}2 +endfunction "------------------------------------------------------------------------------- -" s:RereadTemplates : Initial loading of the templates. {{{1 +" s:Run : Run the current buffer. {{{1 +" +" Parameters: +" args - command-line arguments (string) +" mode - "n" : run complete buffer, "v" : run marked area (string) +" ... - range information +" Returns: +" - "------------------------------------------------------------------------------- -function! s:RereadTemplates () +function! s:Run ( args, mode, ... ) range - "------------------------------------------------------------------------------- - " setup template library - "------------------------------------------------------------------------------- - let g:BASH_Templates = mmtemplates#core#NewLibrary ( 'api_version', '1.0' ) + silent exe 'update' | " write source file if necessary + cclose - " mapleader - if empty ( g:BASH_MapLeader ) - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Mapleader', '\' ) + " prepare and check the executable + if ! executable( s:BASH_Executable ) + return s:ErrorMsg ( + \ 'Command "'.s:BASH_Executable.'" not found. Not configured correctly?', + \ 'Further information: :help g:BASH_Executable' ) + endif + + " get the mode (normal/visual) and the range + let mode = a:mode + + if mode == 'c' && a:0 == 3 + " Vim command-line + if a:3 > 0 + let line_f = a:1 + let line_l = a:2 + let mode = 'v' + else + let mode = 'n' + end + elseif mode == 'v' + let line_f = a:firstline + let line_l = a:lastline + endif + + " the interpreter arguments + let args_interp = '' + + if exists( 'b:BASH_InterpCmdLineArgs' ) + let args_interp = ' '.b:BASH_InterpCmdLineArgs + endif + + " prepare the file (and handle visual mode) + if mode == 'v' + let tmpfile = tempname() + silent exe ":".line_f.",".line_l."write ".tmpfile + + "if s:BASH_DirectRun == 'yes' + " :TODO:27.09.2017 23:33:WM: implement this, parse the shebang + "let exec = mlist[1] + "let args_interp = ' '.mlist[2] " overwrite the value of 'b:BASH_InterpCmdLineArgs' + "let arg_list = [ exec ] + s:ShellParseArgs ( mlist[2] ) + "else + let exec = s:BASH_Executable + "end + let script_orig = tmpfile + let script_esc = tmpfile + elseif s:BASH_DirectRun == 'yes' && executable ( expand ( '%:p' ) ) + let exec = expand ( '%:p' ) + let args_interp = '' " not possible with direct run + let script_orig = '' + let script_esc = '' else - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Mapleader', g:BASH_MapLeader ) + let exec = s:BASH_Executable + let script_orig = expand ( '%:p' ) + let script_esc = shellescape ( script_orig ) endif - " some metainfo - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::PluginName', 'Bash' ) - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::FiletypeName', 'Bash' ) - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::FileCustomNoPersonal', s:plugin_dir.'/bash-support/rc/custom.templates' ) - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::FileCustomWithPersonal', s:plugin_dir.'/bash-support/rc/custom_with_personal.templates' ) - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::FilePersonal', s:plugin_dir.'/bash-support/rc/personal.templates' ) - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::CustomFileVariable', 'g:BASH_CustomTemplateFile' ) + " the cmd.-line arguments + if a:args != '' + let args_script = a:args + elseif exists( 'b:BASH_ScriptCmdLineArgs' ) + let args_script = b:BASH_ScriptCmdLineArgs + else + let args_script = '' + endif - " maps: special operations - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::RereadTemplates::Map', 'ntr' ) - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::ChooseStyle::Map', 'nts' ) - call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::SetupWizard::Map', 'ntw' ) + let errformat = s:BASH_Errorformat - " syntax: comments - call mmtemplates#core#ChangeSyntax ( g:BASH_Templates, 'comment', '§' ) + if s:BASH_OutputMethod == 'cmd-line' - " property: file skeletons - call mmtemplates#core#Resource ( g:BASH_Templates, 'add', 'property', 'Bash::FileSkeleton::Script', 'Comments.shebang;Comments.file header; ;Skeleton.script-set' ) + " method : "cmd.-line" - "------------------------------------------------------------------------------- - " load template library - "------------------------------------------------------------------------------- + exe '!'.exec.args_interp.' '.script_esc.' '.args_script - " global templates (global installation only) - if s:installation == 'system' - call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'load', s:BASH_GlobalTemplateFile, - \ 'name', 'global', 'map', 'ntg' ) - endif + if exists( 'tmpfile' ) + call delete ( tmpfile ) " delete the tmpfile + endif + elseif s:BASH_OutputMethod == 'quickfix' - " local templates (optional for global installation) - if s:installation == 'system' - call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'load', s:BASH_LocalTemplateFile, - \ 'name', 'local', 'map', 'ntl', 'optional', 'hidden' ) - else - call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'load', s:BASH_LocalTemplateFile, - \ 'name', 'local', 'map', 'ntl' ) - endif + " method : "quickfix" - " additional templates (optional) - if ! empty ( s:BASH_AdditionalTemplates ) - call mmtemplates#core#AddCustomTemplateFiles ( g:BASH_Templates, s:BASH_AdditionalTemplates, "Bash's additional templates" ) - endif + " run script + let bash_output = system ( exec.args_interp.' '.script_esc.' '.args_script ) - " personal templates (shared across template libraries) (optional, existence of file checked by template engine) - call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'personalization', - \ 'name', 'personal', 'map', 'ntp' ) + " successful? + if v:shell_error == 0 + " echo script output + echo bash_output + else + " save current settings + let errorf_saved = &g:errorformat - " custom templates (optional, existence of file checked by template engine) - call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'load', s:BASH_CustomTemplateFile, - \ 'name', 'custom', 'map', 'ntc', 'optional' ) + " run code checker + let &g:errorformat = errformat - "------------------------------------------------------------------------------- - " further setup - "------------------------------------------------------------------------------- + silent exe 'cexpr bash_output' - " get the jump tags - let s:BASH_TemplateJumpTarget = mmtemplates#core#Resource ( g:BASH_Templates, "jumptag" )[0] + " restore current settings + let &g:errorformat = errorf_saved - " get the builtin list - let l = mmtemplates#core#Resource ( g:BASH_Templates, 'get', 'list', 'builtins' ) + botright cwindow + cc + endif - if l[1] == '' - let s:BuiltinList = l[0] - else - call s:ErrorMsg ( l[1] ) - endif + if exists( 'tmpfile' ) + call delete ( tmpfile ) " delete the tmpfile + endif + elseif s:BASH_OutputMethod == 'buffer' -endfunction " ---------- end of function s:RereadTemplates ---------- + " method : "buffer" -"------------------------------------------------------------------------------- -" s:CheckTemplatePersonalization : Check whether the name, .. has been set. {{{1 -"------------------------------------------------------------------------------- + let title_name = 'Bash Output' + let title_range = '' + if mode == 'v' + let title_range = 'lines '.line_f.'-'.line_l + endif -let s:DoneCheckTemplatePersonalization = 0 + if s:OpenBuffer ( 'Bash Output', 'topic', title_range ) + " open buffer -function! s:CheckTemplatePersonalization () + setlocal syntax=none - " check whether the templates are personalized - if s:DoneCheckTemplatePersonalization - \ || mmtemplates#core#ExpandText ( g:BASH_Templates, '|AUTHOR|' ) != 'YOUR NAME' - \ || s:BASH_InsertFileHeader != 'yes' - return - endif + call Bash_SetMapLeader () - let s:DoneCheckTemplatePersonalization = 1 + " maps: quickfix list + nnoremap <buffer> <silent> <LocalLeader>qf :call <SID>OutputBufferErrors(0)<CR> + inoremap <buffer> <silent> <LocalLeader>qf <C-C>:call <SID>OutputBufferErrors(0)<CR> + vnoremap <buffer> <silent> <LocalLeader>qf <C-C>:call <SID>OutputBufferErrors(0)<CR> + nnoremap <buffer> <silent> <LocalLeader>qj :call <SID>OutputBufferErrors(1)<CR> + inoremap <buffer> <silent> <LocalLeader>qj <C-C>:call <SID>OutputBufferErrors(1)<CR> + vnoremap <buffer> <silent> <LocalLeader>qj <C-C>:call <SID>OutputBufferErrors(1)<CR> - let maplead = mmtemplates#core#Resource ( g:BASH_Templates, 'get', 'property', 'Templates::Mapleader' )[0] + call Bash_ResetMapLeader () + endif - redraw - call s:ImportantMsg ( 'The personal details are not set in the template library. Use the map "'.maplead.'ntw".' ) + setlocal modifiable -endfunction " ---------- end of function s:CheckTemplatePersonalization ---------- + silent exe '%delete _' + silent exe '0r!'.exec.args_interp.' '.script_esc.' '.args_script + silent exe '$delete _' -"------------------------------------------------------------------------------- -" s:CheckAndRereadTemplates : Make sure the templates are loaded. {{{1 -"------------------------------------------------------------------------------- -function! s:CheckAndRereadTemplates () - if ! exists ( 'g:BASH_Templates' ) - call s:RereadTemplates() - endif -endfunction " ---------- end of function s:CheckAndRereadTemplates ---------- + if v:shell_error == 0 + " jump to the first line of the output + normal! gg -"------------------------------------------------------------------------------- -" s:InsertFileHeader : Insert a file header. {{{1 -"------------------------------------------------------------------------------- -function! s:InsertFileHeader () - call s:CheckAndRereadTemplates() + setlocal nomodifiable + setlocal nomodified + else + " jump to the last line of the output, where the error is mentioned + normal! G - " prevent insertion for a file generated from a some error - if isdirectory(expand('%:p:h')) && s:BASH_InsertFileHeader == 'yes' - let templ_s = mmtemplates#core#Resource ( g:BASH_Templates, 'get', 'property', 'Bash::FileSkeleton::Script' )[0] + " save current settings + let errorf_saved = &l:errorformat - " insert templates in reverse order, always above the first line - " the last one to insert (the first in the list), will determine the - " placement of the cursor - let templ_l = split ( templ_s, ';' ) - for i in range ( len(templ_l)-1, 0, -1 ) + " run code checker + let &l:errorformat = errformat + + silent exe 'cgetbuffer' + + " restore current settings + let &l:errorformat = errorf_saved + + botright cwindow + cc + endif + + if exists( 'tmpfile' ) + call delete ( tmpfile ) " delete the tmpfile + endif + elseif s:BASH_OutputMethod == 'terminal' + + " method : "terminal" + + try + let arg_list = [ exec ] + if args_interp != '' && script_orig != '' + let arg_list += s:ShellParseArgs ( args_interp ) + endif + if script_orig != '' + let arg_list += [ script_orig ] + endif + if args_script != '' + let arg_list += s:ShellParseArgs ( args_script ) " expand to a list + endif + catch /^ShellParseArgs:Syntax:/ + let msg = v:exception[ len( 'ShellParseArgs:Syntax:') : -1 ] + return s:WarningMsg ( 'syntax error while parsing arguments: '.msg ) + catch /.*/ + return s:WarningMsg ( + \ "internal error (" . v:exception . ")", + \ " - occurred at " . v:throwpoint ) + endtry + + let title_name = 'Bash Terminal' + let title_range = '' + if mode == 'v' + let title_range = 'lines '.line_f.'-'.line_l + endif + let is_new_buffer = 0 + + if s:OpenBuffer ( 'Bash Terminal', 'topic', title_range ) + " open buffer + let is_new_buffer = 1 + endif + + if s:NEOVIM + let bn = bufname( '%' ) + let job_id = termopen( arg_list, {} ) + + silent exe 'file '.fnameescape( bn ) + else + let bn = bufname( '%' ) + call term_start( arg_list, { 'curwin' : 1, 'term_name' : bn } ) + endif + + " :TODO:27.09.2017 23:39:WM: needs to handle the tmpfile, use exit callback + + if is_new_buffer + call Bash_SetMapLeader () + + " maps: quickfix list + if empty( maparg( '<LocalLeader>qf', 'n' ) ) + nnoremap <buffer> <silent> <LocalLeader>qf :call <SID>OutputBufferErrors(0)<CR> + inoremap <buffer> <silent> <LocalLeader>qf <C-C>:call <SID>OutputBufferErrors(0)<CR> + vnoremap <buffer> <silent> <LocalLeader>qf <C-C>:call <SID>OutputBufferErrors(0)<CR> + endif + if empty( maparg( '<LocalLeader>qj', 'n' ) ) + nnoremap <buffer> <silent> <LocalLeader>qj :call <SID>OutputBufferErrors(1)<CR> + inoremap <buffer> <silent> <LocalLeader>qj <C-C>:call <SID>OutputBufferErrors(1)<CR> + vnoremap <buffer> <silent> <LocalLeader>qj <C-C>:call <SID>OutputBufferErrors(1)<CR> + endif + + call Bash_ResetMapLeader () + endif + + elseif s:BASH_OutputMethod == 'xterm' + + " method : "xterm" + + if s:Xterm_Executable =~ '\cxterm' + let title = ' -title Bash' + else + let title = '' + endif + let rm_tmp = '' + if mode == 'v' + let title = title.shellescape( ' - lines '.line_f.'-'.line_l ) + let rm_tmp = '; rm '.tmpfile + endif + + " :TODO:27.09.2017 23:39:WM: needs to handle the tmpfile, but Linux only so use 'rm' + + silent exe '!'.s:Xterm_Executable.' '.g:Xterm_Options.title + \ .' -e '.shellescape( exec.args_interp.' '.script_esc.' '.args_script.' ; echo "" ; read -p " ** PRESS ENTER ** " dummy '.rm_tmp ).' &' + + call s:Redraw ( 'r!', '' ) " redraw in terminal + endif +endfunction " ---------- end of function s:Run ---------- + +"---------------------------------------------------------------------- +" === Run: Executable, arguments, output, ... === {{{1 +"---------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" s:SetExecutable : Set s:BASH_Executable {{{2 +"------------------------------------------------------------------------------- +function! s:SetExecutable ( new_exec ) + + let new_exec = expand ( a:new_exec ) + + if new_exec == '' + echo s:BASH_Executable + elseif ! executable ( new_exec ) + return s:ErrorMsg ( '"'.new_exec.'" is not executable, nothing set.' ) + else + let s:BASH_Executable = new_exec + endif +endfunction " ---------- end of function s:SetExecutable ---------- + +"------------------------------------------------------------------------------- +" s:ScriptCmdLineArguments : Set cmd.-line arguments for the script. {{{2 +"------------------------------------------------------------------------------- +function! s:ScriptCmdLineArguments ( args ) + let b:BASH_ScriptCmdLineArgs = a:args +endfunction " ---------- end of function s:ScriptCmdLineArguments ---------- + +"------------------------------------------------------------------------------- +" s:InterpCmdLineArguments : Set cmd.-line arguments for the interpreter. {{{2 +"------------------------------------------------------------------------------- +function! s:InterpCmdLineArguments ( args ) + let b:BASH_InterpCmdLineArgs = a:args +endfunction " ---------- end of function s:InterpCmdLineArguments ---------- + +"------------------------------------------------------------------------------- +" s:GetOutputMethodList : For cmd.-line completion. {{{2 +"------------------------------------------------------------------------------- +function! s:GetOutputMethodList (...) + return join ( s:BASH_OutputMethodList, "\n" ) +endfunction " ---------- end of function s:GetOutputMethodList ---------- + +"------------------------------------------------------------------------------- +" s:SetOutputMethod : Set s:BASH_OutputMethod {{{2 +"------------------------------------------------------------------------------- +function! s:SetOutputMethod ( method ) + + if a:method == '' + echo s:BASH_OutputMethod + return + endif + + " 'method' gives the output method + if index ( s:BASH_OutputMethodList, a:method ) == -1 + return s:ErrorMsg ( 'Invalid option for output method: "'.a:method.'".' ) + endif + + let s:BASH_OutputMethod = a:method + + " update the menu header + if ! has ( 'menu' ) || s:MenuVisible == 0 + return + endif + + exe 'aunmenu '.s:BASH_RootMenu.'.Run.output\ method.Output\ Method' + + if s:BASH_OutputMethod == 'cmd-line' + let current = 'cmd\.-line' + elseif s:BASH_OutputMethod == 'quickfix' + let current = 'quickfix' + elseif s:BASH_OutputMethod == 'buffer' + let current = 'buffer' + elseif s:BASH_OutputMethod == 'terminal' + let current = 'terminal' + elseif s:BASH_OutputMethod == 'xterm' + let current = 'xterm' + endif + + exe 'anoremenu ...400 '.s:BASH_RootMenu.'.Run.output\ method.Output\ Method<TAB>(current\:\ '.current.') :echo "This is a menu header."<CR>' + +endfunction " ---------- end of function s:SetOutputMethod ---------- + +"------------------------------------------------------------------------------- +" s:GetDirectRunList : For cmd.-line completion. {{{2 +"------------------------------------------------------------------------------- +function! s:GetDirectRunList (...) + return "yes\nno" +endfunction " ---------- end of function s:GetDirectRunList ---------- + +"------------------------------------------------------------------------------- +" s:SetDirectRun : Set s:BASH_DirectRun {{{2 +"------------------------------------------------------------------------------- +function! s:SetDirectRun ( option ) + + if a:option == '' + echo s:BASH_DirectRun + return + endif + + " 'option' gives the setting + if a:option != 'yes' && a:option != 'no' + return s:ErrorMsg ( 'Invalid option for direct run: "'.a:option.'".' ) + endif + + let s:BASH_DirectRun = a:option + + " update the menu header + if ! has ( 'menu' ) || s:MenuVisible == 0 + return + endif + + exe 'aunmenu '.s:BASH_RootMenu.'.Run.direct\ run.Direct\ Run' + + let current = s:BASH_DirectRun + + exe 'anoremenu ...400 '.s:BASH_RootMenu.'.Run.direct\ run.Direct\ Run<TAB>(currently\:\ '.current.') :echo "This is a menu header."<CR>' + +endfunction " ---------- end of function s:SetDirectRun ---------- +" }}}2 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" s:SyntaxCheck : Run syntax check. {{{1 +"------------------------------------------------------------------------------- +function! s:SyntaxCheck () + + silent exe 'update' | " write source file if necessary + cclose + + let currentbuffer = bufname("%") + let fullname = expand("%:p") + + " save current settings + let makeprg_saved = &l:makeprg + let errorf_saved = &l:errorformat + + " assemble the options + let options = s:BASH_SyntaxCheckOptionsGlob + if exists( 'b:BASH_SyntaxCheckOptionsLocal' ) + let options .= ' '.b:BASH_SyntaxCheckOptionsLocal + endif + + " match the Bash error messages (quickfix commands) + " ignore any lines that didn't match one of the patterns + let &l:makeprg = s:BASH_Executable + let &l:errorformat = s:BASH_Errorformat + + silent exe ':make! -n '.options.' -- '.fnameescape( fullname ) + + " restore current settings + let &l:makeprg = makeprg_saved + let &l:errorformat = errorf_saved + + call s:Redraw('r!','') " redraw after cclose, before opening the new window + botright cwindow + + " any errors? + if currentbuffer == bufname("%") + call s:Redraw('','r') " redraw after cclose, before echoing + call s:ImportantMsg ( currentbuffer." : Syntax is OK" ) + endif +endfunction " ---------- end of function s:SyntaxCheck ---------- + +"---------------------------------------------------------------------- +" === Syntax Check: Arguments, ... === {{{1 +"---------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" s:ScriptSyntaxCheckOptions : Set cmd.-line arguments for the script. {{{2 +"------------------------------------------------------------------------------- +function! s:ScriptSyntaxCheckOptions ( args ) + let b:BASH_SyntaxCheckOptionsLocal = a:args +endfunction " ---------- end of function s:ScriptSyntaxCheckOptions ---------- + +" }}}2 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" s:HelpMan : Look up word under the cursor. {{{1 +" +" Parameters: +" type - the type (string) +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" s:RemoveSpecialCharacters : Clean CYGWIN output. {{{2 +" +" Clean CYGWIN man(1) output: +" remove _<backspace> +" remove <backspace><any character> +"------------------------------------------------------------------------------- +function! s:RemoveSpecialCharacters ( ) + let patternunderline = '_\%x08' + let patternbold = '\%x08.' + setlocal modifiable + if search(patternunderline) != 0 + silent exe ':%s/'.patternunderline.'//g' + endif + if search(patternbold) != 0 + silent exe ':%s/'.patternbold.'//g' + endif + setlocal nomodifiable + silent normal! gg +endfunction " ---------- end of function s:RemoveSpecialCharacters ---------- +" }}}2 +"------------------------------------------------------------------------------- + +function! s:HelpMan ( type ) + + let cuc = getline(".")[col(".") - 1] " character under the cursor + let item = expand("<cword>") " word under the cursor + if empty(item) || match( item, cuc ) == -1 + if a:type == 'man' + let item = s:UserInput('[tab compl. on] name of command line utility : ', '', 'shellcmd' ) + endif + endif + + if empty(item) && a:type != 'bash' + return + endif + + "------------------------------------------------------------------------------ + " replace buffer content with bash help text + "------------------------------------------------------------------------------ + + " jump to an already open bash help window or create one + if a:type == 'bash' && s:OpenBuffer ( 'Bash Manual', 'reuse_other', 1 ) + \ || a:type != 'bash' && s:OpenBuffer ( 'Bash Help', 'topic', 'man: '.item ) + setlocal syntax=OFF + endif + + " :WORKAROUND:05.04.2016 21:05:WM: setting the filetype changes the global tabstop, + " handle this manually + let ts_save = &g:tabstop + + setlocal filetype=man + + let &g:tabstop = ts_save + + "------------------------------------------------------------------------------- + " open a manual (utilities) + "------------------------------------------------------------------------------- + + let man_warn = '' + + if a:type == 'man' + + " Is there more than one manual? + let manpages = system( s:BASH_ManualReader.' -k '.item ) + if v:shell_error + let man_warn = "shell command '".s:BASH_ManualReader." -k ".item."' failed" + let catalogs = [] + let manual = {} + else + let catalogs = split( manpages, '\n', ) + let manual = {} + endif + + " Select manuals where the name exactly matches + for line in catalogs + if line =~ '^'.item.'\s\+(' + let itempart = split( line, '\s\+' ) + let catalog = itempart[1][1:-2] + let manual[catalog] = catalog + endif + endfor + + " Build a selection list if there are more than one manual + let catalog = "" + if len(keys(manual)) > 1 + for key in keys(manual) + echo ' '.item.' '.key + endfor + let defaultcatalog = '' + if has_key( manual, '1' ) + let defaultcatalog = '1' + elseif has_key( manual, '8' ) + let defaultcatalog = '8' + endif + let catalog = input( 'select manual section (<Enter> cancels) : ', defaultcatalog ) + if ! has_key( manual, catalog ) + let man_warn = "no appropriate manual section '".catalog."'" + endif + endif + endif + + "------------------------------------------------------------------------------- + " open the bash manual + "------------------------------------------------------------------------------- + if a:type == 'bash' + let catalog = 1 + let item = 'bash' + endif + + "------------------------------------------------------------------------------- + " run man(1) to obtain the text + "------------------------------------------------------------------------------- + + if man_warn != '' + close + call s:Redraw ('r!','r') + return s:WarningMsg ( man_warn ) + endif + + setlocal modifiable + + let win_w = winwidth( winnr() ) + if s:UNIX && win_w > 0 + silent exe ":%! MANWIDTH=".win_w." ".s:BASH_ManualReader." ".catalog." ".item + else + silent exe ":%!".s:BASH_ManualReader." ".catalog." ".item + endif + + if s:MSWIN + call s:RemoveSpecialCharacters() + endif + + setlocal nomodifiable +endfunction " ---------- end of function s:HelpMan ---------- + +"------------------------------------------------------------------------------- +" s:HelpBuiltin : Look up help for a built-in. {{{1 +"------------------------------------------------------------------------------- + +let s:BuiltinList = [] + +function! s:HelpBuiltin () + + let cuc = getline(".")[col(".") - 1] " character under the cursor + let item = expand("<cword>") " word under the cursor + if empty(item) || match( item, cuc ) == -1 + let item = s:UserInput('[tab compl. on] name of bash builtin : ', '', 'customlist', s:BuiltinList ) + endif + + if empty(item) + return + endif + + " jump to an already open Bash help window or create one + if s:OpenBuffer ( 'Bash Help', 'topic', 'builtin: '.item ) + setlocal syntax=OFF + endif + + " :WORKAROUND:05.04.2016 21:05:WM: setting the filetype changes the global tabstop, + " handle this manually + let ts_save = &g:tabstop + + setlocal filetype=bashhelp + + let &g:tabstop = ts_save + + " replace buffer content with Bash help + setlocal modifiable + silent exe '1,$delete _' + if s:UNIX + silent exe ":r!help -m ".item + else + silent exe ":r!".s:BASH_Executable." -c 'help -m ".item."'" + endif + " go to first line + normal! gg + setlocal nomodifiable +endfunction " ---------- end of function s:HelpBuiltin ---------- + +"------------------------------------------------------------------------------- +" s:HelpPlugin : Plug-in help. {{{1 +"------------------------------------------------------------------------------- +function! s:HelpPlugin () + try + help bashsupport + catch + exe 'helptags '.s:plugin_dir.'/doc' + help bashsupport + endtry +endfunction " ---------- end of function s:HelpPlugin ---------- + +"------------------------------------------------------------------------------ +" === Templates API === {{{1 +"------------------------------------------------------------------------------ +" +"------------------------------------------------------------------------------ +" Bash_SetMapLeader {{{2 +"------------------------------------------------------------------------------ +function! Bash_SetMapLeader () + if exists ( 'g:BASH_MapLeader' ) + call mmtemplates#core#SetMapleader ( g:BASH_MapLeader ) + endif +endfunction " ---------- end of function Bash_SetMapLeader ---------- +" +"------------------------------------------------------------------------------ +" Bash_ResetMapLeader {{{2 +"------------------------------------------------------------------------------ +function! Bash_ResetMapLeader () + if exists ( 'g:BASH_MapLeader' ) + call mmtemplates#core#ResetMapleader () + endif +endfunction " ---------- end of function Bash_ResetMapLeader ---------- +" }}}2 + +"------------------------------------------------------------------------------- +" s:RereadTemplates : Initial loading of the templates. {{{1 +"------------------------------------------------------------------------------- +function! s:RereadTemplates () + + "------------------------------------------------------------------------------- + " setup template library + "------------------------------------------------------------------------------- + let g:BASH_Templates = mmtemplates#core#NewLibrary ( 'api_version', '1.0' ) + + " mapleader + if empty ( g:BASH_MapLeader ) + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Mapleader', '\' ) + else + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Mapleader', g:BASH_MapLeader ) + endif + + " some metainfo + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::PluginName', 'Bash' ) + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::FiletypeName', 'Bash' ) + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::FileCustomNoPersonal', s:plugin_dir.'/bash-support/rc/custom.templates' ) + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::FileCustomWithPersonal', s:plugin_dir.'/bash-support/rc/custom_with_personal.templates' ) + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::FilePersonal', s:plugin_dir.'/bash-support/rc/personal.templates' ) + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::Wizard::CustomFileVariable', 'g:BASH_CustomTemplateFile' ) + + " maps: special operations + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::RereadTemplates::Map', 'ntr' ) + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::ChooseStyle::Map', 'nts' ) + call mmtemplates#core#Resource ( g:BASH_Templates, 'set', 'property', 'Templates::SetupWizard::Map', 'ntw' ) + + " syntax: comments + call mmtemplates#core#ChangeSyntax ( g:BASH_Templates, 'comment', '§' ) + + " property: file skeletons (use a safe default here, more sensible settings are applied in the template library) + call mmtemplates#core#Resource ( g:BASH_Templates, 'add', 'property', 'Bash::FileSkeleton::Script', 'Comments.file header' ) + + "------------------------------------------------------------------------------- + " load template library + "------------------------------------------------------------------------------- + + " global templates (global installation only) + if s:installation == 'system' + call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'load', s:BASH_GlobalTemplateFile, + \ 'name', 'global', 'map', 'ntg' ) + endif + + " local templates (optional for global installation) + if s:installation == 'system' + call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'load', s:BASH_LocalTemplateFile, + \ 'name', 'local', 'map', 'ntl', 'optional', 'hidden' ) + else + call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'load', s:BASH_LocalTemplateFile, + \ 'name', 'local', 'map', 'ntl' ) + endif + + " additional templates (optional) + if ! empty ( s:BASH_AdditionalTemplates ) + call mmtemplates#core#AddCustomTemplateFiles ( g:BASH_Templates, s:BASH_AdditionalTemplates, "Bash's additional templates" ) + endif + + " personal templates (shared across template libraries) (optional, existence of file checked by template engine) + call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'personalization', + \ 'name', 'personal', 'map', 'ntp' ) + + " custom templates (optional, existence of file checked by template engine) + call mmtemplates#core#ReadTemplates ( g:BASH_Templates, 'load', s:BASH_CustomTemplateFile, + \ 'name', 'custom', 'map', 'ntc', 'optional' ) + + "------------------------------------------------------------------------------- + " further setup + "------------------------------------------------------------------------------- + + " get the jump tags + let s:BASH_TemplateJumpTarget = mmtemplates#core#Resource ( g:BASH_Templates, "jumptag" )[0] + + " get the builtin list + let l = mmtemplates#core#Resource ( g:BASH_Templates, 'get', 'list', 'builtins' ) + + if l[1] == '' + let s:BuiltinList = l[0] + else + call s:ErrorMsg ( l[1] ) + endif + +endfunction " ---------- end of function s:RereadTemplates ---------- + +"------------------------------------------------------------------------------- +" s:CheckTemplatePersonalization : Check whether the name, .. has been set. {{{1 +"------------------------------------------------------------------------------- + +let s:DoneCheckTemplatePersonalization = 0 + +function! s:CheckTemplatePersonalization () + + " check whether the templates are personalized + if s:DoneCheckTemplatePersonalization + \ || mmtemplates#core#ExpandText ( g:BASH_Templates, '|AUTHOR|' ) != 'YOUR NAME' + \ || s:BASH_InsertFileHeader != 'yes' + return + endif + + let s:DoneCheckTemplatePersonalization = 1 + + let maplead = mmtemplates#core#Resource ( g:BASH_Templates, 'get', 'property', 'Templates::Mapleader' )[0] + + redraw + call s:ImportantMsg ( 'The personal details are not set in the template library. Use the map "'.maplead.'ntw".' ) + +endfunction " ---------- end of function s:CheckTemplatePersonalization ---------- + +"------------------------------------------------------------------------------- +" s:CheckAndRereadTemplates : Make sure the templates are loaded. {{{1 +"------------------------------------------------------------------------------- +function! s:CheckAndRereadTemplates () + if ! exists ( 'g:BASH_Templates' ) + call s:RereadTemplates() + endif +endfunction " ---------- end of function s:CheckAndRereadTemplates ---------- + +"------------------------------------------------------------------------------- +" s:InsertFileHeader : Insert a file header. {{{1 +"------------------------------------------------------------------------------- +function! s:InsertFileHeader () + call s:CheckAndRereadTemplates() + + " prevent insertion for a file generated from a some error + if isdirectory(expand('%:p:h')) && s:BASH_InsertFileHeader == 'yes' + let templ_s = mmtemplates#core#Resource ( g:BASH_Templates, 'get', 'property', 'Bash::FileSkeleton::Script' )[0] + + " insert templates in reverse order, always above the first line + " the last one to insert (the first in the list), will determine the + " placement of the cursor + let templ_l = split ( templ_s, ';' ) + for i in range ( len(templ_l)-1, 0, -1 ) exe 1 if -1 != match ( templ_l[i], '^\s\+$' ) put! ='' @@ -1008,19 +1954,16 @@ function! s:JumpForward () return '' endfunction " ---------- end of function s:JumpForward ---------- -"=== FUNCTION ================================================================ -" NAME: InitMenus {{{1 -" DESCRIPTION: Initialize menus. -" PARAMETERS: - -" RETURNS: -"=============================================================================== +"------------------------------------------------------------------------------- +" s:InitMenus : Initialize menus. {{{1 +"------------------------------------------------------------------------------- function! s:InitMenus() - " + if ! has ( 'menu' ) return endif - " - "------------------------------------------------------------------------------- + + "------------------------------------------------------------------------------- " preparation {{{2 "------------------------------------------------------------------------------- call mmtemplates#core#CreateMenus ( 'g:BASH_Templates', s:BASH_RootMenu, 'do_reset' ) @@ -1039,7 +1982,10 @@ function! s:InitMenus() " the other, automatically created menus go here; their priority is the standard priority 500 call mmtemplates#core#CreateMenus ( 'g:BASH_Templates', s:BASH_RootMenu, 'sub_menu', 'S&nippets', 'priority', 600 ) call mmtemplates#core#CreateMenus ( 'g:BASH_Templates', s:BASH_RootMenu, 'sub_menu', '&Run' , 'priority', 700 ) - call mmtemplates#core#CreateMenus ( 'g:BASH_Templates', s:BASH_RootMenu, 'sub_menu', '&Help' , 'priority', 800 ) + if s:BASH_UseToolbox == 'yes' && mmtoolbox#tools#Property ( s:BASH_Toolbox, 'empty-menu' ) == 0 + call mmtemplates#core#CreateMenus ( 'g:BASH_Templates', s:BASH_RootMenu, 'sub_menu', '&Tool\ Box', 'priority', 800 ) + endif + call mmtemplates#core#CreateMenus ( 'g:BASH_Templates', s:BASH_RootMenu, 'sub_menu', '&Help' , 'priority', 900 ) " "------------------------------------------------------------------------------- " comments {{{2 @@ -1066,7 +2012,7 @@ function! s:InitMenus() exe ahead.'-Sep02- <Nop>' " "------------------------------------------------------------------------------- - " generate menus from the templates + " generate menus from the templates {{{2 "------------------------------------------------------------------------------- " call mmtemplates#core#CreateMenus ( 'g:BASH_Templates', s:BASH_RootMenu, 'do_templates' ) @@ -1097,122 +2043,176 @@ function! s:InitMenus() "------------------------------------------------------------------------------- " run {{{2 "------------------------------------------------------------------------------- - " - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.save\ +\ &run\ script<Tab><C-F9>\ \ '.esc_mapl.'rr :call BASH_Run("n")<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.save\ +\ &run\ script<Tab><C-F9>\ \ '.esc_mapl.'rr <C-C>:call BASH_Run("n")<CR>' - exe "vmenu <silent> ".s:BASH_RootMenu.'.&Run.save\ +\ &run\ script<Tab><C-F9>\ \ '.esc_mapl.'rr <C-C>:call BASH_Run("v")<CR>' - " - exe " menu ".s:BASH_RootMenu.'.&Run.script\ cmd\.\ line\ &arg\.<Tab><S-F9>\ \ '.esc_mapl.'ra :BashScriptArguments<Space>' - exe "imenu ".s:BASH_RootMenu.'.&Run.script\ cmd\.\ line\ &arg\.<Tab><S-F9>\ \ '.esc_mapl.'ra <C-C>:BashScriptArguments<Space>' - " - exe " menu ".s:BASH_RootMenu.'.&Run.Bash\ cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'rba :BashArguments<Space>' - exe "imenu ".s:BASH_RootMenu.'.&Run.Bash\ cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'rba <C-C>:BashArguments<Space>' - " - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.update,\ check\ &syntax<Tab><A-F9>\ \ '.esc_mapl.'rc :call BASH_SyntaxCheck()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.update,\ check\ &syntax<Tab><A-F9>\ \ '.esc_mapl.'rc <C-C>:call BASH_SyntaxCheck()<CR>' - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.syntax\ check\ o&ptions<Tab>'.esc_mapl.'rco :call BASH_SyntaxCheckOptionsLocal()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.syntax\ check\ o&ptions<Tab>'.esc_mapl.'rco <C-C>:call BASH_SyntaxCheckOptionsLocal()<CR>' - " - let ahead = 'amenu <silent> '.s:BASH_RootMenu.'.Run.' - let vhead = 'vmenu <silent> '.s:BASH_RootMenu.'.Run.' - " - " - if !s:MSWIN - exe "amenu <silent> ".s:BASH_RootMenu.'.&Run.start\ &debugger<Tab><F9>\ \ '.esc_mapl.'rd :call BASH_Debugger()<CR>' - exe "amenu <silent> ".s:BASH_RootMenu.'.&Run.make\ script\ &exec\./not\ exec\.<Tab>'.esc_mapl.'re :call <SID>MakeExecutable()<CR>' + + let ahead = 'anoremenu <silent> '.s:BASH_RootMenu.'.Run.' + let vhead = 'vnoremenu <silent> '.s:BASH_RootMenu.'.Run.' + let ihead = 'inoremenu <silent> '.s:BASH_RootMenu.'.Run.' + let ahead_loud = 'amenu '.s:BASH_RootMenu.'.Run.' " these have to remap. + let ihead_loud = 'imenu '.s:BASH_RootMenu.'.Run.' " ... so we can use <Plug>Map + + exe ahead.'save\ +\ &run\ script<Tab>'.esc_mapl.'rr :call <SID>Run("","n")<CR>' + exe vhead.'save\ +\ &run\ script<Tab>'.esc_mapl.'rr :call <SID>Run("","v")<CR>' + exe ihead.'save\ +\ &run\ script<Tab>'.esc_mapl.'rr <C-C>:call <SID>Run("","n")<CR>' + + exe ahead_loud.'script\ cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'rsa <Plug>BashSupportSetBashScriptArgs' + exe ihead_loud.'script\ cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'rsa <C-C><Plug>BashSupportSetBashScriptArgs' + exe ahead_loud.'interpreter\ cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'ria <Plug>BashSupportSetBashInterpArgs' + exe ihead_loud.'interpreter\ cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'ria <C-C><Plug>BashSupportSetBashInterpArgs' + + exe ahead.'check\ &syntax<Tab>'.esc_mapl.'rk :call <SID>SyntaxCheck()<CR>' + exe ihead.'check\ &syntax<Tab>'.esc_mapl.'rk <C-C>:call <SID>SyntaxCheck()<CR>' + + exe ahead_loud.'syntax\ check\ o&ptions<Tab>'.esc_mapl.'rso <Plug>BashSupportSetBashSyntaxOpts' + exe ihead_loud.'syntax\ check\ o&ptions<Tab>'.esc_mapl.'rso <C-C><Plug>BashSupportSetBashSyntaxOpts' + + exe ahead.'&buffer\ "Bash\ Output\/Term".buffer\ "Bash\ Output\/Term" :echo "This is a menu header."<CR>' + exe ahead.'&buffer\ "Bash\ Output\/Term".-SepHead- :' + exe ahead.'&buffer\ "Bash\ Output\/Term".load\ into\ quick&fix<TAB>'.esc_mapl.'qf :call <SID>OutputBufferErrors(0)<CR>' + exe ihead.'&buffer\ "Bash\ Output\/Term".load\ into\ quick&fix<TAB>'.esc_mapl.'qf <Esc>:call <SID>OutputBufferErrors(0)<CR>' + exe ahead.'&buffer\ "Bash\ Output\/Term".qf\.\ and\ &jump\ to\ first\ error<TAB>'.esc_mapl.'qj :call <SID>OutputBufferErrors(1)<CR>' + exe ihead.'&buffer\ "Bash\ Output\/Term".qf\.\ and\ &jump\ to\ first\ error<TAB>'.esc_mapl.'qj <Esc>:call <SID>OutputBufferErrors(1)<CR>' + + exe ahead.'-SEP-SETTINGS- :' + + " create a dummy menu header for the "output method" sub-menu + exe ahead.'&output\ method<TAB>'.esc_mapl.'ro.Output\ Method :' + exe ahead.'&output\ method<TAB>'.esc_mapl.'ro.-SepHead- :' + " create a dummy menu header for the "direct run" sub-menu + exe ahead.'&direct\ run<TAB>'.esc_mapl.'rd.Direct\ Run :' + exe ahead.'&direct\ run<TAB>'.esc_mapl.'rd.-SepHead- :' + + exe ahead_loud.'set\ &executable<Tab>'.esc_mapl.'rse :BashExecutable<Space>' + exe ihead_loud.'set\ &executable<Tab>'.esc_mapl.'rse <C-C>:BashExecutable<Space>' + + if index ( s:BASH_OutputMethodList, 'xterm' ) > -1 + exe ahead.'&xterm\ size<Tab>'.esc_mapl.'rx :call <SID>XtermSize()<CR>' + exe ihead.'&xterm\ size<Tab>'.esc_mapl.'rx <C-C>:call <SID>XtermSize()<CR>' endif exe ahead.'-SEP1- :' - if s:MSWIN - exe ahead.'&hardcopy\ to\ printer<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("n")<CR>' + if s:MSWIN + exe ahead.'&hardcopy\ to\ printer<Tab>'.esc_mapl.'rh :call <SID>Hardcopy("n")<CR>' exe vhead.'&hardcopy\ to\ printer<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' + exe ihead.'&hardcopy\ to\ printer<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' else - exe ahead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("n")<CR>' + exe ahead.'make\ script\ &exec\./not\ exec\.<Tab>'.esc_mapl.'re :call <SID>MakeExecutable()<CR>' + exe ihead.'make\ script\ &exec\./not\ exec\.<Tab>'.esc_mapl.'re <C-C>:call <SID>MakeExecutable()<CR>' + exe ahead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh :call <SID>Hardcopy("n")<CR>' exe vhead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' - endif - - exe ahead.'-SEP2- :' - exe ahead.'plugin\ &settings<Tab>'.esc_mapl.'rs :call BASH_Settings(0)<CR>' - " - if !s:MSWIN - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.x&term\ size<Tab>'.esc_mapl.'rx :call BASH_XtermSize()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.x&term\ size<Tab>'.esc_mapl.'rx <C-C>:call BASH_XtermSize()<CR>' - endif - " - if s:MSWIN - if s:BASH_OutputGvim == "buffer" - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->term<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm_MS()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->term<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm_MS()<CR>' - else - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ TERM->buffer<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm_MS()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ TERM->buffer<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm_MS()<CR>' - endif - else - if s:BASH_OutputGvim == "vim" - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ VIM->buffer->xterm<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ VIM->buffer->xterm<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm()<CR>' - else - if s:BASH_OutputGvim == "buffer" - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->xterm->vim<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->xterm->vim<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm()<CR>' - else - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ XTERM->vim->buffer<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ XTERM->vim->buffer<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm()<CR>' - endif + exe ihead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' + endif + + exe ahead.'-SEP2- :' + exe ahead.'plugin\ &settings<Tab>'.esc_mapl.'rs :call Bash_Settings(0)<CR>' + exe ihead.'plugin\ &settings<Tab>'.esc_mapl.'rs <C-C>:call Bash_Settings(0)<CR>' + + " run -> output method + let method_menu_entries = [ + \ [ 'cmd-line', '&cmd\.-line', 'interactive', ], + \ [ 'quickfix', '&quickfix', 'quickfix', ], + \ [ 'buffer', '&buffer', 'quickfix', ], + \ [ 'terminal', '&terminal', 'interact+qf', ], + \ [ 'xterm', '&xterm', 'interactive', ], + \ ] + + for [ method, left, right ] in method_menu_entries + if index ( s:BASH_OutputMethodList, method ) > -1 + exe ahead.'output\ method.'.left.'<TAB>'.right.' :call <SID>SetOutputMethod("'.method.'")<CR>' + exe ihead.'output\ method.'.left.'<TAB>'.right.' <Esc>:call <SID>SetOutputMethod("'.method.'")<CR>' endif - endif - " - "------------------------------------------------------------------------------- + endfor + + " run -> direct run + + exe ahead.'direct\ run.&yes<TAB>use\ executable\ scripts :call <SID>SetDirectRun("yes")<CR>' + exe ihead.'direct\ run.&yes<TAB>use\ executable\ scripts <Esc>:call <SID>SetDirectRun("yes")<CR>' + exe ahead.'direct\ run.&no<TAB>always\ use\ bash :call <SID>SetDirectRun("no")<CR>' + exe ihead.'direct\ run.&no<TAB>always\ use\ bash <Esc>:call <SID>SetDirectRun("no")<CR>' + + " deletes the dummy menu header and displays the current options + " in the menu header of the sub-menus + call s:SetOutputMethod ( s:BASH_OutputMethod ) + call s:SetDirectRun ( s:BASH_DirectRun ) + + "------------------------------------------------------------------------------- " comments {{{2 "------------------------------------------------------------------------------- - exe " noremenu ".s:BASH_RootMenu.'.&Comments.&echo\ "<line>"<Tab>'.esc_mapl.'ce :call <SID>EchoComment()<CR>j' - exe "inoremenu ".s:BASH_RootMenu.'.&Comments.&echo\ "<line>"<Tab>'.esc_mapl.'ce <C-C>:call <SID>EchoComment()<CR>j' - exe " noremenu ".s:BASH_RootMenu.'.&Comments.&remove\ echo<Tab>'.esc_mapl.'cr :call <SID>RemoveEcho()<CR>j' - exe "inoremenu ".s:BASH_RootMenu.'.&Comments.&remove\ echo<Tab>'.esc_mapl.'cr <C-C>:call <SID>RemoveEcho()<CR>j' - " + + let head = ' noremenu <silent> '.s:BASH_RootMenu.'.Comments.' + let ihead = 'inoremenu <silent> '.s:BASH_RootMenu.'.Comments.' + + exe head.'&echo\ "<line>"<Tab>'.esc_mapl.'ce :call <SID>EchoComment()<CR>j' + exe ihead.'&echo\ "<line>"<Tab>'.esc_mapl.'ce <C-C>:call <SID>EchoComment()<CR>j' + exe head.'&remove\ echo<Tab>'.esc_mapl.'cr :call <SID>RemoveEcho()<CR>j' + exe ihead.'&remove\ echo<Tab>'.esc_mapl.'cr <C-C>:call <SID>RemoveEcho()<CR>j' + + "------------------------------------------------------------------------------- + " tool box {{{2 + "------------------------------------------------------------------------------- + + if s:BASH_UseToolbox == 'yes' && mmtoolbox#tools#Property ( s:BASH_Toolbox, 'empty-menu' ) == 0 + call mmtoolbox#tools#AddMenus ( s:BASH_Toolbox, s:BASH_RootMenu.'.&Tool\ Box' ) + endif + "------------------------------------------------------------------------------- " help {{{2 "------------------------------------------------------------------------------- - " - exe " menu <silent> ".s:BASH_RootMenu.'.&Help.&Bash\ manual<Tab>'.esc_mapl.'hb :call BASH_help("bash")<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Help.&Bash\ manual<Tab>'.esc_mapl.'hb <C-C>:call BASH_help("bash")<CR>' - " - exe " menu <silent> ".s:BASH_RootMenu.'.&Help.&help\ (Bash\ builtins)<Tab>'.esc_mapl.'hh :call BASH_help("help")<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Help.&help\ (Bash\ builtins)<Tab>'.esc_mapl.'hh <C-C>:call BASH_help("help")<CR>' - " - exe " menu <silent> ".s:BASH_RootMenu.'.&Help.&manual\ (utilities)<Tab>'.esc_mapl.'hm :call BASH_help("man")<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Help.&manual\ (utilities)<Tab>'.esc_mapl.'hm <C-C>:call BASH_help("man")<CR>' - " - exe " menu <silent> ".s:BASH_RootMenu.'.&Help.-SEP1- :' - exe " menu <silent> ".s:BASH_RootMenu.'.&Help.help\ (Bash-&Support)<Tab>'.esc_mapl.'hbs :call <SID>HelpPlugin()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Help.help\ (Bash-&Support)<Tab>'.esc_mapl.'hbs <C-C>:call <SID>HelpPlugin()<CR>' + + let ahead = 'anoremenu <silent> '.s:BASH_RootMenu.'.Help.' + let ihead = 'inoremenu <silent> '.s:BASH_RootMenu.'.Help.' + + if s:NEOVIM + exe ahead.'&Bash\ manual<Tab>'.esc_mapl.'hb :Man bash(1)<CR>' + exe ihead.'&Bash\ manual<Tab>'.esc_mapl.'hb <C-C>:Man bash(1)<CR>' + exe ahead.'&help\ (Bash\ builtins)<Tab>'.esc_mapl.'hh :call <SID>HelpBuiltin()<CR>' + exe ihead.'&help\ (Bash\ builtins)<Tab>'.esc_mapl.'hh <C-C>:call <SID>HelpBuiltin()<CR>' + exe ahead.'&manual\ (utilities)<Tab>'.esc_mapl.'hm :Man<CR>' + exe ihead.'&manual\ (utilities)<Tab>'.esc_mapl.'hm <C-C>:Man<CR>' + else + exe ahead.'&Bash\ manual<Tab>'.esc_mapl.'hb :call <SID>HelpMan("bash")<CR>' + exe ihead.'&Bash\ manual<Tab>'.esc_mapl.'hb <C-C>:call <SID>HelpMan("bash")<CR>' + exe ahead.'&help\ (Bash\ builtins)<Tab>'.esc_mapl.'hh :call <SID>HelpBuiltin()<CR>' + exe ihead.'&help\ (Bash\ builtins)<Tab>'.esc_mapl.'hh <C-C>:call <SID>HelpBuiltin()<CR>' + exe ahead.'&manual\ (utilities)<Tab>'.esc_mapl.'hm :call <SID>HelpMan("man")<CR>' + exe ihead.'&manual\ (utilities)<Tab>'.esc_mapl.'hm <C-C>:call <SID>HelpMan("man")<CR>' + endif + + exe ahead.'-SEP1- :' + exe ahead.'help\ (Bash-&Support)<Tab>'.esc_mapl.'hp :call <SID>HelpPlugin()<CR>' + exe ihead.'help\ (Bash-&Support)<Tab>'.esc_mapl.'hp <C-C>:call <SID>HelpPlugin()<CR>' + " }}}2 "------------------------------------------------------------------------------- endfunction " ---------- end of function s:InitMenus ---------- -"=== FUNCTION ================================================================ -" NAME: CreateAdditionalMaps {{{1 -" DESCRIPTION: create additional maps -" PARAMETERS: - -" RETURNS: -"=============================================================================== +"------------------------------------------------------------------------------- +" s:CreateAdditionalMaps : Create additional maps. {{{1 +"------------------------------------------------------------------------------- function! s:CreateAdditionalMaps () + + "------------------------------------------------------------------------------- + " Bash dictionary " - " ---------- Bash dictionary ------------------------------------------------- " This will enable keyword completion for Bash " using Vim's dictionary feature |i_CTRL-X_CTRL-K|. - " + "------------------------------------------------------------------------------- if exists("g:BASH_Dictionary_File") silent! exe 'setlocal dictionary+='.g:BASH_Dictionary_File endif - " + "------------------------------------------------------------------------------- - " USER DEFINED COMMANDS + " user defined commands (only working in Bash buffers) "------------------------------------------------------------------------------- - command! -buffer -nargs=* -complete=file BashScriptArguments call BASH_ScriptCmdLineArguments(<q-args>) - command! -buffer -nargs=* -complete=file BashArguments call BASH_BashCmdLineArguments(<q-args>) - " + command! -nargs=* -buffer -complete=file -range=-1 Bash call <SID>Run(<q-args>,'c',<line1>,<line2>,<count>) + command! -nargs=0 -buffer BashCheck call <SID>SyntaxCheck() + + command! -buffer -nargs=* -complete=file BashScriptArguments call <SID>ScriptCmdLineArguments(<q-args>) + command! -buffer -nargs=* -complete=file BashInterpArguments call <SID>InterpCmdLineArguments(<q-args>) + command! -buffer -nargs=* -complete=file BashArguments call <SID>InterpCmdLineArguments(<q-args>) + + command! -buffer -nargs=* -complete=file BashSyntaxCheckOptions call <SID>ScriptSyntaxCheckOptions(<q-args>) + "------------------------------------------------------------------------------- " settings - local leader "------------------------------------------------------------------------------- @@ -1256,6 +2256,7 @@ function! s:CreateAdditionalMaps () inoremap <buffer> <silent> <LocalLeader>ce <C-C>:call <SID>EchoComment()<CR>j' noremap <buffer> <silent> <LocalLeader>cr :call <SID>RemoveEcho()<CR>j' inoremap <buffer> <silent> <LocalLeader>cr <C-C>:call <SID>RemoveEcho()<CR>j' + " EchoComment and RemoveEcho are run once per line, do not escape visual mode "------------------------------------------------------------------------------- " snippets @@ -1272,339 +2273,138 @@ function! s:CreateAdditionalMaps () inoremap <buffer> <silent> <LocalLeader>nv <Esc>:call <SID>CodeSnippet("view")<CR> "------------------------------------------------------------------------------- - " run + " run "------------------------------------------------------------------------------- - " - noremap <buffer> <silent> <LocalLeader>rr :call BASH_Run("n")<CR> - inoremap <buffer> <silent> <LocalLeader>rr <Esc>:call BASH_Run("n")<CR> - vnoremap <buffer> <silent> <LocalLeader>rr <Esc>:call BASH_Run("v")<CR> - noremap <buffer> <silent> <LocalLeader>rc :call BASH_SyntaxCheck()<CR> - inoremap <buffer> <silent> <LocalLeader>rc <C-C>:call BASH_SyntaxCheck()<CR> - noremap <buffer> <silent> <LocalLeader>rco :call BASH_SyntaxCheckOptionsLocal()<CR> - inoremap <buffer> <silent> <LocalLeader>rco <C-C>:call BASH_SyntaxCheckOptionsLocal()<CR> - noremap <buffer> <LocalLeader>ra :BashScriptArguments<Space> - inoremap <buffer> <LocalLeader>ra <Esc>:BashScriptArguments<Space> - noremap <buffer> <LocalLeader>rba :BashArguments<Space> - inoremap <buffer> <LocalLeader>rba <Esc>:BashArguments<Space> + nnoremap <buffer> <silent> <LocalLeader>rr :call <SID>Run("","n")<CR> + inoremap <buffer> <silent> <LocalLeader>rr <Esc>:call <SID>Run("","n")<CR> + vnoremap <buffer> <silent> <LocalLeader>rr :call <SID>Run("","v")<CR> + nnoremap <buffer> <silent> <LocalLeader>rk :call <SID>SyntaxCheck()<CR> + inoremap <buffer> <silent> <LocalLeader>rk <C-C>:call <SID>SyntaxCheck()<CR> + vnoremap <buffer> <silent> <LocalLeader>rk <C-C>:call <SID>SyntaxCheck()<CR> + + " :DEPRECATED:20.03.2018 17:30:WM: remove in next version + nnoremap <buffer> <silent> <LocalLeader>rc :call <SID>SyntaxCheck()<CR> + inoremap <buffer> <silent> <LocalLeader>rc <C-C>:call <SID>SyntaxCheck()<CR> + vnoremap <buffer> <silent> <LocalLeader>rc <C-C>:call <SID>SyntaxCheck()<CR> + + " these maps have to remap + map <buffer> <LocalLeader>rsa <Plug>BashSupportSetBashScriptArgs + imap <buffer> <LocalLeader>rsa <Esc><Plug>BashSupportSetBashScriptArgs + map <buffer> <LocalLeader>ria <Plug>BashSupportSetBashInterpArgs + imap <buffer> <LocalLeader>ria <Esc><Plug>BashSupportSetBashInterpArgs + + " :DEPRECATED:20.03.2018 17:30:WM: remove in next version + map <buffer> <LocalLeader>ra <Plug>BashSupportSetBashScriptArgs + imap <buffer> <LocalLeader>ra <Esc><Plug>BashSupportSetBashScriptArgs + map <buffer> <LocalLeader>rba <Plug>BashSupportSetBashInterpArgs + imap <buffer> <LocalLeader>rba <Esc><Plug>BashSupportSetBashInterpArgs + + nmap <buffer> <LocalLeader>rso <Plug>BashSupportSetBashSyntaxOpts + imap <buffer> <LocalLeader>rso <C-C><Plug>BashSupportSetBashSyntaxOpts + vmap <buffer> <LocalLeader>rso <C-C><Plug>BashSupportSetBashSyntaxOpts + + " :DEPRECATED:20.03.2018 17:30:WM: remove in next version + nmap <buffer> <LocalLeader>rco <Plug>BashSupportSetBashSyntaxOpts + imap <buffer> <LocalLeader>rco <C-C><Plug>BashSupportSetBashSyntaxOpts + vmap <buffer> <LocalLeader>rco <C-C><Plug>BashSupportSetBashSyntaxOpts if s:UNIX nnoremap <buffer> <silent> <LocalLeader>re :call <SID>MakeExecutable()<CR> inoremap <buffer> <silent> <LocalLeader>re <C-C>:call <SID>MakeExecutable()<CR> vnoremap <buffer> <silent> <LocalLeader>re <C-C>:call <SID>MakeExecutable()<CR> endif - nnoremap <buffer> <silent> <LocalLeader>rh :call <SID>Hardcopy("n")<CR> - vnoremap <buffer> <silent> <LocalLeader>rh <C-C>:call <SID>Hardcopy("v")<CR> - - noremap <buffer> <silent> <C-F9> :call BASH_Run("n")<CR> - inoremap <buffer> <silent> <C-F9> <C-C>:call BASH_Run("n")<CR> - vnoremap <buffer> <silent> <C-F9> <C-C>:call BASH_Run("v")<CR> - " - noremap <buffer> <silent> <A-F9> :call BASH_SyntaxCheck()<CR> - inoremap <buffer> <silent> <A-F9> <C-C>:call BASH_SyntaxCheck()<CR> - " - noremap <buffer> <S-F9> :BashScriptArguments<Space> - inoremap <buffer> <S-F9> <C-C>:BashScriptArguments<Space> - - if s:MSWIN - noremap <buffer> <silent> <LocalLeader>ro :call BASH_Toggle_Gvim_Xterm_MS()<CR> - inoremap <buffer> <silent> <LocalLeader>ro <Esc>:call BASH_Toggle_Gvim_Xterm_MS()<CR> - else - noremap <buffer> <silent> <LocalLeader>ro :call BASH_Toggle_Gvim_Xterm()<CR> - inoremap <buffer> <silent> <LocalLeader>ro <Esc>:call BASH_Toggle_Gvim_Xterm()<CR> - noremap <buffer> <silent> <LocalLeader>rd :call BASH_Debugger()<CR> - inoremap <buffer> <silent> <LocalLeader>rd <Esc>:call BASH_Debugger()<CR> - noremap <buffer> <silent> <F9> :call BASH_Debugger()<CR> - inoremap <buffer> <silent> <F9> <C-C>:call BASH_Debugger()<CR> - if has("gui_running") - noremap <buffer> <silent> <LocalLeader>rx :call BASH_XtermSize()<CR> - inoremap <buffer> <silent> <LocalLeader>rx <Esc>:call BASH_XtermSize()<CR> - endif - endif - " - "------------------------------------------------------------------------------- - " help - "------------------------------------------------------------------------------- - nnoremap <buffer> <silent> <LocalLeader>rs :call BASH_Settings(0)<CR> - " - noremap <buffer> <silent> <LocalLeader>hb :call BASH_help('bash')<CR> - inoremap <buffer> <silent> <LocalLeader>hb <Esc>:call BASH_help('bash')<CR> - noremap <buffer> <silent> <LocalLeader>hh :call BASH_help('help')<CR> - inoremap <buffer> <silent> <LocalLeader>hh <Esc>:call BASH_help('help')<CR> - noremap <buffer> <silent> <LocalLeader>hm :call BASH_help('man')<CR> - inoremap <buffer> <silent> <LocalLeader>hm <Esc>:call BASH_help('man')<CR> - noremap <buffer> <silent> <LocalLeader>hbs :call <SID>HelpPlugin()<CR> - inoremap <buffer> <silent> <LocalLeader>hbs <C-C>:call <SID>HelpPlugin()<CR> - - "------------------------------------------------------------------------------- - " settings - reset local leader - "------------------------------------------------------------------------------- - if ! empty ( g:BASH_MapLeader ) - if exists ( 'll_save' ) - let g:maplocalleader = ll_save - else - unlet g:maplocalleader - endif - endif - - "------------------------------------------------------------------------------- - " templates - "------------------------------------------------------------------------------- - if s:BASH_Ctrl_j == 'yes' - nnoremap <buffer> <silent> <C-j> i<C-R>=<SID>JumpForward()<CR> - inoremap <buffer> <silent> <C-j> <C-g>u<C-R>=<SID>JumpForward()<CR> - endif - - if s:BASH_Ctrl_d == 'yes' - call mmtemplates#core#CreateMaps ( 'g:BASH_Templates', g:BASH_MapLeader, 'do_special_maps', 'do_del_opt_map' ) - else - call mmtemplates#core#CreateMaps ( 'g:BASH_Templates', g:BASH_MapLeader, 'do_special_maps' ) - endif - -endfunction " ---------- end of function s:CreateAdditionalMaps ---------- - -"=== FUNCTION ================================================================ -" NAME: BASH_help {{{1 -" DESCRIPTION: lookup word under the cursor or ask -" PARAMETERS: - -" RETURNS: -"=============================================================================== -let s:BASH_DocBufferName = "BASH_HELP" -let s:BASH_DocHelpBufferNumber = -1 - -let s:BuiltinList = [] - -function! BASH_help( type ) - - let cuc = getline(".")[col(".") - 1] " character under the cursor - let item = expand("<cword>") " word under the cursor - if empty(item) || match( item, cuc ) == -1 - if a:type == 'man' - let item = s:UserInput('[tab compl. on] name of command line utility : ', '', 'shellcmd' ) - endif - if a:type == 'help' - let item = s:UserInput('[tab compl. on] name of bash builtin : ', '', 'customlist', s:BuiltinList ) - endif - endif - if empty(item) && a:type != 'bash' - return - endif - "------------------------------------------------------------------------------ - " replace buffer content with bash help text - "------------------------------------------------------------------------------ - " - " jump to an already open bash help window or create one - " - if bufloaded(s:BASH_DocBufferName) != 0 && bufwinnr(s:BASH_DocHelpBufferNumber) != -1 - exe bufwinnr(s:BASH_DocHelpBufferNumber) . "wincmd w" - " buffer number may have changed, e.g. after a 'save as' - if bufnr("%") != s:BASH_DocHelpBufferNumber - let s:BASH_DocHelpBufferNumber=bufnr(s:BASH_OutputBufferName) - exe ":bn ".s:BASH_DocHelpBufferNumber - endif - else - exe ":new ".s:BASH_DocBufferName - let s:BASH_DocHelpBufferNumber=bufnr("%") - setlocal buftype=nofile - setlocal noswapfile - setlocal bufhidden=delete - setlocal syntax=OFF + nnoremap <buffer> <LocalLeader>ro :BashOutputMethod<SPACE> + inoremap <buffer> <LocalLeader>ro <Esc>:BashOutputMethod<SPACE> + vnoremap <buffer> <LocalLeader>ro <Esc>:BashOutputMethod<SPACE> + nnoremap <buffer> <LocalLeader>rd :BashDirectRun<SPACE> + inoremap <buffer> <LocalLeader>rd <Esc>:BashDirectRun<SPACE> + vnoremap <buffer> <LocalLeader>rd <Esc>:BashDirectRun<SPACE> + nnoremap <buffer> <LocalLeader>rse :BashExecutable<SPACE> + inoremap <buffer> <LocalLeader>rse <Esc>:BashExecutable<SPACE> + vnoremap <buffer> <LocalLeader>rse <Esc>:BashExecutable<SPACE> + if index ( s:BASH_OutputMethodList, 'xterm' ) > -1 + nnoremap <buffer> <silent> <LocalLeader>rx :call <SID>XtermSize()<CR> + inoremap <buffer> <silent> <LocalLeader>rx <Esc>:call <SID>XtermSize()<CR> endif - setlocal modifiable - - " :WORKAROUND:05.04.2016 21:05:WM: setting the filetype changes the global tabstop, - " handle this manually - let ts_save = &g:tabstop - - setlocal filetype=man - let &g:tabstop = ts_save + nnoremap <buffer> <silent> <LocalLeader>rh :call <SID>Hardcopy("n")<CR> + inoremap <buffer> <silent> <LocalLeader>rh <C-C>:call <SID>Hardcopy("n")<CR> + vnoremap <buffer> <silent> <LocalLeader>rh <C-C>:call <SID>Hardcopy("v")<CR> "------------------------------------------------------------------------------- - " read Bash help + " help "------------------------------------------------------------------------------- - if a:type == 'help' - setlocal wrap - if s:UNIX - silent exe ":%!help -m ".item - else - silent exe ":%!".s:BASH_Executable." -c 'help -m ".item."'" - endif - setlocal nomodifiable - return + nnoremap <buffer> <silent> <LocalLeader>rs :call Bash_Settings(0)<CR> + + if s:NEOVIM + nnoremap <buffer> <silent> <LocalLeader>hb :Man bash(1)<CR> + inoremap <buffer> <silent> <LocalLeader>hb <Esc>:Man bash(1)<CR> + nnoremap <buffer> <silent> <LocalLeader>hm :Man<CR> + inoremap <buffer> <silent> <LocalLeader>hm <Esc>:Man<CR> + else + nnoremap <buffer> <silent> <LocalLeader>hb :call <SID>HelpMan('bash')<CR> + inoremap <buffer> <silent> <LocalLeader>hb <Esc>:call <SID>HelpMan('bash')<CR> + nnoremap <buffer> <silent> <LocalLeader>hm :call <SID>HelpMan('man')<CR> + inoremap <buffer> <silent> <LocalLeader>hm <Esc>:call <SID>HelpMan('man')<CR> endif - " + nnoremap <buffer> <silent> <LocalLeader>hh :call <SID>HelpBuiltin()<CR> + inoremap <buffer> <silent> <LocalLeader>hh <Esc>:call <SID>HelpBuiltin()<CR> + nnoremap <buffer> <silent> <LocalLeader>hp :call <SID>HelpPlugin()<CR> + inoremap <buffer> <silent> <LocalLeader>hp <C-C>:call <SID>HelpPlugin()<CR> + "------------------------------------------------------------------------------- - " open a manual (utilities) + " settings - reset local leader "------------------------------------------------------------------------------- - if a:type == 'man' - " - " Is there more than one manual ? - " - let manpages = system( s:BASH_ManualReader.' -k '.item ) - if v:shell_error - echomsg "shell command '".s:BASH_ManualReader." -k ".item."' failed" - :close - return - endif - let catalogs = split( manpages, '\n', ) - let manual = {} - " - " Select manuals where the name exactly matches - " - for line in catalogs - if line =~ '^'.item.'\s\+(' - let itempart = split( line, '\s\+' ) - let catalog = itempart[1][1:-2] - let manual[catalog] = catalog - endif - endfor - " - " Build a selection list if there are more than one manual - " - let catalog = "" - if len(keys(manual)) > 1 - for key in keys(manual) - echo ' '.item.' '.key - endfor - let defaultcatalog = '' - if has_key( manual, '1' ) - let defaultcatalog = '1' - else - if has_key( manual, '8' ) - let defaultcatalog = '8' - endif - endif - let catalog = input( 'select manual section (<Enter> cancels) : ', defaultcatalog ) - if ! has_key( manual, catalog ) - :close - :redraw - echomsg "no appropriate manual section '".catalog."'" - return - endif + if ! empty ( g:BASH_MapLeader ) + if exists ( 'll_save' ) + let g:maplocalleader = ll_save + else + unlet g:maplocalleader endif endif "------------------------------------------------------------------------------- - " open the bash manual + " toolbox "------------------------------------------------------------------------------- - if a:type == 'bash' - let catalog = 1 - let item = 'bash' - endif - - let win_w = winwidth( winnr() ) - if s:UNIX && win_w > 0 - silent exe ":%! MANWIDTH=".win_w." ".s:BASH_ManualReader." ".catalog." ".item - else - silent exe ":%!".s:BASH_ManualReader." ".catalog." ".item - endif - - if s:MSWIN - call s:bash_RemoveSpecialCharacters() + if s:BASH_UseToolbox == 'yes' + call mmtoolbox#tools#AddMaps ( s:BASH_Toolbox ) endif - setlocal nomodifiable -endfunction " ---------- end of function BASH_help ---------- -" -"=== FUNCTION ================================================================ -" NAME: Bash_RemoveSpecialCharacters {{{1 -" DESCRIPTION: remove <backspace><any character> in CYGWIN man(1) output -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! s:bash_RemoveSpecialCharacters ( ) - let patternunderline = '_\%x08' - let patternbold = '\%x08.' - setlocal modifiable - if search(patternunderline) != 0 - silent exe ':%s/'.patternunderline.'//g' - endif - if search(patternbold) != 0 - silent exe ':%s/'.patternbold.'//g' + "------------------------------------------------------------------------------- + " templates + "------------------------------------------------------------------------------- + if s:BASH_Ctrl_j == 'yes' + nnoremap <buffer> <silent> <C-j> i<C-R>=<SID>JumpForward()<CR> + inoremap <buffer> <silent> <C-j> <C-g>u<C-R>=<SID>JumpForward()<CR> endif - setlocal nomodifiable - silent normal! gg -endfunction " ---------- end of function s:bash_RemoveSpecialCharacters ---------- -" -"------------------------------------------------------------------------------ -" Bash shopt options -"------------------------------------------------------------------------------ -" -"=== FUNCTION ================================================================ -" NAME: Bash_find_option {{{1 -" DESCRIPTION: check if local options does exist -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! s:bash_find_option ( list, option ) - for item in a:list - if item == a:option - return 0 - endif - endfor - return -1 -endfunction " ---------- end of function s:bash_find_option ---------- -" -"=== FUNCTION ================================================================ -" NAME: BASH_SyntaxCheckOptions {{{1 -" DESCRIPTION: Syntax Check, options -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_SyntaxCheckOptions( options ) - let startpos=0 - while startpos < strlen( a:options ) - " match option switch ' -O ' or ' +O ' - let startpos = matchend ( a:options, '\s*[+-]O\s\+', startpos ) - " match option name - let optionname = matchstr ( a:options, '\h\w*\s*', startpos ) - " remove trailing whitespaces - let optionname = substitute ( optionname, '\s\+$', "", "" ) - " check name - " increment start position for next search - let startpos = matchend ( a:options, '\h\w*\s*', startpos ) - endwhile - return 0 -endfunction " ---------- end of function BASH_SyntaxCheckOptions---------- -" -"=== FUNCTION ================================================================ -" NAME: BASH_SyntaxCheckOptionsLocal {{{1 -" DESCRIPTION: Syntax Check, local options -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_SyntaxCheckOptionsLocal () - let filename = expand("%") - if empty(filename) - redraw - echohl WarningMsg | echo " no file name or not a shell file " | echohl None - return - endif - let prompt = 'syntax check options for "'.filename.'" : ' - if exists("b:BASH_SyntaxCheckOptionsLocal") - let b:BASH_SyntaxCheckOptionsLocal = s:UserInput( prompt, b:BASH_SyntaxCheckOptionsLocal, '' ) + if s:BASH_Ctrl_d == 'yes' + call mmtemplates#core#CreateMaps ( 'g:BASH_Templates', g:BASH_MapLeader, 'do_special_maps', 'do_del_opt_map' ) else - let b:BASH_SyntaxCheckOptionsLocal = s:UserInput( prompt , "", '' ) + call mmtemplates#core#CreateMaps ( 'g:BASH_Templates', g:BASH_MapLeader, 'do_special_maps' ) endif - if BASH_SyntaxCheckOptions( b:BASH_SyntaxCheckOptionsLocal ) != 0 - let b:BASH_SyntaxCheckOptionsLocal = "" - endif -endfunction " ---------- end of function BASH_SyntaxCheckOptionsLocal ---------- +endfunction " ---------- end of function s:CreateAdditionalMaps ---------- + +"------------------------------------------------------------------------------- +" Bash_Settings : Display plug-in settings. {{{1 " -"=== FUNCTION ================================================================ -" NAME: BASH_Settings {{{1 -" DESCRIPTION: Display plugin settings -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_Settings ( verbose ) +" verbosity: +" 0 - basic settings +" 1 - all setting +" 2 - print all settings into buffer +" +" Parameters: +" verbose - verbosity (integer) +"------------------------------------------------------------------------------- +function! Bash_Settings ( verbose ) if s:MSWIN | let sys_name = 'Windows' elseif s:UNIX | let sys_name = 'UN*X' else | let sys_name = 'unknown' | endif + if s:NEOVIM | let vim_name = 'nvim' + else | let vim_name = has('gui_running') ? 'gvim' : 'vim' | endif let txt = " Bash-Support settings\n\n" " template settings: macros, style, ... @@ -1621,7 +2421,18 @@ function! BASH_Settings ( verbose ) let txt .= " templates : -not loaded-\n\n" endif " plug-in installation - let txt .= ' plugin installation : '.s:installation.' on '.sys_name."\n" + let txt .= ' plugin installation : '.s:installation.' in '.vim_name.' on '.sys_name."\n" + " toolbox + if s:BASH_UseToolbox == 'yes' + let toollist = mmtoolbox#tools#GetList ( s:BASH_Toolbox ) + if empty ( toollist ) + let txt .= " using toolbox : -no tools-\n" + else + let sep = "\n"." " + let txt .= " using toolbox : " + \ .join ( toollist, sep )."\n" + endif + endif let txt .= "\n" " templates, snippets if exists ( 'g:BASH_Templates' ) @@ -1649,8 +2460,8 @@ function! BASH_Settings ( verbose ) endif let txt .= "\n" " ----- executables, cmd.-line args, ... ------- - if exists( "b:BASH_BashCmdLineArgs" ) - let cmd_line_args = b:BASH_BashCmdLineArgs + if exists( "b:BASH_InterpCmdLineArgs" ) + let cmd_line_args = b:BASH_InterpCmdLineArgs else let cmd_line_args = '' endif @@ -1665,9 +2476,10 @@ function! BASH_Settings ( verbose ) let txt .= 'buf. syntax check options : "'.syn_check_args."\"\n" let txt = txt."\n" " ----- output ------------------------------ - let txt = txt.' current output dest. : '.s:BASH_OutputGvim."\n" - if !s:MSWIN - let txt = txt.' xterm defaults : '.s:BASH_XtermDefaults."\n" + let txt = txt.' current output method : '.s:BASH_OutputMethod."\n" + if !s:MSWIN && a:verbose >= 1 + let txt = txt.' xterm executable : '.s:Xterm_Executable."\n" + let txt = txt.' xterm options : '.g:Xterm_Options."\n" endif let txt = txt."__________________________________________________________________________\n" let txt = txt." Bash-Support, Version ".g:BASH_Version." / Wolfgang Mehner / wolfgang-mehner@web.de\n\n" @@ -1678,380 +2490,7 @@ function! BASH_Settings ( verbose ) else echo txt endif -endfunction " ---------- end of function BASH_Settings ---------- - -"=== FUNCTION ================================================================ -" NAME: BASH_Toggle_Gvim_Xterm {{{1 -" DESCRIPTION: toggle output destination (Linux/Unix) -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_Toggle_Gvim_Xterm () - - if has("gui_running") - let [ esc_mapl, err ] = mmtemplates#core#Resource ( g:BASH_Templates, 'escaped_mapleader' ) - if s:BASH_OutputGvim == "vim" - exe "aunmenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ VIM->buffer->xterm' - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->xterm->vim<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->xterm->vim<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm()<CR>' - let s:BASH_OutputGvim = "buffer" - else - if s:BASH_OutputGvim == "buffer" - exe "aunmenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->xterm->vim' - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ XTERM->vim->buffer<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ XTERM->vim->buffer<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm()<CR>' - let s:BASH_OutputGvim = "xterm" - else - " ---------- output : xterm -> gvim - exe "aunmenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ XTERM->vim->buffer' - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ VIM->buffer->xterm<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ VIM->buffer->xterm<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm()<CR>' - let s:BASH_OutputGvim = "vim" - endif - endif - else - if s:BASH_OutputGvim == "vim" - let s:BASH_OutputGvim = "buffer" - else - let s:BASH_OutputGvim = "vim" - endif - endif - echomsg "output destination is '".s:BASH_OutputGvim."'" - -endfunction " ---------- end of function BASH_Toggle_Gvim_Xterm ---------- -" -"=== FUNCTION ================================================================ -" NAME: BASH_Toggle_Gvim_Xterm_MS {{{1 -" DESCRIPTION: toggle output destination (Windows) -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_Toggle_Gvim_Xterm_MS () - if has("gui_running") - let [ esc_mapl, err ] = mmtemplates#core#Resource ( g:BASH_Templates, 'escaped_mapleader' ) - if s:BASH_OutputGvim == "buffer" - exe "aunmenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->term' - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ TERM->buffer<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm_MS()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ TERM->buffer<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm_MS()<CR>' - let s:BASH_OutputGvim = "xterm" - else - exe "aunmenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ TERM->buffer' - exe " menu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->term<Tab>'.esc_mapl.'ro :call BASH_Toggle_Gvim_Xterm_MS()<CR>' - exe "imenu <silent> ".s:BASH_RootMenu.'.&Run.&output:\ BUFFER->term<Tab>'.esc_mapl.'ro <C-C>:call BASH_Toggle_Gvim_Xterm_MS()<CR>' - let s:BASH_OutputGvim = "buffer" - endif - endif -endfunction " ---------- end of function BASH_Toggle_Gvim_Xterm_MS ---------- -" -"=== FUNCTION ================================================================ -" NAME: BASH_XtermSize {{{1 -" DESCRIPTION: set xterm size -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_XtermSize () - let regex = '-geometry\s\+\d\+x\d\+' - let geom = matchstr( s:BASH_XtermDefaults, regex ) - let geom = matchstr( geom, '\d\+x\d\+' ) - let geom = substitute( geom, 'x', ' ', "" ) - let answer = s:UserInput(" xterm size (COLUMNS LINES) : ", geom, '' ) - while match(answer, '^\s*\d\+\s\+\d\+\s*$' ) < 0 - let answer = s:UserInput(" + xterm size (COLUMNS LINES) : ", geom, '' ) - endwhile - let answer = substitute( answer, '^\s\+', "", "" ) " remove leading whitespaces - let answer = substitute( answer, '\s\+$', "", "" ) " remove trailing whitespaces - let answer = substitute( answer, '\s\+', "x", "" ) " replace inner whitespaces - let s:BASH_XtermDefaults = substitute( s:BASH_XtermDefaults, regex, "-geometry ".answer , "" ) -endfunction " ---------- end of function BASH_XtermSize ---------- - -"=== FUNCTION ================================================================ -" NAME: BASH_ScriptCmdLineArguments {{{1 -" DESCRIPTION: stringify script command line arguments -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_ScriptCmdLineArguments ( ... ) - let b:BASH_ScriptCmdLineArgs = join( a:000 ) -endfunction " ---------- end of function BASH_ScriptCmdLineArguments ---------- -" -"=== FUNCTION ================================================================ -" NAME: BASH_BashCmdLineArguments {{{1 -" DESCRIPTION: stringify Bash command line arguments -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_BashCmdLineArguments ( ... ) - let b:BASH_BashCmdLineArgs = join( a:000 ) -endfunction " ---------- end of function BASH_BashCmdLineArguments ---------- -" -"=== FUNCTION ================================================================ -" NAME: BASH_Run {{{1 -" DESCRIPTION: -" PARAMETERS: - -" RETURNS: -"=============================================================================== -" -let s:BASH_OutputBufferName = "Bash-Output" -let s:BASH_OutputBufferNumber = -1 -" -function! BASH_Run ( mode ) range - - silent exe ':cclose' -" - let l:arguments = exists("b:BASH_ScriptCmdLineArgs") ? " ".b:BASH_ScriptCmdLineArgs : "" - let l:currentbuffer = bufname("%") - let l:fullname = expand("%:p") - let l:fullnameesc = fnameescape( l:fullname ) - " - silent exe ":update" - " - if a:firstline != a:lastline - let tmpfile = tempname() - silent exe ':'.a:firstline.','.a:lastline.'write '.tmpfile - endif - " - if a:mode=="v" - let tmpfile = tempname() - silent exe ":'<,'>write ".tmpfile - endif - - let l:bashCmdLineArgs = exists("b:BASH_BashCmdLineArgs") ? ' '.b:BASH_BashCmdLineArgs.' ' : '' - " - "------------------------------------------------------------------------------ - " Run : run from the vim command line (Linux only) {{{2 - "------------------------------------------------------------------------------ - " - if s:BASH_OutputGvim == 'vim' - " - " ----- visual mode ---------- - " - if ( a:mode=="v" ) || ( a:firstline != a:lastline ) - exe ":!".s:BASH_Executable.l:bashCmdLineArgs." < ".tmpfile." -s ".l:arguments - call delete(tmpfile) - return - endif - " - " ----- normal mode ---------- - " - " save current settings - let makeprg_saved = &l:makeprg - let errorf_saved = &l:errorformat - - let &l:makeprg = s:BASH_Executable - let &l:errorformat = s:BASH_Errorformat - - if a:mode=="n" - exe ":make ".l:bashCmdLineArgs.l:fullnameesc.l:arguments - endif - if &term == 'xterm' - redraw! - endif - - " restore current settings - let &l:makeprg = makeprg_saved - let &l:errorformat = errorf_saved - - botright cwindow - - if l:currentbuffer != bufname("%") && a:mode=="n" - let pattern = '^||.*\n\?' - setlocal modifiable - " remove the regular script output (appears as comment) - if search(pattern) != 0 - silent exe ':%s/'.pattern.'//' - endif - " read the buffer back to have it parsed and used as the new error list - silent exe ':cgetbuffer' - setlocal nomodifiable - setlocal nomodified - silent exe ':cc' - endif - endif - " - "------------------------------------------------------------------------------ - " Run : redirect output to an output buffer {{{2 - "------------------------------------------------------------------------------ - if s:BASH_OutputGvim == 'buffer' - - let l:currentbuffernr = bufnr("%") - - if l:currentbuffer == bufname("%") - " - if bufloaded(s:BASH_OutputBufferName) != 0 && bufwinnr(s:BASH_OutputBufferNumber)!=-1 - exe bufwinnr(s:BASH_OutputBufferNumber) . "wincmd w" - " buffer number may have changed, e.g. after a 'save as' - if bufnr("%") != s:BASH_OutputBufferNumber - let s:BASH_OutputBufferNumber = bufnr(s:BASH_OutputBufferName) - exe ":bn ".s:BASH_OutputBufferNumber - endif - else - silent exe ":new ".s:BASH_OutputBufferName - let s:BASH_OutputBufferNumber=bufnr("%") - setlocal noswapfile - setlocal buftype=nofile - setlocal syntax=none - setlocal bufhidden=delete - setlocal tabstop=8 - endif - " - " run script - " - setlocal modifiable - if a:mode=="n" - if s:MSWIN - silent exe ":%!".s:BASH_Executable.l:bashCmdLineArgs.' "'.l:fullname.'" '.l:arguments - else - silent exe ":%!".s:BASH_Executable.l:bashCmdLineArgs." ".l:fullnameesc.l:arguments - endif - endif - " - if ( a:mode=="v" ) || ( a:firstline != a:lastline ) - silent exe ":%!".s:BASH_Executable.l:bashCmdLineArgs." < ".tmpfile." -s ".l:arguments - endif - setlocal nomodifiable - " - " stdout is empty / not empty - " - if line("$")==1 && col("$")==1 - silent exe ":bdelete" - else - if winheight(winnr()) >= line("$") - exe bufwinnr(l:currentbuffernr) . "wincmd w" - endif - endif - " - endif - endif - " - "------------------------------------------------------------------------------ - " Run : run in a detached xterm {{{2 - "------------------------------------------------------------------------------ - if s:BASH_OutputGvim == 'xterm' - " - if s:MSWIN - exe ':!'.s:BASH_Executable.l:bashCmdLineArgs.' "'.l:fullname.'" '.l:arguments - else - if a:mode=='n' - if a:firstline != a:lastline - let titlestring = l:fullnameesc.'\ lines\ \ '.a:firstline.'\ -\ '.a:lastline - silent exe ':!xterm -title '.titlestring.' '.s:BASH_XtermDefaults - \ .' -e '.s:BASH_Wrapper.' '.l:bashCmdLineArgs.tmpfile.l:arguments.' &' - else - silent exe '!xterm -title '.l:fullnameesc.' '.s:BASH_XtermDefaults - \ .' -e '.s:BASH_Wrapper.' '.l:bashCmdLineArgs.l:fullnameesc.l:arguments.' &' - endif - elseif a:mode=="v" - let titlestring = l:fullnameesc.'\ lines\ \ '.line("'<").'\ -\ '.line("'>") - silent exe ':!xterm -title '.titlestring.' '.s:BASH_XtermDefaults - \ .' -e '.s:BASH_Wrapper.' '.l:bashCmdLineArgs.tmpfile.l:arguments.' &' - endif - endif - " - endif - " }}}2 - "------------------------------------------------------------------------------ - - if !has("gui_running") && v:progname != 'vim' - redraw! - endif -endfunction " ---------- end of function BASH_Run ---------- -" -"=== FUNCTION ================================================================ -" NAME: BASH_SyntaxCheck {{{1 -" DESCRIPTION: run syntax check -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_SyntaxCheck () - - silent exe 'update' | " write source file if necessary - cclose - - " save current settings - let makeprg_saved = &l:makeprg - let errorf_saved = &l:errorformat - - let l:currentbuffer=bufname("%") - let l:fullname = expand("%:p") - " - " check global syntax check options / reset in case of an error - if BASH_SyntaxCheckOptions( s:BASH_SyntaxCheckOptionsGlob ) != 0 - let s:BASH_SyntaxCheckOptionsGlob = "" - endif - " - let options=s:BASH_SyntaxCheckOptionsGlob - if exists("b:BASH_SyntaxCheckOptionsLocal") - let options=options." ".b:BASH_SyntaxCheckOptionsLocal - endif - " - " match the Bash error messages (quickfix commands) - " errorformat will be reset by function BASH_Handle() - " ignore any lines that didn't match one of the patterns - - let &l:makeprg = s:BASH_Executable - let &l:errorformat = s:BASH_Errorformat - - silent exe ":make! -n ".options.' -- "'.l:fullname.'"' - - " restore current settings - let &l:makeprg = makeprg_saved - let &l:errorformat = errorf_saved - - botright cwindow - - " message in case of success - redraw! - if l:currentbuffer == bufname("%") - echohl Search | echo l:currentbuffer." : Syntax is OK" | echohl None - nohlsearch " delete unwanted highlighting (Vim bug?) - endif -endfunction " ---------- end of function BASH_SyntaxCheck ---------- -" -"=== FUNCTION ================================================================ -" NAME: BASH_Debugger {{{1 -" DESCRIPTION: run debugger -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! BASH_Debugger () - if !executable(s:BASH_bashdb) - echohl Search - echo s:BASH_bashdb.' is not executable or not installed! ' - echohl None - return - endif - " - silent exe ":update" - let l:arguments = exists("b:BASH_ScriptCmdLineArgs") ? " ".b:BASH_ScriptCmdLineArgs : "" - let Sou = fnameescape( expand("%:p") ) - " - " - if has("gui_running") || &term == "xterm" - " - " debugger is ' bashdb' - " - if s:BASH_Debugger == "term" - let dbcommand = "!xterm ".s:BASH_XtermDefaults.' -e '.s:BASH_bashdb.' -- '.Sou.l:arguments.' &' - silent exe dbcommand - endif - " - " debugger is 'ddd' - " - if s:BASH_Debugger == "ddd" - if !executable("ddd") - echohl WarningMsg - echo "The debugger 'ddd' does not exist or is not executable!" - echohl None - return - else - silent exe '!ddd --debugger '.s:BASH_bashdb.' '.Sou.l:arguments.' &' - endif - endif - else - " no GUI : debugger is ' bashdb' - silent exe '!'.s:BASH_bashdb.' -- '.Sou.l:arguments - endif -endfunction " ---------- end of function BASH_Debugger ---------- +endfunction " ---------- end of function Bash_Settings ---------- "------------------------------------------------------------------------------- " s:ToolMenu : Add or remove tool menu entries. {{{1 @@ -2105,10 +2544,35 @@ function! s:RemoveMenus() endif endfunction " ---------- end of function s:RemoveMenus ---------- +"------------------------------------------------------------------------------- +" s:Initialize : Initialize templates, menus, and maps. {{{1 +"------------------------------------------------------------------------------- +function! s:Initialize ( ftype ) + if ! exists( 'g:BASH_Templates' ) + if s:BASH_LoadMenus == 'yes' | call s:AddMenus() + else | call s:RereadTemplates() + endif + endif + call s:CreateAdditionalMaps() + call s:CheckTemplatePersonalization() +endfunction " ---------- end of function s:Initialize ---------- + "---------------------------------------------------------------------- -" === Setup: Templates and menus === {{{1 +" === Setup: Templates, toolbox and menus === {{{1 "---------------------------------------------------------------------- +" setup the toolbox +if s:BASH_UseToolbox == 'yes' + + let s:BASH_Toolbox = mmtoolbox#tools#NewToolbox ( 'Bash' ) + call mmtoolbox#tools#Property ( s:BASH_Toolbox, 'mapleader', g:BASH_MapLeader ) + + call mmtoolbox#tools#Load ( s:BASH_Toolbox, s:BASH_ToolboxDir ) + + " debugging only: + "call mmtoolbox#tools#Info ( s:BASH_Toolbox ) +endif +" " tool menu entry call s:ToolMenu ( 'setup' ) @@ -2116,8 +2580,18 @@ if s:BASH_LoadMenus == 'yes' && s:BASH_CreateMenusDelayed == 'no' call s:AddMenus () endif +" user defined commands (working everywhere) +command! -nargs=? -complete=custom,<SID>GetOutputMethodList BashOutputMethod call <SID>SetOutputMethod(<q-args>) +command! -nargs=? -complete=custom,<SID>GetDirectRunList BashDirectRun call <SID>SetDirectRun(<q-args>) +command! -nargs=? -complete=shellcmd BashExecutable call <SID>SetExecutable(<q-args>) + +nnoremap <expr> <Plug>BashSupportSetBashScriptArgs ':BashScriptArguments '. ( exists( 'b:BASH_ScriptCmdLineArgs' ) ? b:BASH_ScriptCmdLineArgs : '' ) +nnoremap <expr> <Plug>BashSupportSetBashInterpArgs ':BashInterpArguments '. ( exists( 'b:BASH_InterpCmdLineArgs' ) ? b:BASH_InterpCmdLineArgs : '' ) +nnoremap <expr> <Plug>BashSupportSetBashSyntaxOpts ':BashSyntaxCheckOptions '.( exists( 'b:BASH_SyntaxCheckOptionsLocal' ) ? b:BASH_SyntaxCheckOptionsLocal : '' ) + if has( 'autocmd' ) - " + augroup BashSupport + "------------------------------------------------------------------------------- " shell files with extensions other than 'sh' "------------------------------------------------------------------------------- @@ -2126,33 +2600,23 @@ if has( 'autocmd' ) exe "autocmd BufNewFile,BufRead ".item." set filetype=sh" endfor endif - " + "------------------------------------------------------------------------------- - " create menues and maps + " create menus and maps "------------------------------------------------------------------------------- - autocmd FileType * - \ if &filetype == 'sh' | - \ if ! exists( 'g:BASH_Templates' ) | - \ if s:BASH_LoadMenus == 'yes' | call s:AddMenus () | - \ else | call s:RereadTemplates () | - \ endif | - \ endif | - \ call s:CreateAdditionalMaps () | - \ call s:CheckTemplatePersonalization() | - \ endif + autocmd FileType sh call s:Initialize('bash') "------------------------------------------------------------------------------- " insert file header "------------------------------------------------------------------------------- - if s:BASH_InsertFileHeader == 'yes' - autocmd BufNewFile *.sh call s:InsertFileHeader() - if exists( 'g:BASH_AlsoBash' ) - for item in g:BASH_AlsoBash - exe "autocmd BufNewFile ".item." call s:InsertFileHeader()" - endfor - endif + autocmd BufNewFile *.sh call s:InsertFileHeader() + if exists( 'g:BASH_AlsoBash' ) + for item in g:BASH_AlsoBash + exe "autocmd BufNewFile ".item." call s:InsertFileHeader()" + endfor endif + augroup END endif " }}}1 "------------------------------------------------------------------------------- diff --git a/plugin/c.vim b/plugin/c.vim index cba8e9f..00ff137 100644 --- a/plugin/c.vim +++ b/plugin/c.vim @@ -17,9 +17,9 @@ " " Version: see variable g:C_Version below " Created: 04.11.2000 -" Revision: 29.01.2017 +" Revision: 22.11.2020 " License: Copyright (c) 2000-2014, Fritz Mehner -" Copyright (c) 2015-2016, Wolfgang Mehner +" Copyright (c) 2015-2020, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the @@ -50,7 +50,7 @@ if exists("g:C_Version") || &cp finish endif -let g:C_Version= "6.2.1pre" " version number of this script; do not change +let g:C_Version= "6.2.1beta" " version number of this script; do not change "------------------------------------------------------------------------------- " === Auxiliary functions === {{{1 @@ -70,10 +70,10 @@ let g:C_Version= "6.2.1pre" " version number of this script; do "------------------------------------------------------------------------------- function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - let { 'g:'.a:varname } = a:value + if ! exists( 'g:'.a:varname ) + let {'g:'.a:varname} = a:value endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ErrorMsg : Print an error message. {{{2 @@ -92,7 +92,7 @@ function! s:ErrorMsg ( ... ) echomsg line endfor echohl None -endfunction " ---------- end of function s:ErrorMsg ---------- +endfunction "------------------------------------------------------------------------------- " s:GetGlobalSetting : Get a setting from a global variable. {{{2 @@ -113,10 +113,10 @@ endfunction " ---------- end of function s:ErrorMsg ---------- function! s:GetGlobalSetting ( varname, ... ) let lname = a:varname let gname = a:0 >= 1 ? a:1 : lname - if exists ( 'g:'.gname ) - let { 's:'.lname } = { 'g:'.gname } + if exists( 'g:'.gname ) + let {'s:'.lname} = {'g:'.gname} endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ImportantMsg : Print an important message. {{{2 @@ -2546,10 +2546,10 @@ function! s:RereadTemplates () call mmtemplates#core#ChangeSyntax ( g:C_Templates, 'comment', '§' ) " property: file skeletons - call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'C::FileSkeleton::Header', 'Comments.file description impl' ) - call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'C::FileSkeleton::Source', 'Comments.file description header' ) - call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'Cpp::FileSkeleton::Header', 'Comments.file description impl' ) - call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'Cpp::FileSkeleton::Source', 'Comments.file description header' ) + call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'C::FileSkeleton::Header', 'Comments.file description header' ) + call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'C::FileSkeleton::Source', 'Comments.file description impl' ) + call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'Cpp::FileSkeleton::Header', 'Comments.file description header' ) + call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'Cpp::FileSkeleton::Source', 'Comments.file description impl' ) " property: Doxygen menu call mmtemplates#core#Resource ( g:C_Templates, 'add', 'property', 'Doxygen::BriefAM::Menu', '' ) @@ -2950,11 +2950,26 @@ function! s:CreateAdditionalMaps () call mmtemplates#core#CreateMaps ( 'g:C_Templates', g:C_MapLeader, 'do_special_maps', 'do_del_opt_map' ) " endfunction " ---------- end of function s:CreateAdditionalMaps ---------- -" -" Plug-in setup: {{{1 -" + +"------------------------------------------------------------------------------- +" s:Initialize : Initialize templates, menus, and maps. {{{1 +"------------------------------------------------------------------------------- +function! s:Initialize ( ftype ) + if ! exists( 'g:C_Templates' ) | + if s:C_LoadMenus == 'yes' | call C_CreateGuiMenus() + else | call s:RereadTemplates() + endif | + endif | + call s:CreateAdditionalMaps() + call s:CheckTemplatePersonalization() +endfunction " ---------- end of function s:Initialize ---------- + +"------------------------------------------------------------------------------- +" === Setup: Templates, toolbox and menus === {{{1 +"------------------------------------------------------------------------------- + "------------------------------------------------------------------------------ -" setup the toolbox +" setup the toolbox {{{2 "------------------------------------------------------------------------------ " if s:C_UseToolbox == 'yes' @@ -2968,80 +2983,59 @@ if s:C_UseToolbox == 'yes' "call mmtoolbox#tools#Info ( s:C_Toolbox ) " endif -" + "------------------------------------------------------------------------------ -" show / hide the c-support menus -" define key mappings (gVim only) +" show / hide the C-Support menus {{{2 "------------------------------------------------------------------------------ -" + call C_ToolMenu() -" + if s:C_LoadMenus == 'yes' && s:C_CreateMenusDelayed == 'no' call C_CreateGuiMenus() endif -" + "------------------------------------------------------------------------------ -" Automated header insertion -" Local settings for the quickfix window +" lazy initialization / automated header insertion {{{2 " " Vim always adds the {cmd} after existing autocommands, " so that the autocommands execute in the order in which " they were given. The order matters! "------------------------------------------------------------------------------ if has("autocmd") - " - " *.h has filetype 'cpp' by default; this can be changed to 'c' : - " + augroup CSupport + + " adjust header filetype: + " *.h has filetype 'cpp' by default, this can be changed to 'c' if s:C_TypeOfH=='c' - autocmd BufNewFile,BufEnter *.h :set filetype=c - endif - " - " C/C++ source code files which should not be preprocessed. - " - autocmd BufNewFile,BufRead *.i :set filetype=c - autocmd BufNewFile,BufRead *.ii :set filetype=cpp - " - " DELAYED LOADING OF THE TEMPLATE DEFINITIONS - " - autocmd FileType * - \ if ( &filetype == 'cpp' || &filetype == 'c') | - \ if ! exists( 'g:C_Templates' ) | - \ if s:C_LoadMenus == 'yes' | call C_CreateGuiMenus () | - \ else | call s:RereadTemplates () | - \ endif | - \ endif | - \ call s:CreateAdditionalMaps() | - \ call s:CheckTemplatePersonalization() | - \ endif - - "------------------------------------------------------------------------------- - " style switching :Automated header insertion (suffixes from the gcc manual) - "------------------------------------------------------------------------------- - if !exists( 'g:C_Styles' ) - "------------------------------------------------------------------------------- - " template styles are the default settings - "------------------------------------------------------------------------------- - autocmd BufNewFile * if &filetype =~ '^\(c\|cpp\)$' && expand("%:e") !~ 'ii\?' | - \ call s:InsertFileHeader() | endif - " - else - "------------------------------------------------------------------------------- - " template styles are related to file extensions - "------------------------------------------------------------------------------- - for [ pattern, stl ] in items( g:C_Styles ) - exe "autocmd BufNewFile,BufRead,BufEnter ".pattern." call mmtemplates#core#ChooseStyle ( g:C_Templates, '".stl."')" - exe "autocmd BufNewFile ".pattern." call s:InsertFileHeader()" - endfor - " - endif - " - " Wrap error descriptions in the quickfix window. - " - autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak - " - exe 'autocmd BufRead *.'.join( s:C_SourceCodeExtensionsList, '\|*.' ) + autocmd BufNewFile,BufEnter *.h set filetype=c | " COMMENT: g:C_TypeOfH == 'c' + endif + + " create menus and maps + autocmd FileType c call s:Initialize('c') + autocmd FileType cpp call s:Initialize('cpp') + + " insert file header + if !exists( 'g:C_Styles' ) + " template styles are the default settings + autocmd BufNewFile * if &filetype == 'c' && expand("%:e") !~ 'ii\?' | call s:InsertFileHeader() | endif + autocmd BufNewFile * if &filetype == 'cpp' && expand("%:e") !~ 'ii\?' | call s:InsertFileHeader() | endif + else + " template styles are related to file extensions + for [ pattern, stl ] in items( g:C_Styles ) + exe "autocmd BufNewFile,BufReadPost ".pattern." call mmtemplates#core#ChooseStyle ( g:C_Templates, '".stl."')" + exe "autocmd BufNewFile ".pattern." call s:InsertFileHeader()" + endfor + endif + + " highlight jump targets after opening file + exe 'autocmd BufReadPost *.'.join( s:C_SourceCodeExtensionsList, '\|*.' ) \ .' call C_HighlightJumpTargets()' + + augroup END endif " has("autocmd") +" }}}2 +"------------------------------------------------------------------------------- + " }}}1 "------------------------------------------------------------------------------- diff --git a/plugin/git-support.vim b/plugin/git-support.vim deleted file mode 100644 index b92db3a..0000000 --- a/plugin/git-support.vim +++ /dev/null @@ -1,4584 +0,0 @@ -"=============================================================================== -" -" File: git-support.vim -" -" Description: Provides access to Git's functionality from inside Vim. -" -" See help file gitsupport.txt . -" -" VIM Version: 7.0+ -" Author: Wolfgang Mehner, wolfgang-mehner@web.de -" Organization: -" Version: see variable g:GitSupport_Version below -" Created: 06.10.2012 -" Revision: 18.07.2015 -" License: Copyright (c) 2012-2016, Wolfgang Mehner -" This program is free software; you can redistribute it and/or -" modify it under the terms of the GNU General Public License as -" published by the Free Software Foundation, version 2 of the -" License. -" This program is distributed in the hope that it will be -" useful, but WITHOUT ANY WARRANTY; without even the implied -" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -" PURPOSE. -" See the GNU General Public License version 2 for more details. -"=============================================================================== -" -"------------------------------------------------------------------------------- -" Basic checks. {{{1 -"------------------------------------------------------------------------------- -" -" need at least 7.0 -if v:version < 700 - echohl WarningMsg - echo 'The plugin git-support.vim needs Vim version >= 7.' - echohl None - finish -endif -" -" prevent duplicate loading -" need compatible -if &cp || ( exists('g:GitSupport_Version') && ! exists('g:GitSupport_DevelopmentOverwrite') ) - finish -endif -let g:GitSupport_Version= '0.9.3' " version number of this script; do not change -" -"------------------------------------------------------------------------------- -" Auxiliary functions. {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:ApplyDefaultSetting : Write default setting to a global variable. {{{2 -" -" Parameters: -" varname - name of the variable (string) -" value - default value (string) -" Returns: -" - -" -" If g:<varname> does not exists, assign: -" g:<varname> = value -"------------------------------------------------------------------------------- -" -function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - exe 'let g:'.a:varname.' = '.string( a:value ) - endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- -" -"------------------------------------------------------------------------------- -" s:AssembleCmdLine : Assembles a cmd-line with the cursor in the right place. {{{2 -" -" Parameters: -" part1 - part left of the cursor (string) -" part2 - part right of the cursor (string) -" left - used to move the cursor left (string, optional) -" Returns: -" cmd_line - the command line (string) -"------------------------------------------------------------------------------- -" -function! s:AssembleCmdLine ( part1, part2, ... ) - if a:0 == 0 || a:1 == '' - let left = "\<Left>" - else - let left = a:1 - endif - return a:part1.a:part2.repeat( left, s:UnicodeLen( a:part2 ) ) -endfunction " ---------- end of function s:AssembleCmdLine ---------- -" -"------------------------------------------------------------------------------- -" s:ChangeCWD : Check the buffer and the CWD. {{{2 -" -" Parameters: -" [ bufnr, dir ] - data (list: integer and string, optional) -" Returns: -" - -" -" Example: -" First check the current working directory: -" let data = s:CheckCWD () -" then jump to the Git buffer: -" call s:OpenGitBuffer ( 'Git - <name>' ) -" then call this function to correctly set the directory of the buffer: -" call s:ChangeCWD ( data ) -" -" Usage: -" The function s:CheckCWD queries the working directory of the buffer your -" starting out in, which is the buffer where you called the Git command. The -" call to s:OpenGitBuffer then opens the requested buffer or jumps to it if it -" already exists. Finally, s:ChangeCWD sets the working directory of the Git -" buffer. -" The buffer 'data' is a list, containing first the number of the current buffer -" at the time s:CheckCWD was called, and second the name of the directory. -" -" When called without parameters, changes to the directory stored in -" 'b:GitSupport_CWD'. -"------------------------------------------------------------------------------- -" -function! s:ChangeCWD ( ... ) - " - " call originated from outside the Git buffer? - " also the case for a new buffer - if a:0 == 0 - if ! exists ( 'b:GitSupport_CWD' ) - call s:ErrorMsg ( 'Not inside a Git buffer.' ) - return - endif - elseif bufnr('%') != a:1[0] - "echomsg '2 - call from outside: '.a:1[0] - let b:GitSupport_CWD = a:1[1] - else - "echomsg '2 - call from inside: '.bufnr('%') - " noop - endif - " - " change buffer - "echomsg '3 - changing to: '.b:GitSupport_CWD - exe 'lchdir '.fnameescape( b:GitSupport_CWD ) -endfunction " ---------- end of function s:ChangeCWD ---------- -" -"------------------------------------------------------------------------------- -" s:CheckCWD : Check the buffer and the CWD. {{{2 -" -" Parameters: -" - -" Returns: -" [ bufnr, dir ] - data (list: integer and string) -" -" Usage: see s:ChangeCWD -"------------------------------------------------------------------------------- -" -function! s:CheckCWD () - "echomsg '1 - calling from: '.getcwd() - return [ bufnr('%'), getcwd() ] -endfunction " ---------- end of function s:CheckCWD ---------- -" -"------------------------------------------------------------------------------- -" s:ErrorMsg : Print an error message. {{{2 -" -" Parameters: -" line1 - a line (string) -" line2 - a line (string) -" ... - ... -" Returns: -" - -"------------------------------------------------------------------------------- -" -function! s:ErrorMsg ( ... ) - echohl WarningMsg - for line in a:000 - echomsg line - endfor - echohl None -endfunction " ---------- end of function s:ErrorMsg ---------- -" -"------------------------------------------------------------------------------- -" s:EscapeCurrent : Escape the name of the current file for the shell, {{{2 -" and prefix it with "--". -" -" Parameters: -" - -" Returns: -" file_argument - the escaped filename (string) -"------------------------------------------------------------------------------- -" -function! s:EscapeCurrent () - return '-- '.shellescape ( expand ( '%' ) ) -endfunction " ---------- end of function s:EscapeCurrent ---------- -" -"------------------------------------------------------------------------------- -" s:GetGlobalSetting : Get a setting from a global variable. {{{2 -" -" Parameters: -" varname - name of the variable (string) -" Returns: -" - -" -" If g:<varname> exists, assign: -" s:<varname> = g:<varname> -"------------------------------------------------------------------------------- -" -function! s:GetGlobalSetting ( varname ) - if exists ( 'g:'.a:varname ) - exe 'let s:'.a:varname.' = g:'.a:varname - endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- -" -"------------------------------------------------------------------------------- -" s:GitCmdLineArgs : Split command-line parameters into a list. {{{2 -" -" Parameters: -" args - the arguments in one string (string) -" Returns: -" [ <arg1>, <arg2>, ... ] - the split arguments (list of strings) -" -" In case of an error, a list with one empty string is returned: -" [ '' ] -"------------------------------------------------------------------------------- -" -function! s:GitCmdLineArgs ( args ) - " - let [ sh_err, text ] = s:StandardRun ( 'rev-parse', '-- '.a:args, 't' ) - " - if sh_err == 0 - return split ( text, '\n' ) - else - call s:ErrorMsg ( "Can not parse the command line arguments:\n\n".text ) - return [ '' ] - endif - " -endfunction " ---------- end of function s:GitCmdLineArgs ---------- -" -"------------------------------------------------------------------------------- -" s:GitGetConfig : Get an option. {{{2 -" -" Parameters: -" option - name of the option (string) -" source - where to get the option from (string, optional) -" Returns: -" value - the value of the option (string) -" -" The possible sources are: -" 'local' - current repository -" 'global' - global settings -" 'system' - system settings -"------------------------------------------------------------------------------- -" -function! s:GitGetConfig ( option, ... ) - " - let args = '' - " - if a:0 > 0 - if a:1 == '' - " noop - elseif a:1 == 'local' - " noop - elseif a:1 == 'global' - let args = '--global ' - elseif a:1 == 'system' - let args = '--system ' - else - call s:ErrorMsg ( "Unknown option: ".a:1 ) - return '' - endif - endif - " - let args .= '--get '.a:option - " - let [ sh_err, text ] = s:StandardRun ( 'config', args, 't' ) - " - " from the help: - " the section or key is invalid (ret=1) - if sh_err == 1 || text == '' - if has_key ( s:Config_DefaultValues, a:option ) - return s:Config_DefaultValues[ a:option ] - else - return '' - endif - elseif sh_err == 0 - return text - else - call s:ErrorMsg ( "Can not query the option: ".text ) - return '' - endif - " -endfunction " ---------- end of function s:GitGetConfig ---------- -" -"------------------------------------------------------------------------------- -" s:GitRepoDir : Get the base directory of a repository. {{{2 -" -" Parameters: -" file - get another path than the top-level directory (string, optional) -" Returns: -" path - the name of the base directory (string) -" -" The possible options for 'file' are: -" 'top' - the top-level directory (default) -" 'top/<file> - a file in the top-level directory <top-level>/<file> -" 'git/<file>' - a file in the git directory <top-level>/.git/<file>, -" respects $GIT_DIR -"------------------------------------------------------------------------------- -" -function! s:GitRepoDir ( ... ) - " - let get_cmd = 'rev-parse' - let get_arg = '--show-toplevel' - let postfix = '' - " - let dir = 'top' - " - if a:0 == 0 || a:1 == '' || a:1 == 'top' - let [ sh_err, text ] = s:StandardRun ( 'rev-parse', '--show-toplevel', 't' ) - elseif a:1 =~ '^top/' - let dir = a:1 - let [ sh_err, text ] = s:StandardRun ( 'rev-parse', '--show-toplevel', 't' ) - " - if sh_err == 0 - let text = substitute ( a:1, 'top', escape( text, '\&' ), '' ) - endif - elseif a:1 =~ '^git/' - let dir = a:1 - let [ sh_err, text ] = s:StandardRun ( 'rev-parse', '--git-dir', 't' ) - " - if sh_err == 0 - let text = substitute ( a:1, 'git', escape( text, '\&' ), '' ) - endif - else - call s:ErrorMsg ( "Unknown option: ".a:1 ) - return '' - endif - " - if sh_err == 0 - return fnamemodify ( text, ':p' ) - else - call s:ErrorMsg ( "Can not query the directory \"".dir."\":","",text ) - return '' - endif - " -endfunction " ---------- end of function s:GitRepoDir ---------- -" -"------------------------------------------------------------------------------- -" s:ImportantMsg : Print an important message. {{{2 -" -" Parameters: -" line1 - a line (string) -" line2 - a line (string) -" ... - ... -" Returns: -" - -"------------------------------------------------------------------------------- -" -function! s:ImportantMsg ( ... ) - echohl Search - echo join ( a:000, "\n" ) - echohl None -endfunction " ---------- end of function s:ImportantMsg ---------- -" -"------------------------------------------------------------------------------- -" s:OpenFile : Open a file or jump to its window. {{{2 -" -" Parameters: -" filename - the name of the file (string) -" line - line number (integer, optional) -" column - column version number (integer, optional) -" Returns: -" - -" -" If the file is already open, jump to its window. Otherwise open a window -" showing the file. If the line number is given, jump to this line in the -" buffer. If the column number is given, jump to the column. -"------------------------------------------------------------------------------- -" -function! s:OpenFile ( filename, ... ) - " - let filename = resolve ( fnamemodify ( a:filename, ':p' ) ) - " - if bufwinnr ( '^'.filename.'$' ) == -1 - " open buffer - belowright new - exe "edit ".fnameescape( filename ) - else - " jump to window - exe bufwinnr( '^'.filename.'$' ).'wincmd w' - endif - " - if a:0 >= 1 - " jump to line - let pos = getpos( '.' ) - let pos[1] = a:1 " line - if a:0 >= 2 - let pos[2] = a:2 " col - endif - call setpos( '.', pos ) - endif - " - if foldlevel('.') && g:Git_OpenFoldAfterJump == 'yes' - normal! zv - endif -endfunction " ---------- end of function s:OpenFile ---------- -" -"------------------------------------------------------------------------------- -" s:Question : Ask the user a question. {{{2 -" -" Parameters: -" prompt - prompt, shown to the user (string) -" highlight - "normal" or "warning" (string, default "normal") -" Returns: -" retval - the user input (integer) -" -" The possible values of 'retval' are: -" 1 - answer was yes ("y") -" 0 - answer was no ("n") -" -1 - user aborted ("ESC" or "CTRL-C") -"------------------------------------------------------------------------------- -" -function! s:Question ( text, ... ) - " - let ret = -2 - " - " highlight prompt - if a:0 == 0 || a:1 == 'normal' - echohl Search - elseif a:1 == 'warning' - echohl Error - else - echoerr 'Unknown option : "'.a:1.'"' - return - endif - " - " question - echo a:text.' [y/n]: ' - " - " answer: "y", "n", "ESC" or "CTRL-C" - while ret == -2 - let c = nr2char( getchar() ) - " - if c == "y" - let ret = 1 - elseif c == "n" - let ret = 0 - elseif c == "\<ESC>" || c == "\<C-C>" - let ret = -1 - endif - endwhile - " - " reset highlighting - echohl None - " - return ret -endfunction " ---------- end of function s:Question ---------- -" -"------------------------------------------------------------------------------- -" s:StandardRun : execute 'git <cmd> ...' {{{2 -" -" Parameters: -" cmd - the Git command to run (string), this is not the Git executable! -" param - the parameters (string) -" flags - all set flags (string) -" allowed - all allowed flags (string, default: 'cet') -" Returns: -" [ ret, text ] - the status code and text produced by the command (string), -" only if the flag 't' is set -" -" Flags are characters. The parameter 'flags' is a concatenation of all set -" flags, the parameter 'allowed' is a concatenation of all allowed flags. -" -" Flags: -" c - ask for confirmation -" e - expand empty 'param' to current buffer -" t - return the text instead of echoing it -"------------------------------------------------------------------------------- -" -function! s:StandardRun( cmd, param, flags, ... ) - " - if a:0 == 0 - let flag_check = '[^cet]' - else - let flag_check = '[^'.a:1.']' - endif - " - if a:flags =~ flag_check - return s:ErrorMsg ( 'Unknown flag "'.matchstr( a:flags, flag_check ).'".' ) - endif - " - if a:flags =~ 'e' && empty( a:param ) | let param = s:EscapeCurrent() - else | let param = a:param - endif - " - let cmd = s:Git_Executable.' '.a:cmd.' '.param - " - if a:flags =~ 'c' && s:Question ( 'Execute "git '.a:cmd.' '.param.'"?' ) != 1 - echo "aborted" - return - endif - " - let text = system ( cmd ) - " - if a:flags =~ 't' - return [ v:shell_error, substitute ( text, '\_s*$', '', '' ) ] - elseif v:shell_error != 0 - echo "\"".cmd."\" failed:\n\n".text | " failure - elseif text =~ '^\_s*$' - echo "ran successfully" | " success - else - echo "ran successfully:\n".text | " success - endif - " -endfunction " ---------- end of function s:StandardRun ---------- -" -"------------------------------------------------------------------------------- -" s:UnicodeLen : Number of characters in a Unicode string. {{{2 -" -" Parameters: -" str - a string (string) -" Returns: -" len - the length (integer) -" -" Returns the correct length in the presence of Unicode characters which take -" up more than one byte. -"------------------------------------------------------------------------------- -" -function! s:UnicodeLen ( str ) - return len(split(a:str,'.\zs')) -endfunction " ---------- end of function s:UnicodeLen ---------- -" -"------------------------------------------------------------------------------- -" s:VersionLess : Compare two version numbers. {{{2 -" -" Parameters: -" v1 - 1st version number (string) -" v2 - 2nd version number (string) -" Returns: -" less - true, if v1 < v2 (string) -"------------------------------------------------------------------------------- -" -function! s:VersionLess ( v1, v2 ) - " - let l1 = matchlist( a:v1, '^\(\d\+\)\.\(\d\+\)\%(\.\(\d\+\)\)\?\%(\.\(\d\+\)\)\?' ) - let l2 = matchlist( a:v2, '^\(\d\+\)\.\(\d\+\)\%(\.\(\d\+\)\)\?\%(\.\(\d\+\)\)\?' ) - " - if empty( l1 ) || empty( l2 ) - echoerr 'Can not compare version numbers "'.a:v1.'" and "'.a:v2.'".' - return - endif - " - for i in range( 1, 4 ) - " all previous numbers have been identical! - if empty(l2[i]) - " l1[i] is empty as well or "0" -> versions are the same - " l1[i] is not empty -> v1 can not be less - return 0 - elseif empty(l1[i]) - " only l1[i] is empty -> v2 must be larger, unless l2[i] is "0" - return l2[i] != 0 - elseif str2nr(l1[i]) != str2nr( l2[i] ) - return str2nr(l1[i]) < str2nr( l2[i] ) - endif - endfor - " - echoerr 'Something went wrong while comparing "'.a:v1.'" and "'.a:v2.'".' - return -1 -endfunction " ---------- end of function s:VersionLess ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" Custom menus. {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:GenerateCustomMenu : Generate custom menu entries. {{{2 -" -" Parameters: -" prefix - defines the menu the entries will be placed in (string) -" data - custom menu entries (list of lists of strings) -" Returns: -" - -" -" See :help g:Git_CustomMenu for a description of the format 'data' uses. -"------------------------------------------------------------------------------- -" -function! s:GenerateCustomMenu ( prefix, data ) - " - for [ entry_l, entry_r, cmd ] in a:data - " escape special characters and assemble entry - let entry_l = escape ( entry_l, ' |\' ) - let entry_l = substitute ( entry_l, '\.\.', '\\.', 'g' ) - let entry_r = escape ( entry_r, ' .|\' ) - " - if entry_r == '' | let entry = a:prefix.'.'.entry_l - else | let entry = a:prefix.'.'.entry_l.'<TAB>'.entry_r - endif - " - if cmd == '' - let cmd = ':' - endif - " - let silent = '<silent> ' - " - " prepare command - if cmd =~ '<CURSOR>' - let mlist = matchlist ( cmd, '^\(.\+\)<CURSOR>\(.\{-}\)$' ) - let cmd = s:AssembleCmdLine ( mlist[1], mlist[2], '<Left>' ) - let silent = '' - elseif cmd =~ '<EXECUTE>$' - let cmd = substitute ( cmd, '<EXECUTE>$', '<CR>', '' ) - endif - " - let cmd = substitute ( cmd, '<WORD>', '<cword>', 'g' ) - let cmd = substitute ( cmd, '<FILE>', '<cfile>', 'g' ) - let cmd = substitute ( cmd, '<BUFFER>', '%', 'g' ) - " - exe 'anoremenu '.silent.entry.' '.cmd - exe 'vnoremenu '.silent.entry.' <C-C>'.cmd - endfor - " -endfunction " ---------- end of function s:GenerateCustomMenu ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" Modul setup. {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" command lists, help topics {{{2 -" -let s:GitCommands = [ - \ 'add', 'add--interactive', 'am', 'annotate', 'apply', - \ 'archive', 'bisect', 'bisect--helper', 'blame', 'branch', - \ 'bundle', 'cat-file', 'check-attr', 'checkout', 'checkout-index', - \ 'check-ref-format', 'cherry', 'cherry-pick', 'citool', 'clean', - \ 'clone', 'commit', 'commit-tree', 'config', 'count-objects', - \ 'credential-cache', 'credential-cache--daemon', 'credential-store', 'daemon', 'describe', - \ 'diff', 'diff-files', 'diff-index', 'difftool', 'difftool--helper', - \ 'diff-tree', 'fast-export', 'fast-import', 'fetch', 'fetch-pack', - \ 'filter-branch', 'fmt-merge-msg', 'for-each-ref', 'format-patch', 'fsck', - \ 'fsck-objects', 'gc', 'get-tar-commit-id', 'grep', 'gui', - \ 'gui--askpass', 'hash-object', 'help', 'http-backend', 'http-fetch', - \ 'http-push', 'imap-send', 'index-pack', 'init', 'init-db', - \ 'instaweb', 'log', 'lost-found', 'ls-files', 'ls-remote', - \ 'ls-tree', 'mailinfo', 'mailsplit', 'merge', 'merge-base', - \ 'merge-file', 'merge-index', 'merge-octopus', 'merge-one-file', 'merge-ours', - \ 'merge-recursive', 'merge-resolve', 'merge-subtree', 'mergetool', 'merge-tree', - \ 'mktag', 'mktree', 'mv', 'name-rev', 'notes', - \ 'pack-objects', 'pack-redundant', 'pack-refs', 'patch-id', 'peek-remote', - \ 'prune', 'prune-packed', 'pull', 'push', 'quiltimport', - \ 'read-tree', 'rebase', 'receive-pack', 'reflog', 'relink', - \ 'remote', 'remote-ext', 'remote-fd', 'remote-ftp', 'remote-ftps', - \ 'remote-http', 'remote-https', 'remote-testgit', 'repack', 'replace', - \ 'repo-config', 'request-pull', 'rerere', 'reset', 'revert', - \ 'rev-list', 'rev-parse', 'rm', 'send-pack', 'shell', - \ 'sh-i18n--envsubst', 'shortlog', 'show', 'show-branch', 'show-index', - \ 'show-ref', 'stage', 'stash', 'status', 'stripspace', - \ 'submodule', 'symbolic-ref', 'tag', 'tar-tree', 'unpack-file', - \ 'unpack-objects', 'update-index', 'update-ref', 'update-server-info', 'upload-archive', - \ 'upload-pack', 'var', 'verify-pack', 'verify-tag', 'web--browse', - \ 'whatchanged', 'write-tree', - \ ] -" -let s:HelpTopics = s:GitCommands + [ - \ 'attributes', 'cli', 'core-tutorial', 'cvs-migration', 'diffcore', - \ 'gitk', 'glossary', 'hooks', 'ignore', 'modules', - \ 'namespaces', 'repository-layout', 'tutorial', 'tutorial-2', 'workflows' - \ ] -" -function! GitS_HelpTopicsComplete ( ArgLead, CmdLine, CursorPos ) - return filter( copy( s:HelpTopics ), 'v:val =~ "\\V\\<'.escape(a:ArgLead,'\').'\\w\\*"' ) -endfunction " ---------- end of function GitS_HelpTopicsComplete ---------- -" -"---------------------------------------------------------------------- -" list of file IDs for :GitEdit {{{2 -" -let s:EditFileIDs = [ - \ 'config-global', 'config-local', - \ 'description', - \ 'hooks', - \ 'ignore-global', 'ignore-local', 'ignore-private', - \ 'modules', - \ ] -" -function! GitS_EditFilesComplete ( ArgLead, CmdLine, CursorPos ) - return filter( copy( s:EditFileIDs ), 'v:val =~ "\\V\\<'.escape(a:ArgLead,'\').'\\w\\*"' ) -endfunction " ---------- end of function GitS_EditFilesComplete ---------- -" -" configuration defaults {{{2 -" - only defaults which are relevant for Git-Support are listed here -" -let s:Config_DefaultValues = { - \ 'help.format' : 'man', - \ 'status.relativePaths' : 'true' - \ } -" -" platform specifics {{{2 -" -let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") -let s:UNIX = has("unix") || has("macunix") || has("win32unix") -" -if s:MSWIN - " - "------------------------------------------------------------------------------- - " MS Windows - "------------------------------------------------------------------------------- - " - if match( substitute( expand('<sfile>'), '\\', '/', 'g' ), - \ '\V'.substitute( expand('$HOME'), '\\', '/', 'g' ) ) == 0 - " user installation assumed - let s:installation = 'local' - else - " system wide installation - let s:installation = 'system' - endif - " - let s:plugin_dir = substitute( expand('<sfile>:p:h:h'), '\\', '/', 'g' ) - " -else - " - "------------------------------------------------------------------------------- - " Linux/Unix - "------------------------------------------------------------------------------- - " - if match( expand('<sfile>'), '\V'.resolve(expand('$HOME')) ) == 0 - " user installation assumed - let s:installation = 'local' - else - " system wide installation - let s:installation = 'system' - endif - " - let s:plugin_dir = expand('<sfile>:p:h:h') - " -endif -" -" settings {{{2 -" -let s:Git_LoadMenus = 'yes' " load the menus? -let s:Git_RootMenu = '&Git' " name of the root menu -" -let s:Git_CmdLineOptionsFile = s:plugin_dir.'/git-support/data/options.txt' -" -if ! exists ( 's:MenuVisible' ) - let s:MenuVisible = 0 " menus are not visible at the moment -endif -" -let s:Git_CustomMenu = [ - \ [ '&grep, word under cursor', ':GitGrepTop', ':GitGrepTop <WORD><EXECUTE>' ], - \ [ '&grep, version x..y', ':GitGrepTop', ':GitGrepTop -i "Version[^[:digit:]]\+<CURSOR>"' ], - \ [ '-SEP1-', '', '' ], - \ [ '&log, grep commit msg..', ':GitLog', ':GitLog -i --grep="<CURSOR>"' ], - \ [ '&log, grep diff word', ':GitLog', ':GitLog -p -S "<CURSOR>"' ], - \ [ '&log, grep diff line', ':GitLog', ':GitLog -p -G "<CURSOR>"' ], - \ [ '-SEP2-', '', '' ], - \ [ '&merge, fast-forward only', ':GitMerge', ':GitMerge --ff-only <CURSOR>' ], - \ [ '&merge, no commit', ':GitMerge', ':GitMerge --no-commit <CURSOR>' ], - \ [ '&merge, abort', ':GitMerge', ':GitMerge --abort<EXECUTE>' ], - \ ] -" -if s:MSWIN - let s:Git_BinPath = 'C:\Program Files\Git\bin\' -else - let s:Git_BinPath = '' -endif -" -call s:GetGlobalSetting ( 'Git_BinPath' ) -" -if s:MSWIN - let s:Git_BinPath = substitute ( s:Git_BinPath, '[^\\/]$', '&\\', '' ) - " - let s:Git_Executable = s:Git_BinPath.'git.exe' " Git executable - let s:Git_GitKExecutable = s:Git_BinPath.'tclsh.exe' " GitK executable - let s:Git_GitKScript = s:Git_BinPath.'gitk' " GitK script -else - let s:Git_BinPath = substitute ( s:Git_BinPath, '[^\\/]$', '&/', '' ) - " - let s:Git_Executable = s:Git_BinPath.'git' " Git executable - let s:Git_GitKExecutable = s:Git_BinPath.'gitk' " GitK executable - let s:Git_GitKScript = '' " GitK script (do not specify separate script by default) -endif -" -call s:GetGlobalSetting ( 'Git_Executable' ) -call s:GetGlobalSetting ( 'Git_GitKExecutable' ) -call s:GetGlobalSetting ( 'Git_GitKScript' ) -call s:GetGlobalSetting ( 'Git_LoadMenus' ) -call s:GetGlobalSetting ( 'Git_RootMenu' ) -call s:GetGlobalSetting ( 'Git_CustomMenu' ) -" -call s:ApplyDefaultSetting ( 'Git_CheckoutExpandEmpty', 'no' ) -call s:ApplyDefaultSetting ( 'Git_DiffExpandEmpty', 'no' ) -call s:ApplyDefaultSetting ( 'Git_ResetExpandEmpty', 'no' ) -call s:ApplyDefaultSetting ( 'Git_OpenFoldAfterJump', 'yes' ) -call s:ApplyDefaultSetting ( 'Git_StatusStagedOpenDiff', 'cached' ) -call s:ApplyDefaultSetting ( 'Git_Editor', '' ) - -let s:Enabled = 1 " Git enabled? -let s:DisabledMessage = "Git-Support not working:" -let s:DisabledReason = "" -" -let s:EnabledGitK = 1 " gitk enabled? -let s:DisableGitKMessage = "gitk not avaiable:" -let s:DisableGitKReason = "" -" -let s:EnabledGitBash = 1 " git bash enabled? -let s:DisableGitBashMessage = "git bash not avaiable:" -let s:DisableGitBashReason = "" -" -let s:FoundGitKScript = 1 -let s:GitKScriptReason = "" -" -let s:GitVersion = "" " Git Version -let s:GitHelpFormat = "" " 'man' or 'html' -" -" git bash -if s:MSWIN - let s:Git_GitBashExecutable = s:Git_BinPath.'sh.exe' - call s:GetGlobalSetting ( 'Git_GitBashExecutable' ) -else - if exists ( 'g:Xterm_Executable' ) - let s:Git_GitBashExecutable = g:Xterm_Executable - else - let s:Git_GitBashExecutable = 'xterm' - endif - call s:GetGlobalSetting ( 'Git_GitBashExecutable' ) - call s:ApplyDefaultSetting ( 'Xterm_Options', '-fa courier -fs 12 -geometry 80x24' ) -endif -" -" check git executable {{{2 -" -function! s:CheckExecutable ( name, exe ) - " - let executable = a:exe - let enabled = 1 - let reason = "" - " - if executable =~ '^LANG=\w\+\s.' - let [ lang, executable ] = matchlist ( executable, '^\(LANG=\w\+\)\s\+\(.\+\)$' )[1:2] - if ! executable ( executable ) - let enabled = 0 - let reason = a:name." not executable: ".executable - endif - let executable = lang.' '.shellescape( executable ) - elseif executable =~ '^\(["'']\)\zs.\+\ze\1' - if ! executable ( matchstr ( executable, '^\(["'']\)\zs.\+\ze\1' ) ) - let enabled = 0 - let reason = a:name." not executable: ".executable - endif - else - if ! executable ( executable ) - let enabled = 0 - let reason = a:name." not executable: ".executable - endif - let executable = shellescape( executable ) - endif - " - return [ executable, enabled, reason ] -endfunction " ---------- end of function s:CheckExecutable ---------- -" -function! s:CheckFile ( shortname, filename, esc ) - " - let filename = a:filename - let found = 1 - let message = "" - " - if ! filereadable ( filename ) - let found = 0 - let message = a:shortname." not found: ".filename - endif - let filename = shellescape( filename ) - " - return [ filename, found, message ] -endfunction " ---------- end of function s:CheckFile ---------- -" -let [ s:Git_Executable, s:Enabled, s:DisabledReason ] = s:CheckExecutable( 'git', s:Git_Executable ) -let [ s:Git_GitKExecutable, s:EnabledGitK, s:DisableGitKReason ] = s:CheckExecutable( 'gitk', s:Git_GitKExecutable ) -if ! empty ( s:Git_GitKScript ) - let [ s:Git_GitKScript, s:FoundGitKScript, s:GitKScriptReason ] = s:CheckFile( 'gitk script', s:Git_GitKScript, 1 ) -endif -let [ s:Git_GitBashExecutable, s:EnabledGitBash, s:DisableGitBashReason ] = s:CheckExecutable ( 'git bash', s:Git_GitBashExecutable ) -" -" check Git version {{{2 -" -" added in 1.7.2: -" - "git status --ignored" -" - "git status -s -b" -let s:HasStatusIgnore = 0 -let s:HasStatusBranch = 0 -" -" changed in 1.8.5: -" - output of "git status" without leading "#" char. -let s:HasStatus185Format = 0 -" -if s:Enabled - let s:GitVersion = s:StandardRun( '', ' --version', 't' )[1] - if s:GitVersion =~ 'git version [0-9.]\+' - let s:GitVersion = matchstr( s:GitVersion, 'git version \zs[0-9.]\+' ) - " - if ! s:VersionLess ( s:GitVersion, '1.7.2' ) - let s:HasStatusIgnore = 1 - let s:HasStatusBranch = 1 - endif - " - if ! s:VersionLess ( s:GitVersion, '1.8.5' ) - let s:HasStatus185Format = 1 - endif - " - else - call s:ErrorMsg ( 'Can not obtain the version number of Git.' ) - endif -endif -" -" check Git help.format {{{2 -" -if s:Enabled - let s:GitHelpFormat = s:GitGetConfig( 'help.format' ) - " - if s:GitHelpFormat == 'web' - let s:GitHelpFormat = 'html' - endif -endif -" -" standard help text {{{2 -" -let s:HelpTxtStd = "S-F1 : help\n" -let s:HelpTxtStd .= "q : close\n" -let s:HelpTxtStd .= "u : update" -" -let s:HelpTxtStdNoUpdate = "S-F1 : help\n" -let s:HelpTxtStdNoUpdate .= "q : close" -" -" custom commands {{{2 -" -if s:Enabled -" command! -nargs=* -complete=file GitAbove :call GitS_Split('above',<count>,<q-args>) -" command! -nargs=* -complete=file GitBelow :call GitS_Split('below',<count>,<q-args>) -" command! -nargs=* -complete=file -count=1000 GitTab :call GitS_Split('tab',<count>,<q-args>) - command! -nargs=* -complete=file -bang GitAdd :call GitS_Add(<q-args>,'<bang>'=='!'?'ef':'e') - command! -nargs=* -complete=file -range=0 GitBlame :call GitS_Blame('update',<q-args>,<line1>,<line2>) - command! -nargs=* -complete=file GitBranch :call GitS_Branch(<q-args>,'') - command! -nargs=* -complete=file GitCheckout :call GitS_Checkout(<q-args>,'c') - command! -nargs=* -complete=file GitCommit :call GitS_Commit('direct',<q-args>,'') - command! -nargs=? -complete=file GitCommitFile :call GitS_Commit('file',<q-args>,'') - command! -nargs=0 GitCommitMerge :call GitS_Commit('merge','','') - command! -nargs=+ GitCommitMsg :call GitS_Commit('msg',<q-args>,'') - command! -nargs=* -complete=file GitDiff :call GitS_Diff('update',<q-args>) - command! -nargs=* GitFetch :call GitS_Fetch(<q-args>,'') - command! -nargs=+ -complete=file GitGrep :call GitS_Grep('update',<q-args>) - command! -nargs=+ -complete=file GitGrepTop :call GitS_Grep('top',<q-args>) - command! -nargs=* -complete=customlist,GitS_HelpTopicsComplete GitHelp :call GitS_Help('update',<q-args>) - command! -nargs=* -complete=file GitLog :call GitS_Log('update',<q-args>) - command! -nargs=* GitMerge :call GitS_Merge('direct',<q-args>,'') - command! -nargs=* GitMergeUpstream :call GitS_Merge('upstream',<q-args>,'') - command! -nargs=* -complete=file GitMove :call GitS_Move(<q-args>,'') - command! -nargs=* -complete=file GitMv :call GitS_Move(<q-args>,'') - command! -nargs=* GitPull :call GitS_Pull(<q-args>,'') - command! -nargs=* GitPush :call GitS_Push(<q-args>,'') - command! -nargs=* -complete=file GitRemote :call GitS_Remote(<q-args>,'') - command! -nargs=* -complete=file GitRemove :call GitS_Remove(<q-args>,'e') - command! -nargs=* -complete=file GitRm :call GitS_Remove(<q-args>,'e') - command! -nargs=* -complete=file GitReset :call GitS_Reset(<q-args>,'') - command! -nargs=* -complete=file GitShow :call GitS_Show('update',<q-args>) - command! -nargs=* GitStash :call GitS_Stash(<q-args>,'') - command! -nargs=* GitSlist :call GitS_Stash('list '.<q-args>,'') - command! -nargs=? -complete=file GitStatus :call GitS_Status('update',<q-args>) - command! -nargs=* GitTag :call GitS_Tag(<q-args>,'') - command -nargs=* -complete=file -bang Git :call GitS_Run(<q-args>,'<bang>'=='!'?'b':'') - command! -nargs=* -complete=file GitRun :call GitS_Run(<q-args>,'') - command! -nargs=* -complete=file GitBuf :call GitS_Run(<q-args>,'b') - command! -nargs=* -complete=file GitK :call GitS_GitK(<q-args>) - command! -nargs=* -complete=file GitBash :call GitS_GitBash(<q-args>) - command! -nargs=1 -complete=customlist,GitS_EditFilesComplete GitEdit :call GitS_GitEdit(<q-args>) - command! -nargs=0 GitSupportHelp :call GitS_PluginHelp("gitsupport") - command! -nargs=? -bang GitSupportSettings :call GitS_PluginSettings(('<bang>'=='!')+str2nr(<q-args>)) - " -else - command -nargs=* -bang Git :call GitS_Help('disabled') - command! -nargs=* GitRun :call GitS_Help('disabled') - command! -nargs=* GitBuf :call GitS_Help('disabled') - command! -nargs=* GitHelp :call GitS_Help('disabled') - command! -nargs=0 GitSupportHelp :call GitS_PluginHelp("gitsupport") - command! -nargs=? -bang GitSupportSettings :call GitS_PluginSettings(('<bang>'=='!')+str2nr(<q-args>)) -endif -" -" syntax highlighting {{{2 -" -highlight default link GitComment Comment -highlight default GitHeading term=bold cterm=bold gui=bold -highlight default link GitHighlight1 Identifier -highlight default link GitHighlight2 PreProc -highlight default GitHighlight3 term=underline cterm=underline gui=underline -highlight default link GitWarning WarningMsg -highlight default link GitSevere ErrorMsg -" -highlight default link GitAdd DiffAdd -highlight default link GitRemove DiffDelete -highlight default link GitConflict DiffText -" -" }}}2 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:OpenGitBuffer : Put output in a read-only buffer. {{{1 -" -" Parameters: -" buf_name - name of the buffer (string) -" Returns: -" opened - true, if a new buffer was opened (integer) -" -" If a buffer called 'buf_name' already exists, jump to that buffer. Otherwise, -" open a buffer of the given name an set it up as a "temporary" buffer. It is -" deleted after the window is closed. -" -" Settings: -" - noswapfile -" - bufhidden=wipe -" - tabstop=8 -" - foldmethod=syntax -"------------------------------------------------------------------------------- -" -function! s:OpenGitBuffer ( buf_name ) - - " a buffer like this already opened on the current tab page? - if bufwinnr ( a:buf_name ) != -1 - " yes -> go to the window containing the buffer - exe bufwinnr( a:buf_name ).'wincmd w' - return 0 - endif - - " no -> open a new window - if s:SplitMode == '' || s:SplitMode == 'above' - aboveleft new - elseif s:SplitMode == 'below' - belowright new - elseif s:SplitMode == 'tab' - exe s:SplitAddArg.'tabnew' - endif - - " buffer exists elsewhere? - if bufnr ( a:buf_name ) != -1 - " yes -> settings of the new buffer - silent exe 'edit #'.bufnr( a:buf_name ) - return 0 - else - " no -> settings of the new buffer - silent exe 'file '.escape( a:buf_name, ' ' ) - setlocal noswapfile - setlocal bufhidden=wipe - setlocal tabstop=8 - setlocal foldmethod=syntax - endif - - return 1 -endfunction " ---------- end of function s:OpenGitBuffer ---------- -" -"------------------------------------------------------------------------------- -" s:UpdateGitBuffer : Put output in a read-only buffer. {{{1 -" -" Parameters: -" command - the command to run (string) -" stay - if true, return to the old position in the buffer -" (integer, default: 0) -" Returns: -" success - true, if the command was run successfully (integer) -" -" The output of the command is used to replace the text in the current buffer. -" If 'stay' is true, return to the same line the cursor was placed in before -" the update. After updating, 'modified' is cleared. -"------------------------------------------------------------------------------- -" -function! s:UpdateGitBuffer ( command, ... ) - " - if a:0 == 1 && a:1 - " return to old position - let pos_window = line('.') - winline() + 1 - let pos_cursor = line('.') - else - let pos_window = 1 - let pos_cursor = 1 - endif - " - " delete the previous contents - setlocal modifiable - setlocal noro - silent exe '1,$delete _' - " - " pause syntax highlighting (for speed) - if &syntax != '' - setlocal syntax=OFF - endif - " - " insert the output of the command - silent exe 'r! '.a:command - " - " delete the first line (empty) and go to position - normal! gg"_dd - silent exe 'normal! '.pos_window.'zt' - silent exe ':'.pos_cursor - " - " restart syntax highlighting - if &syntax != '' - setlocal syntax=ON - endif - " - " open all folds (closed by the syntax highlighting) - normal! zR - " - " read-only again - setlocal ro - setlocal nomodified - setlocal nomodifiable - " - return v:shell_error == 0 -endfunction " ---------- end of function s:UpdateGitBuffer ---------- -" -"------------------------------------------------------------------------------- -" GitS_FoldLog : fold text for 'git diff/log/show/status' {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_FoldLog () - let line = getline( v:foldstart ) - let head = '+-'.v:folddashes.' ' - let tail = ' ('.( v:foldend - v:foldstart + 1 ).' lines) ' - " - if line =~ '^tag' - " search for the first line which starts with a space, - " this is the first line of the commit message - return head.'tag - '.substitute( line, '^tag\s\+', '', '' ).tail - elseif line =~ '^commit' - " search for the first line which starts with a space, - " this is the first line of the commit message - let pos = v:foldstart - while pos <= v:foldend - if getline(pos) =~ '^\s\+\S' - break - endif - let pos += 1 - endwhile - if pos > v:foldend | let pos = v:foldstart | endif - return head.'commit - '.substitute( getline(pos), '^\s\+', '', '' ).tail - elseif line =~ '^diff' - " take the filename from (we also consider backslashes): - " diff --git a/<file> b/<file> - let file = matchstr ( line, 'a\([/\\]\)\zs\(.*\)\ze b\1\2\s*$' ) - if file != '' - return head.'diff - '.file.tail - else - return head.line.tail - endif - elseif ! s:HasStatus185Format && line =~ '^#\s\a.*:$' - \ || s:HasStatus185Format && line =~ '^\a.*:$' - " we assume a line in the status comment block and try to guess the number of lines (=files) - " :TODO:20.03.2013 19:30:WM: (might be something else) - " - let prefix = s:HasStatus185Format ? '' : '#' - " - let filesstart = v:foldstart+1 - let filesend = v:foldend - while filesstart < v:foldend && getline(filesstart) =~ '\_^'.prefix.'\s*\_$\|\_^'.prefix.'\s\+(' - let filesstart += 1 - endwhile - while filesend > v:foldstart && getline(filesend) =~ '^'.prefix.'\s*$' - let filesend -= 1 - endwhile - return line.' '.( filesend - filesstart + 1 ).' files ' - else - return head.line.tail - endif -endfunction " ---------- end of function GitS_FoldLog ---------- -" -"------------------------------------------------------------------------------- -" GitS_FoldGrep : fold text for 'git grep' {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_FoldGrep () - let line = getline( v:foldstart ) - let head = '+-'.v:folddashes.' ' - let tail = ' ('.( v:foldend - v:foldstart + 1 ).' lines) ' - " - " take the filename from the first line - let file = matchstr ( line, '^[^:]\+\ze:' ) - if file != '' - return file.tail - else - return head.line.tail - endif -endfunction " ---------- end of function GitS_FoldGrep ---------- - -"------------------------------------------------------------------------------- -" GitS_Split : Open a Git buffer differently. {{{1 -" -" Mode: -" above - split aboveleft -" below - split belowright -" tab - open in new tab -"------------------------------------------------------------------------------- - -let s:SplitMode = '' -let s:SplitAddArg = 0 - -function! GitS_Split ( mode, count, args ) - - if a:mode == 'above' - elseif a:mode == 'below' - elseif a:mode == 'tab' - let s:SplitAddArg = a:count == 1000 ? tabpagenr() : a:count - else - return s:ErrorMsg ( 'Unknown mode "'.a:mode.'".' ) - endif - - let s:SplitMode = a:mode - - try - exe a:args - catch /.*/ - call s:ErrorMsg ( substitute ( v:exception, '^Vim:', '', '' ) ) - finally - endtry - - let s:SplitMode = '' - let s:SplitAddArg = 0 - -endfunction " ---------- end of function GitS_Split ---------- - -"------------------------------------------------------------------------------- -" GitS_Run : execute 'git ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Run( param, flags ) - " - if a:flags =~ 'b' - call GitS_RunBuf ( 'update', a:param ) - else - return s:StandardRun ( '', a:param, a:flags, 'bc' ) - endif - " -endfunction " ---------- end of function GitS_Run ---------- -" -"------------------------------------------------------------------------------- -" GitS_RunBuf : execute 'git ...' {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_RunBuf( action, ... ) - " - if a:action == 'help' - echo s:HelpTxtStd - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " - if a:1 =~ '^!' - let subcmd = matchstr ( a:1, '[a-z][a-z\-]*' ) - else - let param = a:1 - let subcmd = matchstr ( a:1, '[a-z][a-z\-]*' ) - endif - " - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - git '.subcmd ) - " - let b:GitSupport_RunBufFlag = 1 - " - exe 'nnoremap <buffer> <S-F1> :call GitS_RunBuf("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_RunBuf("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_RunBuf("update","!'.subcmd.'")<CR>' - endif - " - call s:ChangeCWD ( buf ) - " - if ! exists ( 'param' ) - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' '.param - " - call s:UpdateGitBuffer ( cmd ) - " -endfunction " ---------- end of function GitS_RunBuf ---------- -" -"------------------------------------------------------------------------------- -" GitS_Add : execute 'git add ...' {{{1 -" -" Flags: -" c - Ask for confirmation. -" e - Expand empty 'param' to current buffer. -" f - Force add (cmdline param -f). -"------------------------------------------------------------------------------- -" -function! GitS_Add( param, flags ) - " - if a:flags =~ '[^cef]' - return s:ErrorMsg ( 'Unknown flag "'.matchstr( a:flags, '[^cef]' ).'".' ) - endif - " - if a:flags =~ 'e' && empty( a:param ) | let param = s:EscapeCurrent() - else | let param = a:param - endif - " - if a:flags =~ 'f' | let param = '-f '.param | endif - " - let cmd = s:Git_Executable.' add '.param - " - if a:flags =~ 'c' && s:Question ( 'Execute "git add '.param.'"?' ) != 1 - echo "aborted" - return - endif - " - let text = system ( cmd ) - " - if v:shell_error == 0 && text =~ '^\s*$' - echo "ran successfully" | " success - elseif v:shell_error == 0 - echo "ran successfully:\n".text | " success - else - echo "\"".cmd."\" failed:\n\n".text | " failure, may use the force instead - if ! a:flags =~ 'f' - echo "\nUse \":GitAdd! ...\" to force adding the files.\n" - endif - endif - " -endfunction " ---------- end of function GitS_Add ---------- -" -"------------------------------------------------------------------------------- -" GitS_Blame : execute 'git blame ...' {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:Blame_GetFile : Get the file, line and the commit under the cursor. {{{2 -" -" Parameters: -" - -" Returns: -" [ <file-name>, <line>, <commit> ] - data (list: string, integer, string) -" -" The entries are as follows: -" file name - name of the file under the cursor (string) -" line - the line in the original file (integer) -" commit - the commit (string) -" -" If only the name of the file could be obtained, returns: -" [ <file-name>, -1, ... ] -" If the name of the file could be found: -" [ '', -1, ... ] -" If the line is not committed yet: -" [ ..., ..., '-NEW-' ] -" If the commit could not be obtained: -" [ ..., ..., '' ] -"------------------------------------------------------------------------------- -" -function! s:Blame_GetFile() - " - let f_name = '' - let f_line = '-1' - let commit = '' - " - if exists ( 'b:GitSupport_BlameFile ' ) - let f_name = b:GitSupport_BlameFile - else - let args = s:GitCmdLineArgs( b:GitSupport_Param ) - " - if empty ( args ) - let f_name = '' - else - let f_name = args[-1] - endif - " - let b:GitSupport_BlameFile = f_name - endif - " - " LINE: - " [^] commit [ofile] (INFO line) - " The token 'ofile' appears if the file has been renamed in the meantime. - " INFO: (not used) - " author date time timezone - let line = getline('.') - let mlist = matchlist ( line, '^\^\?\(\x\+\)\s\+\%([^(]\{-}\s\+\)\?(\([^)]\+\)\s\(\d\+\))' ) - " - if empty ( mlist ) - return [ f_name, -1, '' ] - endif - " - let [ commit, info, f_line ] = mlist[1:3] - " - if info =~ '^Not Committed Yet ' - let commit = '-NEW-' - endif - " - return [ f_name, str2nr ( f_line ), commit ] - " -endfunction " ---------- end of function s:Blame_GetFile ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -function! GitS_Blame( action, ... ) - " - let update_only = 0 - let param = '' - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "of : file under cursor: open file (edit)\n" - let txt .= "oj : file under cursor: open and jump to the corresponding line\n" - let txt .= "\n" - let txt .= "cs : commit under cursor: show\n" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " - let update_only = a:0 == 0 - " - if update_only - " run again with old parameters - else - if empty( a:1 ) | let param = s:EscapeCurrent() - else | let param = a:1 - endif - " - if a:0 >= 3 && a:2 <= a:3 && ! ( a:2 == 1 && a:3 == 1 ) - let param = '-L '.a:2.','.a:3.' '.param - endif - " - endif - " - elseif a:action =~ '\<\%(\|edit\|jump\)\>' - " - call s:ChangeCWD () - " - let [ f_name, f_line, commit ] = s:Blame_GetFile () - " - if f_name == '' - return s:ErrorMsg ( 'No file under the cursor.' ) - endif - " - if a:action == 'edit' - \ || ( a:action == 'jump' && f_line == -1 ) - call s:OpenFile( f_name ) - elseif a:action == 'jump' - call s:OpenFile( f_name, f_line, 1 ) - endif - " - return - elseif a:action == 'show' - " - let [ f_name, f_line, commit ] = s:Blame_GetFile () - " - if commit == '-NEW-' - return s:ImportantMsg ( 'Line not committed yet.' ) - elseif commit == '' - return s:ErrorMsg ( 'Not commit under the cursor.' ) - endif - " - call GitS_Show( 'update', commit ) - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - blame' ) - " - let b:GitSupport_BlameFlag = 1 - " -" setlocal filetype=gitsdiff - " - exe 'nnoremap <buffer> <S-F1> :call GitS_Blame("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_Blame("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_Blame("update")<CR>' - " - exe 'nnoremap <silent> <buffer> of :call GitS_Blame("edit")<CR>' - exe 'nnoremap <silent> <buffer> oj :call GitS_Blame("jump")<CR>' - " - exe 'nnoremap <silent> <buffer> cs :call GitS_Blame("show")<CR>' - endif - " - call s:ChangeCWD ( buf ) - " - if update_only - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' blame '.param - " - call s:UpdateGitBuffer ( cmd, update_only ) - " -endfunction " ---------- end of function GitS_Blame ---------- -" -"------------------------------------------------------------------------------- -" GitS_Branch : execute 'git branch ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Branch( param, flags ) - " - if empty ( a:param ) - call GitS_BranchList ( 'update' ) - else - return s:StandardRun ( 'branch', a:param, a:flags, 'c' ) - endif - " -endfunction " ---------- end of function GitS_Branch ---------- -" -"------------------------------------------------------------------------------- -" GitS_BranchList : execute 'git branch' (list branches) {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:BranchList_GetBranch : Get the branch under the cursor. {{{2 -" -" Parameters: -" - -" Returns: -" [ <branch-name>, <flag> ] - data (list: string, string) -" -" The entries are as follows: -" branch name - name of the branch under the cursor (string) -" flag - contains: "r" if remote branch (string) -" -" If only the name of the branch could be obtained, returns: -" [ <branch-name>, '' ] -" If no branch could be found: -" [ '', '' ] -"------------------------------------------------------------------------------- -" -function! s:BranchList_GetBranch() - " - let line = getline('.') - let mlist = matchlist ( line, '^[[:space:]*]*\(remotes/\)\?\(\S\+\)' ) - " - if empty ( mlist ) - return [ '', '' ] - else - let branch = mlist[2] - let flag = empty( mlist[1] ) ? '' : 'r' - return [ branch, flag ] - endif - " -endfunction " ---------- end of function s:BranchList_GetBranch ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -function! GitS_BranchList( action ) - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "branch under cursor ...\n" - let txt .= "ch : checkout\n" - let txt .= "cr : use as starting point for creating a new branch\n" - let txt .= "de : delete\n" - let txt .= "De / DE : delete (via -D)\n" - let txt .= "me : merge with current branch\n" - let txt .= "re : rebase\n" - let txt .= "rn : rename\n" - let txt .= "su : set as upstream from current branch\n" - let txt .= "cs : show the commit\n" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " noop - elseif -1 != index ( [ 'checkout', 'create', 'delete', 'delete-force', 'merge', 'rebase', 'rename', 'set-upstream', 'show' ], a:action ) - " - let [ b_name, b_flag ] = s:BranchList_GetBranch () - " - if b_name == '' - return s:ErrorMsg ( 'No branch under the cursor.' ) - endif - " - if a:action == 'checkout' - call GitS_Checkout( shellescape(b_name), 'c' ) - elseif a:action == 'create' - " - let suggestion = '' - if b_flag =~ 'r' && b_name !~ '/HEAD$' - let suggestion = matchstr ( b_name, '[^/]\+$' ) - endif - " - return s:AssembleCmdLine ( ':GitBranch '.suggestion, ' '.b_name ) - elseif a:action == 'delete' - if b_flag =~ 'r' - call GitS_Branch( '-rd '.shellescape(b_name), 'c' ) - else - call GitS_Branch( '-d '.shellescape(b_name), 'c' ) - endif - elseif a:action == 'delete-force' - if b_flag =~ 'r' - call GitS_Branch( '-rD '.shellescape(b_name), 'c' ) - else - call GitS_Branch( '-D '.shellescape(b_name), 'c' ) - endif - elseif a:action == 'merge' - call GitS_Merge( 'direct', shellescape(b_name), 'c' ) - elseif a:action == 'rebase' - call GitS_Run( 'rebase '.shellescape(b_name), 'c') - elseif a:action == 'rename' - return ':GitBranch -m '.b_name.' ' - elseif a:action == 'set-upstream' - " get short name of current HEAD - let b_current = s:StandardRun ( 'symbolic-ref', '-q HEAD', 't' )[1] - let b_current = s:StandardRun ( 'for-each-ref', " --format='%(refname:short)' ".shellescape( b_current ), 't' )[1] - " - return s:AssembleCmdLine ( ':GitBranch --set-upstream '.b_current, ' '.b_name ) - elseif a:action == 'show' - call GitS_Show( 'update', shellescape(b_name), '' ) - endif - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - if s:OpenGitBuffer ( 'Git - branch' ) - " - let b:GitSupport_BranchFlag = 1 - " - setlocal filetype=gitsbranch - " - exe 'nnoremap <buffer> <S-F1> :call GitS_BranchList("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_BranchList("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_BranchList("update")<CR>' - " - exe 'nnoremap <silent> <buffer> ch :call GitS_BranchList("checkout")<CR>' - exe 'nnoremap <expr> <buffer> cr GitS_BranchList("create")' - exe 'nnoremap <silent> <buffer> de :call GitS_BranchList("delete")<CR>' - exe 'nnoremap <silent> <buffer> De :call GitS_BranchList("delete-force")<CR>' - exe 'nnoremap <silent> <buffer> DE :call GitS_BranchList("delete-force")<CR>' - exe 'nnoremap <silent> <buffer> me :call GitS_BranchList("merge")<CR>' - exe 'nnoremap <silent> <buffer> re :call GitS_BranchList("rebase")<CR>' - exe 'nnoremap <expr> <buffer> rn GitS_BranchList("rename")' - exe 'nnoremap <expr> <buffer> su GitS_BranchList("set-upstream")' - exe 'nnoremap <silent> <buffer> cs :call GitS_BranchList("show")<CR>' - endif - " - let cmd = s:Git_Executable.' branch -avv' - " - call s:UpdateGitBuffer ( cmd, 1 ) - " -endfunction " ---------- end of function GitS_BranchList ---------- -" -"------------------------------------------------------------------------------- -" GitS_Checkout : execute 'git checkout ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Checkout( param, flags ) - " - if a:flags =~ '[^ce]' - return s:ErrorMsg ( 'Unknown flag "'.matchstr( a:flags, '[^ce]' ).'".' ) - endif - " - if g:Git_CheckoutExpandEmpty == 'yes' && empty( a:param ) - " - " checkout on the current file potentially destroys unstaged changed, - " ask question with different highlighting - if a:flags =~ 'c' && s:Question ( 'Check out current file?', 'warning' ) != 1 - echo "aborted" - return - endif - " - " remove confirmation from flags and add expanding of the current file - let flags = substitute ( a:flags, 'c', '', 'g' ) - let flags .= 'e' - " - else - let flags = a:flags - endif - " - return s:StandardRun ( 'checkout', a:param, flags ) - " -endfunction " ---------- end of function GitS_Checkout ---------- -" -"------------------------------------------------------------------------------- -" GitS_Commit : execute 'git commit ...' {{{1 -" -" Flags: -" c - Ask for confirmation. -"------------------------------------------------------------------------------- -" -function! GitS_Commit( mode, param, flags ) - - if a:flags =~ '[^c]' - return s:ErrorMsg ( 'Unknown flag "'.matchstr( a:flags, '[^c]' ).'".' ) - endif - - if a:mode == 'direct' - - let args = s:GitCmdLineArgs ( a:param ) - - if index ( args, '--dry-run', 1 ) != -1 - " dry run in separate buffer - call GitS_CommitDryRun ( 'update', a:param ) - return - elseif ! empty ( a:param ) || exists ( '$GIT_EDITOR' ) || g:Git_Editor != '' - " run assuming sensible parameters ... - " or assuming a correctly set "$GIT_EDITOR", e.g. - " - xterm -e vim - " - gvim -f - let param = a:param - elseif empty ( a:param ) - " empty parameter list - - return s:ErrorMsg ( 'The command :GitCommit currently can not be used this way.', - \ 'Set $GIT_EDITOR properly, or use the confirmation variable "g:Git_Editor".', - \ 'Alternatively, supply the message using either the -m or -F options, or by', - \ 'using the special commands :GitCommitFile, :GitCommitMerge, or :GitCommitMsg.' ) - -" " get ./.git/COMMIT_EDITMSG file -" let file = s:GitRepoDir () -" " -" " could not get base? -" if file == '' | return | endif -" " -" let file .= '/.git/COMMIT_EDITMSG' -" " -" " not readable? -" if ! filereadable ( file ) -" echo 'could not read the file ".git/COMMIT_EDITMSG"' -" return -" endif -" " -" " open new buffer -" belowright new -" exe "edit ".fnameescape( file ) -" " -" return -" " - endif - - elseif a:mode == 'file' - " message from file - - " update the file - try - update - catch /E45.*/ - call s:ErrorMsg ( 'Could not write the file: '.buffer_name( '%' ) ) - catch /.*/ - call s:ErrorMsg ( 'Unknown error while writing the file: '.buffer_name( '%' ) ) - endtry - - " write the given file or the current one - if empty( a:param ) | let param = '-F '.shellescape( expand('%') ) - else | let param = '-F '.a:param - endif - - elseif a:mode == 'merge' - " merge conflict - - " find the file "MERGE_HEAD" - if ! filereadable ( s:GitRepoDir ( 'git/MERGE_HEAD' ) ) - return s:ErrorMsg ( - \ 'could not read the file ".git/MERGE_HEAD" /', - \ 'there does not seem to be a merge conflict' ) - endif - - " message from ./.git/MERGE_MSG file - let file = s:GitRepoDir ( 'git/MERGE_MSG' ) - - " not readable? - if ! filereadable ( file ) - return s:ErrorMsg ( - \ 'could not read the file ".git/MERGE_MSG" /', - \ 'but found ./git/MERGE_HEAD (see :help GitCommitMerge)' ) - endif - - " commit - let param = '-F '.shellescape( file ) - - elseif a:mode == 'msg' - " message from command line - let param = '-m "'.a:param.'"' - else - echoerr 'Unknown mode "'.a:mode.'".' - return - endif - - if a:flags =~ 'c' && s:Question ( 'Execute "git commit '.param.'"?' ) != 1 - echo "aborted" - return - endif - - " set '$GIT_EDITOR' according to 's:Git_Editor' - if g:Git_Editor != '' - if exists ( '$GIT_EDITOR' ) - let git_edit_save = $GIT_EDITOR - endif - if g:Git_Editor == 'vim' - let $GIT_EDITOR = s:Git_GitBashExecutable.' '.g:Xterm_Options.' -title "git commit" -e vim ' - elseif g:Git_Editor == 'gvim' - let $GIT_EDITOR = 'gvim -f' - else - return s:ErrorMsg ( 'Invalid setting for "g:Git_Editor".' ) - endif - endif - - call s:StandardRun ( 'commit', param, '' ) - - " reset '$GIT_EDITOR' if necessary - if exists ( 'git_edit_save' ) - let $GIT_EDITOR = git_edit_save - endif - -endfunction " ---------- end of function GitS_Commit ---------- -" -"------------------------------------------------------------------------------- -" GitS_CommitDryRun : execute 'git commit --dry-run ...' {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_CommitDryRun( action, ... ) - " - let update_only = 0 - let param = '' - " - if a:action == 'help' - echo s:HelpTxtStd - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " - let update_only = a:0 == 0 - " - if update_only | " run again with old parameters - elseif empty( a:1 ) | let param = '' - else | let param = a:1 - endif - " - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - commit --dry-run' ) - " - let b:GitSupport_CommitDryRunFlag = 1 - " - setlocal filetype=gitsstatus - setlocal foldtext=GitS_FoldLog() - " - exe 'nnoremap <buffer> <S-F1> :call GitS_CommitDryRun("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_CommitDryRun("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_CommitDryRun("update")<CR>' - endif - " - call s:ChangeCWD ( buf ) - " - if update_only - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' commit --dry-run '.param - - let success = s:UpdateGitBuffer ( cmd, update_only ) - - if ! success - redraw " redraw after opening the buffer, before echoing - call s:ImportantMsg ( '"git commit --dry-run" reports an error' ) - endif -endfunction " ---------- end of function GitS_CommitDryRun ---------- -" -"------------------------------------------------------------------------------- -" GitS_Diff : execute 'git diff ...' {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:Diff_GetFile : Get the file (and line/col) under the cursor. {{{2 -" -" Parameters: -" line - if the argument equals 'line', return line number (string, optional) -" Returns: -" [ <file-name>, <line>, <column> ] - data (list: string, integer, integer) -" -" The entries are as follows: -" file name - name of the file under the cursor (string) -" line - the line in the original file (integer) -" column - the column in the original file (integer) -" -" Only obtains the line if the optional parameter 'line' is given: -" let [ ... ] = s:Diff_GetFile ( 'line' ) -" -" If only the name of the file could be obtained, returns: -" [ <file-name>, -1, -1 ] -" If no file could be found: -" [ '', -1, -1 ] -"------------------------------------------------------------------------------- -" -function! s:Diff_GetFile( ... ) - " - " :TODO:17.08.2014 15:01:WM: recognized renamed files - " - let f_name = '' - let f_line = -1 - let f_col = -1 - " - let f_pos = line('.') - " - " get line and col - if a:0 > 0 && a:1 == 'line' - " - let r_pos = f_pos - let f_col = getpos( '.' )[2] - let f_off1 = 0 - let f_off2 = 0 - " - while r_pos > 0 - " - if getline(r_pos) =~ '^[+ ]' - let f_off1 += 1 - if getline(r_pos) =~ '^[+ ][+ ]' - let f_off2 += 1 - endif - elseif getline(r_pos) =~ '^@@ ' - let s_range = matchstr( getline(r_pos), '^@@ -\d\+,\d\+ +\zs\d\+\ze,\d\+ @@' ) - let f_line = s_range - 1 + f_off1 - let f_col = max ( [ f_col-1, 1 ] ) - break - elseif getline(r_pos) =~ '^@@@ ' - let s_range = matchstr( getline(r_pos), '^@@@ -\d\+,\d\+ -\d\+,\d\+ +\zs\d\+\ze,\d\+ @@@' ) - let f_line = s_range - 1 + f_off2 - let f_col = max ( [ f_col-2, 1 ] ) - break - elseif getline(r_pos) =~ '^diff ' - break - endif - " - let r_pos -= 1 - endwhile - " - let f_pos = r_pos - " - endif - " - " get file - while f_pos > 0 - " - if getline(f_pos) =~ '^diff --git' - let f_name = matchstr ( getline(f_pos), 'a\([/\\]\)\zs\(.*\)\ze b\1\2\s*$' ) - break - elseif getline(f_pos) =~ '^diff --cc' - let f_name = matchstr ( getline(f_pos), '^diff --cc \zs.*$' ) - break - endif - " - let f_pos -= 1 - endwhile - " - return [ f_name, f_line, f_col ] - " -endfunction " ---------- end of function s:Diff_GetFile ---------- -" -"------------------------------------------------------------------------------- -" s:Diff_GetChunk : Get a diff header and chunk. {{{2 -" -" Parameters: -" line - the chunk containing this line will be extracted (integer) -" Returns: -" [ <diff-head>, <chunk-head>, <chunk-text> ] - extract texts (list of strings) -" -" The entries are as follows: -" diff_head - diff header "diff --git a/..." (string) -" chunk_head - chunk header "@@ -45,6 ..." (string) -" chunk_text - chunk text (string) -" c_pos - position of the chunk header in the buffer (integer) -"------------------------------------------------------------------------------- -" -function! s:Diff_GetChunk ( line ) - " - let pos_save = getpos ( '.' ) - call cursor ( a:line, 1 ) - " - " the positions in the buffer - let d_pos = search ( '\m\_^diff ', 'bcnW' ) " the position of the diff header - let c_pos = search ( '\m\_^@@ ', 'bcnW' ) " the start of the chunk - let c_end = search ( '\m\_^@@ \|\_^diff ', 'nW' ) " ... the end - " - call setpos ( '.', pos_save ) - " - if d_pos == 0 || c_pos == 0 - return [ '', '', 'no valid chunk selected', 0 ] - elseif c_end == 0 - " found the other two positions - " -> the end of the chunk must be the end of the file - let c_end = line('$')+1 - endif - " - " get the diff header - let diff_head = getline(d_pos) - " - while 1 - let d_pos += 1 - let line = getline ( d_pos ) - " - if line =~ '\m\_^\%(diff\|@@\) ' - break - endif - " - let diff_head .= "\n".line - endwhile - " - " get the chunk - let chunk_head = getline ( c_pos ) - let chunk_text = join ( getline ( c_pos+1, c_end-1 ), "\n" ) - " - return [ diff_head, chunk_head, chunk_text, c_pos ] -endfunction " ---------- end of function s:Diff_GetChunk ---------- -" -"------------------------------------------------------------------------------- -" s:Diff_VisualChunk : Rewrite a chunk to only change the visual selection. {{{2 -" -" In case of an error, a list with two empty string and the error message is -" returned: -" [ '', '', <error-msg> ] -" -" Parameters: -" diff_head - diff header "diff --git a/..." (string) -" chunk_head - chunk header "@@ -45,6 ..." (string) -" chunk_text - chunk text (string) -" reverse - will be committed with the "--reverse" flag (integer) -" v_start - start of the visual selection (integer) -" v_end - end of the visual selection (integer) -" Returns: -" diff_head - diff header "diff --git a/..." (string) -" chunk_head - rewritten chunk header "@@ -45,6 ..." (string) -" chunk_text - rewritten chunk text (string) -"------------------------------------------------------------------------------- -" -function! s:Diff_VisualChunk ( diff_head, chunk_head, chunk_text, reverse, v_start, v_end ) - " - " error message from 's:Diff_GetChunk'? - if a:diff_head == '' - return [ a:diff_head, a:chunk_head, a:chunk_text ] - endif - " - let v_start = a:v_start - 1 " convert to indices - let v_end = a:v_end - 1 " ... - let lines = split ( a:chunk_text, '\n' ) - " - if v_start < 0 || v_end >= len ( lines ) - return [ '', '', 'visual selection crosses chunk boundary' ] - elseif a:chunk_head =~ '^@@@' - return [ '', '', 'can not handle this type of chunk' ] - endif - " - let n_add_off = 0 - let n_rm_off = 0 - " - let r = range ( len(lines)-1, v_end+1, -1 ) + range ( v_start-1, 0, -1 ) - " - for i in r - let line = lines[i] - " - if line =~ '^-' && ! a:reverse - let lines[i] = substitute ( line, '^-', ' ', '' ) - let n_add_off += 1 " we add one more line - elseif line =~ '^+' && ! a:reverse - call remove ( lines, i ) - let n_add_off -= 1 " we add one less line - elseif line =~ '^-' && a:reverse - call remove ( lines, i ) - let n_rm_off -= 1 " we remove one less line - elseif line =~ '^+' && a:reverse - let lines[i] = substitute ( line, '^+', ' ', '' ) - let n_rm_off += 1 " we remove one more line - endif - " - endfor - " - let mlist = matchlist ( a:chunk_head, '^@@ -\(\d\+\),\(\d\+\) +\(\d\+\),\(\d\+\) @@\s\?\(.*\)' ) - " - if empty ( mlist ) - return [ '', '', 'can not parse the chunk header' ] - else - let [ l_rm, n_rm, l_add, n_add ] = mlist[1:4] - let n_rm += n_rm_off - let n_add += n_add_off - let chunk_head = printf ( '@@ -%d,%d +%d,%d @@ %s', l_rm, n_rm, l_add, n_add, mlist[5] ) - endif - " - return [ a:diff_head, chunk_head, join ( lines, "\n" ) ] -endfunction " ---------- end of function s:Diff_VisualChunk ---------- -" -"------------------------------------------------------------------------------- -" s:Diff_ChunkHandler : Add/checkout/reset a chunk. {{{2 -" -" Parameters: -" action - "add-chunk", "checkout-chunk", "reset-chunk" (string) -" Returns: -" success - true, if the command was run successfully (integer) -"------------------------------------------------------------------------------- -" -function! s:Diff_ChunkHandler ( action, mode, v_start, v_end ) - " - " get the chunk under the cursor/visual selection - if a:mode == 'n' - let [ diff_head, chunk_head, chunk_text, c_pos ] = s:Diff_GetChunk ( getpos('.')[1] ) - elseif a:mode == 'v' - let reverse = a:action == 'add-chunk' ? 0 : 1 - let [ diff_head, chunk_head, chunk_text, c_pos ] = s:Diff_GetChunk ( a:v_start ) - let [ diff_head, chunk_head, chunk_text ] = s:Diff_VisualChunk ( diff_head, chunk_head, chunk_text, reverse, a:v_start - c_pos, a:v_end - c_pos ) - endif - " - " error while extracting chunk? - if diff_head == '' - echo chunk_text - return 0 - endif - " - " change to the top-level dir - let base = s:GitRepoDir() - " - " could not get top-level? - if base == '' | return | endif - " - silent exe 'lchdir '.fnameescape( base ) - " - " apply the patch, depending on the action - let chunk = diff_head."\n".chunk_head."\n".chunk_text."\n" - " - if a:action == 'add-chunk' - let text = system ( s:Git_Executable.' apply --cached -- -', chunk ) - elseif a:action == 'checkout-chunk' - let text = system ( s:Git_Executable.' apply -R -- -', chunk ) - elseif a:action == 'reset-chunk' - let text = system ( s:Git_Executable.' apply --cached -R -- -', chunk ) - endif - " - silent exe 'lchdir -' - " - " check the result - if v:shell_error != 0 - echo "applying the chunk failed:\n\n".text | " failure - elseif text =~ '^\_s*$' - echo "chunk applied successfully" | " success - else - echo "chunk applied successfully:\n".text | " success - endif - " - return v:shell_error == 0 -endfunction " ---------- end of function s:Diff_ChunkHandler ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" GitS_Diff : execute 'git diff ...' -"------------------------------------------------------------------------------- -" -function! GitS_Diff( action, ... ) range - " - let update_only = 0 - let param = '' - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "file under cursor ...\n" - let txt .= "of : open file (edit)\n" - let txt .= "oj : open and jump to the position under the cursor\n\n" - let txt .= "\n" - let txt .= "chunk under cursor ...\n" - let txt .= "ac : add to index (add chunk)\n" - let txt .= "cc : undo change (checkout chunk)\n" - let txt .= "rc : remove from index (reset chunk)\n" - let txt .= " -> in visual mode, these maps only apply the selected lines\n\n" - let txt .= "For settings see:\n" - let txt .= " :help g:Git_DiffExpandEmpty" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'color-words' - " - " :TODO:18.01.2014 13:46:WM: use own version: git diff --word-diff=porcelain - " :TODO:18.01.2014 13:46:WM: uncheck parameters - call GitS_GitBash( 'diff --word-diff=color '.a:1 ) - return - " - elseif a:action == 'update' - " - let update_only = a:0 == 0 - " - if update_only - " run again with old parameters - elseif empty( a:1 ) && g:Git_DiffExpandEmpty == 'yes' - let param = s:EscapeCurrent() - else - let param = a:1 - endif - " - elseif a:action =~ '\<\%(\|edit\|jump\)\>' - " - let base = s:GitRepoDir() - " - " could not get top-level? - if base == '' | return | endif - " - if a:action == 'edit' - let [ f_name, f_line, f_col ] = s:Diff_GetFile () - elseif a:action == 'jump' - let [ f_name, f_line, f_col ] = s:Diff_GetFile ( 'line' ) - endif - " - if f_name == '' - return s:ErrorMsg ( 'No file under the cursor.' ) - endif - " - let f_name = base.'/'.f_name - " - if a:action == 'edit' - \ || ( a:action == 'jump' && f_line == -1 ) - call s:OpenFile( f_name ) - elseif a:action == 'jump' - call s:OpenFile( f_name, f_line, f_col ) - endif - " - return - elseif a:action =~ '\<\%(\|add\|checkout\|reset\)-chunk\>' - " - if s:Diff_ChunkHandler ( a:action, a:1, a:firstline, a:lastline ) - call GitS_Diff ( 'update' ) - endif - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - diff' ) - " - let b:GitSupport_DiffFlag = 1 - " - setlocal filetype=gitsdiff - setlocal foldtext=GitS_FoldLog() - " - exe 'nnoremap <buffer> <S-F1> :call GitS_Diff("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_Diff("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_Diff("update")<CR>' - " - exe 'nnoremap <silent> <buffer> of :call GitS_Diff("edit")<CR>' - exe 'nnoremap <silent> <buffer> oj :call GitS_Diff("jump")<CR>' - " - exe 'nnoremap <silent> <buffer> ac :call GitS_Diff("add-chunk","n")<CR>' - exe 'vnoremap <silent> <buffer> ac :call GitS_Diff("add-chunk","v")<CR>' - exe 'nnoremap <silent> <buffer> cc :call GitS_Diff("checkout-chunk","n")<CR>' - exe 'vnoremap <silent> <buffer> cc :call GitS_Diff("checkout-chunk","v")<CR>' - exe 'nnoremap <silent> <buffer> rc :call GitS_Diff("reset-chunk","n")<CR>' - exe 'vnoremap <silent> <buffer> rc :call GitS_Diff("reset-chunk","v")<CR>' - endif - " - call s:ChangeCWD ( buf ) - " - if update_only - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' diff '.param - " - call s:UpdateGitBuffer ( cmd, update_only ) - " -endfunction " ---------- end of function GitS_Diff ---------- -" -"------------------------------------------------------------------------------- -" GitS_Fetch : execute 'git fetch ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Fetch( param, flags ) - " - return s:StandardRun ( 'fetch', a:param, a:flags, 'c' ) - " -endfunction " ---------- end of function GitS_Fetch ---------- -" -"------------------------------------------------------------------------------- -" GitS_Grep : execute 'git grep ...' {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:Grep_GetFile : Get the file and line under the cursor. {{{2 -" -" Parameters: -" - -" Returns: -" [ <file-name>, <line> ] - data (list: string, integer) -" -" The entries are as follows: -" file name - name of the file under the cursor (string) -" line - the line in the original file (integer) -" -" If only the name of the file could be obtained, returns: -" [ <file-name>, -1 ] -" If no file could be found: -" [ '', -1 ] -"------------------------------------------------------------------------------- -" -function! s:Grep_GetFile() - " - let mlist = matchlist ( getline('.'), '^\([^:]\+\):\%(\(\d\+\):\)\?' ) - " - if empty ( mlist ) - return [ '', -1 ] - endif - " - let f_name = mlist[1] - let f_line = mlist[2] - " - if f_line == '' - return [ f_name, -1 ] - endif - " - return [ f_name, str2nr ( f_line ) ] - " -endfunction " ---------- end of function s:Grep_GetFile ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -function! GitS_Grep( action, ... ) - " - let update_only = 0 - let param = '' - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "of : file under cursor: open file (edit)\n" - let txt .= "oj : file under cursor: open and jump to the corresponding line\n" - let txt .= "<Enter> : file under cursor: open and jump to the corresponding line" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' || a:action == 'top' - " - let update_only = a:0 == 0 - " - if update_only | " run again with old parameters - elseif empty( a:1 ) | let param = '' - else | let param = a:1 - endif - " - elseif a:action =~ '\<\%(\|edit\|jump\)\>' - " - call s:ChangeCWD () - " - let [ f_name, f_line ] = s:Grep_GetFile () - " - if f_name == '' - return s:ErrorMsg ( 'No file under the cursor.' ) - endif - " - if a:action == 'edit' - \ || ( a:action == 'jump' && f_line == -1 ) - call s:OpenFile( f_name ) - elseif a:action == 'jump' - call s:OpenFile( f_name, f_line, 1 ) - endif - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - " for action 'top', set the working directory to the top-level directory - if a:action == 'top' - let base = s:GitRepoDir() - " - " could not get top-level? - if base == '' | return | endif - " - let buf[1] = base - endif - " - if s:OpenGitBuffer ( 'Git - grep' ) - " - let b:GitSupport_GrepFlag = 1 - " - setlocal filetype=gitsgrep - setlocal foldtext=GitS_FoldGrep() - " - exe 'nnoremap <buffer> <S-F1> :call GitS_Grep("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_Grep("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_Grep("update")<CR>' - " - exe 'nnoremap <silent> <buffer> of :call GitS_Grep("edit")<CR>' - exe 'nnoremap <silent> <buffer> oj :call GitS_Grep("jump")<CR>' - exe 'nnoremap <silent> <buffer> <Enter> :call GitS_Grep("jump")<CR>' - endif - " - call s:ChangeCWD ( buf ) - " - if update_only - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' grep '.param - " - call s:UpdateGitBuffer ( cmd, update_only ) - " -endfunction " ---------- end of function GitS_Grep ---------- -" -"------------------------------------------------------------------------------- -" GitS_Help : execute 'git help' {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_Help( action, ... ) - " - let helpcmd = '' - " - if a:action == 'disabled' - return s:ImportantMsg ( s:DisabledMessage, s:DisabledReason ) - elseif a:action == 'help' - echo s:HelpTxtStdNoUpdate -" let txt = s:HelpTxtStdNoUpdate."\n\n" -" let txt .= "c : show contents and jump to section\n" -" echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - if a:0 == 0 - " noop - else - let helpcmd = a:1 - endif -" elseif a:action == 'toc' -" for i in range( 1, len(b:GitSupport_TOC) ) -" echo i.' - '.b:GitSupport_TOC[i-1][1] -" endfor -" return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - - if s:GitHelpFormat == 'html' - return s:StandardRun ( 'help', helpcmd, '' ) - endif - - let ts_save = &g:tabstop - - if s:OpenGitBuffer ( 'Git - help' ) - " - let b:GitSupport_HelpFlag = 1 - " - setlocal filetype=man - " - exe 'nnoremap <buffer> <S-F1> :call GitS_Help("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_Help("quit")<CR>' - " - "exe 'nnoremap <silent> <buffer> c :call GitS_Help("toc")<CR>' - endif - " - let cmd = s:Git_Executable.' help '.helpcmd - " - if s:UNIX && winwidth( winnr() ) > 0 - let cmd = 'MANWIDTH='.winwidth( winnr() ).' '.cmd - endif - - call s:UpdateGitBuffer ( cmd ) - - let &g:tabstop = ts_save - - " :TODO:19.01.2014 18:26:WM: own toc or via ctags? -" let b:GitSupport_TOC = [] -" " -" let cpos = getpos ('.') -" call setpos ( '.', [ bufnr('%'),1,1,1 ] ) -" " -" while 1 -" let pos = search ( '^\w', 'W' ) -" " -" if pos == 0 | break | endif -" if pos == 1 || pos == line('$') | continue | endif -" " -" let item = matchstr ( getline(pos), '^[0-9A-Za-z \t]\+' ) -" " -" call add ( b:GitSupport_TOC, [ pos, item ] ) -" " -" endwhile -" " -" call setpos ('.',cpos) - " -endfunction " ---------- end of function GitS_Help ---------- -" -"------------------------------------------------------------------------------- -" GitS_Log : execute 'git log ...' {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:Log_GetCommit : Get the commit under the cursor. {{{2 -" -" Parameters: -" - -" Returns: -" <commit-name> - the name of the commit (string) -" -" If the commit could not be obtained returns an empty string. -"------------------------------------------------------------------------------- -" -function! s:Log_GetCommit() - " - " in case of "git log --oneline" - if match ( getline('.'), '^\x\{6,}\(\s\|\_$\)' ) >= 0 - echo 'oneline' - return matchstr ( getline('.'), '^\x\+' ) - endif - " - let c_pos = search ( '\m\_^commit \x', 'bcnW' ) " the position of the commit name - " - if c_pos == 0 - return '' - endif - " - return matchstr ( getline(c_pos), '^commit\s\zs\x\+' ) - " -endfunction " ---------- end of function s:Log_GetCommit ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -function! GitS_Log( action, ... ) - " - let param = '' - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "commit under cursor ...\n" - let txt .= "ch : checkout\n" - let txt .= "cr : use as starting point for creating a new branch\n" - let txt .= "sh / cs : show the commit\n" - let txt .= "ta : tag the commit\n" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " - if a:0 == 0 | " run again with old parameters - elseif empty( a:1 ) | let param = '' - else | let param = a:1 - endif - " - elseif -1 != index ( [ 'checkout', 'create', 'show', 'tag' ], a:action ) - " - let c_name = s:Log_GetCommit () - " - if c_name == '' - return s:ErrorMsg ( 'No commit under the cursor.' ) - endif - " - if a:action == 'checkout' - call GitS_Checkout( shellescape(c_name), 'c' ) - elseif a:action == 'create' - return s:AssembleCmdLine ( ':GitBranch ', ' '.c_name ) - elseif a:action == 'show' - call GitS_Show( 'update', shellescape(c_name), '' ) - elseif a:action == 'tag' - return s:AssembleCmdLine ( ':GitTag ', ' '.c_name ) - endif - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - log' ) - " - let b:GitSupport_LogFlag = 1 - " - setlocal filetype=gitslog - setlocal foldtext=GitS_FoldLog() - " - exe 'nnoremap <buffer> <S-F1> :call GitS_Log("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_Log("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_Log("update")<CR>' - " - exe 'nnoremap <silent> <buffer> ch :call GitS_Log("checkout")<CR>' - exe 'nnoremap <expr> <buffer> cr GitS_Log("create")' - exe 'nnoremap <silent> <buffer> sh :call GitS_Log("show")<CR>' - exe 'nnoremap <silent> <buffer> cs :call GitS_Log("show")<CR>' - exe 'nnoremap <expr> <buffer> ta GitS_Log("tag")' - endif - " - call s:ChangeCWD ( buf ) - " - if a:0 == 0 - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' log '.param - " - call s:UpdateGitBuffer ( cmd ) - " -endfunction " ---------- end of function GitS_Log ---------- -" -"------------------------------------------------------------------------------- -" GitS_Merge : execute 'git merge ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Merge( mode, param, flags ) - " - if a:mode == 'direct' - " - return s:StandardRun ( 'merge', a:param, a:flags, 'c' ) - " - elseif a:mode == 'upstream' - " - let b_current = s:StandardRun ( 'symbolic-ref', '-q HEAD', 't' )[1] - let b_upstream = s:StandardRun ( 'for-each-ref', " --format='%(upstream:short)' ".shellescape( b_current ), 't' )[1] - " - if b_upstream == '' - return s:ImportantMsg ( 'No upstream branch.' ) - elseif a:param == '' - return s:StandardRun ( 'merge', b_upstream, 'c' ) - else - return s:StandardRun ( 'merge', a:param.' '.b_upstream, 'c' ) - endif - " - else - echoerr 'Unknown mode "'.a:mode.'".' - return - endif - " -endfunction " ---------- end of function GitS_Merge ---------- -" -"------------------------------------------------------------------------------- -" GitS_Move : execute 'git move ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Move( param, flags ) - " - return s:StandardRun ( 'mv', a:param, a:flags, 'c' ) - " -endfunction " ---------- end of function GitS_Move ---------- -" -"------------------------------------------------------------------------------- -" GitS_Pull : execute 'git pull ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Pull( param, flags ) - " - return s:StandardRun ( 'pull', a:param, a:flags, 'c' ) - " -endfunction " ---------- end of function GitS_Pull ---------- -" -"------------------------------------------------------------------------------- -" GitS_Push : execute 'git push ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Push( param, flags ) - " - return s:StandardRun ( 'push', a:param, a:flags, 'c' ) - " -endfunction " ---------- end of function GitS_Push ---------- -" -"------------------------------------------------------------------------------- -" GitS_Remote : execute 'git remote ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Remote( param, flags ) - " - if empty ( a:param ) - call GitS_RemoteList ( 'update' ) - else - return s:StandardRun ( 'remote', a:param, a:flags, 'c' ) - endif - " -endfunction " ---------- end of function GitS_Remote ---------- -" -"------------------------------------------------------------------------------- -" GitS_RemoteList : execute 'git remote' (list remotes) {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:RemoteList_GetRemote : Get the remote and URL under the cursor. {{{2 -" -" Parameters: -" - -" Returns: -" [ <remote-name>, <url> ] - data (list: string, string) -" -" The entries are as follows: -" remote name - name of the remote under the cursor (string) -" url - its URL (string) -" -" If only the name of the remote could be obtained, returns: -" [ <remote-name>, '' ] -" If no remote could be found: -" [ '', '' ] -"------------------------------------------------------------------------------- -" -function! s:RemoteList_GetRemote() - " - let line = getline('.') - let mlist = matchlist ( line, '^\s*\(\S\+\)\s\+\(.\+\)\s\+(\w\+)$' ) - " - if empty ( mlist ) - return [ '', '' ] - else - return mlist[1:2] - endif - " -endfunction " ---------- end of function s:RemoteList_GetRemote ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -function! GitS_RemoteList( action ) - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "remote under cursor ...\n" - let txt .= "fe : fetch\n" - let txt .= "ph : push\n" - let txt .= "pl : pull\n" - let txt .= "rm : remove\n" - let txt .= "rn : rename\n" - let txt .= "su : set-url\n" - let txt .= "sh : show\n" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " noop - elseif -1 != index ( [ 'fetch', 'push', 'pull', 'remove', 'rename', 'set-url', 'show' ], a:action ) - " - let [ r_name, r_url ] = s:RemoteList_GetRemote () - " - if r_name == '' - return s:ErrorMsg ( 'No remote under the cursor.' ) - endif - " - if a:action == 'fetch' - return ':GitFetch '.r_name.' ' - elseif a:action == 'push' - return ':GitPush '.r_name.' ' - elseif a:action == 'pull' - return ':GitPull '.r_name.' ' - elseif a:action == 'remove' - call GitS_Remote( 'rm '.shellescape(r_name), 'c' ) - elseif a:action == 'rename' - return ':GitRemote rename '.r_name.' ' - elseif a:action == 'set-url' - if empty ( r_url ) - return ':GitRemote set-url '.r_name.' ' - else - return ':GitRemote set-url '.r_name.' '.shellescape( r_url ) - endif - elseif a:action == 'show' - call GitS_Remote( 'show '.shellescape(r_name), '' ) - endif - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - if s:OpenGitBuffer ( 'Git - remote' ) - " - let b:GitSupport_RemoteFlag = 1 - " - "setlocal filetype= - " - exe 'nnoremap <buffer> <S-F1> :call GitS_RemoteList("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_RemoteList("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_RemoteList("update")<CR>' - " - exe 'nnoremap <expr> <buffer> fe GitS_RemoteList("fetch")' - exe 'nnoremap <expr> <buffer> ph GitS_RemoteList("push")' - exe 'nnoremap <expr> <buffer> pl GitS_RemoteList("pull")' - exe 'nnoremap <silent> <buffer> rm :call GitS_RemoteList("remove")<CR>' - exe 'nnoremap <expr> <buffer> rn GitS_RemoteList("rename")' - exe 'nnoremap <expr> <buffer> su GitS_RemoteList("set-url")' - exe 'nnoremap <silent> <buffer> sh :call GitS_RemoteList("show")<CR>' - endif - " - let cmd = s:Git_Executable.' remote -v' - " - call s:UpdateGitBuffer ( cmd, 1 ) - " -endfunction " ---------- end of function GitS_RemoteList ---------- -" -"------------------------------------------------------------------------------- -" GitS_Remove : execute 'git rm ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Remove( param, flags ) - " - call s:StandardRun ( 'rm', a:param, a:flags ) - " - if empty ( a:param ) && s:Question ( 'Delete the current buffer as well?' ) == 1 - bdelete - echo "deleted" - endif - " -endfunction " ---------- end of function GitS_Remove ---------- -" -"------------------------------------------------------------------------------- -" GitS_Reset : execute 'git reset ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Reset( param, flags ) - " - if g:Git_ResetExpandEmpty == 'yes' - let flags = a:flags.'e' - else - let flags = a:flags - endif - " - return s:StandardRun ( 'reset', a:param, flags ) - " -endfunction " ---------- end of function GitS_Reset ---------- -" -"------------------------------------------------------------------------------- -" GitS_Show : execute 'git show ...' {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:Show_RevisionNames : Special names for git show. {{{2 -"------------------------------------------------------------------------------- -" -let s:Show_RevisionNames = { - \ ':' : 'STAGED', - \ ':0:' : 'STAGED', - \ ':1:' : 'COMMON_ANCESTOR', - \ ':2:' : 'TARGET_BRANCH', - \ ':3:' : 'SOURCE_BRANCH', - \ } -" -"------------------------------------------------------------------------------- -" s:Show_AnalyseObject : Analyse the object given to show. {{{2 -" -" Parameters: -" args - command line args given to :GitShow (string) -" Returns: -" [ <last>, <type> ] - data (list: string, string) -" -" The entries are as follows: -" last - the last argument (string) -" type - type of the object: "blob", "commit", "tag" or "tree" (string) -" -" If the object or type could not be obtained: -" [ '', '' ] -"------------------------------------------------------------------------------- -" -function! s:Show_AnalyseObject( args ) - " - let args = s:GitCmdLineArgs ( a:args ) - if args[-1] == '' - return [ '', '' ] - else - let [ ret, type ] = s:StandardRun ( 'cat-file', " -t ".shellescape( args[-1] ), 't' ) - endif - " - if ret != 0 - return [ '', '' ] - endif - " - return [ args[-1], type ] - " -endfunction " ---------- end of function s:Show_AnalyseObject ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -function! GitS_Show( action, ... ) - " - let param = '' - " - if a:action == 'help' - echo s:HelpTxtStd - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " - if a:0 == 0 - " run again with old parameters - " - let [ last_arg, type ] = [ '', '' ] - elseif a:1 =~ '^\s*$' - let param = '' - " - let [ last_arg, type ] = [ 'HEAD', 'commit' ] - else - " new arguments - let param = a:1 - " - let [ last_arg, type ] = s:Show_AnalyseObject ( param ) - " - endif - " - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - " BLOB: treat separately - if type == 'blob' - " - if last_arg =~ '\_^:[0123]:\|\_^:[^/]' - let obj_src = s:Show_RevisionNames[ matchstr( last_arg, '\_^:[0123]:\|\_^:' ) ] - let last_arg = substitute( last_arg, '\_^:[0123]:\|\_^:', obj_src.'.', '' ) - endif - " - let last_arg = substitute ( last_arg, ':', '.', '' ) - let last_arg = substitute ( last_arg, '/', '.', 'g' ) - " - call s:OpenGitBuffer ( last_arg ) - call s:UpdateGitBuffer ( s:Git_Executable.' show '.param ) - filetype detect - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - show' ) - " - let b:GitSupport_ShowFlag = 1 - " - setlocal filetype=gitslog - setlocal foldtext=GitS_FoldLog() - " - exe 'nnoremap <buffer> <S-F1> :call GitS_Show("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_Show("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_Show("update")<CR>' - endif - " - call s:ChangeCWD ( buf ) - " - if a:0 == 0 - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' show '.param - " - call s:UpdateGitBuffer ( cmd ) - " -endfunction " ---------- end of function GitS_Show ---------- -" -"------------------------------------------------------------------------------- -" GitS_Stash : execute 'git stash ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Stash( param, flags ) - " - let subcmd = matchstr ( a:param, '^\s*\zs\w\+' ) - " - if subcmd == 'list' - call GitS_StashList ( 'update', a:param ) - elseif subcmd == 'show' - call GitS_StashShow ( 'update', a:param ) - else - return s:StandardRun ( 'stash', a:param, a:flags, 'c' ) - endif - " - " -endfunction " ---------- end of function GitS_Stash ---------- -" -"------------------------------------------------------------------------------- -" GitS_StashList : execute 'git stash list ...' {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:StashList_GetStash : Get the stash under the cursor. {{{2 -" -" Parameters: -" - -" Returns: -" <stash-name> - the name of the stash (string) -" -" If the name could not be obtained returns an empty string. -"------------------------------------------------------------------------------- -" -function! s:StashList_GetStash() - " - let line = getline('.') - let name = matchstr ( line, '^stash@{\d\+}' ) - " - return name - " -endfunction " ---------- end of function s:StashList_GetStash ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -function! GitS_StashList( action, ... ) - " - let update_only = 0 - let param = '' - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "sh : show the stash under the cursor\n" - let txt .= "sp : show the stash in patch form\n" - let txt .= "\n" - let txt .= "sa : save with a message\n" - let txt .= "pu : create a new stash (push)\n" - let txt .= "\n" - let txt .= "stash under cursor ...\n" - let txt .= "ap : apply\n" - let txt .= "po : pop\n" - let txt .= "dr : drop\n" - let txt .= "br : create and checkout a new branch\n" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " - let update_only = a:0 == 0 - " - if update_only | " run again with old parameters - elseif empty( a:1 ) | let param = '' - else | let param = a:1 - endif - " - elseif -1 != index ( [ 'save', 'save-msg' ], a:action ) - " - if a:action == 'save' - call GitS_Stash( '', '' ) - elseif a:action == 'save-msg' - return s:AssembleCmdLine ( ':GitStash save "', '"' ) - endif - " - return - elseif -1 != index ( [ 'show', 'show-patch', 'apply', 'drop', 'pop', 'branch' ], a:action ) - " - let s_name = s:StashList_GetStash () - " - if s_name == '' - return s:ErrorMsg ( 'No stash under the cursor.' ) - endif - " - if a:action == 'show' - call GitS_Stash( 'show '.shellescape(s_name), '' ) - elseif a:action == 'show-patch' - call GitS_Stash( 'show -p '.shellescape(s_name), '' ) - elseif a:action == 'apply' - call GitS_Stash( 'apply '.shellescape(s_name), 'c' ) - elseif a:action == 'drop' - call GitS_Stash( 'drop '.shellescape(s_name), 'c' ) - elseif a:action == 'pop' - call GitS_Stash( 'pop '.shellescape(s_name), 'c' ) - elseif a:action == 'branch' - return s:AssembleCmdLine ( ':GitStash branch ', ' '.shellescape(s_name) ) - endif - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - stash list' ) - " - let b:GitSupport_StashListFlag = 1 - " - setlocal filetype=gitslog - " - exe 'nnoremap <buffer> <S-F1> :call GitS_StashList("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_StashList("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_StashList("update")<CR>' - " - exe 'nnoremap <silent> <buffer> sh :call GitS_StashList("show")<CR>' - exe 'nnoremap <silent> <buffer> sp :call GitS_StashList("show-patch")<CR>' - " - exe 'nnoremap <expr> <buffer> sa GitS_StashList("save-msg")' - exe 'nnoremap <silent> <buffer> pu :call GitS_StashList("save")<CR>' - " - exe 'nnoremap <silent> <buffer> ap :call GitS_StashList("apply")<CR>' - exe 'nnoremap <silent> <buffer> dr :call GitS_StashList("drop")<CR>' - exe 'nnoremap <silent> <buffer> po :call GitS_StashList("pop")<CR>' - exe 'nnoremap <expr> <buffer> br GitS_StashList("branch")' - endif - " - call s:ChangeCWD ( buf ) - " - if update_only - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' stash '.param - " - call s:UpdateGitBuffer ( cmd, update_only ) - " -endfunction " ---------- end of function GitS_StashList ---------- -" -"------------------------------------------------------------------------------- -" GitS_StashShow : execute 'git stash show ...' {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_StashShow( action, ... ) - " - let update_only = 0 - let param = '' - " - if a:action == 'help' - echo s:HelpTxtStdNoUpdate - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " - let update_only = a:0 == 0 - " - if update_only | " run again with old parameters - elseif empty( a:1 ) | let param = '' - else | let param = a:1 - endif - " - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - stash show' ) - " - let b:GitSupport_StashShowFlag = 1 - " - setlocal filetype=gitsdiff - " - exe 'nnoremap <buffer> <S-F1> :call GitS_StashShow("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_StashShow("quit")<CR>' - endif - " - call s:ChangeCWD ( buf ) - " - if update_only - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' stash '.param - " - call s:UpdateGitBuffer ( cmd, update_only ) - " -endfunction " ---------- end of function GitS_StashShow ---------- -" -"------------------------------------------------------------------------------- -" GitS_Status : execute 'git status' {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:Status_SectionCodes {{{2 -"------------------------------------------------------------------------------- -" -let s:Status_SectionCodes = { - \ 'b': 'staged/modified', - \ 's': 'staged', - \ 'm': 'modified', - \ 'u': 'untracked', - \ 'i': 'ignored', - \ 'c': 'conflict', - \ 'd': 'diff', - \ } -" -"------------------------------------------------------------------------------- -" s:Status_GetFile : Get the file under the cursor and its status. {{{2 -" -" Parameters: -" - -" Returns: -" [ <section-code>, <file-status>, <file-name> ] - data (list: 3x string) -" or -" [ <section-code>, <file-status>, <old-name>, <new-name> ] - data (list: 4x string) -" -" The entries are as follows: -" section code - one character encoding the section the file was found in, -" use 's:Status_SectionCodes' to decode the meaning (string) -" file status - status of the file, see below (string) -" file name - name of the file under the cursor (string) -" -" Status: -" - "new file" -" - "modified" -" - "deleted" -" - "renamed" -" - "conflict" -" - one of the two-letter status codes of "git status --short" -" -" In case of an error, the list contains to empty strings and an error message: -" [ '', '', <error-message> ] -"------------------------------------------------------------------------------- -" -function! s:Status_GetFile() - " - let f_name = '' - let f_new = '' - let f_status = '' - let s_code = '' - " - if b:GitSupport_ShortOption - " - " short output - " - let line = getline('.') - " - if line =~ '^##' - return [ '', '', 'No file under the cursor.' ] - elseif line =~ '^\%([MARC][MD]\|DM\)\s' - let s_code = 'b' - elseif line =~ '^[MARCD] \s' - let s_code = 's' - elseif line =~ '^ [MD]\s' - let s_code = 'm' - elseif line =~ '^??\s' - let s_code = 'u' - elseif line =~ '^!!\s' - let s_code = 'i' - elseif line =~ '^\%(AA\|DD\|[AD]U\|U[ADU]\)\s' - let s_code = 'c' - else - return [ '', '', 'Unknown section, aborting.' ] - endif - " - let [ f_status, f_name ] = matchlist( line, '^\(..\)\s\(.*\)' )[1:2] - " - elseif ! s:HasStatus185Format - " - " long output (prior to 1.8.5) - " - let c_line = getline('.') " line under the cursor - let c_pos = line('.') " line number - let h_pos = c_pos " header line number - let s_head = '' " header line - " - if c_line =~ '^#' - " - let h_pos = search ( '^# [[:alnum:][:space:]]\+:$', 'bcnW' ) - " - " find header - if h_pos > 0 - let s_head = matchstr( getline(h_pos), '^# \zs[[:alnum:][:space:]]\+\ze:$' ) - else - return [ '', '', 'Not in any section.' ] - endif - " - " which header? - if s_head == 'Changes to be committed' - let s_code = 's' - elseif s_head == 'Changed but not updated' || s_head == 'Changes not staged for commit' - let s_code = 'm' - elseif s_head == 'Untracked files' - let s_code = 'u' - elseif s_head == 'Ignored files' - let s_code = 'i' - elseif s_head == 'Unmerged paths' - let s_code = 'c' - else - return [ '', '', 'Unknown section "'.s_head.'", aborting.' ] - endif - " - " get the filename - if s_code =~ '[smc]' - let mlist = matchlist( c_line, '^#\t\([[:alnum:][:space:]]\+\):\s\+\(\S.*\)$' ) - else - let mlist = matchlist( c_line, '^#\t\(\)\(\S.*\)$' ) - endif - " - " check the filename - if empty( mlist ) - return [ '', '', 'No file under the cursor.' ] - endif - " - let [ f_status, f_name ] = mlist[1:2] - " - if s_code == 'c' - let f_status = 'conflict' - endif - " - elseif b:GitSupport_VerboseOption == 1 - " - let [ f_name, f_line, f_col ] = s:Diff_GetFile () - " - if f_name == '' - return [ '', '', 'No file under the cursor.' ] - else - let base = s:GitRepoDir() - " could not get top-level? - if base == '' - return [ '', '', 'could not obtain the top-level directory' ] - endif - " :TODO:17.01.2014 14:42:WM: might be "new file", "deleted"? - let f_name = base.'/'.f_name - let f_status = 'modified' - let s_code = 'd' - endif - endif - " - else - " - " long output (1.8.5 and after) - " - " :TODO:08.05.2014 09:55:WM: with a few modifications, we can use this for output prior to 1.8.5 as well - " - let c_line = getline('.') " line under the cursor - let c_pos = line('.') " line number - let h_line = '' " header line - let h_pos = c_pos " header line number - " - " find header (including "diff" and "@@") - while h_pos > 0 - " - let h_line = matchstr( getline(h_pos), '^\(\u[[:alnum:][:space:]]*:\_$\|diff\|@@\)' ) - " - if ! empty( h_line ) - break - endif - " - let h_pos -= 1 - endwhile - " - let h_line = substitute ( h_line, ':$', '', '' ) - " - if h_line !~ '^diff' && h_line !~ '^@@' - " - " which header? - if h_line == '' - return [ '', '', 'Not in any section.' ] - elseif h_line == 'Changes to be committed' - let s_code = 's' - elseif h_line == 'Changed but not updated' || h_line == 'Changes not staged for commit' - let s_code = 'm' - elseif h_line == 'Untracked files' - let s_code = 'u' - elseif h_line == 'Ignored files' - let s_code = 'i' - elseif h_line == 'Unmerged paths' - let s_code = 'c' - else - return [ '', '', 'Unknown section "'.h_line.'", aborting.' ] - endif - " - " get the filename - if s_code =~ '[smc]' - let mlist = matchlist( c_line, '^\t\([[:alnum:][:space:]]\+\):\s\+\(\S.*\)$' ) - else - let mlist = matchlist( c_line, '^\t\(\)\(\S.*\)$' ) - endif - " - " check the filename - if empty( mlist ) - return [ '', '', 'No file under the cursor.' ] - endif - " - let [ f_status, f_name ] = mlist[1:2] - " - if s_code == 'c' - let f_status = 'conflict' - endif - " - elseif b:GitSupport_VerboseOption == 1 - " - " diff output - " - let [ f_name, f_line, f_col ] = s:Diff_GetFile () - " - if f_name == '' - return [ '', '', 'No file under the cursor.' ] - else - let base = s:GitRepoDir() - " could not get top-level? - if base == '' - return [ '', '', 'could not obtain the top-level directory' ] - endif - " :TODO:17.01.2014 14:42:WM: might be "new file", "deleted"? - let f_name = base.'/'.f_name - let f_status = 'modified' - let s_code = 'd' - endif - endif - " - endif - " - if f_status == 'renamed' || f_status =~ '^R' - let mlist = matchlist( f_name, '^\(.*\) -> \(.*\)$' ) - " - " check the filename - if empty( mlist ) - return [ '', '', 'Could not correctly detect the rename.' ] - endif - " - let [ f_name, f_new ] = mlist[1:2] - endif - " - if f_name =~ '^".\+"$' - let f_name = substitute ( f_name, '\_^"\|"\_$', '', 'g' ) - let f_name = substitute ( f_name, '\\\(.\)', '\1', 'g' ) - endif - " - if f_new == '' - return [ s_code, f_status, f_name ] - else - return [ s_code, f_status, f_name, f_new ] - endif - " -endfunction " ---------- end of function s:Status_GetFile ---------- -" -"------------------------------------------------------------------------------- -" s:Status_FileAction : Execute a command for the file under the cursor. {{{2 -" -" Parameters: -" action - the action to perform, see below (string) -" Returns: -" success - true, if the command was run successfully (integer) -" -" Uses 's:Status_GetFile' to obtain the section and file under the cursor. Then -" the action is performed, if allowed for this section. The actions are named -" for Git commands, except for "edit" (ckout = checkout): -" -" section / action -" | edit | diff log | add ckout reset rm | del -" staged (b/s) | x | x x | - - x - | - -" modified (b/m) | x | x x | x x - ? | - -" untracked (u) | x | - - | x - - - | x -" ignored (i) | x | - - | x - - - | x -" unmerged (c) | x | x x | x - x - | - -" diff (d) | x | x x | - - x - | - -" -" in section 'staged' : action 'diff' may behave differently -" in section 'modified' : action 'rm' only for status 'deleted' -"------------------------------------------------------------------------------- -" -function! s:Status_FileAction( action ) - " - " the file under the cursor - let fileinfo = s:Status_GetFile() - " - if len ( fileinfo ) == 3 - let [ s_code, f_status, f_name_old ] = fileinfo - let f_name_new = f_name_old - else - let [ s_code, f_status, f_name_old, f_name_new ] = fileinfo - endif - " - if s_code == '' - " in this case 'f_name_old' contains the error message - call s:ErrorMsg ( f_name_old ) - return 0 - endif - " - if a:action == 'edit' - " - " any section, action "edit" - call s:OpenFile( f_name_new ) - " - elseif s_code == 's' && ( a:action == 'diff' || a:action == 'diff-word' ) - " - " section "staged", action "diff" - " - if a:action == 'diff' | let mode = 'update' - else | let mode = 'color-words' | endif - " - if g:Git_StatusStagedOpenDiff == 'cached' - let which = '--cached ' - elseif g:Git_StatusStagedOpenDiff == 'head' - let which = 'HEAD ' - else - let which = '' - endif - " - if f_name_new == f_name_old - call GitS_Diff( mode, which.'-- '.shellescape( f_name_old ) ) - else - call GitS_Diff( mode, '--find-renames '.which.'-- '.shellescape( f_name_old ).' '.shellescape( f_name_new ) ) - endif - " - elseif s_code =~ '[bmcd]' && ( a:action == 'diff' || a:action == 'diff-word' ) - " - " section "modified", "conflict" or "diff", action "diff" - " (this is also called for section "both" in short status output) - " - if a:action == 'diff' | let mode = 'update' - else | let mode = 'color-words' | endif - " - call GitS_Diff( mode, '-- '.shellescape( f_name_new ) ) - " - elseif s_code =~ '[bsmcd]' && a:action == 'log' - " - " section "staged", "modified", "conflict" or "diff", action "log" - call GitS_Log( 'update', '--stat -- '.shellescape( f_name_old ) ) - " - elseif s_code == 'i' && a:action == 'add' - " - " section "ignored", action "add" - if s:Question( 'Add ignored file "'.f_name_old.'"?', 'warning' ) == 1 - call GitS_Add( '-- '.shellescape( f_name_old ), 'f' ) - return 1 - endif - " - elseif s_code == 'u' && a:action == 'add' - " - " section "untracked", action "add" - if s:Question( 'Add untracked file "'.f_name_old.'"?' ) == 1 - call GitS_Add( '-- '.shellescape( f_name_old ), '' ) - return 1 - endif - " - elseif s_code =~ '[bm]' && a:action == 'add' - " - " section "modified", action "add" - " - if f_status == 'modified' || f_status =~ '^.M$' - " add a modified file? - if s:Question( 'Add file "'.f_name_old.'"?' ) == 1 - call GitS_Add( '-- '.shellescape( f_name_old ), '' ) - return 1 - endif - elseif f_status == 'deleted' || f_status =~ '^.D$' - " add a deleted file? -> remove it? - if s:Question( 'Remove file "'.f_name_old.'"?' ) == 1 - call GitS_Remove( '-- '.shellescape( f_name_old ), '' ) - return 1 - endif - else - call s:ErrorMsg ( 'Adding not implemented yet for file status "'.f_status.'".' ) - endif - " - elseif s_code =~ '[bm]' && a:action == 'add-patch' - " - " section "modified", action "add-patch" - " - if f_status == 'modified' || f_status =~ '^.M$' - call GitS_GitBash( 'add -p -- '.shellescape( f_name_old ) ) - return 1 - else - call s:ErrorMsg ( 'No "add -p" for file status "'.f_status.'".' ) - endif - " - elseif s_code =~ '[bm]' && a:action == 'checkout' - " - " section "modified", action "checkout" - " - if f_status == 'modified' || f_status == 'deleted' || f_status =~ '^.[MD]$' - " check out a modified or deleted file? - if s:Question( 'Checkout file "'.f_name_old.'"?', 'warning' ) == 1 - call GitS_Checkout( '-- '.shellescape( f_name_old ), '' ) - return 1 - endif - else - call s:ErrorMsg ( 'Checking out not implemented yet for file status "'.f_status.'".' ) - endif - " - elseif s_code =~ '[bsm]' && a:action == 'checkout-head' - " - " section "staged", "modified" or "both", action "checkout-head" - " - if f_status == 'modified' || f_status == 'deleted' || f_status =~ '^[MAD].$' || f_status =~ '^.[MD]$' - " check out a modified or deleted file? - if s:Question( 'Checkout file "'.f_name_old.'" and change both the index and working tree copy?', 'warning' ) == 1 - call GitS_Checkout( 'HEAD -- '.shellescape( f_name_old ), '' ) - return 1 - endif - else - call s:ErrorMsg ( 'Checking out the HEAD not implemented yet for file status "'.f_status.'".' ) - endif - " - elseif s_code =~ '[bm]' && a:action == 'checkout-patch' - " - " section "modified", action "checkout-patch" - " - if f_status == 'modified' || f_status =~ '^.M$' - call GitS_GitBash( 'checkout -p -- '.shellescape( f_name_old ) ) - return 1 - else - call s:ErrorMsg ( 'No "checkout -p" for file status "'.f_status.'".' ) - endif - " - elseif s_code =~ '[bsd]' && a:action == 'reset' - " - " section "staged" or "diff", action "reset" - " - if f_status == 'modified' || f_status == 'new file' || f_status == 'deleted' || f_status =~ '^[MADC].$' - " reset a modified, new or deleted file? - if s:Question( 'Reset file "'.f_name_old.'"?' ) == 1 - call GitS_Reset( '-q -- '.shellescape( f_name_old ), '' ) " use '-q' to prevent return value '1' and suppress output - return 1 - endif - elseif f_status == 'renamed' || f_status =~ '^R.$' - " reset a modified, new or deleted file? - if s:Question( 'Reset the old file "'.f_name_old.'"?' ) == 1 - call GitS_Reset( '-q -- '.shellescape( f_name_old ), '' ) " use '-q' to prevent return value '1' and suppress output - endif - if s:Question( 'Reset the new file "'.f_name_new.'"?' ) == 1 - call GitS_Reset( '-q -- '.shellescape( f_name_new ), '' ) " use '-q' to prevent return value '1' and suppress output - endif - if s:Question( 'Undo the rename?' ) == 1 - call rename( f_name_new, f_name_old ) - endif - return 1 - else - call s:ErrorMsg ( 'Reseting not implemented yet for file status "'.f_status.'".' ) - endif - " - elseif s_code =~ '[bs]' && a:action == 'reset-patch' - " - " section "staged", action "reset-patch" - " - if f_status == 'modified' || f_status =~ '^M.$' - call GitS_GitBash( 'reset -p -- '.shellescape( f_name_old ) ) - return 1 - else - call s:ErrorMsg ( 'No "reset -p" for file status "'.f_status.'".' ) - endif - " - elseif s_code =~ 'c' && a:action == 'add' - " - " section "unmerged", action "add" - if s:Question( 'Add unmerged file "'.f_name_old.'"?' ) == 1 - call GitS_Add( '-- '.shellescape( f_name_old ), '' ) - return 1 - endif - " - elseif s_code =~ 'c' && a:action == 'reset' - " - " section "unmerged", action "reset" - if s:Question( 'Reset unmerged file "'.f_name_old.'"?' ) == 1 - call GitS_Reset( '-- '.shellescape( f_name_old ), '' ) - return 1 - endif - " - elseif s_code =~ '[ui]' && a:action == 'delete' - " - " section "untracked" or "ignored", action "delete" - " - if ! exists( '*delete' ) - call s:ErrorMsg ( 'Can not delete files from harddisk.' ) - elseif s:Question( 'Delete file "'.f_name_old.'" from harddisk?' ) == 1 - return delete ( f_name_old ) == 0 - endif - " - else - " - " action not implemented for section - " - call s:ErrorMsg ( 'Can not execute "'.a:action.'" in section "'.s:Status_SectionCodes[s_code].'".' ) - " - endif - " - return 0 - " -endfunction " ---------- end of function s:Status_FileAction ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" GitS_Status : execute 'git status' -"------------------------------------------------------------------------------- -" -function! GitS_Status( action, ... ) - " - let update_only = 0 - let limited_dir = '' - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "toggle ...\n" - let txt .= "i : show ignored files\n" - let txt .= "s : short output\n" - let txt .= "v : verbose output\n" - let txt .= "\n" - let txt .= "file under cursor ...\n" - if s:EnabledGitBash - let txt .= "a / ap : add / add --patch\n" - else - let txt .= "a : add\n" - endif - if s:EnabledGitBash - let txt .= "c / cp : checkout / checkout --patch\n" - else - let txt .= "c : checkout\n" - endif - let txt .= "ch : checkout HEAD\n" - let txt .= "od : open diff\n" - let txt .= "of / oj : open file (edit)\n" - let txt .= "ol : open log\n" - if s:EnabledGitBash - let txt .= "r / rp : reset / reset --patch\n" - else - let txt .= "r : reset\n" - endif - let txt .= "D : delete from file system (only untracked files)\n" - let txt .= "\n" - let txt .= "For settings see:\n" - let txt .= " :help g:Git_StatusStagedOpenDiff" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - let update_only = a:0 == 0 - " - if update_only - " run again with old parameters - else - let limited_dir = a:1 - endif - " - elseif a:action == 'ignored' - if ! s:HasStatusIgnore - return s:ErrorMsg ( '"show ignored files" not available in Git version '.s:GitVersion.'.' ) - endif - elseif a:action =~ '\<\%(short\|verbose\)\>' - " noop - elseif -1 != index ( [ 'add', 'add-patch', 'checkout', 'checkout-head', 'checkout-patch', 'diff', 'diff-word', 'edit', 'log', 'reset', 'reset-patch', 'delete' ], a:action ) - " - call s:ChangeCWD () - " - if s:Status_FileAction ( a:action ) - call GitS_Status( 'update' ) - endif - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - " if a directory has been given, set the working directory accordingly - if ! update_only - let relative_paths = s:GitGetConfig ( 'status.relativePaths' ) - " - " use the top-level directory - if relative_paths == 'false' || limited_dir == '/' - let base = s:GitRepoDir() - " - " could not get top-level? - if base == '' | return | endif - " - let buf[1] = base - endif - " - if limited_dir == '/' - " we use the top-level directory as the cwd, no further path required - let limited_dir = '' - elseif relative_paths == 'false' && limited_dir != '' - " we need the limited_dir relative to the top-level directory - silent exe 'lchdir '.fnameescape( limited_dir ) - let [ sh_err, limited_dir ] = s:StandardRun ( 'rev-parse', '--show-prefix', 't' ) - silent exe 'lchdir -' - elseif relative_paths != 'false' && limited_dir != '' - " we set the cwd and restrict the output to it - let buf[1] = fnamemodify( limited_dir, ':p' ) - let limited_dir = '.' - endif - endif - " - if s:OpenGitBuffer ( 'Git - status' ) - " - let b:GitSupport_StatusFlag = 1 - let b:GitSupport_StatusLimitedDir = '' - let b:GitSupport_StatusRelativePath = s:GitGetConfig ( 'status.relativePaths' ) - let b:GitSupport_IgnoredOption = 0 - let b:GitSupport_ShortOption = 0 - let b:GitSupport_VerboseOption = 0 - " - setlocal filetype=gitsstatus - setlocal foldtext=GitS_FoldLog() - " - exe 'nnoremap <buffer> <S-F1> :call GitS_Status("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_Status("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_Status("update")<CR>' - " - exe 'nnoremap <silent> <buffer> i :call GitS_Status("ignored")<CR>' - exe 'nnoremap <silent> <buffer> s :call GitS_Status("short")<CR>' - exe 'nnoremap <silent> <buffer> v :call GitS_Status("verbose")<CR>' - " - exe 'nnoremap <silent> <buffer> a :call GitS_Status("add")<CR>' - exe 'nnoremap <silent> <buffer> c :call GitS_Status("checkout")<CR>' - exe 'nnoremap <silent> <buffer> ch :call GitS_Status("checkout-head")<CR>' - exe 'nnoremap <silent> <buffer> od :call GitS_Status("diff")<CR>' - exe 'nnoremap <silent> <buffer> ow :call GitS_Status("diff-word")<CR>' - exe 'nnoremap <silent> <buffer> of :call GitS_Status("edit")<CR>' - exe 'nnoremap <silent> <buffer> oj :call GitS_Status("edit")<CR>' - exe 'nnoremap <silent> <buffer> ol :call GitS_Status("log")<CR>' - exe 'nnoremap <silent> <buffer> r :call GitS_Status("reset")<CR>' - exe 'nnoremap <silent> <buffer> D :call GitS_Status("delete")<CR>' - " - if s:EnabledGitBash - exe 'nnoremap <silent> <buffer> ap :call GitS_Status("add-patch")<CR>' - exe 'nnoremap <silent> <buffer> cp :call GitS_Status("checkout-patch")<CR>' - exe 'nnoremap <silent> <buffer> rp :call GitS_Status("reset-patch")<CR>' - endif - " - endif - " - call s:ChangeCWD ( buf ) - " - if a:action == 'update' - " - if update_only - let limited_dir = b:GitSupport_StatusLimitedDir - else - let b:GitSupport_StatusLimitedDir = limited_dir - endif - " - elseif a:action == 'ignored' - let b:GitSupport_IgnoredOption = ( b:GitSupport_IgnoredOption + 1 ) % 2 - elseif a:action == 'short' - if b:GitSupport_ShortOption == 0 - " switch to short - let b:GitSupport_ShortOption = 1 - setlocal filetype=gitssshort - else - " switch to normal - let b:GitSupport_ShortOption = 0 - setlocal filetype=gitsstatus - endif - elseif a:action == 'verbose' - let b:GitSupport_VerboseOption = ( b:GitSupport_VerboseOption + 1 ) % 2 - endif - " - let cmd = s:Git_Executable.' status' - " - if limited_dir != '' - let cmd .= ' '.shellescape( limited_dir ) - endif - " - if b:GitSupport_IgnoredOption == 1 && s:HasStatusIgnore | let cmd .= ' --ignored' | endif - if b:GitSupport_ShortOption == 1 && s:HasStatusBranch | let cmd .= ' --short --branch' | endif - if b:GitSupport_ShortOption == 1 && ! s:HasStatusBranch | let cmd .= ' --short' | endif - if b:GitSupport_VerboseOption == 1 | let cmd .= ' --verbose' | endif - " - call s:UpdateGitBuffer ( cmd, update_only ) - " -endfunction " ---------- end of function GitS_Status ---------- -" -"------------------------------------------------------------------------------- -" GitS_Tag : execute 'git tag ...' {{{1 -" -" Flags: -> s:StandardRun -"------------------------------------------------------------------------------- -" -function! GitS_Tag( param, flags ) - " - let args = s:GitCmdLineArgs ( a:param ) - " - if empty ( a:param ) - \ || index ( args, '-l', 1 ) != -1 - \ || index ( args, '--list', 1 ) != -1 - \ || index ( args, '--contains', 1 ) != -1 - \ || match ( args, '^-n\d\?', 1 ) != -1 - call GitS_TagList ( 'update', a:param ) - else - return s:StandardRun ( 'tag', a:param, a:flags, 'c' ) - endif - " - " -endfunction " ---------- end of function GitS_Tag ---------- -" -"------------------------------------------------------------------------------- -" GitS_TagList : execute 'git tag' (list tags) {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:TagList_GetTag : Get the tag under the cursor. {{{2 -" -" Parameters: -" - -" Returns: -" <tag-name> - the name of the tag (string) -" -" If the name could not be obtained returns an empty string. -"------------------------------------------------------------------------------- -" -function! s:TagList_GetTag() - " - let t_pos = search ( '\m\_^\S', 'bcnW' ) " the position of the tag name - " - if t_pos == 0 - return '' - endif - " - return matchstr ( getline(t_pos), '^\S\+' ) - " -endfunction " ---------- end of function s:TagList_GetTag ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -function! GitS_TagList( action, ... ) - " - let update_only = 0 - let param = '' - " - if a:action == 'help' - let txt = s:HelpTxtStd."\n\n" - let txt .= "tag under cursor ...\n" - let txt .= "ch : checkout\n" - let txt .= "cr : use as starting point for creating a new branch\n" - let txt .= "de : delete\n" - let txt .= "me : merge with current branch\n" - let txt .= "sh : show the tag\n" - let txt .= "cs : show the commit\n" - echo txt - return - elseif a:action == 'quit' - close - return - elseif a:action == 'update' - " - let update_only = a:0 == 0 - " - if update_only | " run again with old parameters - elseif empty( a:1 ) | let param = '' - else | let param = a:1 - endif - " - elseif -1 != index ( [ 'checkout', 'create', 'delete', 'merge', 'show-tag', 'show-commit' ], a:action ) - " - let t_name = s:TagList_GetTag () - " - if t_name == '' - return s:ErrorMsg ( 'No tag under the cursor.' ) - endif - " - if a:action == 'checkout' - call GitS_Checkout( shellescape(t_name), 'c' ) - elseif a:action == 'create' - return s:AssembleCmdLine ( ':GitBranch ', ' '.t_name ) - elseif a:action == 'delete' - call GitS_Tag( '-d '.shellescape(t_name), 'c' ) - elseif a:action == 'merge' - call GitS_Merge( 'direct', shellescape(t_name), 'c' ) - elseif a:action == 'show-tag' - call GitS_Show( 'update', shellescape(t_name), '' ) - elseif a:action == 'show-commit' - call GitS_Show( 'update', shellescape(t_name).'^{commit}', '' ) - endif - " - return - else - echoerr 'Unknown action "'.a:action.'".' - return - endif - " - let buf = s:CheckCWD () - " - if s:OpenGitBuffer ( 'Git - tag' ) - " - let b:GitSupport_TagListFlag = 1 - " -" setlocal filetype=gitslog - " - exe 'nnoremap <buffer> <S-F1> :call GitS_TagList("help")<CR>' - exe 'nnoremap <silent> <buffer> q :call GitS_TagList("quit")<CR>' - exe 'nnoremap <silent> <buffer> u :call GitS_TagList("update")<CR>' - " - exe 'nnoremap <silent> <buffer> ch :call GitS_TagList("checkout")<CR>' - exe 'nnoremap <expr> <buffer> cr GitS_TagList("create")' - exe 'nnoremap <silent> <buffer> de :call GitS_TagList("delete")<CR>' - exe 'nnoremap <silent> <buffer> me :call GitS_TagList("merge")<CR>' - exe 'nnoremap <silent> <buffer> sh :call GitS_TagList("show-tag")<CR>' - exe 'nnoremap <silent> <buffer> cs :call GitS_TagList("show-commit")<CR>' - endif - " - call s:ChangeCWD ( buf ) - " - if update_only - let param = b:GitSupport_Param - else - let b:GitSupport_Param = param - endif - " - let cmd = s:Git_Executable.' tag '.param - " - call s:UpdateGitBuffer ( cmd, update_only ) - " -endfunction " ---------- end of function GitS_TagList ---------- -" -"------------------------------------------------------------------------------- -" GitS_GitK : execute 'gitk ...' {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_GitK( param ) - " - " :TODO:10.12.2013 20:14:WM: graphics available? - if s:EnabledGitK == 0 - return s:ErrorMsg ( s:DisableGitKMessage, s:DisableGitKReason ) - elseif s:FoundGitKScript == 0 - return s:ErrorMsg ( s:DisableGitKMessage, s:GitKScriptReason ) - endif - " - let param = escape( a:param, '%#' ) - " - if s:MSWIN - " :TODO:02.01.2014 13:00:WM: Windows: try the shell command 'start' - silent exe '!start '.s:Git_GitKExecutable.' '.s:Git_GitKScript.' '.param - else - silent exe '!'.s:Git_GitKExecutable.' '.s:Git_GitKScript.' '.param.' &' - endif - " -endfunction " ---------- end of function GitS_GitK ---------- -" -"------------------------------------------------------------------------------- -" GitS_GitBash : execute 'xterm git ...' or "git bash" {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_GitBash( param ) - " - " :TODO:10.12.2013 20:14:WM: graphics available? - if s:EnabledGitBash == 0 - return s:ErrorMsg ( s:DisableGitBashMessage, s:DisableGitBashReason ) - endif - " - let title = 'git '.matchstr( a:param, '\S\+' ) - let param = escape( a:param, '%#' ) - " - if s:MSWIN && param =~ '^\s*$' - " no parameters: start interactive mode in background - silent exe '!start '.s:Git_GitBashExecutable.' --login -i' - elseif s:MSWIN - " otherwise: block editor and execute command - silent exe '!'.s:Git_GitBashExecutable.' --login -c '.shellescape ( 'git '.param ) - else - " UNIX: block editor and execute command, wait for confirmation afterwards - silent exe '!'.s:Git_GitBashExecutable.' '.g:Xterm_Options - \ .' -title '.shellescape( title ) - \ .' -e '.shellescape( s:Git_Executable.' '.param.' ; echo "" ; read -p " ** PRESS ENTER ** " dummy ' ) - endif - " -endfunction " ---------- end of function GitS_GitBash ---------- -" -"------------------------------------------------------------------------------- -" GitS_GitEdit : edit a Git config file {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_GitEdit( fileid ) - " - let filename = '' - " - if a:fileid == 'config-global' - let filename = expand ( '$HOME/.gitconfig' ) - elseif a:fileid == 'config-local' - let filename = expand ( '$GIT_CONFIG' ) - if filename == '$GIT_CONFIG' - let filename = s:GitRepoDir ( 'git/config' ) - endif - elseif a:fileid == 'description' - let filename = s:GitRepoDir ( 'git/description' ) - elseif a:fileid == 'hooks' - let filename = s:GitRepoDir ( 'git/hooks/' ) - elseif a:fileid == 'ignore-global' - let filename = s:GitGetConfig ( 'core.excludesfile' ) - elseif a:fileid == 'ignore-local' - let filename = s:GitRepoDir ( 'top/.gitignore' ) - elseif a:fileid == 'ignore-private' - let filename = s:GitRepoDir ( 'git/info/exclude' ) - elseif a:fileid == 'modules' - let filename = s:GitRepoDir ( 'top/.gitmodules' ) - endif - " - if filename == '' - call s:ErrorMsg ( 'No file with ID "'.a:fileid.'".' ) - else - exe 'spl '.fnameescape( filename ) - endif - " -endfunction " ---------- end of function GitS_GitEdit ---------- -" -"------------------------------------------------------------------------------- -" GitS_PluginHelp : Plug-in help. {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_PluginHelp( topic ) - try - silent exe 'help '.a:topic - catch - exe 'helptags '.s:plugin_dir.'/doc' - silent exe 'help '.a:topic - endtry -endfunction " ---------- end of function GitS_PluginHelp ---------- -" -"------------------------------------------------------------------------------- -" GitS_PluginSettings : Print the settings on the command line. {{{1 -"------------------------------------------------------------------------------- -" -function! GitS_PluginSettings( verbose ) - " - if s:MSWIN | let sys_name = 'Windows' - elseif s:UNIX | let sys_name = 'UNIX' - else | let sys_name = 'unknown' | endif - " - if s:Enabled | let git_e_status = ' (version '.s:GitVersion.')' - else | let git_e_status = ' (not executable)' - endif - let gitk_e_status = s:EnabledGitK ? '' : ' (not executable)' - let gitk_s_status = s:FoundGitKScript ? '' : ' (not found)' - let gitbash_status = s:EnabledGitBash ? '' : ' (not executable)' - " - let file_options_status = filereadable ( s:Git_CmdLineOptionsFile ) ? '' : ' (not readable)' - " - let txt = " Git-Support settings\n\n" - \ .' plug-in installation : '.s:installation.' on '.sys_name."\n" - \ .' git executable : '.s:Git_Executable.git_e_status."\n" - \ .' gitk executable : '.s:Git_GitKExecutable.gitk_e_status."\n" - if ! empty ( s:Git_GitKScript ) - let txt .= - \ ' gitk script : '.s:Git_GitKScript.gitk_s_status."\n" - endif - let txt .= - \ ' git bash executable : '.s:Git_GitBashExecutable.gitbash_status."\n" - if s:UNIX && a:verbose >= 1 - let txt .= ' xterm options : "'.g:Xterm_Options."\"\n" - endif - if a:verbose >= 1 - let txt .= "\n" - \ .' expand empty : checkout: "'.g:Git_CheckoutExpandEmpty.'" ; diff: "'.g:Git_DiffExpandEmpty.'" ; reset: "'.g:Git_ResetExpandEmpty."\"\n" - \ .' open fold after jump : "'.g:Git_OpenFoldAfterJump."\"\n" - \ .' status staged open diff : "'.g:Git_StatusStagedOpenDiff."\"\n\n" - \ .' cmd-line options file : '.s:Git_CmdLineOptionsFile.file_options_status."\n" -" \ .' commit editor : "'.g:Git_Editor."\"\n" - endif - let txt .= - \ "________________________________________________________________________________\n" - \ ." Git-Support, Version ".g:GitSupport_Version." / Wolfgang Mehner / wolfgang-mehner@web.de\n\n" - " - if a:verbose == 2 - split GitSupport_Settings.txt - put = txt - else - echo txt - endif -endfunction " ---------- end of function GitS_PluginSettings ---------- -" -"------------------------------------------------------------------------------- -" s:LoadCmdLineOptions : Load s:CmdLineOptions {{{1 -"------------------------------------------------------------------------------- -" -function! s:LoadCmdLineOptions () - " - let s:CmdLineOptions = {} - let current_list = [] - " - if ! filereadable ( s:Git_CmdLineOptionsFile ) - return - endif - " - for line in readfile ( s:Git_CmdLineOptionsFile ) - let name = matchstr ( line, '^\s*\zs.*\S\ze\s*$' ) - " - if line =~ '^\S' - let current_list = [] - let s:CmdLineOptions[ name ] = current_list - else - call add ( current_list, name ) - endif - endfor -endfunction " ---------- end of function s:LoadCmdLineOptions ---------- -" -call s:LoadCmdLineOptions () -" -"------------------------------------------------------------------------------- -" s:CmdLineComplete : Command line completion. {{{1 -"------------------------------------------------------------------------------- -" -function! s:CmdLineComplete ( mode, ... ) - " - let forward = 1 - " - if a:0 >= 1 && a:1 == 1 - let forward = 0 - endif - " - let cmdline = getcmdline() - let cmdpos = getcmdpos() - 1 - " - let cmdline_tail = strpart ( cmdline, cmdpos ) - let cmdline_head = strpart ( cmdline, 0, cmdpos ) - " - let idx = match ( cmdline_head, '[^[:blank:]:]*$' ) - " - " prefixed by --option= - if a:mode != 'command' && -1 != match ( strpart ( cmdline_head, idx ), '^--[^=]\+=' ) - let idx2 = matchend ( strpart ( cmdline_head, idx ), '^--[^=]\+=' ) - if idx2 >= 0 - let idx += idx2 - endif - endif - " - " for a branch or tag, split at a ".." or "..." - if a:mode == 'branch' || a:mode == 'tag' - let idx2 = matchend ( strpart ( cmdline_head, idx ), '\.\.\.\?' ) - if idx2 >= 0 - let idx += idx2 - endif - endif - " - let cmdline_pre = strpart ( cmdline_head, 0, idx ) - " - " not a word, skip completion - if idx < 0 - return cmdline_head.cmdline_tail - endif - " - " s:vars initial if first time or changed cmdline - if ! exists('b:GitSupport_NewCmdLine') || cmdline_head != b:GitSupport_NewCmdLine || a:mode != b:GitSupport_CurrentMode - " - let b:GitSupport_NewCmdLine = '' - let b:GitSupport_CurrentMode = a:mode - " - let b:GitSupport_WordPrefix = strpart ( cmdline_head, idx ) - let b:GitSupport_WordMatch = escape ( b:GitSupport_WordPrefix, '\' ) - let b:GitSupport_WordList = [ b:GitSupport_WordPrefix ] - let b:GitSupport_WordIndex = 0 - " - if a:mode == 'branch' - let [ suc, txt ] = s:StandardRun ( 'branch', '-a', 't' ) - " - for part in split( txt, "\n" ) + [ 'HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'MERGE_HEAD' ] - " remove leading whitespaces, "*" (current branch), and "remotes/" - " remove trailing "-> ..." (as in "origin/HEAD -> origin/master") - let branch = matchstr( part, '^[ *]*\%(remotes\/\)\?\zs.\{-}\ze\%(\s*->.*\)\?$' ) - if -1 != match( branch, '\V\^'.b:GitSupport_WordMatch ) - call add ( b:GitSupport_WordList, branch ) - endif - endfor - elseif a:mode == 'command' - let suc = 0 " initialized variable 'suc' needed below - let use_list = s:GitCommands - let sub_cmd = matchstr ( cmdline_pre, - \ '\c\_^Git\%(!\|Run\|Buf\|Bash\)\?\s\+\zs[a-z\-]\+\ze\s' - \ .'\|'.'\c\_^Git\zs[a-z]\+\ze\s' ) - " - if sub_cmd != '' - let sub_cmd = tolower ( sub_cmd ) - if has_key ( s:CmdLineOptions, sub_cmd ) - let use_list = get ( s:CmdLineOptions, sub_cmd, s:GitCommands ) - endif - endif - " - for part in use_list - if -1 != match( part, '\V\^'.b:GitSupport_WordMatch ) - call add ( b:GitSupport_WordList, part ) - endif - endfor - elseif a:mode == 'remote' - let [ suc, txt ] = s:StandardRun ( 'remote', '', 't' ) - " - for part in split( txt, "\n" ) - if -1 != match( part, '\V\^'.b:GitSupport_WordMatch ) - call add ( b:GitSupport_WordList, part ) - endif - endfor - elseif a:mode == 'tag' - let [ suc, txt ] = s:StandardRun ( 'tag', '', 't' ) - " - for part in split( txt, "\n" ) - if -1 != match( part, '\V\^'.b:GitSupport_WordMatch ) - call add ( b:GitSupport_WordList, part ) - endif - endfor - else - return cmdline_head.cmdline_tail - endif - " - if suc != 0 - return cmdline_head.cmdline_tail - endif - " - endif - " - if forward - let b:GitSupport_WordIndex = ( b:GitSupport_WordIndex + 1 ) % len( b:GitSupport_WordList ) - else - let b:GitSupport_WordIndex = ( b:GitSupport_WordIndex - 1 + len( b:GitSupport_WordList ) ) % len( b:GitSupport_WordList ) - endif - " - let word = b:GitSupport_WordList[ b:GitSupport_WordIndex ] - " - " new cmdline - let b:GitSupport_NewCmdLine = cmdline_pre.word - " - " overcome map silent - " (silent map together with this trick seems to look prettier) - call feedkeys(" \<bs>") - " - " set new cmdline cursor postion - call setcmdpos ( len(b:GitSupport_NewCmdLine)+1 ) - " - return b:GitSupport_NewCmdLine.cmdline_tail - " -endfunction " ---------- end of function s:CmdLineComplete ---------- -" -"------------------------------------------------------------------------------- -" s:InitMenus : Initialize menus. {{{1 -"------------------------------------------------------------------------------- -" -function! s:InitMenus() - - if ! has ( 'menu' ) - return - endif - - let ahead = 'anoremenu '.s:Git_RootMenu.'.' - - exe ahead.'Git :echo "This is a menu header!"<CR>' - exe ahead.'-Sep00- :' - - " Commands {{{2 - let ahead = 'anoremenu '.s:Git_RootMenu.'.&git\ \.\.\..' - let vhead = 'vnoremenu '.s:Git_RootMenu.'.&git\ \.\.\..' - - exe ahead.'Commands<TAB>Git :echo "This is a menu header!"<CR>' - exe ahead.'-Sep00- :' - - exe ahead.'&add<TAB>:GitAdd :GitAdd<space>' - exe ahead.'&blame<TAB>:GitBlame :GitBlame<space>' - exe vhead.'&blame<TAB>:GitBlame :GitBlame<space>' - exe ahead.'&branch<TAB>:GitBranch :GitBranch<space>' - exe ahead.'&checkout<TAB>:GitCheckout :GitCheckout<space>' - exe ahead.'&commit<TAB>:GitCommit :GitCommit<space>' - exe ahead.'&diff<TAB>:GitDiff :GitDiff<space>' - exe ahead.'&fetch<TAB>:GitFetch :GitFetch<space>' - exe ahead.'&grep<TAB>:GitGrep :GitGrep<space>' - exe ahead.'&help<TAB>:GitHelp :GitHelp<space>' - exe ahead.'&log<TAB>:GitLog :GitLog<space>' - exe ahead.'&merge<TAB>:GitMerge :GitMerge<space>' - exe ahead.'&mv<TAB>:GitMv :GitMv<space>' - exe ahead.'&pull<TAB>:GitPull :GitPull<space>' - exe ahead.'&push<TAB>:GitPush :GitPush<space>' - exe ahead.'&remote<TAB>:GitRemote :GitRemote<space>' - exe ahead.'&rm<TAB>:GitRm :GitRm<space>' - exe ahead.'&reset<TAB>:GitReset :GitReset<space>' - exe ahead.'&show<TAB>:GitShow :GitShow<space>' - exe ahead.'&stash<TAB>:GitStash :GitStash<space>' - exe ahead.'&status<TAB>:GitStatus :GitStatus<space>' - exe ahead.'&tag<TAB>:GitTag :GitTag<space>' - - exe ahead.'-Sep01- :' - exe ahead.'run\ git&k<TAB>:GitK :GitK<space>' - exe ahead.'run\ git\ &bash<TAB>:GitBash :GitBash<space>' - - " Current File {{{2 - let shead = 'anoremenu <silent> '.s:Git_RootMenu.'.&file.' - let vhead = 'vnoremenu <silent> '.s:Git_RootMenu.'.&file.' - - exe shead.'Current\ File<TAB>Git :echo "This is a menu header!"<CR>' - exe shead.'-Sep00- :' - - exe shead.'&add<TAB>:GitAdd :GitAdd -- %<CR>' - exe shead.'&blame<TAB>:GitBlame :GitBlame -- %<CR>' - exe vhead.'&blame<TAB>:GitBlame :GitBlame -- %<CR>' - exe shead.'&checkout<TAB>:GitCheckout :GitCheckout -- %<CR>' - exe shead.'&diff<TAB>:GitDiff :GitDiff -- %<CR>' - exe shead.'&diff\ --cached<TAB>:GitDiff :GitDiff --cached -- %<CR>' - exe shead.'&log<TAB>:GitLog :GitLog --stat -- %<CR>' - exe shead.'r&m<TAB>:GitRm :GitRm -- %<CR>' - exe shead.'&reset<TAB>:GitReset :GitReset -q -- %<CR>' - - " Specials {{{2 - let ahead = 'anoremenu '.s:Git_RootMenu.'.s&pecials.' - let shead = 'anoremenu <silent> '.s:Git_RootMenu.'.s&pecials.' - - exe ahead.'Specials<TAB>Git :echo "This is a menu header!"<CR>' - exe ahead.'-Sep00- :' - - exe ahead.'&commit,\ msg\ from\ file<TAB>:GitCommitFile :GitCommitFile<space>' - exe shead.'&commit,\ msg\ from\ merge<TAB>:GitCommitMerge :GitCommitMerge<CR>' - exe ahead.'&commit,\ msg\ from\ cmdline<TAB>:GitCommitMsg :GitCommitMsg<space>' - exe ahead.'-Sep01- :' - - exe ahead.'&grep,\ use\ top-level\ dir<TAB>:GitGrepTop :GitGrepTop<space>' - exe ahead.'&merge,\ upstream\ branch<TAB>:GitMergeUpstream :GitMergeUpstream<space>' - exe shead.'&stash\ list<TAB>:GitSlist :GitSlist<CR>' - - " Custom Menu {{{2 - if ! empty ( s:Git_CustomMenu ) - - let ahead = 'anoremenu '.s:Git_RootMenu.'.&custom.' - let ahead = 'anoremenu <silent> '.s:Git_RootMenu.'.&custom.' - - exe ahead.'Custom<TAB>Git :echo "This is a menu header!"<CR>' - exe ahead.'-Sep00- :' - - call s:GenerateCustomMenu ( s:Git_RootMenu.'.custom', s:Git_CustomMenu ) - - exe ahead.'-HelpSep- :' - exe ahead.'help\ (custom\ menu)<TAB>:GitSupportHelp :call GitS_PluginHelp("gitsupport-menus")<CR>' - - endif - - " Edit {{{2 - let ahead = 'anoremenu '.s:Git_RootMenu.'.&edit.' - let shead = 'anoremenu <silent> '.s:Git_RootMenu.'.&edit.' - - exe ahead.'Edit File<TAB>Git :echo "This is a menu header!"<CR>' - exe ahead.'-Sep00- :' - - for fileid in s:EditFileIDs - let filepretty = substitute ( fileid, '-', '\\ ', 'g' ) - exe shead.'&'.filepretty.'<TAB>:GitEdit :GitEdit '.fileid.'<CR>' - endfor - - " Help {{{2 - let ahead = 'anoremenu '.s:Git_RootMenu.'.help.' - let shead = 'anoremenu <silent> '.s:Git_RootMenu.'.help.' - - exe ahead.'Help<TAB>Git :echo "This is a menu header!"<CR>' - exe ahead.'-Sep00- :' - - exe shead.'help\ (Git-Support)<TAB>:GitSupportHelp :call GitS_PluginHelp("gitsupport")<CR>' - exe shead.'plug-in\ settings<TAB>:GitSupportSettings :call GitS_PluginSettings(0)<CR>' - - " Main Menu - open buffers {{{2 - let ahead = 'anoremenu '.s:Git_RootMenu.'.' - let shead = 'anoremenu <silent> '.s:Git_RootMenu.'.' - - exe ahead.'-Sep01- :' - - exe ahead.'&run\ git<TAB>:Git :Git<space>' - exe shead.'&branch<TAB>:GitBranch :GitBranch<CR>' - exe ahead.'&help\ \.\.\.<TAB>:GitHelp :GitHelp<space>' - exe shead.'&log<TAB>:GitLog :GitLog<CR>' - exe shead.'&remote<TAB>:GitRemote :GitRemote<CR>' - exe shead.'&stash\ list<TAB>:GitSlist :GitSlist<CR>' - exe shead.'&status<TAB>:GitStatus :GitStatus<CR>' - exe shead.'&tag<TAB>:GitTag :GitTag<CR>' - " }}}2 - -endfunction " ---------- end of function s:InitMenus ---------- -" -"------------------------------------------------------------------------------- -" s:ToolMenu : Add or remove tool menu entries. {{{1 -"------------------------------------------------------------------------------- -" -function! s:ToolMenu( action ) - " - if ! has ( 'menu' ) - return - endif - " - if a:action == 'setup' - anoremenu <silent> 40.1000 &Tools.-SEP100- : - anoremenu <silent> 40.1080 &Tools.Load\ Git\ Support :call Git_AddMenus()<CR> - elseif a:action == 'loading' - aunmenu <silent> &Tools.Load\ Git\ Support - anoremenu <silent> 40.1080 &Tools.Unload\ Git\ Support :call Git_RemoveMenus()<CR> - elseif a:action == 'unloading' - aunmenu <silent> &Tools.Unload\ Git\ Support - anoremenu <silent> 40.1080 &Tools.Load\ Git\ Support :call Git_AddMenus()<CR> - endif - " -endfunction " ---------- end of function s:ToolMenu ---------- -" -"------------------------------------------------------------------------------- -" Git_AddMenus : Add menus. {{{1 -"------------------------------------------------------------------------------- -" -function! Git_AddMenus() - if s:MenuVisible == 0 - " initialize if not existing - call s:ToolMenu ( 'loading' ) - call s:InitMenus () - " the menu is now visible - let s:MenuVisible = 1 - endif -endfunction " ---------- end of function Git_AddMenus ---------- -" -"------------------------------------------------------------------------------- -" Git_RemoveMenus : Remove menus. {{{1 -"------------------------------------------------------------------------------- -" -function! Git_RemoveMenus() - if s:MenuVisible == 1 - " destroy if visible - call s:ToolMenu ( 'unloading' ) - if has ( 'menu' ) - exe 'aunmenu <silent> '.s:Git_RootMenu - endif - " the menu is now invisible - let s:MenuVisible = 0 - endif -endfunction " ---------- end of function Git_RemoveMenus ---------- -" -"------------------------------------------------------------------------------- -" Setup maps. {{{1 -"------------------------------------------------------------------------------- -" -let s:maps = [ - \ [ 'complete branch', 'g:Git_MapCompleteBranch', '<C-\>e<SID>CmdLineComplete("branch")<CR>' ], - \ [ 'complete command', 'g:Git_MapCompleteCommand', '<C-\>e<SID>CmdLineComplete("command")<CR>' ], - \ [ 'complete remote', 'g:Git_MapCompleteRemote', '<C-\>e<SID>CmdLineComplete("remote")<CR>' ], - \ [ 'complete tag', 'g:Git_MapCompleteTag', '<C-\>e<SID>CmdLineComplete("tag")<CR>' ], - \ ] -" -for [ name, map_var, cmd ] in s:maps - if exists ( map_var ) - try - silent exe 'cnoremap <silent> '.{map_var}.' '.cmd - catch /.*/ - call s:ErrorMsg ( 'Error while creating the map "'.name.'", with lhs "'.{map_var}.'":', v:exception ) - finally - endtry - endif -endfor -" -"------------------------------------------------------------------------------- -" Setup menus. {{{1 -"------------------------------------------------------------------------------- -" -" tool menu entry -call s:ToolMenu ( 'setup' ) -" -" load the menu right now? -if s:Git_LoadMenus == 'yes' - call Git_AddMenus () -endif -" }}}1 -"------------------------------------------------------------------------------- -" -" ===================================================================================== -" vim: foldmethod=marker diff --git a/plugin/latex-support.vim b/plugin/latex-support.vim index 761117c..6fb36bb 100644 --- a/plugin/latex-support.vim +++ b/plugin/latex-support.vim @@ -2,23 +2,23 @@ " " File: latex-support.vim " -" Description: LaTeX support (VIM Version 7.0+) +" Description: LaTeX support " " Write LaTeX scripts by inserting comments, statements, " variables and builtins. " " See help file latexsupport.txt . " -" VIM Version: 7.0+ +" VIM Version: 7.4+ " " Author: Wolfgang Mehner <wolfgang-mehner@web.de> " (formerly Fritz Mehner <mehner.fritz@web.de>) " " Version: see variable g:LatexSupportVersion below. " Created: 27.12.2012 -" Revision: 27.01.2017 +" Revision: 22.11.2020 " License: Copyright (c) 2012-2015, Fritz Mehner -" Copyright (c) 2016-2017, Wolfgang Mehner +" Copyright (c) 2016-2020, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the @@ -34,10 +34,10 @@ " === Basic checks === {{{1 "------------------------------------------------------------------------------- -" need at least 7.0 -if v:version < 700 +" need at least 7.4 +if v:version < 704 echohl WarningMsg - echo 'The plugin latex-support.vim needs Vim version >= 7.' + echo 'The plugin latex-support.vim needs Vim version >= 7.4' echohl None finish endif @@ -48,7 +48,7 @@ if exists("g:LatexSupportVersion") || &cp finish endif -let g:LatexSupportVersion= "1.3alpha" " version number of this script; do not change +let g:LatexSupportVersion= "2.0beta" " version number of this script; do not change "------------------------------------------------------------------------------- " === Auxiliary functions === {{{1 @@ -68,10 +68,36 @@ let g:LatexSupportVersion= "1.3alpha" " version number of this "------------------------------------------------------------------------------- function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - let { 'g:'.a:varname } = a:value + if ! exists( 'g:'.a:varname ) + let {'g:'.a:varname} = a:value endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- +endfunction + +"------------------------------------------------------------------------------- +" s:ChangeDir : Change the working directory. {{{2 +" +" Respects the local directory if 'haslocaldir' is avaiable. +" (in newer Vim version) +" +" Parameters: +" dir - the new directory, might be "-" (string) +" Returns: +" - +"------------------------------------------------------------------------------- + +let g:has_ld = exists( '*haslocaldir' ) + +function! s:ChangeDir ( dir ) + + let cmd = 'cd' + + if g:has_ld && haslocaldir() + let cmd = 'lchdir' + endif + + exec cmd fnameescape ( a:dir ) + +endfunction " ---------- end of function s:ChangeDir ---------- "------------------------------------------------------------------------------- " s:ErrorMsg : Print an error message. {{{2 @@ -111,10 +137,10 @@ endfunction " ---------- end of function s:ErrorMsg ---------- function! s:GetGlobalSetting ( varname, ... ) let lname = a:varname let gname = a:0 >= 1 ? a:1 : lname - if exists ( 'g:'.gname ) - let { 's:'.lname } = { 'g:'.gname } + if exists( 'g:'.gname ) + let {'s:'.lname} = {'g:'.gname} endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ImportantMsg : Print an important message. {{{2 @@ -160,6 +186,71 @@ function! s:Redraw ( cmd_term, cmd_gui ) endif endfunction " ---------- end of function s:Redraw ---------- +"------------------------------------------------------------------------------- +" s:ShellParseArgs : Turn cmd.-line arguments into a list. {{{2 +" +" Parameters: +" line - the command-line arguments to parse (string) +" Returns: +" list - the arguments as a list (list) +"------------------------------------------------------------------------------- + +function! s:ShellParseArgs ( line ) + + let list = [] + let curr = '' + + let line = a:line + + while line != '' + + if match ( line, '^\s' ) != -1 + " non-escaped space -> finishes current argument + let line = matchstr ( line, '^\s\+\zs.*' ) + if curr != '' + call add ( list, curr ) + let curr = '' + endif + elseif match ( line, "^'" ) != -1 + " start of a single-quoted string, parse past next single quote + let mlist = matchlist ( line, "^'\\([^']*\\)'\\(.*\\)" ) + if empty ( mlist ) + throw "ShellParseArgs:Syntax:no matching quote '" + endif + let curr .= mlist[1] + let line = mlist[2] + elseif match ( line, '^"' ) != -1 + " start of a double-quoted string, parse past next double quote + let mlist = matchlist ( line, '^"\(\%([^\"]\|\\.\)*\)"\(.*\)' ) + if empty ( mlist ) + throw 'ShellParseArgs:Syntax:no matching quote "' + endif + let curr .= substitute ( mlist[1], '\\\([\"]\)', '\1', 'g' ) + let line = mlist[2] + elseif match ( line, '^\\' ) != -1 + " escape sequence outside of a string, parse one additional character + let mlist = matchlist ( line, '^\\\(.\)\(.*\)' ) + if empty ( mlist ) + throw 'ShellParseArgs:Syntax:single backspace \' + endif + let curr .= mlist[1] + let line = mlist[2] + else + " otherwise parse up to next special char.: space, backslash, quote + let mlist = matchlist ( line, '^\([^[:space:]\\''"]\+\)\(.*\)' ) + let curr .= mlist[1] + let line = mlist[2] + endif + endwhile + + " add last argument + if curr != '' + call add ( list, curr ) + endif + + return list +endfunction " ---------- end of function s:ShellParseArgs ---------- + "------------------------------------------------------------------------------- " s:SID : Return the <SID>. {{{2 " @@ -443,7 +534,9 @@ endfunction " ---------- end of function s:Hardcopy ---------- let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") -" + +let s:NEOVIM = has("nvim") + let s:installation = '*undefined*' let s:Latex_GlobalTemplateFile = '' let s:Latex_LocalTemplateFile = '' @@ -566,12 +659,10 @@ endif " User configurable options {{{3 "------------------------------------------------------------------------------- -let s:escfilename = ' \%#[]' let s:Latex_TexFlavor = 'latex' -let s:Latex_CreateMenusDelayed = 'yes' let s:Latex_GuiSnippetBrowser = 'gui' " gui / commandline -let s:Latex_LoadMenus = 'yes' " load the menus? -let s:Latex_RootMenu = 'LaTe&X' " name of the root menu +let s:Latex_LoadMenus = 'auto' " load the menus? +let s:Latex_RootMenu = 'LaTe&X' " name of the root menu let s:Latex_Processing = 'foreground' let s:Latex_UseToolbox = 'yes' call s:ApplyDefaultSetting ( 'Latex_UseTool_make', 'yes' ) @@ -585,7 +676,6 @@ endif let s:Latex_LineEndCommColDefault = 49 let s:Latex_TemplateJumpTarget = '' let s:Latex_Wrapper = s:plugin_dir.'/latex-support/scripts/wrapper.sh' -let s:Latex_InsertFileProlog = 'yes' let s:Latex_Ctrl_j = 'yes' let s:Latex_Ctrl_d = 'yes' @@ -601,7 +691,6 @@ let s:Latex_BibtexErrorf = "------------------------------------------------------------------------------- call s:GetGlobalSetting( 'Latex_CustomTemplateFile' ) -call s:GetGlobalSetting( 'Latex_CreateMenusDelayed' ) call s:GetGlobalSetting( 'Latex_DviPdf' ) call s:GetGlobalSetting( 'Latex_DviPng' ) call s:GetGlobalSetting( 'Latex_DviPs' ) @@ -612,7 +701,6 @@ call s:GetGlobalSetting( 'Latex_Ctrl_j' ) call s:GetGlobalSetting( 'Latex_Ctrl_d' ) call s:GetGlobalSetting( 'Latex_EpsPdf' ) call s:GetGlobalSetting( 'Latex_GuiSnippetBrowser' ) -call s:GetGlobalSetting( 'Latex_InsertFileProlog' ) call s:GetGlobalSetting( 'Latex_Latex' ) call s:GetGlobalSetting( 'Latex_LineEndCommColDefault' ) call s:GetGlobalSetting( 'Latex_LoadMenus' ) @@ -633,9 +721,22 @@ call s:GetGlobalSetting( 'Latex_Typesetter' ) call s:GetGlobalSetting( 'Latex_UseToolbox' ) " overwrite the mapleader, we should not use use "\" in LaTeX -call s:ApplyDefaultSetting ( 'Latex_MapLeader', '´' ) +call s:ApplyDefaultSetting ( 'Latex_InsertFileProlog', 'yes' ) " default: do insert a file prolog +call s:ApplyDefaultSetting ( 'Latex_MapLeader', '´' ) " default: overwrite 'maplocalleader' call s:ApplyDefaultSetting ( 'Latex_Printheader', "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" ) +" adapt for backwards compatibility +if s:Latex_LoadMenus == 'no' + let s:Latex_LoadMenus = 'manual' +elseif s:Latex_LoadMenus == 'yes' + if exists ( 'g:Latex_CreateMenusDelayed' ) + let s:Latex_LoadMenus = g:Latex_CreateMenusDelayed == 'yes' ? 'auto' : 'startup' + else + " old default for 'Latex_CreateMenusDelayed' is 'yes' + let s:Latex_LoadMenus = 'auto' + endif +endif + "------------------------------------------------------------------------------- " Internal variables {{{3 "------------------------------------------------------------------------------- @@ -672,7 +773,8 @@ let s:Latex_ViewerCall = { let s:Latex_ProcessingList = [ 'foreground' ] -if has('job') +" :TODO:25.09.2017 17:17:WM: enable Windows, check how to start jobs with arguments under Windows +if has('job') && ! s:MSWIN || s:NEOVIM call add ( s:Latex_ProcessingList, 'background' ) endif @@ -930,7 +1032,7 @@ function! s:WizardTabbing() if param == "" return elseif match( param, '^\s*\d\+\(\s\+\d\+\)\{0,2}\s*$' ) < 0 - return s:WarningMsg ( 'Wrong input format.' ) + return s:WarningMsg ( ' Wrong input format.' ) endif " parse the input @@ -975,7 +1077,7 @@ function! s:WizardTabular() if param == "" return elseif match( param, '^\s*\d\+\(\s\+\d\+\)\{0,2}\s*$' ) < 0 - return s:WarningMsg ( 'Wrong input format.' ) + return s:WarningMsg ( ' Wrong input format.' ) endif " parse the input @@ -1014,21 +1116,140 @@ endfunction " ---------- end of function s:WizardTabular ---------- let s:BackgroundType = '' " type of the job let s:BackgroundStatus = -1 " status of the last job -let s:BackgroundOutput = [] " output of the last job +let s:BackgroundOutStd = [] " output of the last job +let s:BackgroundOutErr = [] " output of the last job + +"------------------------------------------------------------------------------- +" Neovim {{{2 +"------------------------------------------------------------------------------- +if s:NEOVIM + +"------------------------------------------------------------------------------- +" s:BackgroundStart : Start a background job. {{{3 +" +" Parameters: +" id - the job ID (string) +" cmd - the shell command to run (string, or list of strings) +" opt - job options (dict) +" Returns: +" - +"------------------------------------------------------------------------------- +function! s:BackgroundStart ( id, cmd, opt ) + if exists ( 's:BackgroundJob' ) + return s:WarningMsg ( 'Job "'.s:BackgroundType.'" still running.' ) + endif + + let s:BackgroundType = a:id + let s:BackgroundStatus = -1 + let s:BackgroundOutStd = [] + let s:BackgroundOutErr = [] + + let opt = copy ( a:opt ) + let opt.on_stdout = '<SNR>'.s:SID().'_BackgroundCB_IO' + let opt.on_stderr = '<SNR>'.s:SID().'_BackgroundCB_IO' + let opt.on_exit = '<SNR>'.s:SID().'_BackgroundCB_Exit' + + let s:BackgroundJob = jobstart ( a:cmd, opt ) + + if s:BackgroundJob <= 0 + call s:WarningMsg ( 'Starting "'.s:BackgroundType.'" failed!' ) + unlet s:BackgroundJob + else + call s:ImportantMsg ( 'Starting "'.s:BackgroundType.'" in background.' ) + endif + + return +endfunction " ---------- end of function s:BackgroundStart ---------- + +"------------------------------------------------------------------------------- +" s:BackgroundCB_IO : Callback for output from the background job. {{{3 +" +" Parameters: +" chn - the channel (channel) +" msg - the new line (string) +"------------------------------------------------------------------------------- +function! s:BackgroundCB_IO ( job_id, data, event ) + if a:event == 'stdout' + let s:BackgroundOutStd += a:data + elseif a:event == 'stdout' + let s:BackgroundOutErr += a:data + endif +endfunction " ---------- end of function s:BackgroundCB_IO ---------- + +"------------------------------------------------------------------------------- +" s:BackgroundCB_Exit : Callback for a finished background job. {{{3 +" +" Parameters: +" job - the job (job) +" status - the status (number) +"------------------------------------------------------------------------------- +function! s:BackgroundCB_Exit ( job_id, data, event ) + if a:data == 0 + call s:ImportantMsg ( 'Job "'.s:BackgroundType.'" finished successfully.' ) + else + call s:ImportantMsg ( 'Job "'.s:BackgroundType.'" failed (exit status '.a:data.').' ) + endif + + let s:BackgroundStatus = a:data + unlet s:BackgroundJob +endfunction " ---------- end of function s:BackgroundCB_Exit ---------- + +" }}}3 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" Vim/gVim {{{2 +"------------------------------------------------------------------------------- +else " ! s:NEOVIM + +"------------------------------------------------------------------------------- +" s:BackgroundStart : Start a background job. {{{3 +" +" Parameters: +" id - the job ID (string) +" cmd - the shell command to run (string, or list of strings) +" opt - job options (dict) +" Returns: +" - +"------------------------------------------------------------------------------- +function! s:BackgroundStart ( id, cmd, opt ) + if exists ( 's:BackgroundJob' ) + return s:WarningMsg ( 'Job "'.s:BackgroundType.'" still running.' ) + endif + + let s:BackgroundType = a:id + let s:BackgroundStatus = -1 + let s:BackgroundOutStd = [] + + let opt = copy ( a:opt ) + let opt.callback = '<SNR>'.s:SID().'_BackgroundCB_IO' + let opt.exit_cb = '<SNR>'.s:SID().'_BackgroundCB_Exit' + + let s:BackgroundJob = job_start ( a:cmd, opt ) + + if job_status ( s:BackgroundJob ) == 'fail' + call s:WarningMsg ( 'Starting "'.s:BackgroundType.'" failed!' ) + unlet s:BackgroundJob + else + call s:ImportantMsg ( 'Starting "'.s:BackgroundType.'" in background.' ) + endif + + return +endfunction " ---------- end of function s:BackgroundStart ---------- "------------------------------------------------------------------------------- -" s:BackgroundCB_IO : Callback for output from the background job. {{{2 +" s:BackgroundCB_IO : Callback for output from the background job. {{{3 " " Parameters: " chn - the channel (channel) " msg - the new line (string) "------------------------------------------------------------------------------- function! s:BackgroundCB_IO ( chn, msg ) - call add ( s:BackgroundOutput, a:msg ) + call add ( s:BackgroundOutStd, a:msg ) endfunction " ---------- end of function s:BackgroundCB_IO ---------- "------------------------------------------------------------------------------- -" s:BackgroundCB_Exit : Callback for a finished background job. {{{2 +" s:BackgroundCB_Exit : Callback for a finished background job. {{{3 " " Parameters: " job - the job (job) @@ -1045,6 +1266,10 @@ function! s:BackgroundCB_Exit ( job, status ) unlet s:BackgroundJob endfunction " ---------- end of function s:BackgroundCB_Exit ---------- +" }}}3 +"------------------------------------------------------------------------------- +endif + "------------------------------------------------------------------------------- " s:BackgroundErrors : Quickfix background errors. {{{2 "------------------------------------------------------------------------------- @@ -1052,7 +1277,7 @@ function! s:BackgroundErrors () if exists ( 's:BackgroundJob' ) return s:WarningMsg ( 'Job "'.s:BackgroundType.'" still running.' ) - elseif len ( s:BackgroundOutput ) == 0 + elseif len ( s:BackgroundOutStd ) == 0 && len ( s:BackgroundOutErr ) == 0 return s:WarningMsg ( 'Not output for last job.' ) endif @@ -1064,7 +1289,7 @@ function! s:BackgroundErrors () " run typesetter let &g:errorformat = s:Latex_LatexErrorf - let errors = join ( s:BackgroundOutput, "\n" ) + let errors = join ( s:BackgroundOutStd + s:BackgroundOutErr, "\n" ) silent exe 'cgetexpr errors' " restore current settings @@ -1120,7 +1345,7 @@ endfunction " ---------- end of function s:SetMainDocument ---------- function! s:Compile ( args ) let typesettercall = s:Latex_TypesetterCall[s:Latex_Typesetter] - let typesetter = split( s:Latex_TypesetterCall[s:Latex_Typesetter] )[0] + let typesetter = split( typesettercall )[0] if ! executable( typesetter ) return s:ErrorMsg ( 'Typesetter "'.typesetter.'" does not exist or its name is not unique.' ) endif @@ -1128,16 +1353,13 @@ function! s:Compile ( args ) let dir = '' " get the name of the source file - if a:args == '' - if s:Latex_MainDocument != '' - let source = s:Latex_MainDocument " name of the main document - let dir = fnamemodify ( source, ':p:h' ) - exe 'lchdir '.fnameescape( dir ) - else - let source = expand("%") " name of the file in the current buffer - endif - else + if a:args != '' let source = a:args + elseif s:Latex_MainDocument != '' + let source = s:Latex_MainDocument " name of the main document + let dir = fnamemodify ( source, ':p:h' ) + else + let source = expand("%") " name of the file in the current buffer endif " write source file if necessary @@ -1147,25 +1369,34 @@ function! s:Compile ( args ) cclose - try - if s:Latex_Processing == 'background' && has ( 'job' ) - if exists ( 's:BackgroundJob' ) - return s:WarningMsg ( 'Job "'.s:BackgroundType.'" still running.' ) - endif - - let s:BackgroundType = s:Latex_Typesetter - let s:BackgroundStatus = -1 - let s:BackgroundOutput = [] - - let s:BackgroundJob = job_start ( - \ typesettercall.' "'.( source ).'"', { - \ 'callback' : '<SNR>'.s:SID().'_BackgroundCB_IO', - \ 'exit_cb' : '<SNR>'.s:SID().'_BackgroundCB_Exit' - \ } ) + " --- Background Processing ---------------------------------- + if s:Latex_Processing == 'background' + try + let arg_list = s:ShellParseArgs ( typesettercall ) + [ source ] + catch /^ShellParseArgs:Syntax:/ + let msg = v:exception[ len( 'ShellParseArgs:Syntax:') : -1 ] + return s:WarningMsg ( 'syntax error while parsing typersetter arguments: '.msg, + \ ' - typersetter call: '.typesettercall ) + catch /.*/ + return s:WarningMsg ( + \ "internal error (" . v:exception . ")", + \ " - occurred at " . v:throwpoint ) + endtry + + let opt = {} + if dir != '' + let opt.cwd = dir + endif - call s:ImportantMsg ( 'Starting "'.s:Latex_Typesetter.'" in background.' ) + call s:BackgroundStart ( s:Latex_Typesetter, arg_list, opt ) + return + endif - return + " --- Foreground Processing ---------------------------------- + try + " set working directory + if dir != '' + call s:ChangeDir( dir ) endif " save current settings @@ -1182,10 +1413,14 @@ function! s:Compile ( args ) let &l:makeprg = makeprg_saved let &l:errorformat = errorf_saved + catch /.*/ + return s:WarningMsg ( + \ "internal error (" . v:exception . ")", + \ " - occurred at " . v:throwpoint ) finally " jump back to the old working directory if dir != '' - lchdir - + call s:ChangeDir( '-' ) endif endtry @@ -1202,11 +1437,17 @@ endfunction " ---------- end of function s:Compile ---------- "------------------------------------------------------------------------------- function! s:Bibtex ( args ) + let dir = '' + " get the root of the name of the current buffer - if a:args == '' - let aux_file = expand("%:r") - else + if a:args != '' let aux_file = a:args + elseif s:Latex_MainDocument != '' + let source = s:Latex_MainDocument " name of the main document + let dir = fnamemodify ( source, ':p:h' ) + let aux_file = fnamemodify ( source, ':r' ) + else + let aux_file = expand("%:r") endif " write source file if necessary @@ -1216,19 +1457,38 @@ function! s:Bibtex ( args ) cclose - " save current settings - let makeprg_saved = &l:makeprg - let errorf_saved = &l:errorformat + try + " set working directory + if dir != '' + call s:ChangeDir( dir ) + endif + + " :WORKAROUND:12.02.2018 20:25:WM: bibtex seems to have problems with absolute paths + let aux_file = fnamemodify ( aux_file, ':.' ) + + " save current settings + let makeprg_saved = &l:makeprg + let errorf_saved = &l:errorformat - " run bibtex - let &l:makeprg = s:Latex_Bibtex - let &l:errorformat = s:Latex_BibtexErrorf + " run bibtex + let &l:makeprg = s:Latex_Bibtex + let &l:errorformat = s:Latex_BibtexErrorf - exe "make! ".shellescape ( aux_file ) | " do not jump to the first error + exe "make! ".shellescape ( aux_file ) | " do not jump to the first error - " restore current settings - let &l:makeprg = makeprg_saved - let &l:errorformat = errorf_saved + " restore current settings + let &l:makeprg = makeprg_saved + let &l:errorformat = errorf_saved + catch /.*/ + return s:WarningMsg ( + \ "internal error (" . v:exception . ")", + \ " - occurred at " . v:throwpoint ) + finally + " jump back to the old working directory + if dir != '' + call s:ChangeDir( '-' ) + endif + endtry " open error window if necessary botright cwindow @@ -1324,7 +1584,7 @@ function! s:Lacheck ( args ) let v:statusmsg = '' " reset, so we are able to check it below silent exe "make ".shellescape ( source ) | " do not jump to the first error - " :TODO:26.11.2016 22:12:WM: using make! here seems to cause v:statusmsg to + " :TRICKY:26.11.2016 22:12:WM: using make! here seems to cause v:statusmsg to " never be set to a none-emtpy value " restore current settings @@ -1370,7 +1630,11 @@ function! s:View ( args ) if a:args =~ '^\s*\(dvi\|pdf\|ps\)\s*$' " :LatexView fmt let format = substitute ( a:args, '\s\+', '', 'g' ) - let targetfile = expand("%:r").'.'.format + if s:Latex_MainDocument != '' + let targetfile = fnamemodify( s:Latex_MainDocument, ':p:r' ).'.'.format + else + let targetfile = expand("%:r").'.'.format + endif elseif a:args =~ '^\s*\(dvi\|pdf\|ps\)\s' " :LatexView fmt file let mlist = matchlist ( a:args, '^\s*\(dvi\|pdf\|ps\)\s\+\(.*\)' ) @@ -1397,7 +1661,11 @@ function! s:View ( args ) endif " get the file - let targetfile = expand("%:r").'.'.format + if s:Latex_MainDocument != '' + let targetfile = fnamemodify( s:Latex_MainDocument, ':p:r' ).'.'.format + else + let targetfile = expand("%:r").'.'.format + endif endif " check the file ... @@ -1417,7 +1685,9 @@ function! s:View ( args ) endif " run the command - if s:MSWIN + if s:NEOVIM + call jobstart ( viewer.' '.targetfile, { 'detach' : 1 } ) + elseif s:MSWIN silent exe '!start '.viewer.' '.targetfile else silent exe '!'.viewer.' '.targetfile.' &' @@ -1435,46 +1705,103 @@ endfunction " ---------- end of function s:View ---------- " format - the conversion (string, can be empty) "------------------------------------------------------------------------------- function! s:Conversions ( filename, format ) -" if &filetype != 'tex' -" echomsg 'The filetype of this buffer is not "tex".' -" return -" endif - let filename = a:filename let convert = a:format " handle the conversion if convert == '' let convert = s:UserInput ( "start converter (tab exp.): ", '', 'customlist', sort( keys( s:Latex_ConverterCall ) ) ) + if convert == '' + return + endif + echo ' ' endif if ! has_key( s:Latex_ConverterCall, convert ) return s:WarningMsg ( 'Converter "'.convert.'" does not exist.' ) endif - let converter = s:Latex_ConverterCall[convert][0] - if converter == '' + let convertercall = s:Latex_ConverterCall[convert][0] + if convertercall == '' return s:WarningMsg ( 'Converter "'.convert.'" not properly configured.' ) - elseif ! executable( split(converter)[0] ) + endif + let converter = split( convertercall )[0] + if ! executable( converter ) return s:WarningMsg ( 'Converter "'.converter.'" does not exist or its name is not unique.' ) endif + let need_output_file = s:Latex_ConverterCall[convert][1] == 'yes' + cclose + let dir = '' + " handle the input file - if filename == '' + if a:filename != '' + let filename = a:filename + elseif s:Latex_MainDocument != '' + let filename = s:Latex_MainDocument " name of the main document + let dir = fnamemodify ( filename, ':p:h' ) + else let filename = expand("%") endif let fileroot = fnamemodify ( filename, ':r' ) let source = fileroot.'.'.split( convert, '-' )[0] - let logfile = fileroot.'.conversion.log' let target = '' - if s:Latex_ConverterCall[convert][1] == 'yes' - let target = shellescape ( fileroot.'.'.split( convert, '-' )[1] ) + let t_ext = split( convert, '-' )[1] + + " --- Background Processing ---------------------------------- + if s:Latex_Processing == 'background' + try + let arg_list = s:ShellParseArgs ( convertercall ) + [ source ] + catch /^ShellParseArgs:Syntax:/ + let msg = v:exception[ len( 'ShellParseArgs:Syntax:') : -1 ] + return s:WarningMsg ( 'syntax error while parsing converter arguments: '.msg, + \ ' - converter call: '.convertercall ) + catch /.*/ + return s:WarningMsg ( + \ "internal error (" . v:exception . ")", + \ " - occurred at " . v:throwpoint ) + endtry + + if need_output_file + let arg_list += [ fileroot.'.'.t_ext ] + endif + + let opt = {} + if dir != '' + let opt.cwd = dir + endif + + call s:BackgroundStart ( convert, arg_list, opt ) + return endif - silent exe '!'.converter.' '.shellescape( source ).' '.target.' > '.shellescape( logfile ) + " --- Foreground Processing ---------------------------------- + if need_output_file + let target = shellescape ( fileroot.'.'.t_ext ) + endif + let logfile = fileroot.'.conversion.log' + + try + " set working directory + if dir != '' + call s:ChangeDir( dir ) + endif + + silent exe '!'.convertercall.' '.shellescape( source ).' '.target.' > '.shellescape( logfile ) + + catch /.*/ + return s:WarningMsg ( + \ "internal error (" . v:exception . ")", + \ " - occurred at " . v:throwpoint ) + finally + " jump back to the old working directory + if dir != '' + call s:ChangeDir( '-' ) + endif + endtry if v:shell_error call s:Redraw('r!','r') " redraw after cclose, before echoing @@ -1582,10 +1909,16 @@ function! s:Texdoc( ) endif if !empty(item) - let cmd = 'texdoc '.item.' &' - call system( cmd ) - if v:shell_error - return s:ErrorMsg ( 'Shell command "'.cmd.'" failed.' ) + if s:NEOVIM + let jobid = jobstart ( 'texdoc '.item, { 'detach' : 1 } ) + if jobid <= 0 + return s:ErrorMsg ( 'Shell command "texdoc '.item.'" failed.' ) + endif + else + call system( 'texdoc '.item.' &' ) + if v:shell_error + return s:ErrorMsg ( 'Shell command "texdoc '.item.'" failed.' ) + endif endif endif endfunction " ---------- end of function s:Texdoc ---------- @@ -1706,32 +2039,6 @@ function! s:RereadTemplates () " endfunction " ---------- end of function s:RereadTemplates ---------- -"------------------------------------------------------------------------------- -" s:CheckTemplatePersonalization : Check template personalization. {{{1 -" -" Check whether the |AUTHOR| has been set in the template library. -" If not, display help on how to set up the template personalization. -"------------------------------------------------------------------------------- -let s:DoneCheckTemplatePersonalization = 0 - -function! s:CheckTemplatePersonalization () - - " check whether the templates are personalized - if s:DoneCheckTemplatePersonalization - \ || mmtemplates#core#ExpandText ( g:Latex_Templates, '|AUTHOR|' ) != 'YOUR NAME' - \ || s:Latex_InsertFileProlog != 'yes' - return - endif - - let s:DoneCheckTemplatePersonalization = 1 - - let maplead = mmtemplates#core#Resource ( g:Latex_Templates, 'get', 'property', 'Templates::Mapleader' )[0] - - redraw - call s:ImportantMsg ( 'The personal details are not set in the template library. Use the map "'.maplead.'ntw".' ) - -endfunction " ---------- end of function s:CheckTemplatePersonalization ---------- - "------------------------------------------------------------------------------- " s:CheckAndRereadTemplates : Make sure the templates are loaded. {{{1 "------------------------------------------------------------------------------- @@ -1748,7 +2055,7 @@ function! s:InsertFileHeader () call s:CheckAndRereadTemplates() " prevent insertion for a file generated from a some error - if isdirectory(expand('%:p:h')) && s:Latex_InsertFileProlog == 'yes' + if isdirectory(expand('%:p:h')) && g:Latex_InsertFileProlog == 'yes' let templ_s = mmtemplates#core#Resource ( g:Latex_Templates, 'get', 'property', 'Latex::FileSkeleton::Script' )[0] " insert templates in reverse order, always above the first line @@ -1865,9 +2172,9 @@ function! s:CreateAdditionalLatexMaps () noremap <buffer> <silent> <LocalLeader>rla :call <SID>Lacheck("")<CR> inoremap <buffer> <silent> <LocalLeader>rla <C-C>:call <SID>Lacheck("")<CR> vnoremap <buffer> <silent> <LocalLeader>rla <C-C>:call <SID>Lacheck("")<CR> - noremap <buffer> <LocalLeader>rsd :LatexMainDoc<SPACE> - inoremap <buffer> <LocalLeader>rsd <C-C>:LatexMainDoc<SPACE> - vnoremap <buffer> <LocalLeader>rsd <C-C>:LatexMainDoc<SPACE> + noremap <buffer> <LocalLeader>rmd :LatexMainDoc<SPACE> + inoremap <buffer> <LocalLeader>rmd <C-C>:LatexMainDoc<SPACE> + vnoremap <buffer> <LocalLeader>rmd <C-C>:LatexMainDoc<SPACE> noremap <buffer> <silent> <LocalLeader>re :call <SID>BackgroundErrors()<CR> inoremap <buffer> <silent> <LocalLeader>re <C-C>:call <SID>BackgroundErrors()<CR> vnoremap <buffer> <silent> <LocalLeader>re <C-C>:call <SID>BackgroundErrors()<CR> @@ -1900,8 +2207,8 @@ function! s:CreateAdditionalLatexMaps () inoremap <buffer> <LocalLeader>rp <Esc>:LatexProcessing<SPACE> vnoremap <buffer> <LocalLeader>rp <Esc>:LatexProcessing<SPACE> - nnoremap <buffer> <silent> <LocalLeader>rse :call Latex_Settings(0)<CR> - " + nnoremap <buffer> <silent> <LocalLeader>rs :call Latex_Settings(0)<CR> + noremap <buffer> <silent> <LocalLeader>rh :call <SID>Hardcopy("n")<CR> vnoremap <buffer> <silent> <LocalLeader>rh <C-C>:call <SID>Hardcopy("v")<CR> inoremap <buffer> <silent> <LocalLeader>rh <C-C>:call <SID>Hardcopy("n")<CR> @@ -2025,7 +2332,7 @@ function! s:CreateAdditionalBibtexMaps () inoremap <buffer> <silent> <LocalLeader>rbi <C-C>:call <SID>Bibtex("")<CR> vnoremap <buffer> <silent> <LocalLeader>rbi <C-C>:call <SID>Bibtex("")<CR> " - nnoremap <buffer> <silent> <LocalLeader>rse :call Latex_Settings(0)<CR> + nnoremap <buffer> <silent> <LocalLeader>rs :call Latex_Settings(0)<CR> " noremap <buffer> <silent> <LocalLeader>rh :call <SID>Hardcopy("n")<CR> vnoremap <buffer> <silent> <LocalLeader>rh <C-C>:call <SID>Hardcopy("v")<CR> @@ -2184,8 +2491,8 @@ function! s:InitMenus() exe ihead.'save\ +\ &run\ typesetter<Tab>'.esc_mapl.'rr <C-C>:call <SID>Compile("")<CR><CR>' exe ahead.'save\ +\ run\ &lacheck<Tab>'.esc_mapl.'rla :call <SID>Lacheck("")<CR>' exe ihead.'save\ +\ run\ &lacheck<Tab>'.esc_mapl.'rla <C-C>:call <SID>Lacheck("")<CR>' - exe ahead_loud.'&set\ main\ document<Tab>'.esc_mapl.'rsd :LatexMainDoc ' - exe ihead_loud.'&set\ main\ document<Tab>'.esc_mapl.'rsd <C-C>:LatexMainDoc ' + exe ahead_loud.'&set\ main\ document<Tab>'.esc_mapl.'rmd :LatexMainDoc ' + exe ihead_loud.'&set\ main\ document<Tab>'.esc_mapl.'rmd <C-C>:LatexMainDoc ' exe ahead.'view\ last\ &errors<Tab>'.esc_mapl.'re :call <SID>BackgroundErrors()<CR>' exe ihead.'view\ last\ &errors<Tab>'.esc_mapl.'re <C-C>:call <SID>BackgroundErrors()<CR>' @@ -2235,8 +2542,8 @@ function! s:InitMenus() exe ihead.'&hardcopy\ to\ FILENAME\.ps<Tab>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("n")<CR>' exe ahead.'-SEP4- :' - exe ahead.'plug-in\ &settings<Tab>'.esc_mapl.'rse :call Latex_Settings(0)<CR>' - exe ihead.'plug-in\ &settings<Tab>'.esc_mapl.'rse <C-C>:call Latex_Settings(0)<CR>' + exe ahead.'plug-in\ &settings<Tab>'.esc_mapl.'rs :call Latex_Settings(0)<CR>' + exe ihead.'plug-in\ &settings<Tab>'.esc_mapl.'rs <C-C>:call Latex_Settings(0)<CR>' " run -> choose typesetter for ts in s:Latex_TypesetterList @@ -2333,6 +2640,22 @@ function! s:RemoveMenus() endif endfunction " ---------- end of function s:RemoveMenus ---------- +"------------------------------------------------------------------------------- +" s:Initialize : Initialize templates, menus, and maps. {{{1 +"------------------------------------------------------------------------------- +function! s:Initialize ( ftype ) + if ! exists( 'g:Latex_Templates' ) + if s:Latex_LoadMenus == 'auto' | call s:AddMenus() + else | call s:RereadTemplates() + endif + endif + if a:ftype == 'latex' + call s:CreateAdditionalLatexMaps() + elseif a:ftype == 'bib' + call s:CreateAdditionalBibtexMaps() + endif +endfunction " ---------- end of function s:Initialize ---------- + "------------------------------------------------------------------------------- " Latex_Settings : Display plug-in settings. {{{1 " @@ -2349,7 +2672,9 @@ function! Latex_Settings ( verbose ) if s:MSWIN | let sys_name = 'Windows' elseif s:UNIX | let sys_name = 'UN*X' else | let sys_name = 'unknown' | endif - " + if s:NEOVIM | let vim_name = 'nvim' + else | let vim_name = has('gui_running') ? 'gvim' : 'vim' | endif + let txt = " LaTeX-Support settings\n\n" " template settings: macros, style, ... if exists ( 'g:Latex_Templates' ) @@ -2364,7 +2689,7 @@ function! Latex_Settings ( verbose ) let txt .= " templates : -not loaded-\n\n" endif " plug-in installation - let txt .= ' plugin installation : '.s:installation.' on '.sys_name."\n" + let txt .= ' plugin installation : '.s:installation.' in '.vim_name.' on '.sys_name."\n" " toolbox if s:Latex_UseToolbox == 'yes' let toollist = mmtoolbox#tools#GetList ( s:Latex_Toolbox ) @@ -2386,7 +2711,7 @@ function! Latex_Settings ( verbose ) else let txt .= " template files : -not loaded-\n" endif - let txt = txt.' code snippet directory : "'.g:Latex_CodeSnippets."\"\n" + let txt = txt.' code snippet directory : "'.s:Latex_CodeSnippets."\"\n" " ----- dictionaries ------------------------ if !empty(g:Latex_Dictionary_File) let ausgabe= &dictionary @@ -2397,8 +2722,8 @@ function! Latex_Settings ( verbose ) if a:verbose >= 1 let txt .= "\n" \ .' mapleader : "'.g:Latex_MapLeader."\"\n" - \ .' load menus / delayed : "'.s:Latex_LoadMenus.'" / "'.s:Latex_CreateMenusDelayed."\"\n" - \ .' insert file prolog : "'.s:Latex_InsertFileProlog."\"\n" + \ .' load menus : "'.s:Latex_LoadMenus."\"\n" + \ .' insert file prolog : "'.g:Latex_InsertFileProlog."\"\n" endif let txt = txt."\n" let txt = txt.' typesetter : "'.s:Latex_TypesetterCall[s:Latex_Typesetter]."\"\n" @@ -2435,7 +2760,7 @@ endif call s:ToolMenu ( 'setup' ) " load the menu right now? -if s:Latex_LoadMenus == 'yes' && s:Latex_CreateMenusDelayed == 'no' +if s:Latex_LoadMenus == 'startup' call s:AddMenus () endif @@ -2455,39 +2780,24 @@ command! -nargs=? -complete=custom,<SID>GetTypesetterList LatexTypesetter cal command! -nargs=? -complete=custom,<SID>GetProcessingList LatexProcessing call <SID>SetProcessing(<q-args>) if has( 'autocmd' ) + augroup LatexSupport + + " In the absence of any LaTeX keywords, the default filetype for *.tex files is 'plaintex'. + " This means new files have this filetype. + if s:Latex_TexFlavor == 'latex' + autocmd FileType plaintex set filetype=tex | " COMMENT: g:Latex_TexFlavor == 'latex' + endif + + " create menus and maps + autocmd FileType tex call s:Initialize('latex') + autocmd FileType bib call s:Initialize('bib') - " In the absence of any LaTeX keywords, the default filetype for *.tex files is 'plaintex'. - " This means new files have this filetype. - - autocmd FileType * - \ if &filetype == 'plaintex' && s:Latex_TexFlavor == 'latex' | - \ set filetype=tex | - \ endif | - \ if &filetype == 'tex' | - \ if ! exists( 'g:Latex_Templates' ) | - \ if s:Latex_LoadMenus == 'yes' | call s:AddMenus () | - \ else | call s:RereadTemplates () | - \ endif | - \ endif | - \ call s:CreateAdditionalLatexMaps () | - \ call s:CheckTemplatePersonalization() | - \ endif - - autocmd FileType * - \ if &filetype == 'bib' | - \ if ! exists( 'g:Latex_Templates' ) | - \ if s:Latex_LoadMenus == 'yes' | call s:AddMenus () | - \ else | call s:RereadTemplates () | - \ endif | - \ endif | - \ call s:CreateAdditionalBibtexMaps () | - \ call s:CheckTemplatePersonalization() | - \ endif - - if s:Latex_TexFlavor == 'latex' && s:Latex_InsertFileProlog == 'yes' - autocmd BufNewFile *.tex call s:InsertFileHeader() + " insert file header + if s:Latex_TexFlavor == 'latex' + autocmd BufNewFile *.tex call s:InsertFileHeader() | " COMMENT: g:Latex_TexFlavor == 'latex' endif + augroup END endif " }}}1 "------------------------------------------------------------------------------- diff --git a/plugin/lua-support.vim b/plugin/lua-support.vim index 67bac0b..a4f31dd 100644 --- a/plugin/lua-support.vim +++ b/plugin/lua-support.vim @@ -2,7 +2,7 @@ " " File: lua-support.vim " -" Description: Lua IDE for Vim/gVim. +" Description: Lua IDE for Vim/gVim/Neovim. " " See help file luasupport.txt . " @@ -11,8 +11,8 @@ " Organization: " Version: see variable g:Lua_Version below " Created: 26.03.2014 -" Revision: 02.07.2017 -" License: Copyright (c) 2014-2017, Wolfgang Mehner +" Revision: 19.04.2019 +" License: Copyright (c) 2014-2019, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the @@ -42,7 +42,7 @@ if &cp || ( exists('g:Lua_Version') && ! exists('g:Lua_DevelopmentOverwrite') ) finish endif -let g:Lua_Version= '1.0.1pre' " version number of this script; do not change +let g:Lua_Version= '1.1alpha' " version number of this script; do not change "------------------------------------------------------------------------------- " === Auxiliary functions === {{{1 @@ -62,10 +62,10 @@ let g:Lua_Version= '1.0.1pre' " version number of this script; do not change "------------------------------------------------------------------------------- function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - let { 'g:'.a:varname } = a:value + if ! exists( 'g:'.a:varname ) + let {'g:'.a:varname} = a:value endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ErrorMsg : Print an error message. {{{2 @@ -84,7 +84,7 @@ function! s:ErrorMsg ( ... ) echomsg line endfor echohl None -endfunction " ---------- end of function s:ErrorMsg ---------- +endfunction "------------------------------------------------------------------------------- " s:GetGlobalSetting : Get a setting from a global variable. {{{2 @@ -105,10 +105,10 @@ endfunction " ---------- end of function s:ErrorMsg ---------- function! s:GetGlobalSetting ( varname, ... ) let lname = a:varname let gname = a:0 >= 1 ? a:1 : lname - if exists ( 'g:'.gname ) - let { 's:'.lname } = { 'g:'.gname } + if exists( 'g:'.gname ) + let {'s:'.lname} = {'g:'.gname} endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ImportantMsg : Print an important message. {{{2 @@ -175,6 +175,71 @@ function! s:ShellEscExec ( exec ) endif endfunction " ---------- end of function s:ShellEscExec ---------- +"------------------------------------------------------------------------------- +" s:ShellParseArgs : Turn cmd.-line arguments into a list. {{{2 +" +" Parameters: +" line - the command-line arguments to parse (string) +" Returns: +" list - the arguments as a list (list) +"------------------------------------------------------------------------------- + +function! s:ShellParseArgs ( line ) + + let list = [] + let curr = '' + + let line = a:line + + while line != '' + + if match ( line, '^\s' ) != -1 + " non-escaped space -> finishes current argument + let line = matchstr ( line, '^\s\+\zs.*' ) + if curr != '' + call add ( list, curr ) + let curr = '' + endif + elseif match ( line, "^'" ) != -1 + " start of a single-quoted string, parse past next single quote + let mlist = matchlist ( line, "^'\\([^']*\\)'\\(.*\\)" ) + if empty ( mlist ) + throw "ShellParseArgs:Syntax:no matching quote '" + endif + let curr .= mlist[1] + let line = mlist[2] + elseif match ( line, '^"' ) != -1 + " start of a double-quoted string, parse past next double quote + let mlist = matchlist ( line, '^"\(\%([^\"]\|\\.\)*\)"\(.*\)' ) + if empty ( mlist ) + throw 'ShellParseArgs:Syntax:no matching quote "' + endif + let curr .= substitute ( mlist[1], '\\\([\"]\)', '\1', 'g' ) + let line = mlist[2] + elseif match ( line, '^\\' ) != -1 + " escape sequence outside of a string, parse one additional character + let mlist = matchlist ( line, '^\\\(.\)\(.*\)' ) + if empty ( mlist ) + throw 'ShellParseArgs:Syntax:single backspace \' + endif + let curr .= mlist[1] + let line = mlist[2] + else + " otherwise parse up to next special char.: space, backslash, quote + let mlist = matchlist ( line, '^\([^[:space:]\\''"]\+\)\(.*\)' ) + let curr .= mlist[1] + let line = mlist[2] + endif + endwhile + + " add last argument + if curr != '' + call add ( list, curr ) + endif + + return list +endfunction " ---------- end of function s:ShellParseArgs ---------- + "------------------------------------------------------------------------------- " s:SID : Return the <SID>. {{{2 " @@ -503,6 +568,9 @@ endfunction " ---------- end of function s:MakeExecutable ---------- let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") +let s:NEOVIM = has("nvim") +let s:VIM8 = ! s:NEOVIM && v:version >= 800 + let s:installation = '*undefined*' " 'local' or 'system' let s:plugin_dir = '' " the directory hosting ftplugin/ plugin/ lua-support/ ... let s:Lua_GlobalTemplateFile = '' " the global templates, undefined for s:installation == 'local' @@ -569,21 +637,14 @@ else endif " "------------------------------------------------------------------------------- -" == Various setting == {{{2 +" == Various settings == {{{2 "------------------------------------------------------------------------------- " let s:CmdLineEscChar = ' |"\' " let s:Lua_LoadMenus = 'auto' " load the menus? let s:Lua_RootMenu = '&Lua' " name of the root menu -" -if s:MSWIN - let s:Lua_OutputMethodList = [ 'vim-io', 'vim-qf', 'buffer' ] -else - let s:Lua_OutputMethodList = [ 'vim-io', 'vim-qf', 'buffer', 'xterm' ] -endif -let s:Lua_OutputMethod = 'vim-io' " 'vim-io', 'vim-qf', 'buffer' or 'xterm' -let s:Lua_DirectRun = 'no' " 'yes' or 'no' + let s:Lua_LineEndCommColDefault = 49 let s:Lua_CommentLabel = "BlockCommentNo_" let s:Lua_SnippetDir = s:plugin_dir.'/lua-support/codesnippets/' @@ -624,8 +685,6 @@ call s:GetGlobalSetting ( 'Lua_LocalTemplateFile' ) call s:GetGlobalSetting ( 'Lua_CustomTemplateFile' ) call s:GetGlobalSetting ( 'Lua_LoadMenus' ) call s:GetGlobalSetting ( 'Lua_RootMenu' ) -call s:GetGlobalSetting ( 'Lua_OutputMethod' ) -call s:GetGlobalSetting ( 'Lua_DirectRun' ) call s:GetGlobalSetting ( 'Lua_Executable' ) call s:GetGlobalSetting ( 'Lua_CompilerExec' ) call s:GetGlobalSetting ( 'Lua_LineEndCommColDefault' ) @@ -647,10 +706,43 @@ let s:Lua_GlobalTemplateFile = expand ( s:Lua_GlobalTemplateFile ) let s:Lua_LocalTemplateFile = expand ( s:Lua_LocalTemplateFile ) let s:Lua_CustomTemplateFile = expand ( s:Lua_CustomTemplateFile ) let s:Lua_SnippetDir = expand ( s:Lua_SnippetDir ) -" + +"------------------------------------------------------------------------------- +" == Output method == {{{2 +"------------------------------------------------------------------------------- + +if s:NEOVIM + " can not use 'cmd-line' in Neovim, since :! is not interactive + let s:Lua_OutputMethodList = [ 'quickfix', 'buffer', 'terminal' ] + let s:Lua_OutputMethod = 'terminal' " one of 's:Lua_OutputMethodList' +else + let s:Lua_OutputMethodList = [ 'cmd-line', 'quickfix', 'buffer' ] + let s:Lua_OutputMethod = 'cmd-line' " one of 's:Lua_OutputMethodList' +endif +if ! s:MSWIN + let s:Lua_OutputMethodList += [ 'xterm' ] +endif +if has ( 'terminal' ) && ! s:MSWIN " :TODO:25.09.2017 16:16:WM: enable Windows, check how to start jobs with arguments under Windows + let s:Lua_OutputMethodList += [ 'terminal' ] +endif +call sort ( s:Lua_OutputMethodList ) +let s:Lua_DirectRun = 'no' " 'yes' or 'no' + +call s:GetGlobalSetting ( 'Lua_DirectRun' ) +call s:GetGlobalSetting ( 'Lua_OutputMethod' ) + +" adapt for backwards compatibility +if s:Lua_OutputMethod == 'vim-io' && s:NEOVIM + let s:Lua_OutputMethod = 'terminal' +elseif s:Lua_OutputMethod == 'vim-io' + let s:Lua_OutputMethod = 'cmd-line' +elseif s:Lua_OutputMethod == 'vim-qf' + let s:Lua_OutputMethod = 'quickfix' +endif + " }}}2 "------------------------------------------------------------------------------- -" + "------------------------------------------------------------------------------- " s:EndOfLineComment : Append end-of-line comment. {{{1 "------------------------------------------------------------------------------- @@ -1087,11 +1179,11 @@ endfunction " ---------- end of function s:EscMagicChar ---------- "------------------------------------------------------------------------------- function! s:OutputBufferErrors ( jump ) - " - if bufname('%') !~ 'Lua Output$' - return s:ImportantMsg ( 'not inside the "Lua Output" buffer' ) + + if bufname('%') !~ 'Lua Output$' && bufname('%') !~ 'Lua Terminal - ' + return s:ImportantMsg ( 'not inside a Lua output buffer' ) endif - " + cclose " " :TODO:26.03.2014 20:54:WM: check escaping of errorformat @@ -1156,66 +1248,65 @@ function! s:Run ( args ) if s:Lua_DirectRun == 'yes' && executable ( expand ( '%:p' ) ) let exec = expand ( '%:p' ) let script = '' + let arg_list = [ exec ] else let exec = s:Lua_Executable - let script = shellescape ( expand ( '%' ) ) + let script = shellescape ( expand ( '%:p' ) ) + let arg_list = [ exec, expand( '%' ) ] endif let exec = s:ShellEscExec ( exec ) - if s:Lua_OutputMethod == 'vim-io' - " - " method : "vim - interactive" - " + if s:Lua_OutputMethod == 'cmd-line' + + " method : "cmd.-line" + exe '!'.exec.' '.script.' '.a:args - " - elseif s:Lua_OutputMethod == 'vim-qf' - " - " method : "vim - quickfix" - " + + elseif s:Lua_OutputMethod == 'quickfix' + + " method : "quickfix" + " run script let lua_output = system ( exec.' '.script.' '.a:args ) " " successful? if v:shell_error == 0 - " " echo script output echo lua_output - " else - " " save current settings let errorf_saved = &g:errorformat - " + " run code checker let &g:errorformat = errformat - " + silent exe 'cexpr lua_output' - " + " restore current settings let &g:errorformat = errorf_saved - " + botright cwindow cc - " endif elseif s:Lua_OutputMethod == 'buffer' - " + " method : "buffer" - " + if bufwinnr ( 'Lua Output$' ) == -1 " open buffer above new file Lua\ Output - " + " TODO: name might exist on a different tab page + " settings setlocal buftype=nofile setlocal noswapfile setlocal syntax=none setlocal tabstop=8 - " + call Lua_SetMapLeader () - " + " maps: quickfix list nnoremap <buffer> <silent> <LocalLeader>qf :call <SID>OutputBufferErrors(0)<CR> inoremap <buffer> <silent> <LocalLeader>qf <C-C>:call <SID>OutputBufferErrors(0)<CR> @@ -1223,58 +1314,104 @@ function! s:Run ( args ) nnoremap <buffer> <silent> <LocalLeader>qj :call <SID>OutputBufferErrors(1)<CR> inoremap <buffer> <silent> <LocalLeader>qj <C-C>:call <SID>OutputBufferErrors(1)<CR> vnoremap <buffer> <silent> <LocalLeader>qj <C-C>:call <SID>OutputBufferErrors(1)<CR> - " + call Lua_ResetMapLeader () else " jump to window exe bufwinnr( 'Lua Output$' ).'wincmd w' endif - " + setlocal modifiable - " + silent exe '%delete _' silent exe '0r!'.exec.' '.script.' '.a:args silent exe '$delete _' - " + if v:shell_error == 0 " jump to the first line of the output normal! gg - " + setlocal nomodifiable setlocal nomodified else " jump to the last line of the output, where the error is mentioned normal! G - " + " save current settings let errorf_saved = &l:errorformat - " + " run code checker let &l:errorformat = errformat - " + silent exe 'cgetbuffer' - " + " restore current settings let &l:errorformat = errorf_saved - " + botright cwindow cc - " endif - " + elseif s:Lua_OutputMethod == 'terminal' + + " method : "terminal" + + try + let arg_list += s:ShellParseArgs ( a:args ) " expand to a list + catch /^ShellParseArgs:Syntax:/ + let msg = v:exception[ len( 'ShellParseArgs:Syntax:') : -1 ] + return s:WarningMsg ( 'syntax error while parsing arguments: '.msg ) + catch /.*/ + return s:WarningMsg ( + \ "internal error (" . v:exception . ")", + \ " - occurred at " . v:throwpoint ) + endtry + + let title = 'Lua Terminal - '.expand( '%:t' ) + + if s:NEOVIM + " :TODO:11.10.2017 18:03:WM: better handling than using 'job_id', but ensures + " successful operation for now + above new + let job_id = termopen ( arg_list, {} ) + + silent exe 'file '.fnameescape( title.' -'.job_id.'-' ) + else + call term_start ( arg_list, { 'term_name' : title, } ) + endif + + call Lua_SetMapLeader () + + " maps: quickfix list + if empty( maparg( '<LocalLeader>qf', 'n' ) ) + nnoremap <buffer> <silent> <LocalLeader>qf :call <SID>OutputBufferErrors(0)<CR> + inoremap <buffer> <silent> <LocalLeader>qf <C-C>:call <SID>OutputBufferErrors(0)<CR> + vnoremap <buffer> <silent> <LocalLeader>qf <C-C>:call <SID>OutputBufferErrors(0)<CR> + endif + if empty( maparg( '<LocalLeader>qj', 'n' ) ) + nnoremap <buffer> <silent> <LocalLeader>qj :call <SID>OutputBufferErrors(1)<CR> + inoremap <buffer> <silent> <LocalLeader>qj <C-C>:call <SID>OutputBufferErrors(1)<CR> + vnoremap <buffer> <silent> <LocalLeader>qj <C-C>:call <SID>OutputBufferErrors(1)<CR> + endif + + call Lua_ResetMapLeader () + elseif s:Lua_OutputMethod == 'xterm' - " + " method : "xterm" - " - let title = 'Lua' + + if s:Xterm_Executable =~ '\cxterm' + let title = ' -title Lua' + else + let title = '' + endif let args = a:args - " - silent exe '!'.s:Xterm_Executable.' '.g:Xterm_Options - \ .' -title '.shellescape( title ) + + " :TODO:13.04.2019 19:48:WM: Neovim + silent exe '!'.s:Xterm_Executable.' '.g:Xterm_Options.title \ .' -e '.shellescape( exec.' '.script.' '.args.' ; echo "" ; read -p " ** PRESS ENTER ** " dummy ' ).' &' - " + + call s:Redraw ( 'r!', '' ) " redraw in terminal endif - " endfunction " ---------- end of function s:Run ---------- "------------------------------------------------------------------------------- @@ -1339,6 +1476,120 @@ function! s:Compile( mode ) range endfunction " ---------- end of function s:Compile ---------- +"------------------------------------------------------------------------------- +" === Run: Executable, arguments, output, ... === {{{1 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" s:SetExecutable : Set s:Lua_Executable or s:Lua_CompilerExec {{{2 +"------------------------------------------------------------------------------- +function! s:SetExecutable ( exe_type, new_exec ) + + if a:exe_type == 'exe' + let var = 's:Lua_Executable' + elseif a:exe_type == 'compile' + let var = 's:Lua_CompilerExec' + else + return s:ErrorMsg ( 'Unknown type "'.a:exe_type.'".' ) + endif + + let new_exec = expand ( a:new_exec ) + + if new_exec == '' + echo {var} + elseif ! executable ( new_exec ) + return s:ErrorMsg ( '"'.new_exec.'" is not executable, nothing set.' ) + else + let {var} = new_exec + endif +endfunction " ---------- end of function s:SetExecutable ---------- + +"------------------------------------------------------------------------------- +" s:GetOutputMethodList : For cmd.-line completion. {{{2 +"------------------------------------------------------------------------------- +function! s:GetOutputMethodList (...) + return join ( s:Lua_OutputMethodList, "\n" ) +endfunction " ---------- end of function s:GetOutputMethodList ---------- + +"------------------------------------------------------------------------------- +" s:SetOutputMethod : Set s:Lua_OutputMethod {{{2 +"------------------------------------------------------------------------------- +function! s:SetOutputMethod ( method ) + + if a:method == '' + echo s:Lua_OutputMethod + return + endif + + " 'method' gives the output method + if index ( s:Lua_OutputMethodList, a:method ) == -1 + return s:ErrorMsg ( 'Invalid option for output method: "'.a:method.'".' ) + endif + + let s:Lua_OutputMethod = a:method + + " update the menu header + if ! has ( 'menu' ) || s:MenuVisible == 0 + return + endif + + exe 'aunmenu '.s:Lua_RootMenu.'.Run.output\ method.Output\ Method' + + if s:Lua_OutputMethod == 'cmd-line' + let current = 'cmd\.-line' + elseif s:Lua_OutputMethod == 'quickfix' + let current = 'quickfix' + elseif s:Lua_OutputMethod == 'buffer' + let current = 'buffer' + elseif s:Lua_OutputMethod == 'terminal' + let current = 'terminal' + elseif s:Lua_OutputMethod == 'xterm' + let current = 'xterm' + endif + + exe 'anoremenu ...400 '.s:Lua_RootMenu.'.Run.output\ method.Output\ Method<TAB>(current\:\ '.current.') :echo "This is a menu header."<CR>' + +endfunction " ---------- end of function s:SetOutputMethod ---------- + +"------------------------------------------------------------------------------- +" s:GetDirectRunList : For cmd.-line completion. {{{2 +"------------------------------------------------------------------------------- +function! s:GetDirectRunList (...) + return "yes\nno" +endfunction " ---------- end of function s:GetDirectRunList ---------- + +"------------------------------------------------------------------------------- +" s:SetDirectRun : Set s:Lua_DirectRun {{{2 +"------------------------------------------------------------------------------- +function! s:SetDirectRun ( option ) + + if a:option == '' + echo s:Lua_DirectRun + return + endif + + " 'option' gives the setting + if a:option != 'yes' && a:option != 'no' + return s:ErrorMsg ( 'Invalid option for direct run: "'.a:option.'".' ) + endif + + let s:Lua_DirectRun = a:option + + " update the menu header + if ! has ( 'menu' ) || s:MenuVisible == 0 + return + endif + + exe 'aunmenu '.s:Lua_RootMenu.'.Run.direct\ run.Direct\ Run' + + let current = s:Lua_DirectRun + + exe 'anoremenu ...400 '.s:Lua_RootMenu.'.Run.direct\ run.Direct\ Run<TAB>(currently\:\ '.current.') :echo "This is a menu header."<CR>' + +endfunction " ---------- end of function s:SetDirectRun ---------- +" }}}2 +"------------------------------------------------------------------------------- + "------------------------------------------------------------------------------- " s:HelpPlugin : Plug-in help. {{{1 "------------------------------------------------------------------------------- @@ -1479,7 +1730,8 @@ function! s:InsertFileHeader () return endif - if g:Lua_InsertFileHeader == 'yes' + " prevent insertion for a file generated from a quickfix error + if g:Lua_InsertFileHeader == 'yes' && isdirectory ( expand('%:p:h') ) let templ_s = mmtemplates#core#Resource ( g:Lua_Templates, 'get', 'property', 'Lua::FileSkeleton::Script' )[0] " insert templates in reverse order, always above the first line @@ -1500,119 +1752,6 @@ function! s:InsertFileHeader () endif endfunction " ---------- end of function s:InsertFileHeader ---------- -"------------------------------------------------------------------------------- -" s:SetExecutable : Set s:Lua_Executable or s:Lua_CompilerExec {{{1 -"------------------------------------------------------------------------------- -" -function! s:SetExecutable ( exe_type, new_exec ) - " - if a:exe_type == 'exe' - let var = 's:Lua_Executable' - elseif a:exe_type == 'compile' - let var = 's:Lua_CompilerExec' - else - return s:ErrorMsg ( 'Unknown type "'.a:exe_type.'".' ) - endif - " - let new_exec = expand ( a:new_exec ) - " - if new_exec == '' - echo {var} - elseif ! executable ( new_exec ) - return s:ErrorMsg ( '"'.new_exec.'" is not executable, nothing set.' ) - else - let {var} = new_exec - endif - " - return -endfunction " ---------- end of function s:SetExecutable ---------- -" -"------------------------------------------------------------------------------- -" s:GetOutputMethodList : For cmd.-line completion. {{{1 -"------------------------------------------------------------------------------- -" -function! s:GetOutputMethodList (...) - return join ( s:Lua_OutputMethodList, "\n" ) -endfunction " ---------- end of function s:GetOutputMethodList ---------- -" -"------------------------------------------------------------------------------- -" s:SetOutputMethod : Set s:Lua_OutputMethod {{{1 -"------------------------------------------------------------------------------- -" -function! s:SetOutputMethod ( method ) - " - if a:method == '' - echo s:Lua_OutputMethod - return - endif - " - " 'method' gives the output method - if index ( s:Lua_OutputMethodList, a:method ) == -1 - return s:ErrorMsg ( 'Invalid option for output method: "'.a:method.'".' ) - endif - " - let s:Lua_OutputMethod = a:method - " - " update the menu header - if ! has ( 'menu' ) || s:MenuVisible == 0 - return - endif - " - exe 'aunmenu '.s:Lua_RootMenu.'.Run.output\ method.Output\ Method' - " - if s:Lua_OutputMethod == 'vim-io' - let current = 'vim\ io' - elseif s:Lua_OutputMethod == 'vim-qf' - let current = 'vim\ qf' - elseif s:Lua_OutputMethod == 'buffer' - let current = 'buffer' - elseif s:Lua_OutputMethod == 'xterm' - let current = 'xterm' - endif - " - exe 'anoremenu ...400 '.s:Lua_RootMenu.'.Run.output\ method.Output\ Method<TAB>(current\:\ '.current.') :echo "This is a menu header."<CR>' - " -endfunction " ---------- end of function s:SetOutputMethod ---------- -" -"------------------------------------------------------------------------------- -" s:GetDirectRunList : For cmd.-line completion. {{{1 -"------------------------------------------------------------------------------- -" -function! s:GetDirectRunList (...) - return "yes\nno" -endfunction " ---------- end of function s:GetDirectRunList ---------- -" -"------------------------------------------------------------------------------- -" s:SetDirectRun : Set s:Lua_DirectRun {{{1 -"------------------------------------------------------------------------------- -" -function! s:SetDirectRun ( option ) - " - if a:option == '' - echo s:Lua_DirectRun - return - endif - " - " 'option' gives the setting - if a:option != 'yes' && a:option != 'no' - return s:ErrorMsg ( 'Invalid option for direct run: "'.a:option.'".' ) - endif - " - let s:Lua_DirectRun = a:option - " - " update the menu header - if ! has ( 'menu' ) || s:MenuVisible == 0 - return - endif - " - exe 'aunmenu '.s:Lua_RootMenu.'.Run.direct\ run.Direct\ Run' - " - let current = s:Lua_DirectRun - " - exe 'anoremenu ...400 '.s:Lua_RootMenu.'.Run.direct\ run.Direct\ Run<TAB>(currently\:\ '.current.') :echo "This is a menu header."<CR>' - " -endfunction " ---------- end of function s:SetDirectRun ---------- -" "------------------------------------------------------------------------------- " s:CreateMaps : Create additional maps. {{{1 "------------------------------------------------------------------------------- @@ -1624,8 +1763,8 @@ function! s:CreateMaps () "------------------------------------------------------------------------------- " command! -nargs=* -buffer -complete=file Lua call <SID>Run(<q-args>) - command! -nargs=0 -buffer -complete=file LuaCompile call <SID>Compile('compile') - command! -nargs=0 -buffer -complete=file LuaCheck call <SID>Compile('check') + command! -nargs=0 -buffer LuaCompile call <SID>Compile('compile') + command! -nargs=0 -buffer LuaCheck call <SID>Compile('check') " "------------------------------------------------------------------------------- " settings - local leader @@ -1897,21 +2036,19 @@ function! s:InitMenus() let ahead_loud = 'anoremenu '.s:Lua_RootMenu.'.Run.' let ihead_loud = 'inoremenu '.s:Lua_RootMenu.'.Run.' - exe ahead.'&run<TAB><F9>\ '.esc_mapl.'rr :call <SID>Run("")<CR>' - exe ihead.'&run<TAB><F9>\ '.esc_mapl.'rr <Esc>:call <SID>Run("")<CR>' - exe ahead.'&compile<TAB><S-F9>\ '.esc_mapl.'rc :call <SID>Compile("compile")<CR>' - exe ihead.'&compile<TAB><S-F9>\ '.esc_mapl.'rc <Esc>:call <SID>Compile("compile")<CR>' - exe ahead.'chec&k\ code<TAB><A-F9>\ '.esc_mapl.'rk :call <SID>Compile("check")<CR>' - exe ihead.'chec&k\ code<TAB><A-F9>\ '.esc_mapl.'rk <Esc>:call <SID>Compile("check")<CR>' - exe ahead.'make\ &executable<TAB>'.esc_mapl.'re :call <SID>MakeExecutable()<CR>' - exe ihead.'make\ &executable<TAB>'.esc_mapl.'re <Esc>:call <SID>MakeExecutable()<CR>' - - exe ahead.'&buffer\ "Lua\ Output".buffer\ "Lua\ Output" :echo "This is a menu header."<CR>' - exe ahead.'&buffer\ "Lua\ Output".-SepHead- :' - exe ahead.'&buffer\ "Lua\ Output".load\ into\ quick&fix<TAB>'.esc_mapl.'qf :call <SID>OutputBufferErrors(0)<CR>' - exe ihead.'&buffer\ "Lua\ Output".load\ into\ quick&fix<TAB>'.esc_mapl.'qf <Esc>:call <SID>OutputBufferErrors(0)<CR>' - exe ahead.'&buffer\ "Lua\ Output".qf\.\ and\ &jump\ to\ first\ error<TAB>'.esc_mapl.'qj :call <SID>OutputBufferErrors(1)<CR>' - exe ihead.'&buffer\ "Lua\ Output".qf\.\ and\ &jump\ to\ first\ error<TAB>'.esc_mapl.'qj <Esc>:call <SID>OutputBufferErrors(1)<CR>' + exe ahead.'&run<TAB>'.esc_mapl.'rr :call <SID>Run("")<CR>' + exe ihead.'&run<TAB>'.esc_mapl.'rr <Esc>:call <SID>Run("")<CR>' + exe ahead.'&compile<TAB>'.esc_mapl.'rc :call <SID>Compile("compile")<CR>' + exe ihead.'&compile<TAB>'.esc_mapl.'rc <Esc>:call <SID>Compile("compile")<CR>' + exe ahead.'chec&k\ code<TAB>'.esc_mapl.'rk :call <SID>Compile("check")<CR>' + exe ihead.'chec&k\ code<TAB>'.esc_mapl.'rk <Esc>:call <SID>Compile("check")<CR>' + + exe ahead.'&buffer\ "Lua\ Output\/Term".buffer\ "Lua\ Output\/Term" :echo "This is a menu header."<CR>' + exe ahead.'&buffer\ "Lua\ Output\/Term".-SepHead- :' + exe ahead.'&buffer\ "Lua\ Output\/Term".load\ into\ quick&fix<TAB>'.esc_mapl.'qf :call <SID>OutputBufferErrors(0)<CR>' + exe ihead.'&buffer\ "Lua\ Output\/Term".load\ into\ quick&fix<TAB>'.esc_mapl.'qf <Esc>:call <SID>OutputBufferErrors(0)<CR>' + exe ahead.'&buffer\ "Lua\ Output\/Term".qf\.\ and\ &jump\ to\ first\ error<TAB>'.esc_mapl.'qj :call <SID>OutputBufferErrors(1)<CR>' + exe ihead.'&buffer\ "Lua\ Output\/Term".qf\.\ and\ &jump\ to\ first\ error<TAB>'.esc_mapl.'qj <Esc>:call <SID>OutputBufferErrors(1)<CR>' exe ahead.'-Sep01- :' @@ -1928,6 +2065,8 @@ function! s:InitMenus() exe ihead_loud.'&set\ compiler\ exec\.<TAB>'.esc_mapl.'rsc <Esc>:LuaCompilerExec<SPACE>' exe ahead.'-Sep02- :' + exe ahead.'make\ &executable<TAB>'.esc_mapl.'re :call <SID>MakeExecutable()<CR>' + exe ihead.'make\ &executable<TAB>'.esc_mapl.'re <Esc>:call <SID>MakeExecutable()<CR>' exe ahead.'&hardcopy\ to\ filename\.ps<TAB>'.esc_mapl.'rh :call <SID>Hardcopy("n")<CR>' exe vhead.'&hardcopy\ to\ filename\.ps<TAB>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("v")<CR>' exe ihead.'&hardcopy\ to\ filename\.ps<TAB>'.esc_mapl.'rh <C-C>:call <SID>Hardcopy("n")<CR>' @@ -1937,20 +2076,22 @@ function! s:InitMenus() exe ihead.'&settings<TAB>'.esc_mapl.'rs <Esc>:call Lua_Settings(0)<CR>' " run -> output method - - exe ahead.'output\ method.vim\ &io<TAB>interactive :call <SID>SetOutputMethod("vim-io")<CR>' - exe ihead.'output\ method.vim\ &io<TAB>interactive <Esc>:call <SID>SetOutputMethod("vim-io")<CR>' - exe ahead.'output\ method.vim\ &qf<TAB>quickfix :call <SID>SetOutputMethod("vim-qf")<CR>' - exe ihead.'output\ method.vim\ &qf<TAB>quickfix <Esc>:call <SID>SetOutputMethod("vim-qf")<CR>' - exe ahead.'output\ method.&buffer<TAB>quickfix :call <SID>SetOutputMethod("buffer")<CR>' - exe ihead.'output\ method.&buffer<TAB>quickfix <Esc>:call <SID>SetOutputMethod("buffer")<CR>' - if ! s:MSWIN - exe ahead.'output\ method.&xterm<TAB>interactive :call <SID>SetOutputMethod("xterm")<CR>' - exe ihead.'output\ method.&xterm<TAB>interactive <Esc>:call <SID>SetOutputMethod("xterm")<CR>' - endif + let method_menu_entries = [ + \ [ 'cmd-line', '&cmd\.-line', 'interactive', ], + \ [ 'quickfix', '&quickfix', 'quickfix', ], + \ [ 'buffer', '&buffer', 'quickfix', ], + \ [ 'terminal', '&terminal', 'interact+qf', ], + \ [ 'xterm', '&xterm', 'interactive', ], + \ ] + + for [ method, left, right ] in method_menu_entries + if index ( s:Lua_OutputMethodList, method ) > -1 + exe ahead.'output\ method.'.left.'<TAB>'.right.' :call <SID>SetOutputMethod("'.method.'")<CR>' + exe ihead.'output\ method.'.left.'<TAB>'.right.' <Esc>:call <SID>SetOutputMethod("'.method.'")<CR>' + endif + endfor " run -> direct run - exe ahead.'direct\ run.&yes<TAB>use\ executable\ scripts :call <SID>SetDirectRun("yes")<CR>' exe ihead.'direct\ run.&yes<TAB>use\ executable\ scripts <Esc>:call <SID>SetDirectRun("yes")<CR>' exe ahead.'direct\ run.&no<TAB>always\ use\ :LuaExecutable :call <SID>SetDirectRun("no")<CR>' @@ -2036,17 +2177,38 @@ function! s:RemoveMenus() let s:MenuVisible = 0 endif endfunction " ---------- end of function s:RemoveMenus ---------- -" + +"------------------------------------------------------------------------------- +" s:Initialize : Initialize templates, menus, and maps. {{{1 +"------------------------------------------------------------------------------- +function! s:Initialize ( ftype ) + if ! exists( 'g:Lua_Templates' ) + if s:Lua_LoadMenus == 'auto' | call s:AddMenus() + else | call s:SetupTemplates() + endif + endif + call s:CreateMaps() + call s:CheckTemplatePersonalization() +endfunction " ---------- end of function s:Initialize ---------- + "------------------------------------------------------------------------------- " Lua_Settings : Print the settings on the command line. {{{1 "------------------------------------------------------------------------------- " function! Lua_Settings( verbose ) - " + if s:MSWIN | let sys_name = 'Windows' elseif s:UNIX | let sys_name = 'UN*X' else | let sys_name = 'unknown' | endif - " + if s:NEOVIM + let vim_name = 'nvim' + else + let vim_name = has('gui_running') ? 'gvim' : 'vim' + if s:VIM8 + let vim_name .= '(v8.0)' + endif + endif + let lua_exe_status = executable( s:Lua_Executable ) ? '' : ' (not executable)' let luac_exe_status = executable( s:Lua_CompilerExec ) ? '' : ' (not executable)' " @@ -2071,7 +2233,7 @@ function! Lua_Settings( verbose ) endif " plug-in installation, template engine let txt .= - \ ' plugin installation : '.s:installation.' on '.sys_name."\n" + \ ' plugin installation : '.s:installation.' in '.vim_name.' on '.sys_name."\n" " toolbox if s:Lua_UseToolbox == 'yes' let toollist = mmtoolbox#tools#GetList ( s:Lua_Toolbox ) @@ -2161,20 +2323,12 @@ command! -nargs=? -complete=custom,<SID>GetOutputMethodList LuaOutputMethod ca command! -nargs=? -complete=custom,<SID>GetDirectRunList LuaDirectRun call <SID>SetDirectRun(<q-args>) command! -nargs=? -complete=shellcmd LuaExecutable call <SID>SetExecutable('exe',<q-args>) command! -nargs=? -complete=shellcmd LuaCompilerExec call <SID>SetExecutable('compile',<q-args>) -" + if has( 'autocmd' ) - autocmd FileType * - \ if &filetype == 'lua' && ! exists( 'g:Lua_Templates' ) | - \ if s:Lua_LoadMenus == 'auto' | call s:AddMenus () | - \ else | call s:SetupTemplates () | - \ endif | - \ endif - autocmd FileType * - \ if &filetype == 'lua' | - \ call s:CreateMaps() | - \ call s:CheckTemplatePersonalization() | - \ endif - autocmd BufNewFile *.lua call s:InsertFileHeader() + augroup LuaSupport + autocmd FileType lua call s:Initialize('lua') + autocmd BufNewFile *.lua call s:InsertFileHeader() + augroup END endif " }}}1 "------------------------------------------------------------------------------- diff --git a/plugin/matlab-support.vim b/plugin/matlab-support.vim deleted file mode 100644 index 7af981f..0000000 --- a/plugin/matlab-support.vim +++ /dev/null @@ -1,1238 +0,0 @@ -"=============================================================================== -" -" File: matlab-support.vim -" -" Description: Matlab IDE for Vim/gVim. -" -" See help file matlabsupport.txt . -" -" VIM Version: 7.0+ -" Author: Wolfgang Mehner, wolfgang-mehner@web.de -" Organization: -" Version: see variable g:Matlab_Version below -" Created: 11.04.2010 -" Revision: 24.11.2013 -" License: Copyright (c) 2012-2015, Wolfgang Mehner -" This program is free software; you can redistribute it and/or -" modify it under the terms of the GNU General Public License as -" published by the Free Software Foundation, version 2 of the -" License. -" This program is distributed in the hope that it will be -" useful, but WITHOUT ANY WARRANTY; without even the implied -" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -" PURPOSE. -" See the GNU General Public License version 2 for more details. -"=============================================================================== -" -"------------------------------------------------------------------------------- -" Basic checks. {{{1 -"------------------------------------------------------------------------------- -" -" need at least 7.0 -if v:version < 700 - echohl WarningMsg - echo 'The plugin matlab-support.vim needs Vim version >= 7.' - echohl None - finish -endif -" -" prevent duplicate loading -" need compatible -if &cp || ( exists('g:Matlab_Version') && ! exists('g:Matlab_DevelopmentOverwrite') ) - finish -endif -let g:Matlab_Version= '0.8rc2' " version number of this script; do not change -" -"------------------------------------------------------------------------------- -" Auxiliary functions. {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" s:ApplyDefaultSetting : Write default setting to a global variable. {{{2 -" -" Parameters: -" varname - name of the variable (string) -" value - default value (string) -" Returns: -" - -" -" If g:<varname> does not exists, assign: -" g:<varname> = value -"------------------------------------------------------------------------------- -" -function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - exe 'let g:'.a:varname.' = '.string( a:value ) - endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- -" -"------------------------------------------------------------------------------- -" s:ErrorMsg : Print an error message. {{{2 -" -" Parameters: -" line1 - a line (string) -" line2 - a line (string) -" ... - ... -" Returns: -" - -"------------------------------------------------------------------------------- -" -function! s:ErrorMsg ( ... ) - echohl WarningMsg - for line in a:000 - echomsg line - endfor - echohl None -endfunction " ---------- end of function s:ErrorMsg ---------- -" -"------------------------------------------------------------------------------- -" s:GetGlobalSetting : Get a setting from a global variable. {{{2 -" -" Parameters: -" varname - name of the variable (string) -" Returns: -" - -" -" If g:<varname> exists, assign: -" s:<varname> = g:<varname> -"------------------------------------------------------------------------------- -" -function! s:GetGlobalSetting ( varname ) - if exists ( 'g:'.a:varname ) - exe 'let s:'.a:varname.' = g:'.a:varname - endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- -" -"------------------------------------------------------------------------------- -" s:ImportantMsg : Print an important message. {{{2 -" -" Parameters: -" line1 - a line (string) -" line2 - a line (string) -" ... - ... -" Returns: -" - -"------------------------------------------------------------------------------- -" -function! s:ImportantMsg ( ... ) - echohl Search - echo join ( a:000, "\n" ) - echohl None -endfunction " ---------- end of function s:ImportantMsg ---------- -" }}}2 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" Modul setup. {{{1 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" Installation. {{{2 -"------------------------------------------------------------------------------- -" -let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") -let s:UNIX = has("unix") || has("macunix") || has("win32unix") -" -let s:installation = '*undefined*' " 'local' or 'system' -let s:plugin_dir = '' " the directory hosting ftplugin/ plugin/ matlab-support/ ... -let s:Matlab_GlbTemplateFile = '' " the global templates, undefined for s:installation == 'local' -let s:Matlab_LclTemplateFile = '' " the local templates -" -if s:MSWIN - " - "------------------------------------------------------------------------------- - " MS Windows - "------------------------------------------------------------------------------- - " - let s:plugin_dir = substitute( expand('<sfile>:p:h:h'), '\\', '/', 'g' ) - " - if match( substitute( expand('<sfile>'), '\\', '/', 'g' ), - \ '\V'.substitute( expand('$HOME'), '\\', '/', 'g' ) ) == 0 - " - " user installation assumed - let s:installation = 'local' - let s:Matlab_LclTemplateFile = s:plugin_dir.'/matlab-support/templates/Templates' - else - " - " system wide installation - let s:installation = 'system' - let s:Matlab_GlbTemplateFile = s:plugin_dir.'/matlab-support/templates/Templates' - let s:Matlab_LclTemplateFile = $HOME.'/vimfiles/matlab-support/templates/Templates' - endif - " -else - " - "------------------------------------------------------------------------------- - " Linux/Unix - "------------------------------------------------------------------------------- - " - let s:plugin_dir = expand('<sfile>:p:h:h') - " - if match( expand('<sfile>'), '\V'.resolve(expand('$HOME')) ) == 0 - " - " user installation assumed - let s:installation = 'local' - let s:Matlab_LclTemplateFile = s:plugin_dir.'/matlab-support/templates/Templates' - else - " - " system wide installation - let s:installation = 'system' - let s:Matlab_GlbTemplateFile = s:plugin_dir.'/matlab-support/templates/Templates' - let s:Matlab_LclTemplateFile = $HOME.'/.vim/matlab-support/templates/Templates' - endif - " -endif -" -"------------------------------------------------------------------------------- -" Various setting. {{{2 -"------------------------------------------------------------------------------- -" -let s:CmdLineEscChar = ' |"\' -" -let s:Matlab_LoadMenus = 'auto' " load the menus? -let s:Matlab_RootMenu = '&Matlab' " name of the root menu -" -let s:Matlab_MapLeader = '' " default: do not overwrite 'maplocalleader' -" -let s:Matlab_MlintExecutable = 'mlint' " default: mlint on system path -" -let s:Matlab_LineEndCommColDefault = 49 -let s:Matlab_SnippetDir = s:plugin_dir.'/matlab-support/codesnippets/' -let s:Matlab_SnippetBrowser = 'gui' -" -if ! exists ( 's:MenuVisible' ) - let s:MenuVisible = 0 " menus are not visible at the moment -endif -" -call s:GetGlobalSetting ( 'Matlab_GlbTemplateFile' ) -call s:GetGlobalSetting ( 'Matlab_LclTemplateFile' ) -call s:GetGlobalSetting ( 'Matlab_LoadMenus' ) -call s:GetGlobalSetting ( 'Matlab_RootMenu' ) -call s:GetGlobalSetting ( 'Matlab_MlintExecutable' ) -call s:GetGlobalSetting ( 'Matlab_LineEndCommColDefault' ) -call s:GetGlobalSetting ( 'Matlab_SnippetDir' ) -call s:GetGlobalSetting ( 'Matlab_SnippetBrowser' ) -" -call s:ApplyDefaultSetting ( 'Matlab_MapLeader', '' ) -" -let s:Matlab_GlbTemplateFile = expand ( s:Matlab_GlbTemplateFile ) -let s:Matlab_LclTemplateFile = expand ( s:Matlab_LclTemplateFile ) -let s:Matlab_SnippetDir = expand ( s:Matlab_SnippetDir ) -" -" }}}2 -"------------------------------------------------------------------------------- -" -"------------------------------------------------------------------------------- -" Matlab_EndOfLineComment : Append end-of-line comment. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_EndOfLineComment () range - " - " local position - if !exists( 'b:Matlab_LineEndCommentColumn' ) - let b:Matlab_LineEndCommentColumn = s:Matlab_LineEndCommColDefault - endif - " - " ----- trim whitespaces ----- - exe a:firstline.','.a:lastline.'s/\s*$//' - " - for line in range( a:lastline, a:firstline, -1 ) - silent exe ':'.line - if getline(line) !~ '^\s*$' - let linelength = virtcol( [line,'$'] ) - 1 - let diff = 1 - if linelength < b:Matlab_LineEndCommentColumn - let diff = b:Matlab_LineEndCommentColumn - 1 - linelength - endif - exe 'normal! '.diff.'A ' - call mmtemplates#core#InsertTemplate (g:Matlab_Templates, 'Comments.end-of-line comment') - endif - endfor - " -endfunction " ---------- end of function Matlab_EndOfLineComment ---------- -" -"------------------------------------------------------------------------------- -" Matlab_AdjustEndOfLineComm : Adjust end-of-line comment. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_AdjustEndOfLineComm () range - " - " comment character (for use in regular expression) - let cc = '%' - " - " patterns to ignore when adjusting line-end comments (maybe incomplete): - " - single-quoted strings, includes '' \n \\ ... - " :TODO:01.12.2013 14:26:WM: does Matlab support escape sequences like that? - let align_regex = "'\\%(''\\|\\\\.\\|[^']\\)*'" - " - " local position - if !exists( 'b:Matlab_LineEndCommentColumn' ) - let b:Matlab_LineEndCommentColumn = s:Matlab_LineEndCommColDefault - endif - let correct_idx = b:Matlab_LineEndCommentColumn - " - " === plug-in specific code ends here === - " === the behavior is governed by the variables above === - " - " save the cursor position - let save_cursor = getpos('.') - " - for line in range( a:firstline, a:lastline ) - silent exe ':'.line - " - let linetxt = getline('.') - " - " "pure" comment line left unchanged - if match ( linetxt, '^\s*'.cc ) == 0 - "echo 'line '.line.': "pure" comment' - continue - endif - " - let b_idx1 = 1 + match ( linetxt, '\s*'.cc.'.*$', 0 ) - let b_idx2 = 1 + match ( linetxt, cc.'.*$', 0 ) - " - " not found? - if b_idx1 == 0 - "echo 'line '.line.': no end-of-line comment' - continue - endif - " - " walk through ignored patterns - let idx_start = 0 - " - while 1 - let this_start = match ( linetxt, align_regex, idx_start ) - " - if this_start == -1 - break - else - let idx_start = matchend ( linetxt, align_regex, idx_start ) - "echo 'line '.line.': ignoring >>>'.strpart(linetxt,this_start,idx_start-this_start).'<<<' - endif - endwhile - " - let b_idx1 = 1 + match ( linetxt, '\s*'.cc.'.*$', idx_start ) - let b_idx2 = 1 + match ( linetxt, cc.'.*$', idx_start ) - " - " not found? - if b_idx1 == 0 - "echo 'line '.line.': no end-of-line comment' - continue - endif - " - call cursor ( line, b_idx2 ) - let v_idx2 = virtcol('.') - " - " do b_idx1 last, so the cursor is in the right position for substitute below - call cursor ( line, b_idx1 ) - let v_idx1 = virtcol('.') - " - " already at right position? - if ( v_idx2 == correct_idx ) - "echo 'line '.line.': already at right position' - continue - endif - " ... or line too long? - if ( v_idx1 > correct_idx ) - "echo 'line '.line.': line too long' - continue - endif - " - " substitute all whitespaces behind the cursor (regex '\%#') and the next character, - " to ensure the match is at least one character long - silent exe 'substitute/\%#\s*\(\S\)/'.repeat( ' ', correct_idx - v_idx1 ).'\1/' - "echo 'line '.line.': adjusted' - " - endfor - " - " restore the cursor position - call setpos ( '.', save_cursor ) - " -endfunction " ---------- end of function Matlab_AdjustEndOfLineComm ---------- -" -"------------------------------------------------------------------------------- -" Matlab_SetEndOfLineCommPos : Set end-of-line comment position. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_SetEndOfLineCommPos () range - " - let b:Matlab_LineEndCommentColumn = virtcol('.') - call s:ImportantMsg ( 'line end comments will start at column '.b:Matlab_LineEndCommentColumn ) - " -endfunction " ---------- end of function Matlab_SetEndOfLineCommPos ---------- -" -"------------------------------------------------------------------------------- -" Matlab_CodeComment : Code -> Comment {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_CodeComment() range - " - " add '%' at the beginning of the lines - silent exe ":".a:firstline.",".a:lastline."s/^/%/" - " -endfunction " ---------- end of function Matlab_CodeComment ---------- -" -"------------------------------------------------------------------------------- -" Matlab_CommentCode : Comment -> Code {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_CommentCode( toggle ) range - " - " remove comments: - " - remove '%' from the beginning of the line - " and, in toggling mode: - " - if the line is not a comment, comment it - for i in range( a:firstline, a:lastline ) - if getline( i ) =~ '^%' - silent exe i."s/^%//" - elseif a:toggle - silent exe i."s/^/%/" - endif - endfor - " -endfunction " ---------- end of function Matlab_CommentCode ---------- -" -"------------------------------------------------------------------------------- -" s:GetFunctionParameters : Get the name, parameters, ... of a function. {{{1 -" -" Parameters: -" fun_line - the function definition (string) -" Returns: -" [ <fun_name>, <returns>, <params> ] - data (list: string, list, list) -" -" The entries are as follows: -" file name - name of the function (string) -" returns - the name of the return arguments (list of strings) -" params - the names of the parameters (list of strings) -" -" In case of an error, an empty list is returned. -"------------------------------------------------------------------------------- -function! s:GetFunctionParameters( fun_line ) - " - " 1st expression: the syntax category - " 2nd expression: as before, but with brackets to catch the match - " - let identifier = '[a-zA-Z][a-zA-Z0-9_]*' - let identifier_c = '\('.identifier.'\)' - let in_bracket = '[^)\]]*' - let in_bracket_c = '\('.in_bracket.'\)' - let spaces = '\s*' - let spaces_c = '\('.spaces.'\)' - let tail_c = '\(.*\)$' - " - let mlist = matchlist ( a:fun_line, '^'.spaces_c.'function\s*'.tail_c ) - " - " no function? - if empty( mlist ) - return [] - endif - " - " found a function! - let tail = mlist[2] - let fun_name = '' - let return_str = '' - let param_str = '' - " - " no return - let mlist = matchlist( tail, '^'.identifier_c.'\s*(\s*'.in_bracket_c.')' ) - if ! empty( mlist ) - let fun_name = mlist[1] - let return_str = '' - let param_str = mlist[2] - endif - " - " single return - let mlist = matchlist( tail, '^'.identifier_c.'\s*=\s*'.identifier_c.'\s*(\s*'.in_bracket_c.')' ) - if ! empty( mlist ) - let fun_name = mlist[2] - let return_str = mlist[1] - let param_str = mlist[3] - endif - " - " multiple returns - let mlist = matchlist( tail, '^\[\s*'.in_bracket_c.'\]\s*=\s*'.identifier_c.'\s*(\s*'.in_bracket_c.')' ) - if ! empty( mlist ) - let fun_name = mlist[2] - let return_str = mlist[1] - let param_str = mlist[3] - endif - " - let param_str = substitute ( param_str, '\s*$', '', '' ) - let param_list = split ( param_str, '\s*,\s*' ) - " - let return_str = substitute ( return_str, '\s*$', '', '' ) - let return_list = split ( return_str, '\s*,\s*' ) - " - if empty ( fun_name ) - return [] - else - return [ fun_name, return_list, param_list ] - endif - " -endfunction " ---------- end of function s:GetFunctionParameters ---------- -" -"------------------------------------------------------------------------------- -" Matlab_FunctionComment : Automatically comment a function. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_FunctionComment() range - " - " TODO: varargin, varargout - " TODO: multiple lines possible? - " TODO: remove '...' operator - let linestring = getline(a:firstline) - for i in range(a:firstline+1,a:lastline) - let linestring .= ' '.getline(i) - endfor - " - let res_list = s:GetFunctionParameters( linestring ) - " - if empty( res_list ) - return s:ImportantMsg ( 'No function found.' ) - endif - " - " get all the parts - let [ fun_name, return_list, param_list ] = res_list - let base_name = mmtemplates#core#ExpandText ( g:Matlab_Templates, '|BASENAME|' ) - " - " description of the file or another function? - if fun_name == base_name - call mmtemplates#core#InsertTemplate ( g:Matlab_Templates, 'Comments.file description', - \ '|PARAMETERS|', param_list, '|RETURNS|', return_list ) - else - call mmtemplates#core#InsertTemplate ( g:Matlab_Templates, 'Comments.function description', - \ '|FUNCTION_NAME|', fun_name, '|PARAMETERS|', param_list, '|RETURNS|', return_list ) - endif - " -endfunction " ---------- end of function Matlab_FunctionComment ---------- -" -"------------------------------------------------------------------------------- -" Matlab_CodeSnippet : Code snippets. {{{1 -" -" Parameters: -" action - "insert", "create", "vcreate", "view" or "edit" (string) -"------------------------------------------------------------------------------- -" -function! Matlab_CodeSnippet ( action ) - " - "------------------------------------------------------------------------------- - " setup - "------------------------------------------------------------------------------- - " - " check directory - if ! isdirectory( s:Matlab_SnippetDir ) - return s:ErrorMsg ( - \ 'Code snippet directory '.s:Matlab_SnippetDir.' does not exist.', - \ '(Please create it.)' ) - endif - " - " save option 'browsefilter' - if has( 'browsefilter' ) && exists( 'b:browsefilter' ) - let browsefilter_save = b:browsefilter - let b:browsefilter = '*' - endif - " - "------------------------------------------------------------------------------- - " do action - "------------------------------------------------------------------------------- - " - if a:action == 'insert' - " - "------------------------------------------------------------------------------- - " action "insert" - "------------------------------------------------------------------------------- - " - " select file - if has('browse') && s:Matlab_SnippetBrowser == 'gui' - let snippetfile = browse ( 0, 'insert a code snippet', s:Matlab_SnippetDir, '' ) - else - let snippetfile = input ( 'insert snippet ', s:Matlab_SnippetDir, 'file' ) - endif - " - " insert snippet - if filereadable(snippetfile) - let linesread = line('$') - " - let old_cpoptions = &cpoptions " prevent the alternate buffer from being set to this files - setlocal cpoptions-=a - " - exe 'read '.snippetfile - " - let &cpoptions = old_cpoptions " restore previous options - " - let linesread = line('$') - linesread - 1 " number of lines inserted - " - " :TODO:03.12.2013 14:29:WM: indent here? - " indent lines - if linesread >= 0 && match( snippetfile, '\.\(ni\|noindent\)$' ) < 0 - silent exe 'normal! ='.linesread.'+' - endif - endif - " - " delete first line if empty - if line('.') == 2 && getline(1) =~ '^$' - silent exe ':1,1d' - endif - " - elseif a:action == 'create' || a:action == 'vcreate' - " - "------------------------------------------------------------------------------- - " action "create" or "vcreate" - "------------------------------------------------------------------------------- - " - " select file - if has('browse') && s:Matlab_SnippetBrowser == 'gui' - let snippetfile = browse ( 1, 'create a code snippet', s:Matlab_SnippetDir, '' ) - else - let snippetfile = input ( 'create snippet ', s:Matlab_SnippetDir, 'file' ) - endif - " - " create snippet - if ! empty( snippetfile ) - " new file or overwrite? - if ! filereadable( snippetfile ) || confirm( 'File '.snippetfile.' exists! Overwrite? ', "&Cancel\n&No\n&Yes" ) == 3 - if a:action == 'create' && confirm( 'Write whole file as a snippet? ', "&Cancel\n&No\n&Yes" ) == 3 - exe 'write! '.fnameescape( snippetfile ) - elseif a:action == 'vcreate' - exe '*write! '.fnameescape( snippetfile ) - endif - endif - endif - " - elseif a:action == 'view' || a:action == 'edit' - " - "------------------------------------------------------------------------------- - " action "view" or "edit" - "------------------------------------------------------------------------------- - if a:action == 'view' | let saving = 0 - else | let saving = 1 | endif - " - " select file - if has('browse') && s:Matlab_SnippetBrowser == 'gui' - let snippetfile = browse ( saving, a:action.' a code snippet', s:Matlab_SnippetDir, '' ) - else - let snippetfile = input ( a:action.' snippet ', s:Matlab_SnippetDir, 'file' ) - endif - " - " open file - if ! empty( snippetfile ) - exe 'split | '.a:action.' '.fnameescape( snippetfile ) - endif - else - call s:ErrorMsg ( 'Unknown action "'.a:action.'".' ) - endif - " - "------------------------------------------------------------------------------- - " wrap up - "------------------------------------------------------------------------------- - " - " restore option 'browsefilter' - if has( 'browsefilter' ) && exists( 'b:browsefilter' ) - let b:browsefilter = browsefilter_save - endif - " -endfunction " ---------- end of function Matlab_CodeSnippet ---------- -" -"------------------------------------------------------------------------------- -" Matlab_CheckCode : Use mlint to check the code. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_CheckCode() range - " - silent exe 'update' | " write source file if necessary - cclose - " - " assemble all the information - let currentdir = getcwd() - let currentbuffer = bufname('%') - let fullname = currentdir.'/'.currentbuffer - let fullname = shellescape( fullname, 1 ) - " - " prepare and check the executable - if ! executable( s:Matlab_MlintExecutable ) - return s:ErrorMsg ( - \ 'Command "'.s:Matlab_MlintExecutable.'" not found. Not configured correctly?', - \ 'Further information: :help matlabsupport-config-mlint' ) - endif - " - " call 'mlint' and process the output - let errors_mlint = system ( shellescape( s:Matlab_MlintExecutable ).' -id '.fullname ) - " - if empty( errors_mlint ) - let errors = '' - else - let errors = 'FILE '.currentbuffer."\n".errors_mlint.'FILEEND' - endif - " - let errorf_saved = &g:errorformat - " - let &g:errorformat = - \ '%-PFILE %f,%-QFILEEND,' - \ .'L %l (C %c): %m,L %l (C %c-%*\d): %m' - silent exe 'cexpr errors' - " - let &g:errorformat = errorf_saved - " - if empty ( errors_mlint ) - redraw " redraw after cclose, before echoing - call s:ImportantMsg ( bufname('%').': No warnings.' ) - else - botright cwindow - cc - endif - " -endfunction " ---------- end of function Matlab_CheckCode ---------- -" -"------------------------------------------------------------------------------- -" Matlab_IgnoreWarning : Ignore the current mlint warning. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_IgnoreWarning() range - " - " the list of errors - let qf_list = getqflist () - " - if empty ( qf_list ) - return s:ImportantMsg ( 'No warnings.' ) - endif - " - " assemble all the information - let my_buf = bufnr ( '%' ) - let my_line = line ( '.' ) - let my_col = col ( '.' ) - let text = '' - let type = '' - " - " look for the right error - " number of errors on the line: - " - none : abort - " - one : continue with this error - " - two or more : the column must match as well - let err_on_line = 0 - " - for error in qf_list - " ignore invalid errors, errors on other lines - if ! error.valid || error.bufnr != my_buf || error.lnum != my_line - continue - endif - " - " matches the location precisely - if error.col == my_col - let text = error.text - let err_on_line = 1 - break - endif - " - let text = error.text - let err_on_line += 1 - continue - endfor - " - if empty ( text ) - return s:ImportantMsg ( 'No warning for this line.' ) - elseif err_on_line > 1 - return s:ImportantMsg ( 'There is more than one warning for this line. Go to the correct location.' ) - endif - " - let type = matchstr ( text, '^\w\+' ) - " - " append or add to the special comment - let line = getline ( '.' ) - let mlist = matchlist ( line, '%#ok\%(:\|<\)\([a-zA-Z,]\+\)>\?\s*$' ) - if ! empty ( mlist ) - " line contains %#ok, check if the error-code is contained as well - if -1 == match ( mlist[1], type ) - exe ':.s/\(>\?\)\s*$/,'.type.'\1' - else - call s:ImportantMsg ( 'Error is already being ignored.' ) - endif - else - " append %#ok:... - exe ':.s/\s*$/ %#ok<'.type.'>' - endif - " - " reposition the cursor - call cursor ( my_line, my_col ) - " -endfunction " ---------- end of function Matlab_IgnoreWarning ---------- -" -"------------------------------------------------------------------------------ -" === Templates API === {{{1 -"------------------------------------------------------------------------------ -" -"------------------------------------------------------------------------------ -" Matlab_SetMapLeader {{{2 -"------------------------------------------------------------------------------ -function! Matlab_SetMapLeader () - if exists ( 'g:Matlab_MapLeader' ) - call mmtemplates#core#SetMapleader ( g:Matlab_MapLeader ) - endif -endfunction " ---------- end of function Matlab_SetMapLeader ---------- -" -"------------------------------------------------------------------------------ -" Matlab_ResetMapLeader {{{2 -"------------------------------------------------------------------------------ -function! Matlab_ResetMapLeader () - if exists ( 'g:Matlab_MapLeader' ) - call mmtemplates#core#ResetMapleader () - endif -endfunction " ---------- end of function Matlab_ResetMapLeader ---------- -" }}}2 -" -"------------------------------------------------------------------------------- -" s:SetupTemplates : Initial loading of the templates. {{{1 -"------------------------------------------------------------------------------- -" -function! s:SetupTemplates() - " - "------------------------------------------------------------------------------- - " setup template library - "------------------------------------------------------------------------------- - let g:Matlab_Templates = mmtemplates#core#NewLibrary () - " - " mapleader - if empty ( g:Matlab_MapLeader ) - call mmtemplates#core#Resource ( g:Matlab_Templates, 'set', 'property', 'Templates::Mapleader', '\' ) - else - call mmtemplates#core#Resource ( g:Matlab_Templates, 'set', 'property', 'Templates::Mapleader', g:Matlab_MapLeader ) - endif - " - " map: choose style - call mmtemplates#core#Resource ( g:Matlab_Templates, 'set', 'property', 'Templates::ChooseStyle::Map', 'nts' ) - " - " syntax: comments - call mmtemplates#core#ChangeSyntax ( g:Matlab_Templates, 'comment', '§' ) - " - "------------------------------------------------------------------------------- - " load template library - "------------------------------------------------------------------------------- - if s:installation == 'system' - "------------------------------------------------------------------------------- - " system installation - "------------------------------------------------------------------------------- - " - " global templates - if filereadable( s:Matlab_GlbTemplateFile ) - call mmtemplates#core#ReadTemplates ( g:Matlab_Templates, 'load', s:Matlab_GlbTemplateFile ) - else - return s:ErrorMsg ( 'Global template file "'.s:Matlab_GlbTemplateFile.'" not readable.' ) - endif - " - let local_dir = fnamemodify ( s:Matlab_LclTemplateFile, ':p:h' ) - " - if ! isdirectory( local_dir ) && exists('*mkdir') - try - call mkdir ( local_dir, 'p' ) - catch /.*/ - endtry - endif - " - if isdirectory( local_dir ) && ! filereadable( s:Matlab_LclTemplateFile ) - let sample_template_file = s:plugin_dir.'/matlab-support/rc/sample_template_file' - if filereadable( sample_template_file ) - call writefile ( readfile ( sample_template_file ), s:Matlab_LclTemplateFile ) - endif - endif - " - " local templates - if filereadable( s:Matlab_LclTemplateFile ) - call mmtemplates#core#ReadTemplates ( g:Matlab_Templates, 'load', s:Matlab_LclTemplateFile ) - if mmtemplates#core#ExpandText ( g:Matlab_Templates, '|AUTHOR|' ) == 'YOUR NAME' - call s:ErrorMsg ( 'Please set your personal details in the file "'.s:Matlab_LclTemplateFile.'".' ) - endif - endif - " - elseif s:installation == 'local' - "------------------------------------------------------------------------------- - " local installation - "------------------------------------------------------------------------------- - " - " local templates - if filereadable ( s:Matlab_LclTemplateFile ) - call mmtemplates#core#ReadTemplates ( g:Matlab_Templates, 'load', s:Matlab_LclTemplateFile ) - else - return s:ErrorMsg ( 'Local template file "'.s:Matlab_LclTemplateFile.'" not readable.' ) - endif - endif -endfunction " ---------- end of function s:SetupTemplates ---------- -" -"------------------------------------------------------------------------------- -" Matlab_HelpPlugin : Plug-in help. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_HelpPlugin () - try - help matlab-support - catch - exe 'helptags '.s:plugin_dir.'/doc' - help matlab-support - endtry -endfunction " ---------- end of function Matlab_HelpPlugin ---------- -" -"------------------------------------------------------------------------------- -" s:CreateMaps : Create additional maps. {{{1 -"------------------------------------------------------------------------------- -" -function! s:CreateMaps () - " - "------------------------------------------------------------------------------- - " settings - local leader - "------------------------------------------------------------------------------- - if ! empty ( g:Matlab_MapLeader ) - if exists ( 'g:maplocalleader' ) - let ll_save = g:maplocalleader - endif - let g:maplocalleader = g:Matlab_MapLeader - endif - " - "------------------------------------------------------------------------------- - " comments - "------------------------------------------------------------------------------- - noremap <buffer> <silent> <LocalLeader>cl :call Matlab_EndOfLineComment()<CR> - inoremap <buffer> <silent> <LocalLeader>cl <Esc>:call Matlab_EndOfLineComment()<CR> - noremap <buffer> <silent> <LocalLeader>cj :call Matlab_AdjustEndOfLineComm()<CR> - inoremap <buffer> <silent> <LocalLeader>cj <Esc>:call Matlab_AdjustEndOfLineComm()<CR> - noremap <buffer> <silent> <LocalLeader>cs :call Matlab_SetEndOfLineCommPos()<CR> - inoremap <buffer> <silent> <LocalLeader>cs <Esc>:call Matlab_SetEndOfLineCommPos()<CR> - " - noremap <buffer> <silent> <LocalLeader>cc :call Matlab_CodeComment()<CR> - inoremap <buffer> <silent> <LocalLeader>cc <Esc>:call Matlab_CodeComment()<CR> - noremap <buffer> <silent> <LocalLeader>co :call Matlab_CommentCode(0)<CR> - inoremap <buffer> <silent> <LocalLeader>co <Esc>:call Matlab_CommentCode(0)<CR> - noremap <buffer> <silent> <LocalLeader>ct :call Matlab_CommentCode(1)<CR> - inoremap <buffer> <silent> <LocalLeader>ct <Esc>:call Matlab_CommentCode(1)<CR> - " - noremap <buffer> <silent> <LocalLeader>ca :call Matlab_FunctionComment()<CR> - inoremap <buffer> <silent> <LocalLeader>ca <Esc>:call Matlab_FunctionComment()<CR> - " - "------------------------------------------------------------------------------- - " snippets - "------------------------------------------------------------------------------- - nnoremap <buffer> <silent> <LocalLeader>ni :call Matlab_CodeSnippet('insert')<CR> - inoremap <buffer> <silent> <LocalLeader>ni <C-C>:call Matlab_CodeSnippet('insert')<CR> - vnoremap <buffer> <silent> <LocalLeader>ni <C-C>:call Matlab_CodeSnippet('insert')<CR> - nnoremap <buffer> <silent> <LocalLeader>nc :call Matlab_CodeSnippet('create')<CR> - inoremap <buffer> <silent> <LocalLeader>nc <C-C>:call Matlab_CodeSnippet('create')<CR> - vnoremap <buffer> <silent> <LocalLeader>nc <C-C>:call Matlab_CodeSnippet('vcreate')<CR> - nnoremap <buffer> <silent> <LocalLeader>nv :call Matlab_CodeSnippet('view')<CR> - inoremap <buffer> <silent> <LocalLeader>nv <C-C>:call Matlab_CodeSnippet('view')<CR> - vnoremap <buffer> <silent> <LocalLeader>nv <C-C>:call Matlab_CodeSnippet('view')<CR> - nnoremap <buffer> <silent> <LocalLeader>ne :call Matlab_CodeSnippet('edit')<CR> - inoremap <buffer> <silent> <LocalLeader>ne <C-C>:call Matlab_CodeSnippet('edit')<CR> - vnoremap <buffer> <silent> <LocalLeader>ne <C-C>:call Matlab_CodeSnippet('edit')<CR> - " - "------------------------------------------------------------------------------- - " templates - specials - "------------------------------------------------------------------------------- - nnoremap <buffer> <silent> <LocalLeader>ntl :call mmtemplates#core#EditTemplateFiles(g:Matlab_Templates,-1)<CR> - inoremap <buffer> <silent> <LocalLeader>ntl <C-C>:call mmtemplates#core#EditTemplateFiles(g:Matlab_Templates,-1)<CR> - vnoremap <buffer> <silent> <LocalLeader>ntl <C-C>:call mmtemplates#core#EditTemplateFiles(g:Matlab_Templates,-1)<CR> - if s:installation == 'system' - nnoremap <buffer> <silent> <LocalLeader>ntg :call mmtemplates#core#EditTemplateFiles(g:Matlab_Templates,0)<CR> - inoremap <buffer> <silent> <LocalLeader>ntg <C-C>:call mmtemplates#core#EditTemplateFiles(g:Matlab_Templates,0)<CR> - vnoremap <buffer> <silent> <LocalLeader>ntg <C-C>:call mmtemplates#core#EditTemplateFiles(g:Matlab_Templates,0)<CR> - endif - nnoremap <buffer> <silent> <LocalLeader>ntr :call mmtemplates#core#ReadTemplates(g:Matlab_Templates,"reload","all")<CR> - inoremap <buffer> <silent> <LocalLeader>ntr <C-C>:call mmtemplates#core#ReadTemplates(g:Matlab_Templates,"reload","all")<CR> - vnoremap <buffer> <silent> <LocalLeader>ntr <C-C>:call mmtemplates#core#ReadTemplates(g:Matlab_Templates,"reload","all")<CR> - nnoremap <buffer> <silent> <LocalLeader>nts :call mmtemplates#core#ChooseStyle(g:Matlab_Templates,"!pick")<CR> - inoremap <buffer> <silent> <LocalLeader>nts <C-C>:call mmtemplates#core#ChooseStyle(g:Matlab_Templates,"!pick")<CR> - vnoremap <buffer> <silent> <LocalLeader>nts <C-C>:call mmtemplates#core#ChooseStyle(g:Matlab_Templates,"!pick")<CR> - " - "------------------------------------------------------------------------------- - " code checker - "------------------------------------------------------------------------------- - nnoremap <buffer> <silent> <LocalLeader>rk :call Matlab_CheckCode()<CR> - inoremap <buffer> <silent> <LocalLeader>rk <Esc>:call Matlab_CheckCode()<CR> - vnoremap <buffer> <silent> <LocalLeader>rk <Esc>:call Matlab_CheckCode()<CR> - nnoremap <buffer> <silent> <LocalLeader>ri :call Matlab_IgnoreWarning()<CR> - inoremap <buffer> <silent> <LocalLeader>ri <Esc>:call Matlab_IgnoreWarning()<CR> - vnoremap <buffer> <silent> <LocalLeader>ri <Esc>:call Matlab_IgnoreWarning()<CR> - " - "------------------------------------------------------------------------------- - " settings - "------------------------------------------------------------------------------- - nnoremap <buffer> <silent> <LocalLeader>rs :call Matlab_Settings(0)<CR> - inoremap <buffer> <silent> <LocalLeader>rs <Esc>:call Matlab_Settings(0)<CR> - vnoremap <buffer> <silent> <LocalLeader>rs <Esc>:call Matlab_Settings(0)<CR> - " - "------------------------------------------------------------------------------- - " help - "------------------------------------------------------------------------------- - nnoremap <buffer> <silent> <LocalLeader>hs :call Matlab_HelpPlugin()<CR> - inoremap <buffer> <silent> <LocalLeader>hs <Esc>:call Matlab_HelpPlugin()<CR> - vnoremap <buffer> <silent> <LocalLeader>hs <Esc>:call Matlab_HelpPlugin()<CR> - " - "------------------------------------------------------------------------------- - " settings - reset local leader - "------------------------------------------------------------------------------- - if ! empty ( g:Matlab_MapLeader ) - if exists ( 'll_save' ) - let g:maplocalleader = ll_save - else - unlet g:maplocalleader - endif - endif - " - "------------------------------------------------------------------------------- - " templates - "------------------------------------------------------------------------------- - call mmtemplates#core#CreateMaps ( 'g:Matlab_Templates', g:Matlab_MapLeader, 'do_jump_map' ) - " -endfunction " ---------- end of function s:CreateMaps ---------- -" -"------------------------------------------------------------------------------- -" s:InitMenus : Initialize menus. {{{1 -"------------------------------------------------------------------------------- -" -function! s:InitMenus() - " - if ! has ( 'menu' ) - return - endif - " - " Preparation - call mmtemplates#core#CreateMenus ( 'g:Matlab_Templates', s:Matlab_RootMenu, 'do_reset' ) - " - " get the mapleader (correctly escaped) - let [ esc_mapl, err ] = mmtemplates#core#Resource ( g:Matlab_Templates, 'escaped_mapleader' ) - " - exe 'anoremenu '.s:Matlab_RootMenu.'.Matlab <Nop>' - exe 'anoremenu '.s:Matlab_RootMenu.'.-Sep00- <Nop>' - " - "------------------------------------------------------------------------------- - " menu headers - "------------------------------------------------------------------------------- - " - call mmtemplates#core#CreateMenus ( 'g:Matlab_Templates', s:Matlab_RootMenu, 'sub_menu', '&Comments', 'priority', 500 ) - " the other, automatically created menus go here; their priority is the standard priority 500 - call mmtemplates#core#CreateMenus ( 'g:Matlab_Templates', s:Matlab_RootMenu, 'sub_menu', 'S&nippets', 'priority', 600 ) - call mmtemplates#core#CreateMenus ( 'g:Matlab_Templates', s:Matlab_RootMenu, 'sub_menu', '&Run' , 'priority', 700 ) - call mmtemplates#core#CreateMenus ( 'g:Matlab_Templates', s:Matlab_RootMenu, 'sub_menu', '&Help' , 'priority', 800 ) - " - "------------------------------------------------------------------------------- - " comments - "------------------------------------------------------------------------------- - " - let ahead = 'anoremenu <silent> '.s:Matlab_RootMenu.'.Comments.' - let vhead = 'vnoremenu <silent> '.s:Matlab_RootMenu.'.Comments.' - " - exe ahead.'end-of-&line\ comment<TAB>'.esc_mapl.'cl :call Matlab_EndOfLineComment()<CR>' - exe vhead.'end-of-&line\ comment<TAB>'.esc_mapl.'cl :call Matlab_EndOfLineComment()<CR>' - exe ahead.'ad&just\ end-of-line\ com\.<TAB>'.esc_mapl.'cj :call Matlab_AdjustEndOfLineComm()<CR>' - exe vhead.'ad&just\ end-of-line\ com\.<TAB>'.esc_mapl.'cj :call Matlab_AdjustEndOfLineComm()<CR>' - exe ahead.'&set\ end-of-line\ com\.\ col\.<TAB>'.esc_mapl.'cs :call Matlab_SetEndOfLineCommPos()<CR>' - exe vhead.'&set\ end-of-line\ com\.\ col\.<TAB>'.esc_mapl.'cs :call Matlab_SetEndOfLineCommPos()<CR>' - exe ahead.'-Sep01- :' - " - exe ahead.'&code\ ->\ comment<TAB>'.esc_mapl.'cc :call Matlab_CodeComment()<CR>' - exe vhead.'&code\ ->\ comment<TAB>'.esc_mapl.'cc :call Matlab_CodeComment()<CR>' - exe ahead.'c&omment\ ->\ code<TAB>'.esc_mapl.'co :call Matlab_CommentCode(0)<CR>' - exe vhead.'c&omment\ ->\ code<TAB>'.esc_mapl.'co :call Matlab_CommentCode(0)<CR>' - exe ahead.'&toggle\ code\ <->\ com\.<TAB>'.esc_mapl.'ct :call Matlab_CommentCode(1)<CR>' - exe vhead.'&toggle\ code\ <->\ com\.<TAB>'.esc_mapl.'ct :call Matlab_CommentCode(1)<CR>' - exe ahead.'-Sep02- :' - " - exe ahead.'function\ description\ (&auto)<TAB>'.esc_mapl.'ca :call Matlab_FunctionComment()<CR>' - exe vhead.'function\ description\ (&auto)<TAB>'.esc_mapl.'ca :call Matlab_FunctionComment()<CR>' - exe ahead.'-Sep03- :' - " - "------------------------------------------------------------------------------- - " templates - "------------------------------------------------------------------------------- - " - call mmtemplates#core#CreateMenus ( 'g:Matlab_Templates', s:Matlab_RootMenu, 'do_templates' ) - " - "------------------------------------------------------------------------------- - " snippets - "------------------------------------------------------------------------------- - " - let ahead = 'anoremenu <silent> '.s:Matlab_RootMenu.'.Snippets.' - let vhead = 'vnoremenu <silent> '.s:Matlab_RootMenu.'.Snippets.' - " - exe ahead.'&insert\ code\ snippet<Tab>'.esc_mapl.'ni :call Matlab_CodeSnippet("insert")<CR>' - exe ahead.'&create\ code\ snippet<Tab>'.esc_mapl.'nc :call Matlab_CodeSnippet("create")<CR>' - exe vhead.'&create\ code\ snippet<Tab>'.esc_mapl.'nc <C-C>:call Matlab_CodeSnippet("vcreate")<CR>' - exe ahead.'&view\ code\ snippet<Tab>'.esc_mapl.'nv :call Matlab_CodeSnippet("view")<CR>' - exe ahead.'&edit\ code\ snippet<Tab>'.esc_mapl.'ne :call Matlab_CodeSnippet("edit")<CR>' - exe ahead.'-Sep01- :' - " - exe ahead.'edit\ &local\ templates<Tab>'.esc_mapl.'ntl :call mmtemplates#core#EditTemplateFiles(g:Matlab_Templates,-1)<CR>' - if s:installation == 'system' - exe ahead.'edit\ &global\ templates<Tab>'.esc_mapl.'ntg :call mmtemplates#core#EditTemplateFiles(g:Matlab_Templates,0)<CR>' - endif - exe ahead.'reread\ &templates<Tab>'.esc_mapl.'ntr :call mmtemplates#core#ReadTemplates(g:Matlab_Templates,"reload","all")<CR>' - " - " styles - call mmtemplates#core#CreateMenus ( 'g:Matlab_Templates', s:Matlab_RootMenu, 'do_styles', - \ 'specials_menu', 'Snippets' ) - " - "------------------------------------------------------------------------------- - " run - "------------------------------------------------------------------------------- - " - let ahead = 'anoremenu <silent> '.s:Matlab_RootMenu.'.Run.' - let vhead = 'vnoremenu <silent> '.s:Matlab_RootMenu.'.Run.' - " - exe ahead.'&check\ code<TAB>'.esc_mapl.'rk :call Matlab_CheckCode()<CR>' - exe ahead.'&ignore\ warning<TAB>'.esc_mapl.'ri :call Matlab_IgnoreWarning()<CR>' - exe ahead.'-Sep01- :' - " - exe ahead.'&settings<TAB>'.esc_mapl.'rs :call Matlab_Settings(0)<CR>' - " - "------------------------------------------------------------------------------- - " help - "------------------------------------------------------------------------------- - " - let ahead = 'anoremenu <silent> '.s:Matlab_RootMenu.'.Help.' - let vhead = 'vnoremenu <silent> '.s:Matlab_RootMenu.'.Help.' - " - exe ahead.'-Sep01- :' - exe ahead.'&help\ (Matlab-Support)<TAB>'.esc_mapl.'hs :call Matlab_HelpPlugin()<CR>' - " -endfunction " ---------- end of function s:InitMenus ---------- -" -"------------------------------------------------------------------------------- -" s:ToolMenu : Add or remove tool menu entries. {{{1 -"------------------------------------------------------------------------------- -" -function! s:ToolMenu( action ) - " - if ! has ( 'menu' ) - return - endif - " - if a:action == 'setup' - anoremenu <silent> 40.1000 &Tools.-SEP100- : - anoremenu <silent> 40.1140 &Tools.Load\ Matlab\ Support :call Matlab_AddMenus()<CR> - elseif a:action == 'loading' - aunmenu <silent> &Tools.Load\ Matlab\ Support - anoremenu <silent> 40.1140 &Tools.Unload\ Matlab\ Support :call Matlab_RemoveMenus()<CR> - elseif a:action == 'unloading' - aunmenu <silent> &Tools.Unload\ Matlab\ Support - anoremenu <silent> 40.1140 &Tools.Load\ Matlab\ Support :call Matlab_AddMenus()<CR> - endif - " -endfunction " ---------- end of function s:ToolMenu ---------- -" -"------------------------------------------------------------------------------- -" Matlab_AddMenus : Add menus. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_AddMenus() - if s:MenuVisible == 0 - " make sure the templates are loaded - call s:SetupTemplates () - " initialize if not existing - call s:ToolMenu ( 'loading' ) - call s:InitMenus () - " the menu is now visible - let s:MenuVisible = 1 - endif -endfunction " ---------- end of function Matlab_AddMenus ---------- -" -"------------------------------------------------------------------------------- -" Matlab_RemoveMenus : Remove menus. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_RemoveMenus() - if s:MenuVisible == 1 - " destroy if visible - call s:ToolMenu ( 'unloading' ) - if has ( 'menu' ) - exe 'aunmenu <silent> '.s:Matlab_RootMenu - endif - " the menu is now invisible - let s:MenuVisible = 0 - endif -endfunction " ---------- end of function Matlab_RemoveMenus ---------- -" -"------------------------------------------------------------------------------- -" Matlab_Settings : Print the settings on the command line. {{{1 -"------------------------------------------------------------------------------- -" -function! Matlab_Settings( verbose ) - " - if s:MSWIN | let sys_name = 'Windows' - elseif s:UNIX | let sys_name = 'UN*X' - else | let sys_name = 'unknown' | endif - " - let glb_t_status = filereadable ( s:Matlab_GlbTemplateFile ) ? '' : ' (not readable)' - let lcl_t_status = filereadable ( s:Matlab_LclTemplateFile ) ? '' : ' (not readable)' - let mlint_status = executable( s:Matlab_MlintExecutable ) ? '' : ' (not executable)' - " - let txt = " Matlab-Support settings\n\n" - if exists ( 'g:Matlab_Templates' ) - let [ templ_style, msg ] = mmtemplates#core#Resource( g:Matlab_Templates, 'style' ) - " - let txt .= - \ ' author : "'.mmtemplates#core#ExpandText( g:Matlab_Templates, '|AUTHOR|' )."\"\n" - \ .' authorref : "'.mmtemplates#core#ExpandText( g:Matlab_Templates, '|AUTHORREF|' )."\"\n" - \ .' email : "'.mmtemplates#core#ExpandText( g:Matlab_Templates, '|EMAIL|' )."\"\n" - \ .' organization : "'.mmtemplates#core#ExpandText( g:Matlab_Templates, '|ORGANIZATION|' )."\"\n" - \ .' copyright holder : "'.mmtemplates#core#ExpandText( g:Matlab_Templates, '|COPYRIGHT|' )."\"\n" - \ .' licence : "'.mmtemplates#core#ExpandText( g:Matlab_Templates, '|LICENSE|' )."\"\n" - \ .' template style : "'.templ_style."\"\n" - \ ."\n" - else - let txt .= - \ " templates : -not loaded- \n" - \ ."\n" - endif - let txt .= - \ ' plugin installation : '.s:installation.' on '.sys_name."\n" - \ .' using template engine : version '.g:Templates_Version." by Wolfgang Mehner\n" - \ ."\n" - if s:installation == 'system' - let txt .= ' global template file : '.s:Matlab_GlbTemplateFile.glb_t_status."\n" - endif - let txt .= - \ ' local template file : '.s:Matlab_LclTemplateFile.lcl_t_status."\n" - \ .' code snippets dir. : '.s:Matlab_SnippetDir."\n" - \ .' mlint path and exe : '.s:Matlab_MlintExecutable.mlint_status."\n" - if a:verbose >= 1 - let txt .= "\n" - \ .' mapleader : "'.g:Matlab_MapLeader."\"\n" - \ .' load menus : "'.s:Matlab_LoadMenus."\"\n" - endif - let txt .= - \ "________________________________________________________________________________\n" - \ ." Matlab-Support, Version ".g:Matlab_Version." / Wolfgang Mehner / wolfgang-mehner@web.de\n\n" - " - if a:verbose == 2 - split MatlabSupport_Settings.txt - put = txt - else - echo txt - endif -endfunction " ---------- end of function Matlab_Settings ---------- -" -"------------------------------------------------------------------------------- -" Setup: Templates and menus. {{{1 -"------------------------------------------------------------------------------- -" -" tool menu entry -call s:ToolMenu ( 'setup' ) -" -" load the menu right now? -if s:Matlab_LoadMenus == 'startup' - call Matlab_AddMenus () -endif -" -if has( 'autocmd' ) - autocmd FileType * - \ if &filetype == 'matlab' && ! exists( 'g:Matlab_Templates' ) | - \ if s:Matlab_LoadMenus == 'auto' | call Matlab_AddMenus () | - \ else | call s:SetupTemplates () | - \ endif | - \ endif - autocmd FileType * - \ if &filetype == 'matlab' | - \ call s:CreateMaps() | - \ endif -endif -" }}}1 -"------------------------------------------------------------------------------- -" -" ===================================================================================== -" vim: foldmethod=marker diff --git a/plugin/perl-support.vim b/plugin/perl-support.vim index 8116ed3..bd35031 100644 --- a/plugin/perl-support.vim +++ b/plugin/perl-support.vim @@ -39,9 +39,9 @@ " " Version: see variable g:Perl_PluginVersion below " Created: 09.07.2001 -" Revision: 12.02.2017 +" Revision: 26.06.2019 " License: Copyright (c) 2001-2014, Fritz Mehner -" Copyright (c) 2015-2017, Wolfgang Mehner +" Copyright (c) 2015-2020, Wolfgang Mehner " This program is free software; you can redistribute it " and/or modify it under the terms of the GNU General Public " License as published by the Free Software Foundation, @@ -61,7 +61,7 @@ " need at least 7.0 if v:version < 700 echohl WarningMsg - echo 'The plugin latex-support.vim needs Vim version >= 7.' + echo 'The plugin perl-support.vim needs Vim version >= 7.' echohl None finish endif @@ -72,7 +72,7 @@ if exists("g:Perl_PluginVersion") || &cp finish endif -let g:Perl_PluginVersion= "5.5pre" +let g:Perl_PluginVersion= "5.5alpha" " version number of this script; do not change "------------------------------------------------------------------------------- " === Auxiliary functions === {{{1 @@ -92,10 +92,10 @@ let g:Perl_PluginVersion= "5.5pre" "------------------------------------------------------------------------------- function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - let { 'g:'.a:varname } = a:value + if ! exists( 'g:'.a:varname ) + let {'g:'.a:varname} = a:value endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ErrorMsg : Print an error message. {{{2 @@ -114,7 +114,7 @@ function! s:ErrorMsg ( ... ) echomsg line endfor echohl None -endfunction " ---------- end of function s:ErrorMsg ---------- +endfunction "------------------------------------------------------------------------------- " s:GetGlobalSetting : Get a setting from a global variable. {{{2 @@ -135,10 +135,10 @@ endfunction " ---------- end of function s:ErrorMsg ---------- function! s:GetGlobalSetting ( varname, ... ) let lname = a:varname let gname = a:0 >= 1 ? a:1 : lname - if exists ( 'g:'.gname ) - let { 's:'.lname } = { 'g:'.gname } + if exists( 'g:'.gname ) + let {'s:'.lname} = {'g:'.gname} endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ImportantMsg : Print an important message. {{{2 @@ -237,15 +237,17 @@ endfunction " ---------- end of function s:WarningMsg ---------- " }}}2 "------------------------------------------------------------------------------- -"------------------------------------------------------------------------------ -" -" Platform specific items: {{{1 -" - plugin directory -" - characters that must be escaped for filenames -" -let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") -let s:UNIX = has("unix") || has("macunix") || has("win32unix") -" +"------------------------------------------------------------------------------- +" === Module setup === {{{1 +"------------------------------------------------------------------------------- + +"------------------------------------------------------------------------------- +" == Platform specific items == {{{2 +"------------------------------------------------------------------------------- + +let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") +let s:UNIX = has("unix") || has("macunix") || has("win32unix") + let s:Perl_Executable = '' " the Perl interpreter used let s:Perl_Perl_is_executable = 0 " the Perl interpreter used let g:Perl_Installation = '*undefined*' @@ -257,12 +259,12 @@ let s:Perl_CustomTemplateFile = '' " the custom templates let g:Perl_FilenameEscChar = '' " let s:Perl_ToolboxDir = [] -" -if s:MSWIN - " ========== MS Windows ====================================================== - " + +if s:MSWIN + " ========== MS Windows ====================================================== + let g:Perl_PluginDir = substitute( expand('<sfile>:p:h:h'), '\', '/', 'g' ) - " + " change '\' to '/' to avoid interpretation as escape character if match( substitute( expand("<sfile>"), '\', '/', 'g' ), \ substitute( expand("$HOME"), '\', '/', 'g' ) ) == 0 @@ -280,16 +282,16 @@ if s:MSWIN let s:Perl_ToolboxDir += [ \ g:Perl_PluginDir.'/autoload/mmtoolbox/', \ $HOME.'/vimfiles/autoload/mmtoolbox/' ] - end - " + endif + let s:Perl_Executable = 'C:/Perl/bin/perl.exe' let g:Perl_FilenameEscChar = '' - " + else - " ========== Linux/Unix ====================================================== - " + " ========== Linux/Unix ====================================================== + let g:Perl_PluginDir = expand("<sfile>:p:h:h") - " + if match( expand("<sfile>"), resolve( expand("$HOME") ) ) == 0 " USER INSTALLATION ASSUMED let g:Perl_Installation = 'local' @@ -306,32 +308,41 @@ else \ g:Perl_PluginDir.'/autoload/mmtoolbox/', \ $HOME.'/.vim/autoload/mmtoolbox/' ] endif - " - let s:Perl_Executable = '/usr/bin/perl' + + let s:Perl_Executable = 'perl' let g:Perl_FilenameEscChar = ' \%#[]' - " + " ============================================================================== endif -" + " g:Perl_CodeSnippets is used in autoload/perlsupportgui.vim -" let s:Perl_CodeSnippets = g:Perl_PluginDir.'/perl-support/codesnippets/' call s:ApplyDefaultSetting( 'Perl_CodeSnippets', s:Perl_CodeSnippets ) -" -" + +"------------------------------------------------------------------------------- +" == Various settings == {{{2 +"------------------------------------------------------------------------------- + call s:ApplyDefaultSetting( 'Perl_PerlTags', 'off' ) + +"------------------------------------------------------------------------------- +" Use of dictionaries {{{3 " +" - keyword completion is enabled by the function 's:CreateAdditionalMaps' below +"------------------------------------------------------------------------------- + if !exists("g:Perl_Dictionary_File") - let g:Perl_Dictionary_File = g:Perl_PluginDir.'/perl-support/wordlists/perl.list' + let g:Perl_Dictionary_File = g:Perl_PluginDir.'/perl-support/wordlists/perl.list' endif -" -" -" Modul global variables (with default values) which can be overridden. {{{1 -" + +"------------------------------------------------------------------------------- +" User configurable options {{{3 +"------------------------------------------------------------------------------- + let s:Perl_LoadMenus = 'yes' " display the menus ? -let s:Perl_TemplateOverriddenMsg = 'no' -let s:Perl_Ctrl_j = 'on' -" +let s:Perl_Ctrl_j = 'yes' +let s:Perl_Ctrl_d = 'yes' + let s:Perl_TimestampFormat = '%Y%m%d.%H%M%S' let s:Perl_PerlModuleList = g:Perl_PluginDir.'/perl-support/modules/perl-modules.list' @@ -348,8 +359,6 @@ let s:Perl_GuiSnippetBrowser = 'gui' " gui / commandline let s:Perl_CreateMenusDelayed = 'yes' let s:Perl_DirectRun = 'no' -let s:Xterm_Executable = 'xterm' - let s:Perl_InsertFileHeader = 'yes' let s:Perl_Wrapper = g:Perl_PluginDir.'/perl-support/scripts/wrapper.sh' let s:Perl_PerlModuleListGenerator = g:Perl_PluginDir.'/perl-support/scripts/pmdesc3.pl' @@ -361,10 +370,10 @@ let s:Perl_RootMenu = '&Perl' let s:Perl_AdditionalTemplates = mmtemplates#config#GetFt ( 'perl' ) let s:Perl_UseToolbox = 'yes' call s:ApplyDefaultSetting ( 'Perl_UseTool_make', 'yes' ) -" -"------------------------------------------------------------------------------ -" look for global variables (if any), to override the defaults +"------------------------------------------------------------------------------- +" Get user configuration {{{3 +"------------------------------------------------------------------------------- call s:GetGlobalSetting('Perl_Executable','Perl_Perl') call s:GetGlobalSetting('Perl_Executable') @@ -372,6 +381,7 @@ call s:GetGlobalSetting('Perl_DirectRun') call s:GetGlobalSetting('Perl_InsertFileHeader') call s:GetGlobalSetting('Perl_CreateMenusDelayed') call s:GetGlobalSetting('Perl_Ctrl_j') +call s:GetGlobalSetting('Perl_Ctrl_d') call s:GetGlobalSetting('Perl_Debugger') call s:GetGlobalSetting('Perl_GlobalTemplateFile') call s:GetGlobalSetting('Perl_LocalTemplateFile') @@ -390,7 +400,6 @@ call s:GetGlobalSetting('Perl_PerltidyBackup') call s:GetGlobalSetting('Perl_PodcheckerWarnings') call s:GetGlobalSetting('Perl_Printheader') call s:GetGlobalSetting('Perl_ProfilerTimestamp') -call s:GetGlobalSetting('Perl_TemplateOverriddenMsg') call s:GetGlobalSetting('Perl_TimestampFormat') call s:GetGlobalSetting('Perl_UseToolbox') @@ -399,9 +408,12 @@ call s:GetGlobalSetting('Perl_UseToolbox') call s:ApplyDefaultSetting( "Perl_OutputGvim",'vim' ) call s:ApplyDefaultSetting( "Perl_PerlRegexSubstitution",'$~' ) -" xterm +"------------------------------------------------------------------------------- +" Xterm {{{3 +"------------------------------------------------------------------------------- -let s:Perl_XtermDefaults = "-fa courier -fs 12 -geometry 80x24" +let s:Xterm_Executable = 'xterm' +let s:Perl_XtermDefaults = '-fa courier -fs 12 -geometry 80x24' " check 'g:Perl_XtermDefaults' for backwards compatibility if ! exists ( 'g:Xterm_Options' ) @@ -415,8 +427,11 @@ endif call s:GetGlobalSetting ( 'Xterm_Executable' ) call s:ApplyDefaultSetting ( 'Xterm_Options', s:Perl_XtermDefaults ) -" flags for perldoc +"------------------------------------------------------------------------------- +" Control variables (not user configurable) {{{3 +"------------------------------------------------------------------------------- +" flags for perldoc if has("gui_running") let s:Perl_perldoc_flags = "" else @@ -431,10 +446,6 @@ let s:Perl_Printheader = escape( s:Perl_Printheader, ' %' ) let s:Perl_Perl_is_executable = executable(s:Perl_Executable) let s:Perl_InterfaceVersion = '' -"------------------------------------------------------------------------------ -" Control variables (not user configurable) -"------------------------------------------------------------------------------ -" let s:Perl_MenuVisible = 'no' let s:Perl_TemplateJumpTarget = '' @@ -445,30 +456,13 @@ let s:Perl_saved_global_option = {} " let s:PCseverityName = [ "DUMMY", "brutal", "cruel", "harsh", "stern", "gentle" ] let s:PCverbosityName = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' ] -" -"=== FUNCTION ================================================================ -" NAME: Perl_Input {{{1 -" DESCRIPTION: Input after a highlighted prompt -" PARAMETERS: prompt - prompt -" text - default reply -" ... - completion (optional) -" RETURNS: -"=============================================================================== -function! Perl_Input ( prompt, text, ... ) - echohl Search " highlight prompt - call inputsave() " preserve typeahead - if a:0 == 0 || empty(a:1) - let retval =input( a:prompt, a:text ) - else - let retval =input( a:prompt, a:text, a:1 ) - endif - call inputrestore() " restore typeahead - echohl None " reset highlighting - let retval = substitute( retval, '^\s\+', "", "" ) " remove leading whitespaces - let retval = substitute( retval, '\s\+$', "", "" ) " remove trailing whitespaces - return retval -endfunction " ---------- end of function Perl_Input ---------- -" + +" }}}3 +"------------------------------------------------------------------------------- + +" }}}2 +"------------------------------------------------------------------------------- + "------------------------------------------------------------------------------ " Perl_SaveGlobalOption {{{1 " param 1 : option name @@ -860,24 +854,27 @@ function! Perl_CodeSnippet(mode) echohl None endif endfunction " ---------- end of function Perl_CodeSnippet ---------- + +"------------------------------------------------------------------------------- +" s:PerlDoc : Look up help. {{{1 " -"------------------------------------------------------------------------------ -" Perl-Run : Perl_perldoc - lookup word under the cursor or ask -"------------------------------------------------------------------------------ -" +" Parameters: +" item - get help for this item (string, optional) +" Returns: +" - +"------------------------------------------------------------------------------- + let s:Perl_PerldocBufferName = "PERLDOC" let s:Perl_PerldocHelpBufferNumber = -1 let s:Perl_PerldocModulelistBuffer = -1 let s:Perl_PerldocSearchWord = "" let s:Perl_PerldocTry = "module" -" -"=== FUNCTION ================================================================ -" NAME: Perl_perldoc {{{1 -" DESCRIPTION: Perl_perldoc - lookup word under the cursor or ask -"=============================================================================== -function! Perl_perldoc() - if( expand("%:p") == s:Perl_PerlModuleList ) +function! s:PerlDoc( item ) + + if a:item != '' + let item = a:item + elseif( expand("%:p") == s:Perl_PerlModuleList ) normal! 0 let item=expand("<cWORD>") " WORD under the cursor else @@ -1006,10 +1003,10 @@ function! Perl_perldoc() " ---------- Add ':' to the keyword characters ------------------------------- " Tokens like 'File::Find' are recognized as one keyword setlocal iskeyword+=: - noremap <buffer> <silent> <S-F1> :call Perl_perldoc()<CR> - inoremap <buffer> <silent> <S-F1> <C-C>:call Perl_perldoc()<CR> + noremap <buffer> <silent> <S-F1> :call <SID>PerlDoc("")<CR> + inoremap <buffer> <silent> <S-F1> <C-C>:call <SID>PerlDoc("")<CR> endif -endfunction " ---------- end of function Perl_perldoc ---------- +endfunction " ---------- end of function s:PerlDoc ---------- " "=== FUNCTION ================================================================ " NAME: Perl_RemoveSpecialCharacters {{{1 @@ -1052,8 +1049,8 @@ function! Perl_perldoc_show_module_list() setlocal nomodifiable setlocal filetype=perl setlocal syntax=none - noremap <buffer> <silent> <S-F1> :call Perl_perldoc()<CR> - inoremap <buffer> <silent> <S-F1> <C-C>:call Perl_perldoc()<CR> + noremap <buffer> <silent> <S-F1> :call <SID>PerlDoc("")<CR> + inoremap <buffer> <silent> <S-F1> <C-C>:call <SID>PerlDoc("")<CR> endif normal! gg redraw! @@ -1182,15 +1179,6 @@ function! Perl_Settings ( verbose ) let txt = txt.' xterm executable : '.s:Xterm_Executable."\n" let txt = txt.' xterm options : '.g:Xterm_Options."\n" endif - if a:verbose == 0 - let txt = txt."\n" - let txt = txt." Additional hot keys\n\n" - let txt = txt." Shift-F1 : read perldoc (for word under cursor)\n" - let txt = txt." F9 : start a debugger (".s:Perl_Debugger.")\n" - let txt = txt." Alt-F9 : run syntax check \n" - let txt = txt." Ctrl-F9 : run script \n" - let txt = txt." Shift-F9 : set command line arguments\n" - endif let txt = txt."________________________________________________________________________________\n" let txt = txt." Perl-Support, Version ".g:Perl_PluginVersion." / Wolfgang Mehner / wolfgang-mehner@web.de\n\n" @@ -1201,16 +1189,18 @@ function! Perl_Settings ( verbose ) echo txt endif endfunction " ---------- end of function Perl_Settings ---------- + +"------------------------------------------------------------------------------- +" s:SyntaxCheck : Run the syntax checker. {{{1 " -"=== FUNCTION ================================================================ -" NAME: Perl_SyntaxCheck {{{1 -" DESCRIPTION: syntax check -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! Perl_SyntaxCheck () +" Parameters: +" Returns: +" - +"------------------------------------------------------------------------------- + +function! s:SyntaxCheck () - if !Perl_Check_Interpreter() + if !s:CheckInterpreter() return endif @@ -1251,8 +1241,8 @@ function! Perl_SyntaxCheck () setlocal wrap setlocal linebreak endif -endfunction " ---------- end of function Perl_SyntaxCheck ---------- -" +endfunction " ---------- end of function s:SyntaxCheck ---------- + "=== FUNCTION ================================================================ " NAME: Perl_Toggle_Gvim_Xterm {{{1 " DESCRIPTION: toggle output destination (vim/buffer/xterm) @@ -1303,14 +1293,16 @@ endfunction " ---------- end of function Perl_ScriptCmdLineArguments -------- function! Perl_PerlCmdLineArguments ( ... ) let b:Perl_Switches = join( a:000 ) endfunction " ---------- end of function Perl_PerlCmdLineArguments ---------- + +"------------------------------------------------------------------------------- +" s:CheckInterpreter : Check perl executable. {{{1 " -let s:Perl_OutputBufferName = "Perl-Output" -let s:Perl_OutputBufferNumber = -1 -" -"------------------------------------------------------------------------------ -" Check if perl interpreter is executable {{{1 -"------------------------------------------------------------------------------ -function! Perl_Check_Interpreter () +" Parameters: +" Returns: +" is_executable - true, if perl is executable (boolean) +"------------------------------------------------------------------------------- + +function! s:CheckInterpreter () if !s:Perl_Perl_is_executable echohl WarningMsg echomsg '(possibly default) Perl interpreter "'.s:Perl_Executable.'" not executable' @@ -1318,17 +1310,23 @@ function! Perl_Check_Interpreter () return 0 endif return 1 -endfunction " ---------- end of function Perl_Check_Interpreter ---------- +endfunction " ---------- end of function s:CheckInterpreter ---------- -"=== FUNCTION ================================================================ -" NAME: Perl_Run {{{1 -" DESCRIPTION: run the current buffer -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! Perl_Run () +"------------------------------------------------------------------------------- +" s:Run : Run the current buffer. {{{1 +" +" Parameters: +" args - command-line arguments (string) +" Returns: +" - +"------------------------------------------------------------------------------- + +let s:Perl_OutputBufferName = "Perl-Output" +let s:Perl_OutputBufferNumber = -1 + +function! s:Run ( args ) - if !Perl_Check_Interpreter() + if !s:CheckInterpreter() return endif @@ -1340,25 +1338,32 @@ function! Perl_Run () if fnamemodify( s:Perl_PerlModuleList, ":p:t" ) == buffername || s:Perl_PerldocBufferName == buffername return endif - " + let l:currentbuffernr = bufnr("%") - let l:arguments = exists("b:Perl_CmdLineArgs") ? " ".b:Perl_CmdLineArgs : "" let l:switches = exists("b:Perl_Switches") ? b:Perl_Switches.' ' : "" let l:currentbuffer = bufname("%") let l:fullname = expand("%:p") - " - silent exe ":update" - silent exe ":cclose" - " + + if a:args != '' + let args_script = a:args + elseif exists("b:Perl_CmdLineArgs") + let args_script = b:Perl_CmdLineArgs + else + let args_script = '' + endif + + silent exe 'update' + silent exe 'cclose' + "------------------------------------------------------------------------------ " run : run from the vim command line "------------------------------------------------------------------------------ if g:Perl_OutputGvim == "vim" " if executable(l:fullname) && s:Perl_DirectRun == 'yes' - exe "!".shellescape(l:fullname).l:arguments + exe "!".shellescape(l:fullname).' '.args_script else - exe '!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).l:arguments + exe '!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).' '.args_script endif " endif @@ -1394,9 +1399,9 @@ function! Perl_Run () silent exe ":update" " if executable(l:fullname) && s:Perl_DirectRun == 'yes' - exe "%!".shellescape(l:fullname).l:arguments + exe "%!".shellescape(l:fullname).' '.args_script else - exe '%!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).l:arguments + exe '%!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).' '.args_script endif " setlocal nomodifiable @@ -1415,89 +1420,97 @@ function! Perl_Run () " if s:MSWIN " MSWIN : same as "vim" - exe '!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).l:arguments + exe '!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).' '.args_script else " Linux if executable(l:fullname) == 1 && s:Perl_DirectRun == 'yes' - silent exe '!'.s:Xterm_Executable.' -title '.shellescape(l:fullname).' '.g:Xterm_Options.' -e '.s:Perl_Wrapper.' '.shellescape(l:fullname).l:arguments + silent exe '!'.s:Xterm_Executable.' -title '.shellescape(l:fullname).' '.g:Xterm_Options.' -e '.s:Perl_Wrapper.' '.shellescape(l:fullname).' '.args_script else - silent exe '!'.s:Xterm_Executable.' -title '.shellescape(l:fullname).' '.g:Xterm_Options.' -e '.s:Perl_Wrapper.' '.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).l:arguments + silent exe '!'.s:Xterm_Executable.' -title '.shellescape(l:fullname).' '.g:Xterm_Options.' -e '.s:Perl_Wrapper.' '.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).' '.args_script endif :redraw! endif " endif " -endfunction " ---------- end of function Perl_Run ---------- +endfunction " ---------- end of function s:Run ---------- + +"------------------------------------------------------------------------------- +" s:Debugger : Start a debugger. {{{1 " -"=== FUNCTION ================================================================ -" NAME: Perl_Debugger {{{1 -" DESCRIPTION: start debugger -" PARAMETERS: - -" RETURNS: -"=============================================================================== -function! Perl_Debugger () - " - silent exe ":update" - let l:arguments = exists("b:Perl_CmdLineArgs") ? " ".b:Perl_CmdLineArgs : "" - let l:switches = exists("b:Perl_Switches") ? b:Perl_Switches.' ' : "" - let filename = expand("%:p") - " - if s:MSWIN - let l:arguments = substitute( l:arguments, '^\s\+', ' ', '' ) - let l:arguments = substitute( l:arguments, '\s\+', "\" \"", 'g') - let l:switches = substitute( l:switches, '^\s\+', ' ', '' ) - let l:switches = substitute( l:switches, '\s\+', "\" \"", 'g') - endif - " - " debugger is ' perl -d ... ' - " - if s:Perl_Debugger == "perl" +" Parameters: +" args - command-line arguments (string) +" Returns: +" - +"------------------------------------------------------------------------------- + +function! s:Debugger ( args ) + + silent exe 'update' + let args_interp = exists("b:Perl_Switches") ? b:Perl_Switches.' ' : "" + let filename = expand("%:p") - if !Perl_Check_Interpreter() + if a:args != '' + let args_script = a:args + elseif exists("b:Perl_CmdLineArgs") + let args_script = b:Perl_CmdLineArgs + else + let args_script = '' + endif + + " :TODO:25.06.2019 19:49:WM: proper shell escaping + if s:MSWIN + let args_script = substitute( args_script, '^\s\+', ' ', '' ) + let args_script = substitute( args_script, '\s\+', "\" \"", 'g') + let args_interp = substitute( args_interp, '^\s\+', ' ', '' ) + let args_interp = substitute( args_interp, '\s\+', "\" \"", 'g') + endif + + " debugger is ' perl -d ... ' + if s:Perl_Debugger == "perl" + + if !s:CheckInterpreter() return endif - if s:MSWIN - exe '!'. s:Perl_Executable .' -d '.shellescape( filename.l:arguments ) - else - if has("gui_running") || &term == "xterm" - silent exe '!'.s:Xterm_Executable.' '.g:Xterm_Options.' -e ' . s:Perl_Executable . l:switches .' -d '.shellescape(filename).l:arguments.' &' - else - silent exe '!clear; ' .s:Perl_Executable. l:switches . ' -d '.shellescape(filename).l:arguments - endif - endif - endif - " - if v:windowid != 0 - " - " grapical debugger is 'ptkdb', uses a PerlTk interface - " - if s:Perl_Debugger == "ptkdb" - if s:MSWIN - exe '!perl -d:ptkdb "'.filename.l:arguments.'"' - else - silent exe '!perl -d:ptkdb '.shellescape(filename).l:arguments.' &' - endif - endif - " - " debugger is 'ddd' (not available for MS Windows); graphical front-end for GDB - " - if s:Perl_Debugger == "ddd" && !s:MSWIN - if !executable("ddd") - echohl WarningMsg - echo 'ddd does not exist or is not executable!' - echohl None - return - else - silent exe '!ddd '.shellescape(filename).l:arguments.' &' - endif - endif - " - endif - " + if s:MSWIN + exe '!'.s:Perl_Executable.' -d '.shellescape( filename.' '.args_script ) + else + if has("gui_running") || &term == "xterm" + silent exe '!'.s:Xterm_Executable.' '.g:Xterm_Options.' -e ' . s:Perl_Executable.' '.args_interp .' -d '.shellescape(filename).' '.args_script.' &' + else + silent exe '!clear; ' .s:Perl_Executable.' '.args_interp.' -d '.shellescape(filename).' '.args_script + endif + endif + endif + + if v:windowid != 0 + + " grapical debugger is 'ptkdb', uses a PerlTk interface + if s:Perl_Debugger == "ptkdb" + if s:MSWIN + exe '!perl -d:ptkdb "'.filename.' '.args_script.'"' + else + silent exe '!perl -d:ptkdb '.shellescape(filename).' '.args_script.' &' + endif + endif + + " debugger is 'ddd' (not available for MS Windows); graphical front-end for GDB + if s:Perl_Debugger == "ddd" && !s:MSWIN + if !executable("ddd") + echohl WarningMsg + echo 'ddd does not exist or is not executable!' + echohl None + return + else + silent exe '!ddd '.shellescape(filename).' '.args_script.' &' + endif + endif + + endif + redraw! -endfunction " ---------- end of function Perl_Debugger ---------- -" +endfunction " ---------- end of function s:Debugger ---------- + "=== FUNCTION ================================================================ " NAME: Perl_XtermSize {{{1 " DESCRIPTION: read xterm geometry @@ -2176,7 +2189,13 @@ function! s:RereadTemplates () " " syntax: comments call mmtemplates#core#ChangeSyntax ( g:Perl_Templates, 'comment', '§' ) - " + + " property: file skeletons (use safe defaults here, more sensible settings are applied in the template library) + call mmtemplates#core#Resource ( g:Perl_Templates, 'add', 'property', 'Perl::FileSkeleton::Script', 'Comments.file description pl' ) + call mmtemplates#core#Resource ( g:Perl_Templates, 'add', 'property', 'Perl::FileSkeleton::Module', 'Comments.file description pm' ) + call mmtemplates#core#Resource ( g:Perl_Templates, 'add', 'property', 'Perl::FileSkeleton::Test', 'Comments.file description t' ) + call mmtemplates#core#Resource ( g:Perl_Templates, 'add', 'property', 'Perl::FileSkeleton::POD', '' ) + "------------------------------------------------------------------------------- " load template library "------------------------------------------------------------------------------- @@ -2219,36 +2238,53 @@ function! s:RereadTemplates () endfunction " ---------- end of function s:RereadTemplates ---------- "------------------------------------------------------------------------------- -" s:CheckTemplatePersonalization : Check template personalization. {{{1 -" -" Check whether the |AUTHOR| has been set in the template library. -" If not, display help on how to set up the template personalization. +" s:CheckAndRereadTemplates : Make sure the templates are loaded. {{{1 "------------------------------------------------------------------------------- -let s:DoneCheckTemplatePersonalization = 0 - -function! s:CheckTemplatePersonalization () - - " check whether the templates are personalized - if s:DoneCheckTemplatePersonalization - \ || mmtemplates#core#ExpandText ( g:Perl_Templates, '|AUTHOR|' ) != 'YOUR NAME' - \ || s:Perl_InsertFileHeader != 'yes' - return +function! s:CheckAndRereadTemplates () + if ! exists ( 'g:Perl_Templates' ) + call s:RereadTemplates() endif +endfunction " ---------- end of function s:CheckAndRereadTemplates ---------- - let s:DoneCheckTemplatePersonalization = 1 - - let maplead = mmtemplates#core#Resource ( g:Perl_Templates, 'get', 'property', 'Templates::Mapleader' )[0] - - redraw - call s:ImportantMsg ( 'The personal details are not set in the template library. Use the map "'.maplead.'ntw".' ) - -endfunction " ---------- end of function s:CheckTemplatePersonalization ---------- +"------------------------------------------------------------------------------- +" s:InsertFileHeader : Insert a file header. {{{1 +" +" The type must be one for which a property exists: +" Perl::FileSkeleton::<script_type> +" +" Parameters: +" script_type - type (string) +"------------------------------------------------------------------------------- +function! s:InsertFileHeader ( script_type ) + call s:CheckAndRereadTemplates() + + " prevent insertion for a file generated from a some error + if isdirectory(expand('%:p:h')) && s:Perl_InsertFileHeader == 'yes' + let templ_s = mmtemplates#core#Resource ( g:Perl_Templates, 'get', 'property', 'Perl::FileSkeleton::'.a:script_type )[0] + + " insert templates in reverse order, always above the first line + " the last one to insert (the first in the list), will determine the + " placement of the cursor + let templ_l = split ( templ_s, ';' ) + for i in range ( len(templ_l)-1, 0, -1 ) + exe 1 + if -1 != match ( templ_l[i], '^\s\+$' ) + put! ='' + else + call mmtemplates#core#InsertTemplate ( g:Perl_Templates, templ_l[i], 'placement', 'above' ) + endif + endfor + if len(templ_l) > 0 + set modified + endif + endif +endfunction " ---------- end of function s:InsertFileHeader ---------- "------------------------------------------------------------------------------- " s:HighlightJumpTargets : Highlight the jump targets. {{{1 "------------------------------------------------------------------------------- function! s:HighlightJumpTargets () - if s:Perl_Ctrl_j == 'on' + if s:Perl_Ctrl_j == 'yes' exe 'match Search /'.s:Perl_TemplateJumpTarget.'/' endif endfunction " ---------- end of function s:HighlightJumpTargets ---------- @@ -2452,16 +2488,16 @@ function! s:Perl_InitMenus () let vhead = 'vmenu <silent> '.s:Perl_RootMenu.'.&Run.' " ----- run, syntax check ----- - exe ahead.'update,\ &run\ script<Tab>'.esc_mapl.'rr\ \ <C-F9> :call Perl_Run()<CR>' - exe ahead.'update,\ check\ &syntax<Tab>'.esc_mapl.'rs\ \ <A-F9> :call Perl_SyntaxCheck()<CR>' - exe 'amenu '.s:Perl_RootMenu.'.&Run.cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'ra\ \ <S-F9> :PerlScriptArguments<Space>' - exe 'amenu .'s:Perl_RootMenu.'.&Run.perl\ s&witches<Tab>'.esc_mapl.'rw :PerlSwitches<Space>' + exe ahead.'update,\ &run\ script<Tab>'.esc_mapl.'rr :call <SID>Run("")<CR>' + exe ahead.'update,\ check\ &syntax<Tab>'.esc_mapl.'rs :call <SID>SyntaxCheck()<CR>' + exe 'amenu '.s:Perl_RootMenu.'.&Run.cmd\.\ line\ &arg\.<Tab>'.esc_mapl.'ra :PerlScriptArguments<Space>' + exe 'amenu .'s:Perl_RootMenu.'.&Run.perl\ s&witches<Tab>'.esc_mapl.'rw :PerlSwitches<Space>' " ----- set execution rights for user only ( user may be root ! ) ----- if !s:MSWIN exe ahead.'make\ script\ &exe\./not\ exec\.<Tab>'.esc_mapl.'re :call Perl_MakeScriptExecutable()<CR>' endif - exe ahead.'start\ &debugger<Tab>'.esc_mapl.'rd\ \ <F9> :call Perl_Debugger()<CR>' + exe ahead.'start\ &debugger<Tab>'.esc_mapl.'rd :call <SID>Debugger("")<CR>' " ----- module list ----- exe ahead.'-SEP2- :' @@ -2532,8 +2568,8 @@ function! s:Perl_InitMenus () let vhead = 'vnoremenu <silent> '.s:Perl_RootMenu.'.Help.' let ihead = 'inoremenu <silent> '.s:Perl_RootMenu.'.Help.' " - exe ahead.'read\ &perldoc<Tab>'.esc_mapl.'h :call Perl_perldoc()<CR>' - exe ihead.'read\ &perldoc<Tab>'.esc_mapl.'h <C-C>:call Perl_perldoc()<CR>' + exe ahead.'read\ &perldoc<Tab>'.esc_mapl.'h :call <SID>PerlDoc("")<CR>' + exe ihead.'read\ &perldoc<Tab>'.esc_mapl.'h <C-C>:call <SID>PerlDoc("")<CR>' exe ahead.'-SEP1- :' exe ahead.'&help\ (Perl-Support)<Tab>'.esc_mapl.'hp :call Perl_HelpPerlsupport()<CR>' exe ihead.'&help\ (Perl-Support)<Tab>'.esc_mapl.'hp <C-C>:call Perl_HelpPerlsupport()<CR>' @@ -2640,19 +2676,17 @@ INITIALIZE_PERL_INTERFACE endif endif endfunction " ---------- end of function Perl_InitializePerlInterface ---------- -" -"=== FUNCTION ================================================================ -" NAME: CreateAdditionalMaps {{{1 -" DESCRIPTION: create additional maps -" PARAMETERS: - -" RETURNS: -"=============================================================================== + +"------------------------------------------------------------------------------- +" s:CreateAdditionalMaps : Create additional maps. {{{1 +"------------------------------------------------------------------------------- function! s:CreateAdditionalMaps () - " + + " we allow this, since the default is 'off' if exists('g:Perl_Perltidy') && g:Perl_Perltidy == 'on' && executable("perltidy") setlocal equalprg='perltidy' endif - " + " ---------- Perl dictionary ------------------------------------------------- " This will enable keyword completion for Perl " using Vim's dictionary feature |i_CTRL-X_CTRL-K|. @@ -2660,22 +2694,28 @@ function! s:CreateAdditionalMaps () if exists("g:Perl_Dictionary_File") silent! exe 'setlocal dictionary+='.g:Perl_Dictionary_File endif - " + "------------------------------------------------------------------------------- " USER DEFINED COMMANDS "------------------------------------------------------------------------------- - " + + " ---------- commands : help ------------------------------------- + command! -nargs=? -buffer PerlDoc call <SID>PerlDoc(<q-args>) + " ---------- commands : run ------------------------------------- - command! -nargs=* -complete=file PerlScriptArguments call Perl_ScriptCmdLineArguments(<q-args>) - command! -nargs=* -complete=file PerlSwitches call Perl_PerlCmdLineArguments(<q-args>) + command! -nargs=* -buffer -complete=file Perl call <SID>Run(<q-args>) + command! -nargs=0 -buffer PerlCheck call <SID>SyntaxCheck() + command! -nargs=* -buffer -complete=file PerlDebug call <SID>Debugger(<q-args>) + + command! -nargs=* -complete=file PerlScriptArguments call Perl_ScriptCmdLineArguments(<q-args>) + command! -nargs=* -complete=file PerlSwitches call Perl_PerlCmdLineArguments(<q-args>) - " " ---------- commands : perlcritic ------------------------------------- command! -nargs=? CriticOptions call Perl_GetPerlcriticOptions (<f-args>) command! -nargs=1 -complete=customlist,Perl_PerlcriticSeverityList CriticSeverity call Perl_GetPerlcriticSeverity (<f-args>) command! -nargs=1 -complete=customlist,Perl_PerlcriticVerbosityList CriticVerbosity call Perl_GetPerlcriticVerbosity(<f-args>) - " - " ---------- commands : perlcritic ------------------------------------- + + " ---------- commands : regex ------------------------------------- command! -nargs=1 RegexSubstitutions call perlsupportregex#Perl_PerlRegexSubstitutions(<f-args>) " " ---------- commands : profiling ------------------------------------- @@ -2703,34 +2743,13 @@ function! s:CreateAdditionalMaps () endif let g:maplocalleader = g:Perl_MapLeader endif - " - " ---------- Key mappings : function keys ------------------------------------ - " - " Ctrl-F9 run script - " Alt-F9 run syntax check - " Shift-F9 set command line arguments - " Shift-F1 read Perl documentation - " Vim (non-GUI) : shifted keys are mapped to their unshifted key !!! - " - if has("gui_running") - " - noremap <buffer> <silent> <A-F9> :call Perl_SyntaxCheck()<CR> - inoremap <buffer> <silent> <A-F9> <C-C>:call Perl_SyntaxCheck()<CR> - " - noremap <buffer> <silent> <C-F9> :call Perl_Run()<CR> - inoremap <buffer> <silent> <C-F9> <C-C>:call Perl_Run()<CR> - " - noremap <buffer> <S-F9> :PerlScriptArguments<Space> - inoremap <buffer> <S-F9> <C-C>:PerlScriptArguments<Space> - " - noremap <buffer> <silent> <S-F1> :call Perl_perldoc()<CR> - inoremap <buffer> <silent> <S-F1> <C-C>:call Perl_perldoc()<CR> - endif - " - " ---------- plugin help ----------------------------------------------------- - " - noremap <buffer> <silent> <LocalLeader>h :call Perl_perldoc()<CR> - inoremap <buffer> <silent> <LocalLeader>h <C-C>:call Perl_perldoc()<CR> + + " ---------------------------------------------------------------------------- + " Help + " ---------------------------------------------------------------------------- + + noremap <buffer> <silent> <LocalLeader>h :call <SID>PerlDoc("")<CR> + inoremap <buffer> <silent> <LocalLeader>h <C-C>:call <SID>PerlDoc("")<CR> noremap <buffer> <silent> <LocalLeader>hp :call Perl_HelpPerlsupport()<CR> inoremap <buffer> <silent> <LocalLeader>hp <C-C>:call Perl_HelpPerlsupport()<CR> " @@ -2829,20 +2848,19 @@ function! s:CreateAdditionalMaps () " Run " ---------------------------------------------------------------------------- " - noremap <buffer> <silent> <LocalLeader>rr :call Perl_Run()<CR> - noremap <buffer> <silent> <LocalLeader>rs :call Perl_SyntaxCheck()<CR> + noremap <buffer> <silent> <LocalLeader>rr :call <SID>Run("")<CR> + noremap <buffer> <silent> <LocalLeader>rs :call <SID>SyntaxCheck()<CR> noremap <buffer> <LocalLeader>ra :PerlScriptArguments<Space> noremap <buffer> <LocalLeader>rw :PerlSwitches<Space> " - inoremap <buffer> <silent> <LocalLeader>rr <C-C>:call Perl_Run()<CR> - inoremap <buffer> <silent> <LocalLeader>rs <C-C>:call Perl_SyntaxCheck()<CR> + inoremap <buffer> <silent> <LocalLeader>rr <C-C>:call <SID>Run("")<CR> + inoremap <buffer> <silent> <LocalLeader>rs <C-C>:call <SID>SyntaxCheck()<CR> inoremap <buffer> <LocalLeader>ra <C-C>:PerlScriptArguments<Space> inoremap <buffer> <LocalLeader>rw <C-C>:PerlSwitches<Space> - " - noremap <buffer> <silent> <LocalLeader>rd :call Perl_Debugger()<CR> - noremap <buffer> <silent> <F9> :call Perl_Debugger()<CR> - inoremap <buffer> <silent> <F9> <C-C>:call Perl_Debugger()<CR> - " + + noremap <buffer> <silent> <LocalLeader>rd :call <SID>Debugger("")<CR> + inoremap <buffer> <silent> <LocalLeader>rd :call <SID>Debugger("")<CR> + if s:UNIX noremap <buffer> <silent> <LocalLeader>re :call Perl_MakeScriptExecutable()<CR> inoremap <buffer> <silent> <LocalLeader>re <C-C>:call Perl_MakeScriptExecutable()<CR> @@ -2904,16 +2922,17 @@ function! s:CreateAdditionalMaps () "------------------------------------------------------------------------------- " templates "------------------------------------------------------------------------------- - " - if s:Perl_Ctrl_j == 'on' + if s:Perl_Ctrl_j == 'yes' || s:Perl_Ctrl_j == 'on' nnoremap <buffer> <silent> <C-j> i<C-R>=<SID>JumpForward()<CR> inoremap <buffer> <silent> <C-j> <C-g>u<C-R>=<SID>JumpForward()<CR> endif - " - " ---------------------------------------------------------------------------- - " - call mmtemplates#core#CreateMaps ( 'g:Perl_Templates', g:Perl_MapLeader, 'do_special_maps', 'do_del_opt_map' ) | - " + + if s:Perl_Ctrl_d == 'yes' + call mmtemplates#core#CreateMaps ( 'g:Perl_Templates', g:Perl_MapLeader, 'do_special_maps', 'do_del_opt_map' ) + else + call mmtemplates#core#CreateMaps ( 'g:Perl_Templates', g:Perl_MapLeader, 'do_special_maps' ) + endif + " ---------------------------------------------------------------------------- " Generate (possibly exuberant) Ctags style tags for Perl sourcecode. " Controlled by g:Perl_PerlTags, disabled by default. @@ -2956,14 +2975,26 @@ endif " endfunction " ---------- end of function s:CreateAdditionalMaps ---------- -"=============================================================================== -" -" Plug-in setup: {{{1 -" +"------------------------------------------------------------------------------- +" s:Initialize : Initialize templates, menus, and maps. {{{1 +"------------------------------------------------------------------------------- +function! s:Initialize ( ftype ) + if ! exists( 'g:Perl_Templates' ) + if s:Perl_LoadMenus == 'yes' | call Perl_CreateGuiMenus() + else | call s:RereadTemplates() + endif + endif + call s:CreateAdditionalMaps() +endfunction " ---------- end of function s:Initialize ---------- + +"------------------------------------------------------------------------------- +" === Setup: Templates, toolbox and menus === {{{1 +"------------------------------------------------------------------------------- + "------------------------------------------------------------------------------ " setup the toolbox "------------------------------------------------------------------------------ -" + if s:Perl_UseToolbox == 'yes' " let s:Perl_Toolbox = mmtoolbox#tools#NewToolbox ( 'Perl' ) @@ -2986,35 +3017,28 @@ endif " Automated header insertion "------------------------------------------------------------------------------ if has("autocmd") - " - autocmd FileType * - \ if ( &filetype == 'perl' || &filetype == 'pod') | - \ if ! exists( 'g:Perl_Templates' ) | - \ if s:Perl_LoadMenus == 'yes' | call Perl_CreateGuiMenus () | - \ else | call s:RereadTemplates () | - \ endif | - \ endif | - \ call s:CreateAdditionalMaps() | - \ call s:CheckTemplatePersonalization() | - \ endif - " - autocmd BufNewFile,BufRead *.pod setlocal syntax=perl - autocmd BufNewFile,BufRead *.t setlocal filetype=perl - " - if s:Perl_InsertFileHeader == 'yes' - autocmd BufNewFile *.pl call mmtemplates#core#InsertTemplate(g:Perl_Templates, 'Comments.file description pl') - autocmd BufNewFile *.pm call mmtemplates#core#InsertTemplate(g:Perl_Templates, 'Comments.file description pm') - autocmd BufNewFile *.t call mmtemplates#core#InsertTemplate(g:Perl_Templates, 'Comments.file description t') - endif + augroup PerlSupport - autocmd BufNew *.pl,*.pm,*.t,*.pod call Perl_InitializePerlInterface() - autocmd BufRead *.pl,*.pm,*.t,*.pod call s:HighlightJumpTargets() - " - " Wrap error descriptions in the quickfix window. - autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak - " - exe 'autocmd BufNewFile,BufReadPost '.s:Perl_PerlModuleList.' setlocal foldmethod=expr | setlocal foldexpr=Perl_ModuleListFold(v:lnum)' - " + " create menus and maps + autocmd FileType perl call s:Initialize('perl') + autocmd FileType pod call s:Initialize('pod') + + " insert file header + autocmd BufNewFile *.pl call s:InsertFileHeader('Script') + autocmd BufNewFile *.pm call s:InsertFileHeader('Module') + autocmd BufNewFile *.t call s:InsertFileHeader('Test') + autocmd BufNewFile *.pod call s:InsertFileHeader('POD') + + " highlight jump targets after opening file + autocmd BufReadPost *.pl,*.pm,*.t,*.pod call s:HighlightJumpTargets() + + " initialize the Perl interface + autocmd FileType perl,pod call Perl_InitializePerlInterface() + + " set foldmethod and expression for file s:Perl_PerlModuleList + exe 'autocmd BufNewFile,BufReadPost' s:Perl_PerlModuleList 'setlocal foldmethod=expr | setlocal foldexpr=Perl_ModuleListFold(v:lnum)' + + augroup END endif " }}}1 "------------------------------------------------------------------------------- diff --git a/plugin/template-support.vim b/plugin/template-support.vim index 91cc3d0..80c4201 100644 --- a/plugin/template-support.vim +++ b/plugin/template-support.vim @@ -340,9 +340,11 @@ endfunction " ---------- end of function s:HandleFiletype ---------- "------------------------------------------------------------------------------- if has( 'autocmd' ) - for ft in s:filetype_names - exe 'autocmd FileType '.ft.' call <SID>HandleFiletype ( '.string( ft ).' )' - endfor + augroup TemplateSupport + for ft in s:filetype_names + exe 'autocmd FileType '.ft.' call <SID>HandleFiletype ( '.string( ft ).' )' + endfor + augroup END endif " }}}1 "------------------------------------------------------------------------------- diff --git a/plugin/vim-support.vim b/plugin/vim-support.vim index 15ba8e6..9f5c6c7 100644 --- a/plugin/vim-support.vim +++ b/plugin/vim-support.vim @@ -16,9 +16,9 @@ " " Version: see variable g:VimSupportVersion below " Created: 14.01.2012 -" Revision: 08.07.2017 +" Revision: 22.11.2020 " License: Copyright (c) 2012-2015, Fritz Mehner -" Copyright (c) 2016-2017, Wolfgang Mehner +" Copyright (c) 2016-2020, Wolfgang Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the @@ -48,7 +48,7 @@ if exists("g:VimSupportVersion") || &cp finish endif -let g:VimSupportVersion= "2.4.1beta" " version number of this script; do not change +let g:VimSupportVersion= "2.5beta" " version number of this script; do not change "------------------------------------------------------------------------------- " === Auxiliary functions === {{{1 @@ -68,10 +68,10 @@ let g:VimSupportVersion= "2.4.1beta" " version number of this s "------------------------------------------------------------------------------- function! s:ApplyDefaultSetting ( varname, value ) - if ! exists ( 'g:'.a:varname ) - let { 'g:'.a:varname } = a:value + if ! exists( 'g:'.a:varname ) + let {'g:'.a:varname} = a:value endif -endfunction " ---------- end of function s:ApplyDefaultSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ErrorMsg : Print an error message. {{{2 @@ -90,7 +90,7 @@ function! s:ErrorMsg ( ... ) echomsg line endfor echohl None -endfunction " ---------- end of function s:ErrorMsg ---------- +endfunction "------------------------------------------------------------------------------- " s:GetGlobalSetting : Get a setting from a global variable. {{{2 @@ -111,10 +111,10 @@ endfunction " ---------- end of function s:ErrorMsg ---------- function! s:GetGlobalSetting ( varname, ... ) let lname = a:varname let gname = a:0 >= 1 ? a:1 : lname - if exists ( 'g:'.gname ) - let { 's:'.lname } = { 'g:'.gname } + if exists( 'g:'.gname ) + let {'s:'.lname} = {'g:'.gname} endif -endfunction " ---------- end of function s:GetGlobalSetting ---------- +endfunction "------------------------------------------------------------------------------- " s:ImportantMsg : Print an important message. {{{2 @@ -417,6 +417,8 @@ endfunction " ---------- end of function s:Hardcopy ---------- let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") +let s:NEOVIM = has("nvim") + let s:installation = '*undefined*' let s:plugin_dir = '' let s:Vim_GlobalTemplateFile = '' @@ -485,10 +487,8 @@ let s:Vim_CodeSnippets = s:plugin_dir.'/vim-support/codesnippets/' " User configurable options {{{3 "------------------------------------------------------------------------------- -let s:Vim_CreateMenusDelayed= 'yes' -let s:Vim_MenuVisible = 'no' let s:Vim_GuiSnippetBrowser = 'gui' " gui / commandline -let s:Vim_LoadMenus = 'yes' " load the menus? +let s:Vim_LoadMenus = 'auto' " load the menus? let s:Vim_RootMenu = '&Vim' " name of the root menu let s:Vim_Ctrl_j = 'yes' let s:Vim_Ctrl_d = 'yes' @@ -516,12 +516,23 @@ call s:GetGlobalSetting ( 'Vim_LocalTemplateFile' ) call s:GetGlobalSetting ( 'Vim_GlobalTemplateFile' ) call s:GetGlobalSetting ( 'Vim_CustomTemplateFile' ) call s:GetGlobalSetting ( 'Vim_CodeSnippets' ) -call s:GetGlobalSetting ( 'Vim_CreateMenusDelayed' ) call s:GetGlobalSetting ( 'Vim_LineEndCommColDefault' ) call s:ApplyDefaultSetting ( 'Vim_MapLeader', '' ) " default: do not overwrite 'maplocalleader' call s:ApplyDefaultSetting ( 'Vim_Printheader', "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" ) +" adapt for backwards compatibility +if s:Vim_LoadMenus == 'no' + let s:Vim_LoadMenus = 'manual' +elseif s:Vim_LoadMenus == 'yes' + if exists ( 'g:Vim_CreateMenusDelayed' ) + let s:Vim_LoadMenus = g:Vim_CreateMenusDelayed == 'yes' ? 'auto' : 'startup' + else + " old default for 'Vim_CreateMenusDelayed' is 'yes' + let s:Vim_LoadMenus = 'auto' + endif +endif + " }}}3 "------------------------------------------------------------------------------- @@ -854,6 +865,30 @@ function! s:HelpPlugin () endtry endfunction " ---------- end of function s:HelpPlugin ---------- +"------------------------------------------------------------------------------ +" === Templates API === {{{1 +"------------------------------------------------------------------------------ + +"------------------------------------------------------------------------------ +" Vim_SetMapLeader: Set the local mapleader to 'g:Vim_MapLeader'. {{{2 +"------------------------------------------------------------------------------ +function! Vim_SetMapLeader () + if exists ( 'g:Vim_MapLeader' ) + call mmtemplates#core#SetMapleader ( g:Vim_MapLeader ) + endif +endfunction " ---------- end of function Vim_SetMapLeader ---------- + +"------------------------------------------------------------------------------ +" Vim_ResetMapLeader: Reset the mapleader. {{{2 +"------------------------------------------------------------------------------ +function! Vim_ResetMapLeader () + if exists ( 'g:Vim_MapLeader' ) + call mmtemplates#core#ResetMapleader () + endif +endfunction " ---------- end of function Vim_ResetMapLeader ---------- +" }}}2 +"------------------------------------------------------------------------------ + "------------------------------------------------------------------------------- " s:RereadTemplates : Initial loading of the templates. {{{1 " @@ -1077,16 +1112,18 @@ function! s:InitMenus() exe ahead.'plugin\ &settings<Tab>'.esc_mapl.'rs :call Vim_Settings(0)<CR>' - "------------------------------------------------------------------------------- - " help - "------------------------------------------------------------------------------- + "------------------------------------------------------------------------------- + " help + "------------------------------------------------------------------------------- let ahead = 'anoremenu <silent> '.s:Vim_RootMenu.'.Help.' let ihead = 'inoremenu <silent> '.s:Vim_RootMenu.'.Help.' - exe ahead.'&keyword\ help<Tab>'.esc_mapl.'hk\ \ <S-F1> :call <SID>KeywordHelp()<CR>' + exe ahead.'&keyword\ help<Tab>'.esc_mapl.'hk :call <SID>KeywordHelp()<CR>' + exe ihead.'&keyword\ help<Tab>'.esc_mapl.'hk <C-C>:call <SID>KeywordHelp()<CR>' exe ahead.'-SEP1- <Nop>' exe ahead.'&help\ (Vim-Support)<Tab>'.esc_mapl.'hp :call <SID>HelpPlugin()<CR>' + exe ihead.'&help\ (Vim-Support)<Tab>'.esc_mapl.'hp <C-C>:call <SID>HelpPlugin()<CR>' endfunction " ---------- end of function s:InitMenus ---------- @@ -1174,11 +1211,6 @@ function! s:CreateAdditionalMaps () nnoremap <buffer> <silent> <LocalLeader>hp :call <SID>HelpPlugin()<CR> inoremap <buffer> <silent> <LocalLeader>hp <C-C>:call <SID>HelpPlugin()<CR> - if has("gui_running") - nnoremap <buffer> <silent> <S-F1> :call <SID>KeywordHelp()<CR> - inoremap <buffer> <silent> <S-F1> <C-C>:call <SID>KeywordHelp()<CR> - endif - "------------------------------------------------------------------------------- " settings - reset local leader "------------------------------------------------------------------------------- @@ -1215,11 +1247,13 @@ endfunction " ---------- end of function s:CreateAdditionalMaps ---------- " - "------------------------------------------------------------------------------- function! Vim_Settings ( verbose ) - " + if s:MSWIN | let sys_name = 'Windows' elseif s:UNIX | let sys_name = 'UN*X' else | let sys_name = 'unknown' | endif - " + if s:NEOVIM | let vim_name = 'nvim' + else | let vim_name = has('gui_running') ? 'gvim' : 'vim' | endif + let txt = " Vim-Support settings\n\n" " template settings: macros, style, ... if exists ( 'g:Vim_Templates' ) @@ -1234,7 +1268,7 @@ function! Vim_Settings ( verbose ) let txt .= " templates : -not loaded-\n\n" endif " plug-in installation - let txt .= ' plugin installation : '.s:installation.' on '.sys_name."\n" + let txt .= ' plugin installation : '.s:installation.' in '.vim_name.' on '.sys_name."\n" let txt .= "\n" " templates, snippets if exists ( 'g:Vim_Templates' ) @@ -1250,7 +1284,7 @@ function! Vim_Settings ( verbose ) if a:verbose >= 1 let txt .= "\n" \ .' mapleader : "'.g:Vim_MapLeader."\"\n" - \ .' load menus / delayed : "'.s:Vim_LoadMenus.'" / "'.s:Vim_CreateMenusDelayed."\"\n" + \ .' load menus : "'.s:Vim_LoadMenus."\"\n" endif let txt .= "__________________________________________________________________________\n" let txt .= " Vim-Support, Version ".g:VimSupportVersion." / Wolfgang Mehner / wolfgang-mehner@web.de\n\n" @@ -1315,6 +1349,19 @@ function! s:RemoveMenus() endif endfunction " ---------- end of function s:RemoveMenus ---------- +"------------------------------------------------------------------------------- +" s:Initialize : Initialize templates, menus, and maps. {{{1 +"------------------------------------------------------------------------------- +function! s:Initialize ( ftype ) + if ! exists( 'g:Vim_Templates' ) + if s:Vim_LoadMenus == 'auto' | call s:AddMenus() + else | call s:RereadTemplates() + endif + endif + call s:CreateAdditionalMaps() + call s:CheckTemplatePersonalization() +endfunction " ---------- end of function s:CreateTemplAndMenu ---------- + "------------------------------------------------------------------------------- " === Setup: Templates, toolbox and menus === {{{1 "------------------------------------------------------------------------------- @@ -1322,24 +1369,24 @@ endfunction " ---------- end of function s:RemoveMenus ---------- " tool menu entry call s:ToolMenu ( 'setup' ) -if s:Vim_LoadMenus == 'yes' && s:Vim_CreateMenusDelayed == 'no' +if s:Vim_LoadMenus == 'startup' call s:AddMenus () endif +" user interface for remapping +nnoremap <silent> <Plug>VimSupportKeywordHelp :call <SID>KeywordHelp()<CR> +inoremap <silent> <Plug>VimSupportKeywordHelp <C-C>:call <SID>KeywordHelp()<CR> + if has( 'autocmd' ) + augroup VimSupport - " create menues and maps - autocmd FileType * - \ if &filetype == 'vim' || ( &filetype == 'help' && &modifiable == 1 && s:Vim_CreateMapsForHelp == 'yes' ) | - \ if ! exists( 'g:Vim_Templates' ) | - \ if s:Vim_LoadMenus == 'yes' | call s:AddMenus () | - \ else | call s:RereadTemplates () | - \ endif | - \ endif | - \ call s:CreateAdditionalMaps() | - \ call s:CheckTemplatePersonalization() | - \ endif + " create menus and maps + autocmd FileType vim call s:Initialize('vim') + if s:Vim_CreateMapsForHelp == 'yes' + autocmd FileType help if &modifiable == 1 | call s:Initialize('help') | endif | " COMMENT: g:Vim_CreateMapsForHelp == 'yes' + endif + augroup END endif " }}}1 "------------------------------------------------------------------------------- diff --git a/project/TODO.txt b/project/TODO.txt index 53be918..e648ae9 100644 --- a/project/TODO.txt +++ b/project/TODO.txt @@ -12,15 +12,22 @@ Project: somewhere? - (DONE?) Improve 'adjust end-of-line comment' to change the line if the comment itself contains ignored sections? -- Remove old ".../rc/sample_template_file". - Do not always jump to errors automatically from the quickfix list. Make this configurable. -- Configure the template which is inserted automatically when a new file is +- (DONE) Configure the template which is inserted automatically when a new file is created. - Use 'Xterm_Executable' and 'Xterm_Options' everywhere. +- Do not use 'lchdir' for starting external jobs in a directory. This may have + undesired side effects. Use 'ch' instead, and use haslocaldir() when + available. +- Check how to start jobs with arguments under Windows. + Important for job_start() and term_start(). +- Add plug-in set-up guide. +- (DONE) Remove mailing list links from plug-in pages and GitHub README. vim.org: - (DONE) Reference GitHub on plug-in pages. +- All links should use 'https://www.vim.org/' Templates: - (DONE) API 'EditTemplateFiles'. @@ -44,16 +51,23 @@ Templates: - Configure CTRL+J and CTRL+D. - Add an appropriate action if 'mmtemplates#core#EditTemplateFiles' is called for a file which is not yet available. +- All maps and menus for visual mode should have the "v" flag. + Consequently, remove the "visual" template option. Awk: - (DONE) 'code->comment' should not insert a space following the hash? +- Add example filetype plug-in. +- Still need Awk wrapper script? Bash: - (DONE) 'code->comment' should not insert a space following the hash? - (DONE) Template library, list 'IORedirection': check "duplicate STDIN from file descr n" and "duplicate STDOUT to file descr n" - (DONE) Template library, list 'TestsFileTypes': "symbolic link -h". - (DONE) Template library, list 'TestsFileCharacteristics': "file exists -a". Is apparently deprecated. -- Compl.-func. 'BASH_BuiltinComplete' missing. +- (DONE) Compl.-func. 'BASH_BuiltinComplete' missing. + -> Solved via 's:UserInput' and built-in list from template library. +- (DONE) Move 'ftplugin/sh.vim'. +- Still need Bash wrapper script? C/C++: - (FM, DONE) Documentation: Change documentation with regard to Make integration. @@ -73,50 +87,19 @@ C/C++: - (DONE) Documentation: Change the description of the Doxygen setup. - README: Change the description of the Doxygen setup. - (DONE) Documentation: Adding additional template files. -- Configure the template which is inserted automatically when a new file is - created. - (DONE) Add a template to insert all section comments into a file at once. - -Git: -- Add more suggestions for custom menu entries to 's:Git_CustomMenu'. -- Add current custom menu entries to documentation and/or "git-support/rc/", - as a starting point for customization. -- Current method for jumping to Git buffers does not work for tabs. - * (DONE) Open the buffer in a new window. - * Optionally: Jump across tab pages. -- How about jumping to windows? - * (DONE) Open the buffer in a new window. - * Optionally: Jump across tab pages. -- (DONE) Problem with 's:OpenFile()': - Since the name of the buffer has to match exactly, this does not always work - with different working directories. -- (DONE) Maps for completing Git commands, branches, tags, remotes, ... - similar to the cmd-line completion plug-in. -- (DONE) New status buffer output (version > 1.8.5): - Update syntax highlighting, folding function, file actions -- (WM) Do not use "sync fromstart" in syntax highlighting, - is extremely slow for diff and log. -- (WM) Document map "ow" in status buffer, mention in the README. -- (DONE) Document map "ac", "cc", and "rc" in diff buffer, mention in the README. -- (WM) Update buffer after executing a command: :GitBranch, :GitRemote, :GitStash, ... -- (WM) Buffer "git stash list", maps for: create -- (WM) Feed output of "git apply" into quickfix. -- (WM) Rename function 'GitS_FoldLog' into 'GitS_FoldLogTxt'. -- (WM) Set 'foldmethod' individually and not in 's:OpenGitBuffer'. -- Enable and document :GitAbove, :GitBelow, and :GitTab. -- Document 'g:Git_Editor', and the use of '$GIT_EDITOR', and add it to :GitSupportSettings. +- (DONE) Move 'ftplugin/c.vim'. +- (DONE) Move 'ftplugin/make.vim'. LaTeX: -- (DONE) Add 'luatex' as a type setter. - (DONE) Add :LatexConvert as an ex-command. +- Enable processing method "background" under Windows. (:TODO:25.09.2017 17:17:WM:) Lua: -- (DONE) Documentation: Add setup of C API templates. - -Matlab: -- The old setup of the help via "SetMacro( 'HELP_BROWSER', ... )" is still - mentioned in the documentations. -- Remove old release script 'release.lua'. +- Enable output method "terminal" under Windows. (:TODO:25.09.2017 16:16:WM:) +- Change behavior of terminal output. Opens a new window every time. +- (DONE) Add maps 'qf' and 'qj' for terminal output. +- Complete documentation with regards to terminals. Perl: - (DONE?) 'perldoc' does not print the correct error message if it is not installed. @@ -124,6 +107,10 @@ Perl: - Documentation: Check that maps are introduced properly. - (DONE) Documentation: Adding additional template files. - (DONE) Remove old release script. +- (DONE) Move 'ftplugin/make.vim'. +- (DONE) Move 'ftplugin/perl.vim'. +- (DONE) Move 'ftplugin/pod.vim'. +- (DONE) Move 'ftplugin/qf.vim'. Vim: - (DONE) Documentation: Adding additional template files. diff --git a/project/git_cheat_sheet.tex b/project/git_cheat_sheet.tex deleted file mode 100644 index 9a80102..0000000 --- a/project/git_cheat_sheet.tex +++ /dev/null @@ -1,284 +0,0 @@ -%%===================================================================================== -%% -%% Filename: git_cheat_sheet.tex -%% -%% Description: -%% -%% Version: 1.0 -%% Created: 23.09.2012 11:07:49 CEST -%% Revision: none -%% -%% Author: Wolfgang Mehner (WM) <wolfgang-mehner@web.de> -%% Company: -%% Copyright: Copyright (C) 2012 Wolfgang Mehner <wolfgang-mehner@web.de> -%% -%% Notes: -%% -%%===================================================================================== - -%% Packages -\documentclass[oneside,11pt,a4paper,DIV15]{scrartcl} -\usepackage[german]{babel} -\usepackage[latin1]{inputenc} -\usepackage[T1]{fontenc} - -\usepackage{multicol} -\usepackage{parskip} - -% Settings -\setlength{\parindent}{0pt} -\setlength{\parskip}{3mm} - -% Document -\author{Wolfgang Mehner} -\title{Git - Schummel Zettel} -\date{\today} - -%% Document -\begin{document} -% -\maketitle -% -\tableofcontents -% -%%====================================================================== -%% Workflow {{{1 -%%====================================================================== -\section{Workflow} -\label{S_WORKFLOW} -% -%%---------------------------------------------------------------------- -%% Repositories {{{2 -%%---------------------------------------------------------------------- -\subsection{Repositories} -\label{SS_REPOSITORIES} -% -�nderungen vom Repository \verb'<repo>' holen (default: \verb'origin'): \\ -\verb' git fetch [<repo>]' \par -% -�nderungen vom Repository \verb'<repo>' holen (default: \verb'origin') -und auf den aktuellen \textit{branch} anwenden, -falls dieser einen \textit{branch} des Repositories \textit{tracked}: \\ -\verb' git pull [<repo>]' \\ -entspricht: \\ -\verb' git fetch <repo>' \\ -\verb' git merge <repo>/<branch>' \\ -wobei \verb'<branch>' dem aktuell ausgecheckten \textit{branch} entspricht. \par -% -�nderungen zum Repository \verb'<repo>' hochladen (default: \verb'origin'): \\ -\verb' git push [<repo>]' \par -% -%%---------------------------------------------------------------------- -%% Dateien {{{2 -%%---------------------------------------------------------------------- -\subsection{Dateien} -\label{SS_DATEIEN} -% -Eine Datei zum \textit{staging area} (zum n�chsten \textit{commit}) hinzuf�gen: \\ -\verb' git add <file>' \\ -Eine Datei aus dem \textit{staging area} entfernen: \\ -\verb' git reset HEAD <file>' \par -% -�nderungen, die noch nicht zum \textit{staging area} hinzugef�gt wurden, r�ckg�ngig machen: \\ -\verb' git checkout -- <file>' \\ -Alle �nderungen seit dem letzten \textit{commit} r�ckg�ngig machen: \\ -\verb' git checkout HEAD -- <file>' \par -% -Dateien umbenennen und l�schen: \\ -\verb' git mv <oldname> <newname>' \\ -\verb' git rm <file>' \par -% -%%---------------------------------------------------------------------- -%% Commits {{{2 -%%---------------------------------------------------------------------- -\subsection{Commits} -\label{SS_COMMITS} -% -Die �nderungen im \textit{staging area} als ein \textit{commit} ablegen: \\ -\verb' git commit' \\ -oder die Beschreibung des \textit{commit} direkt angeben: \\ -\verb' git commit -m "<message>"' \\ -oder die Beschreibung des \textit{commit} aus einer Datei laden: \\ -\verb' git commit -F <file>' \par -% -Ein gerade erzeugtes \textit{commit} kann noch berichtigt werden: \\ -\verb' git commit --amend' \\ -Vor dem Aufruf k�nnen weitere Dateien hinzugef�gt werden, -sowie weitere �nderungen erfolgen (welche?). -Mit dem Aufruf wird ein Editor ge�ffnet -und die Beschreibung des \textit{commit} kann erweitert oder berichtigt werden. -Der \textit{commit} darf vor dem Aufruf AUF KEINEN FALL via \verb'push' ver�ffentlicht sein. \par -% -%%---------------------------------------------------------------------- -%% Inspektion {{{2 -%%---------------------------------------------------------------------- -\subsection{Inspektion} -\label{SS_INSPEKTION} -% -Aktuellen Status anzeigen (zum n�chsten \textit{commit} hinzugef�gte, -ge�nderte, nicht getrackte und optional ignorierte Dateien): \\ -\verb' git status [--ignored]' \par -% -Geschichte eines \textit{branch} anzeigen (default: aktueller \textit{branch}): \\ -\verb' git log [--oneline] [--shortstat] [--stat] [<branch>] [<path>]' \\ -Dabei k�nnen nur die erste Zeile der Beschreibung jedes \textit{commit} ausgegeben werden (\verb'--oneline'), -oder Statistiken �ber die ge�nderten Dateien (\verb'--stat' oder \verb'--shortstat'). -Zudem k�nnen nur die \textit{commits} aufgef�hrt werden, -die einen Pfad oder eine einzelne Datei betreffen. -Die Ausgabe von \verb'git log' zeigt neben der Beschreibung auch den \textit{hash}, -der den \textit{commit} identifiziert: \\ -\verb' ebdb9c5 Templates: Minor bug fixed.' \\ -\verb' ba19aec Merge remote-tracking branch "origin/master"' \\ -\verb' 4b7f288 C-Support: ... improved.' \par -% -Differenz \textit{staging area} $\leftrightarrow$ Arbeitsbereich anzeigen: \\ -\verb' git diff [<file>]' \\ -Differenz letzter \textit{commit} $\leftrightarrow$ Arbeitsbereich anzeigen: \\ -\verb' git diff HEAD [<file>]' \\ -Differenz letzter \textit{commit} $\leftrightarrow$ \textit{staging area} anzeigen: \\ -\verb' git diff --staged [<file>]' \par -% -%%====================================================================== -%% Fortgeschrittene Themen {{{1 -%%====================================================================== -\section{Fortgeschrittene Themen} -\label{S_ADVANCED} -% -%%---------------------------------------------------------------------- -%% Branches {{{2 -%%---------------------------------------------------------------------- -\subsection{Branches} -\label{SS_BRANCHES} -% -Alle lokalen \textit{branches} anzeigen: \\ -\verb' git branch' \\ -Der aktuelle \textit{branch} ist mit einem \verb'*' markiert: \\ -\verb' csupport-dev' \\ -\verb'* master' \\ -\verb' templates-dev' \par -% -�berblick �ber alle \textit{branches} (\textit{all, very verbose}): \\ -\verb' git branch -avv' \\ -Zeigt eine Ausgabe wie diese: \\ -\verb' csupport-dev 7f035e8 [origin/csupport-dev] ...' \\ -\verb'* master e5af596 [origin/master] Merge ...' \\ -\verb' templates-dev ee06315 Templates: Fixed ...' \\ -\verb' remotes/origin/HEAD -> origin/master' \\ -\verb' remotes/origin/csupport-dev 7f035e8 C-Support: Changed ...' \\ -\verb' remotes/origin/master e5af596 Merge branch "..."' \\ -\verb' remotes/origin/perlsupport-dev 7f035e8 Perl-Support: Added ...' \\ -Jeder \textit{branch} wird mit dem \textit{hash} und der Beschreibung des letzten \textit{commit} aufgef�hrt, -Zus�tzlich stehen die getrackten \textit{branches} in eckigen Klammern (\verb'csupport-dev' trackt \verb'origin/csupport-dev'). \par -% -Einen neuen \textit{branch} anlegen: \\ -\verb' git branch <name> [<start>]' \\ -Der Startpunkt kann ein \textit{commit}, ein \textit{branch} oder ein \textit{tag} sein. -Ist kein Startpunkt angegeben wird der \verb'HEAD' des aktuellen \textit{branch} verwendet. -Der neue \textit{branch} ist ausschlie�lich lokal, bis er gepusht wird: \\ -\verb' git push <repo> <name>' \par -% -Das tracken von \textit{branches} erleichtert das Verfolgen der �nderungen in anderen Repositories -(siehe Befehl \verb'pull', Abschnitt \ref{SS_REPOSITORIES}). \\ -Einen existierenden \textit{branch} aus einem anderen Repository tracken: \\ -\verb' git branch --track <name> <repo>/<name>' \\ -Einen existierenden \textit{branch} als \textit{remote-tracking branch} einstellen: \\ -\verb' git branch --set-upstream <name> <repo>/<name>' \par -% -Beispiel: Tracken des existierenden \textit{branch} \verb'perlsupport-dev' aus \verb'origin': \\ -\verb' git fetch' \\ -\verb' git branch --track perlsupport-dev origin/templates-dev' \par -% -Beispiel: Anlegen eines neuen \textit{branch} \verb'bashsupport-dev' und die Ver�ffentlichung: \\ -\verb' git branch bashsupport-dev' \\ -\verb' git push origin bashsupport-dev' \\ -\verb' git fetch' \\ -\verb' git branch --set-upstream bashsupport-dev origin/bashsupport-dev' \par -% -Zum einem \textit{branch} wechseln: \\ -\verb' git checkout <branch>' \\ -Zu diesem Zeitpunkt sollten keine �nderungen an den verwaltenden Dateien vorliegen. \par -% -Die �nderungen aus einem anderen \textit{branch} \verb'other' �bernehmen: \\ -\verb' git merge <other>' \par -% -Beispiel: �nderungen im Entwicklungs-Zweig in den Hauptzweig �bernehmen: \\ -\verb' git checkout master' \\ -\verb' git merge bashsupport-dev' \par -% -%%---------------------------------------------------------------------- -%% Tags {{{2 -%%---------------------------------------------------------------------- -\subsection{Tags} -\label{SS_TAGS} -% -Einen \textit{tag} hinzuf�gen: \\ -\verb' git tag <name> [<commit>]' \\ -Setzt einen \textit{tag} auf das \textit{commit} (default: letzter \textit{commit}?). \\ -Einen \textit{tag} wieder l�schen: \\ -\verb' git tag -d <name>' \\ -Dies sollte passieren, bevor der \textit{tag} ver�ffentlicht wurde. \\ -Einen \textit{tag} ver�ffentlichen: \\ -\verb' git push <repo> <name>' \par -% -%%====================================================================== -%% Standards f�r VIMPLUGINS {{{1 -%%====================================================================== -\section{Standards f�r \glqq VIMPLUGINS\grqq} -\label{S_STANDARDS} -% -%%---------------------------------------------------------------------- -%% Commits {{{2 -%%---------------------------------------------------------------------- -\subsection{Commits} -\label{SS_STD_COMMITS} -% -Commit-Messages sollten der folgenden Form folgen, -u. A. aufgrund der besonderen Rolle, die der ersten Zeile zukommt -(siehe Befehl \verb'log', Abschnitt \ref{SS_INSPEKTION}): \\ -\verb' <module>: <first line>.' \\ -\verb'' \\ -\verb' - <bullet point 1>' \\ -\verb' - <bullet point 2>' \\ -\verb' - ...' \\ -Die erste Zeile benennt das ge�nderte Modul und gibt einen kurzen �berblick �ber den Commit. -Die weiteren Punkt beschreiben wichtige Details der �nderungen. \par -% -Mehrere Dateien sollten zu einem Commit zusammenfasste werden, -wenn z. B. ein Feature ge�ndert und zugleich die Dokumentation angepasst wurde. -Alle wichtigen Punkte werden in der Aufz�hlung angef�hrt. -Insbesondere sollten alle �nderungen, -die aufgrund der Kommunikation der Entwickler oder aufgrund von R�ckmeldungen der Anwender vorgenommen wurden, -hier explizit Erw�hnung finden. -Eventuelle weitere �nderungen k�nnen zusammengefasst werden, -beispielsweise in der Form: \\ -\verb' - Minor bugfixes and improvements.' \\ -Dies betrifft kleine �nderungen, -wie die Formatierung, Rechtschreibfehler oder kleine Berichtigung vorheriger Commits, -besonders solcher, die noch nicht ver�ffentlicht wurden. \par -% -Beispiel: \\ -\verb' C-Support: Fixed issue XY.' \\ -\verb' ' \\ -\verb' - Updated the documentation.' \\ -\verb' - Minor improvements.' \par -% -Beispiel: \\ -\verb' Templates: Added feature XY.' \\ -\verb' ' \\ -\verb' - Updated the documentation.' \\ -\verb' - Minor bugfixes.' \par -% -%%---------------------------------------------------------------------- -%% Tags {{{2 -%%---------------------------------------------------------------------- -\subsection{Tags} -\label{SS_STD_TAGS} -% -Tags m�ssen die folgende Form haben: \\ -\verb' <module>-<version>' \par -% -Beispiele: \\ -\verb' csupport-6.0.1' \\ -\verb' templates-1.2' \par -% -\end{document} diff --git a/project/make-html.sh b/project/make-html.sh index 5477854..980ee67 100755 --- a/project/make-html.sh +++ b/project/make-html.sh @@ -14,7 +14,8 @@ # REQUIREMENTS: --- # BUGS: --- # NOTES: --- -# AUTHOR: Dr.-Ing. Fritz Mehner (fgm), mehner@web.de +# AUTHOR: Wolfgang Mehner <wolfgang-mehner@web.de> +# Fritz Mehner <mehner.fritz@web.de> # VERSION: 1.0 # CREATED: 20.03.2009 # REVISION: 15.11.2014 diff --git a/project/maps_overview.txt b/project/maps_overview.txt new file mode 100644 index 0000000..779efd0 --- /dev/null +++ b/project/maps_overview.txt @@ -0,0 +1,40 @@ + + Awk Bash C LaTeX Lua Perl Vim + +Run + ------------------------------------------------------------------ + typesetter rr + lacheck rla + convert rc + set main doc rmd + ------------------------------------------------------------------ + compile rc rc + link rl - + ------------------------------------------------------------------ + run rr rr rr rr rr + exec. to run - - re - - + syntax check rs>rk rk - rk rs>rk + s.c. options - rso - - - + lint check rl - - - - + debugger - - rd - rd + script args ra rsa ra - ra + interp. args raa ria - rw + output dest. ro ro ro - ro ro - + ex. process - - - rp - - - + direct run - rd - - rd - - + set exec. - rse - - rse - - + set compiler - - - - rsc - - + xterm size rx rx rx - - rx - + ------------------------------------------------------------------ + make exec. re re - - re re - + hardcopy rh rh rh rh rh rh rh + timestamped - - - - - rt - + ------------------------------------------------------------------ + settings rse>rs rs rs rs rs rk>rs rs + ------------------------------------------------------------------ +Help + ------------------------------------------------------------------ + plug-in hp hp hp hp hs hp hp + ------------------------------------------------------------------ + +# vim: tabstop=8 diff --git a/project/release.lua b/project/release.lua index 0da1611..5286129 100755 --- a/project/release.lua +++ b/project/release.lua @@ -11,10 +11,8 @@ -- - awk -- - bash -- - c --- - git -- - latex -- - lua --- - matlab -- - perl -- - vim -- @@ -41,7 +39,7 @@ -- Auxiliary Functions {{{1 ------------------------------------------------------------------------ -function escape_shell ( text ) +local function escape_shell ( text ) return string.gsub ( text, '[%(%);&=\' ]', function ( m ) return '\\' .. m end ) end ---------- end of function escape_shell ---------- @@ -100,12 +98,17 @@ filelists_repo.awk = { filelists.bash = { 'autoload/mmtemplates/', + 'autoload/mmtoolbox/tools.vim', + 'autoload/mmtoolbox/bash/bashdb.vim', 'doc/bashsupport.txt', 'doc/templatesupport.txt', + 'doc/toolbox.txt', + 'doc/bashdbintegration.txt', 'ftdetect/template.vim', - 'ftplugin/sh.vim', + 'ftplugin/bashhelp.vim', 'ftplugin/template.vim', 'plugin/bash-support.vim', + 'syntax/bashhelp.vim', 'syntax/template.vim', 'bash-support/codesnippets/', 'bash-support/doc/ChangeLog', @@ -139,8 +142,6 @@ filelists.c = { 'doc/toolboxdoxygen.txt', 'doc/toolboxmake.txt', 'ftdetect/template.vim', - 'ftplugin/c.vim', - 'ftplugin/make.vim', 'ftplugin/template.vim', 'plugin/c.vim', 'syntax/template.vim', @@ -159,24 +160,6 @@ filelists_repo.c = { 'project/release.lua', } ------------------------------------------------------------------------- --- Git {{{1 ------------------------------------------------------------------------- - -filelists.git = { - 'doc/gitsupport.txt', - 'plugin/git-support.vim', - 'git-support/doc/', - 'git-support/rc/', - 'git-support/README.md', - 'syntax/gits*.vim', -} - -filelists_repo.git = { - 'git-support/git-doc/', - 'project/release.lua', -} - ------------------------------------------------------------------------ -- LaTeX {{{1 ------------------------------------------------------------------------ @@ -238,30 +221,6 @@ filelists_repo.lua = { 'project/release.lua', } ------------------------------------------------------------------------- --- Matlab {{{1 ------------------------------------------------------------------------- - -filelists.matlab = { - 'autoload/mmtemplates/', - 'doc/matlabsupport.txt', - 'doc/templatesupport.txt', - 'ftdetect/template.vim', - 'ftplugin/matlab.vim', - 'ftplugin/template.vim', - 'plugin/matlab-support.vim', - 'syntax/template.vim', - 'matlab-support/codesnippets/', - 'matlab-support/doc/', - 'matlab-support/rc/', - 'matlab-support/templates/', - 'matlab-support/README.md', -} - -filelists_repo.matlab = { - 'project/release.lua', -} - ------------------------------------------------------------------------ -- Perl {{{1 ------------------------------------------------------------------------ @@ -277,10 +236,6 @@ filelists.perl = { 'doc/toolbox.txt', 'doc/toolboxmake.txt', 'ftdetect/template.vim', - 'ftplugin/make.vim', - 'ftplugin/perl.vim', - 'ftplugin/pod.vim', - 'ftplugin/qf.vim', 'ftplugin/template.vim', 'plugin/perl-support.vim', 'syntax/template.vim', @@ -447,7 +402,7 @@ elseif args[2] == 'cp-repo' then if #args >= 3 then local dest_dir = args[3] - filelist_compl = {} + local filelist_compl = {} for key, val in pairs ( filelist ) do table.insert ( filelist_compl, val ) @@ -458,7 +413,6 @@ elseif args[2] == 'cp-repo' then end os.execute ( 'mkdir -p '..dest_dir ) - os.execute ( 'mkdir -p '..dest_dir..'/project' ) local cmd = 'cp --parents -r '..table.concat ( filelist_compl, ' ' )..' '..dest_dir @@ -473,7 +427,7 @@ elseif args[2] == 'cp-repo' then end if success then - cmd = 'echo "\\ntaken from WolfgangMehner/vim-plugins, revision\\nhttps://github.com/WolfgangMehner/vim-plugins/commit/$(git rev-parse HEAD)" >> '..dest_dir..'/project/commit.txt' + cmd = 'echo "\\ntaken from WolfgangMehner/vim-plugins, revision\\nhttps://github.com/WolfgangMehner/vim-plugins/commit/$(git rev-parse HEAD)" >> '..dest_dir..'/commit.txt' success, res_reason, res_status = os.execute ( cmd ) end @@ -511,10 +465,8 @@ if print_help then print ( '\tawk' ) print ( '\tbash' ) print ( '\tc' ) - print ( '\tgit' ) print ( '\tlatex' ) print ( '\tlua' ) - print ( '\tmatlab' ) print ( '\tperl' ) print ( '\tvim' ) print ( '' ) diff --git a/project/scripts/check_repos.sh b/project/scripts/check_repos.sh new file mode 100755 index 0000000..a06e2a0 --- /dev/null +++ b/project/scripts/check_repos.sh @@ -0,0 +1,42 @@ +#!/bin/bash - +#=============================================================================== +# +# FILE: check_repos.sh +# +# USAGE: ./check_repos.sh +# +# DESCRIPTION: Short status of standalone repos. +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Wolfgang Mehner (WM), wolfgang-mehner@web.de +# ORGANIZATION: +# CREATED: 18.10.2017 22:30 +# REVISION: --- +#=============================================================================== + +set -o nounset # Treat unset variables as an error + +LIST=" +Awk +Bash +C +Git +Latex +Lua +Perl +Vim +" + +for NAME in $LIST; do + cd $NAME"Support" + + if [ ${?} -ne 0 ] ; then + continue + fi + + printf "%-6s : %s (%s )\n" $NAME "$(git log -n1 --date=short --pretty=format:"%ad : %s")" "$(git diff --shortstat HEAD)" + cd .. +done | sort -k 2 diff --git a/project/scripts/get_cmake_policies.sh b/project/scripts/get_cmake_policies.sh new file mode 100644 index 0000000..c8d9d58 --- /dev/null +++ b/project/scripts/get_cmake_policies.sh @@ -0,0 +1,60 @@ +#!/bin/bash - +#=============================================================================== +# +# FILE: get_cmake_policies.sh +# +# USAGE: ./get_cmake_policies.sh +# +# DESCRIPTION: +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Wolfgang Mehner (WM), wolfgang-mehner@web.de +# ORGANIZATION: +# CREATED: 16.10.2017 +# REVISION: --- +#=============================================================================== + +set -o nounset # Treat unset variables as an hrror +shopt -s extglob + +CMAKE_VERSION="3.10" +POLICY_MIN=0 +POLICY_MAX=71 + +DOC_URL="https://cmake.org/cmake/help/v$CMAKE_VERSION/policy/CMP%04d.html" + +for (( POLICY=POLICY_MIN; POLICY<=POLICY_MAX; POLICY+=1 )); do + #printf "processing policy CMP%04d\n" $POLICY + + printf -v URL $DOC_URL $POLICY + + TEXT=$( wget -O - $URL 2> /dev/null ) + + # <span id="policy:CMP0027"></span><h1>CMP0027<a class="headerlink" href="#cmp0027" title="Permalink to this headline">¶</a></h1> + # <p>Conditionally linked imported targets with missing include directories.</p> + # + # <span id="policy:CMP0030"></span><h1>CMP0030<a class="headerlink" href="#cmp0030" title="Permalink to this headline">¶</a></h1> + # <p>The <span class="target" id="index-0-command:use_mangled_mesa"></span><a class="reference internal" href="http://github.com/command/use_mangled_mesa.html#command:use_mangled_mesa" title="use_mangled_mesa"><code class="xref cmake cmake-command docutils literal"><span class="pre">use_mangled_mesa()</span></code></a> command should not be called.</p> + + HEAD=${TEXT#*<span id=?policy:CMP[[:digit:]][[:digit:]][[:digit:]][[:digit:]]?><\/span><h1>} + HEAD=${HEAD%%<\/p>*} + + P_NAME=${HEAD%%<a*} + P_DESC=${HEAD##*<p>} + + P_DESC=$( echo $P_DESC | tr -d \\n ) + + P_VERSION=${TEXT#*This policy was introduced in CMake version } + P_VERSION=${P_VERSION%%.[^[:digit:]]*} + + #echo $HEAD + #echo $P_NAME + #echo $P_DESC + #echo $P_VERSION + + printf "\\ [ '%s', '%s', '%s' ],\n" "$P_NAME" "$P_DESC" "$P_VERSION" +done + diff --git a/project/scripts/update_repos.sh b/project/scripts/update_repos.sh new file mode 100755 index 0000000..fa773b0 --- /dev/null +++ b/project/scripts/update_repos.sh @@ -0,0 +1,105 @@ +#!/bin/bash - +#=============================================================================== +# +# FILE: update_repos.sh +# +# USAGE: ./update_repos.sh +# +# DESCRIPTION: Update information on standalone repos. +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Wolfgang Mehner (WM), wolfgang-mehner@web.de +# ORGANIZATION: +# CREATED: 18.10.2017 22:29 +# REVISION: --- +#=============================================================================== + +set -o nounset # Treat unset variables as an error +shopt -s extglob + +LIST=" +Awk +Bash +C +Git +Latex +Lua +Perl +Vim +" + +for NAME in $LIST; do + echo $NAME"Support" + cd $NAME"Support" + + if [ ${?} -ne 0 ] ; then + echo "" + continue + fi + + git fetch + + echo "" + cd .. +done + +for NAME in $LIST; do + echo $NAME"Support" + cd $NAME"Support" + + if [ ${?} -ne 0 ] ; then + echo "" + continue + fi + + SHORT_STAT=$(git diff --shortstat) + SHA_MASTER=$(git for-each-ref --format='%(objectname)' refs/heads/master) + SHA_ORIGIN=$(git for-each-ref --format='%(objectname)' refs/remotes/origin/master) + + if [ "$SHORT_STAT" != "" ] ; then + echo " requires commit: $SHORT_STAT" + fi + if [ $SHA_MASTER != $SHA_ORIGIN ] ; then + SHA_BASE=$(git merge-base $SHA_MASTER $SHA_ORIGIN) + + if [ $SHA_MASTER == $SHA_BASE ] ; then + echo " requires merge" + elif [ $SHA_ORIGIN == $SHA_BASE ] ; then + echo " requires push" + else + echo " OUT OF DATE" + fi + fi + + COMMIT_MSG=$(git log -n1) + SHA_ORIGINAL=${COMMIT_MSG##*commit\/} + + cd .. + + cd ../VimPlugins/ + + TAG_NAME="_repos_/"${NAME,,}"-support" + + SHA_TAG=$(git for-each-ref --format='%(objectname)' refs/tags/$TAG_NAME) + + if [ "$SHA_TAG" != "$SHA_ORIGINAL" ] ; then + if [ "$SHA_TAG" == "" ] ; then + echo " tag not set" + else + echo " tag outdated" + fi + + read -p "Update tag? [y/n] " ANSWER + + if [ "${ANSWER,,}" == 'y' ] ; then + echo " setting tag .." + git tag -f $TAG_NAME $SHA_ORIGINAL + fi + fi + + echo "" + cd ../VimRepos/ +done diff --git a/project/scripts/vim-doc-ref.pl b/project/scripts/vim-doc-ref.pl new file mode 100755 index 0000000..75f394d --- /dev/null +++ b/project/scripts/vim-doc-ref.pl @@ -0,0 +1,153 @@ +#!/usr/bin/perl +#=============================================================================== +# +# FILE: vim-doc-ref.pl +# +# USAGE: ./vim-doc-ref.pl vim-help-file +# +# DESCRIPTION: Check vim documentation file for unused hyper targets und +# undefined links. +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Fritz Mehner <mehner.fritz@web.de> +# VERSION: 1.0 +# CREATED: 18.03.2006 +# REVISION: 28.10.2017 +#=============================================================================== + +package main; + +use strict; +use warnings; + +#--------------------------------------------------------------------------- +# command line parameter +#--------------------------------------------------------------------------- +if ( $#ARGV < 0 ) +{ + print "\n\tusage: $0 helpfile\n\n"; + exit 1; +} + +my $INFILE_file_name = $ARGV[0]; # input file nam + + +open my $INFILE, '<', $INFILE_file_name + or die "$0 : failed to open input file $INFILE_file_name : $!\n"; + +my %target; +my %otherTarget; +my %ignoreTarget; + +my $rgx_target = qr/\*([\w\d:.-]+)\*/; +my $rgx_link = qr/\|([\w\d:.-]+)\|/; + +my $filecontent = do{ + local $/ = undef; # input record separator undefined + <$INFILE> +}; + +close $INFILE + or warn "$0 : failed to close input file $INFILE_file_name : $!\n"; + +while ( $filecontent =~ m/$rgx_target/gxm ) { + $target{$1} = 0; # gather targets +} + + +while ( my $key = <DATA> ) { # links to ignore + chomp $key; + $ignoreTarget{$key} = 0; +} + +while ( $filecontent =~ m/$rgx_link/gxm ) { + if ( defined $target{$1} ) { + $target{$1}++; # link for existing target + } + else { + $otherTarget{$1} = 0; # link for non-existing target + } +} + +print "\n input file : $0\n"; +print "\n ***** unused targets *****\n\n"; + +foreach my $key ( sort keys %target ) { + if ( $target{$key} == 0 ) { + print "\t$key\n"; + } +} + +print "\n ***** undefined links *****\n\n"; +foreach my $key ( sort keys %otherTarget ) { + if ( $otherTarget{$key} == 0 && ! exists $ignoreTarget{$key} ) { + print "\t$key\n"; + } +} + +print "\n ***** ignored links *****\n\n"; +foreach my $key ( sort keys %ignoreTarget ) { + print "\t$key\n"; +} +print "\n"; + + +#--------------------------------------------------------------------------- +# links to ignore +#--------------------------------------------------------------------------- +__DATA__ +AUTHOR +AUTHORREF +BASENAME +CLASSNAME +COMPANY +COPYRIGHT +COPYRIGHTHOLDER +CURSOR +DATE +EMAIL +FILENAME +LICENSE +ORGANIZATION +PATH +PROJECT +SUFFIX +TIME +YEAR +INTERPRETER +WORD +folding +ftplugin +globpath +mapleader +maplocalleader +quickfix +quickfix.txt +printheader +regexp +runtimepath +terminal +word +Dictionary +List +:Explore +:cclose +:cnext +:copen +:cprevious +i_CTRL-N +i_CTRL-P +i_CTRL-X_CTRL-K +templatesupport.txt +template-support +template-support-basics +template-support-options +g:Templates_PersonalizationFile +g:Templates_TemplateBrowser +g:Templates_InternetBrowserExec +g:Templates_InternetBrowserFlags +toolbox +toolbox-make diff --git a/project/tool_menu_priorities.txt b/project/tool_menu_priorities.txt index 91bd1f7..e3218c1 100644 --- a/project/tool_menu_priorities.txt +++ b/project/tool_menu_priorities.txt @@ -10,7 +10,6 @@ Tools.C 40.1030 Tools.Git 40.1080 Tools.Latex 40.1110 Tools.Lua 40.1122 -Tools.Matlab 40.1140 Tools.Perl 40.1160 Tools.Python 40.1162 Tools.Verilog 40.1168 diff --git a/project/vim2html.pl b/project/vim2html.pl index e10a459..47b2947 100755 --- a/project/vim2html.pl +++ b/project/vim2html.pl @@ -5,7 +5,7 @@ # Sun Feb 24 14:49:17 CET 2002 # -# Modified by Fritz Mehner and Wolfgang Mehner 15.11.2014 18:32:13 +# Modified by Fritz Mehner and Wolfgang Mehner 19.11.2017 use strict; use vars qw/%url $date/; @@ -102,8 +102,9 @@ sub vim2html while( <IN> ) { chop; # if ( /^\s*[-=]+\s*$/ ) { - if ( /^[-=]+\s*$/ ) { # :CHANGE:15.11.2014 18:32:23:WM: <hr> only for lines which start with "-" or "=" - print OUT "</pre><hr><pre>"; +# print OUT "</pre><hr><pre>"; + if ( /^[-=]+\s*$/ ) { # :CHANGE:17.10.2017 18:46:WM: lines which start with "-" or "=": print the separator as it is and use highlighting + print OUT "<code class='section'>".$_."<\/code>\n"; next; } @@ -128,7 +129,8 @@ sub vim2html foreach my $token ( split /((?:\|[^\|]+\|)|(?:\*[^\*]+\*))/ ) { if ( $token =~ /^\|([^\|]+)\|/ ) { # link - push( @out, "|".maplink( $1 )."|" ); +# push( @out, "|".maplink( $1 )."|" ); + push( @out, maplink( $1 ) ); # :CHANGE:17.10.2017 18:48:WM: do not output the bars, to emulate Vim's conceal feature next LOOP; } # elsif ( $token =~ /^\*([^\*]+)\*/ ) { diff --git a/project/vim_org/awk-support.txt b/project/vim_org/awk-support.txt index 10068ee..27f6a4f 100644 --- a/project/vim_org/awk-support.txt +++ b/project/vim_org/awk-support.txt @@ -29,7 +29,7 @@ DOCUMENTATION -------------------------------------------------------- This plug-in comes with a help file (awksupport.txt). Read it with - :h awksupport + :help awksupport ** PLEASE READ THE DOCUMENTATION ** @@ -38,22 +38,11 @@ can be configured or customized to match your needs. GitHub -------------------------------------------------------- -AWK-Support is on GitHub: +AWK-Support is on GitHub. We are happy to receive your questions, suggestions, and bug reports here: https://github.com/WolfgangMehner/vim-plugins (Please help us keep track of all the issues and name your report/request "AWK-Support: <title>") - -MAILING LIST --------------------------------------------------------- -You can subscribe to the vim-plugins-list mailing list to post your questions or -suggestions for improvement or to report bugs. The list will also be used to -announce new releases ( c.vim / perl-support / bash-support / awk-support ). -Visit the following page for subscribing to the mailing list: - - http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list - -The vim-plugins-list list is very low on traffic. ================================================================================ ===== install details ================================================================================ diff --git a/project/vim_org/bash-support.txt b/project/vim_org/bash-support.txt index eda7229..7562858 100644 --- a/project/vim_org/bash-support.txt +++ b/project/vim_org/bash-support.txt @@ -35,22 +35,11 @@ can be configured or customized to match your needs. GitHub -------------------------------------------------------- -Bash-Support is on GitHub: +Bash-Support is on GitHub. We are happy to receive your questions, suggestions, and bug reports here: https://github.com/WolfgangMehner/vim-plugins (Please help us keep track of all the issues and name your report/request "Bash-Support: <title>") - -MAILING LIST --------------------------------------------------------- -You can subscribe to the vim-plugins-list mailing list to post your questions or -suggestions for improvement or to report bugs. The list will also be used to -announce new releases ( c.vim / perl-support / bash-support / awk-support ). -Visit the following page for subscribing to the mailing list: - - http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list - -The vim-plugins-list list is very low on traffic. ================================================================================ ===== install details ================================================================================ diff --git a/project/vim_org/c-support.txt b/project/vim_org/c-support.txt index 75ad660..ead5752 100644 --- a/project/vim_org/c-support.txt +++ b/project/vim_org/c-support.txt @@ -48,22 +48,11 @@ can be configured or customized to match your needs. GitHub -------------------------------------------------------- -C-Support is on GitHub: +C-Support is on GitHub. We are happy to receive your questions, suggestions, and bug reports here: https://github.com/WolfgangMehner/vim-plugins (Please help us keep track of all the issues and name your report/request "C-Support: <title>") - -MAILING LIST --------------------------------------------------------- -You can subscribe to the vim-plugins-list mailing list to post your questions or -suggestions for improvement or to report bugs. The list will also be used to -announce new releases ( c.vim / perl-support / bash-support / latex-support ). -Visit the following page for subscribing to the mailing list: - - http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list - -The vim-plugins-list list is very low on traffic. ================================================================================ ===== install details ================================================================================ diff --git a/project/vim_org/git-support.txt b/project/vim_org/git-support.txt deleted file mode 100644 index f871668..0000000 --- a/project/vim_org/git-support.txt +++ /dev/null @@ -1,71 +0,0 @@ -================================================================================ -===== summary -================================================================================ -Inspect the state of a repository and execute Git commands without leaving Vim. -================================================================================ -===== detailed description -================================================================================ -Integration of Git for Vim/gVim: -- use Git from within Vim and eliminate the need for context switches -- quickly add the file in the current buffer or show its diff -- the output of commands like "git status" is redirected into buffers -- ... the commit can be manipulated from right there -- show the stash, logs, branches, tags, remotes, ... -- show the Git help in a buffer, or open it in the browser -- each buffer comes with a short help: press <SHIFT+F1> -- run arbitrary Git commands and optionally redirect their output into a buffer -- start gitk with arguments: :GitK --all - -- comes with a menu, which also severs as an overview of the plug-in's functionality -- custom menu for often used combination of arguments -- configurable syntax highlighting designed to match Git's own highlighting -- automatic folds for diffs and logs - -Some screen shots : https://wolfgangmehner.github.io/vim-plugins/gitsupport.html - -For plug-in managers : https://github.com/WolfgangMehner/git-support - -The help file online : https://wolfgangmehner.github.io/vim-plugins/doc/gitsupport.html - -DOCUMENTATION --------------------------------------------------------- -This plug-in comes with a help file (gitsupport.txt). Read it with - - :help git-support - -GitHub --------------------------------------------------------- -Git Support is on GitHub: - - https://github.com/WolfgangMehner/vim-plugins - -(Please help us keep track of all the issues and name your report/request "Git-Support: <title>") - -MAILING LIST --------------------------------------------------------- -You can subscribe to the vim-plugins-list mailing list to post your questions or -suggestions for improvement or to report bugs. The list will also be used to -announce new releases ( c.vim / perl-support / bash-support / git-support ). -Visit the following page for subscribing to the mailing list: - - http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list - -The vim-plugins-list list is very low on traffic. -================================================================================ -===== install details -================================================================================ -Copy the zip archive git-support.zip to $HOME/.vim/ (Linux/Unix) or -$HOME/vimfiles (Windows) and run: - unzip git-support.zip - -Windows: Set the correct executable. See git-support/README.gitsupport or: - :help g:Git_Executable -(the default is "C:\Program Files\Git\bin\git.exe") - -Consider configuring the syntax highlighting. By default, the syntax highlighting -uses Vim's own syntax categories. See git-support/README.gitsupport or -git-support/rc/additions.vimrc for information on how to configure the syntax -highlighting to look more like Git's output. -================================================================================ -===== end -================================================================================ diff --git a/project/vim_org/latex-support.txt b/project/vim_org/latex-support.txt index b8261fa..19d1266 100644 --- a/project/vim_org/latex-support.txt +++ b/project/vim_org/latex-support.txt @@ -36,16 +36,13 @@ This plug-in comes with a help file (latexsupport.txt). Read it with Editing actions differ for different modes! There are a lot of features which can be configured or customized to match your needs. -MAILING LIST +GitHub -------------------------------------------------------- -You can subscribe to the vim-plugins-list mailing list to post your questions or -suggestions for improvement or to report bugs. The list will also be used to -announce new releases ( c.vim / perl-support / bash-support / latex-support ). -Visit the following page for subscribing to the mailing list: +LaTeX-Support is on GitHub. We are happy to receive your questions, suggestions, and bug reports here: - http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list + https://github.com/WolfgangMehner/vim-plugins -The vim-plugins-list list is very low on traffic. +(Please help us keep track of all the issues and name your report/request "LaTeX-Support: <title>") ================================================================================ ===== install details ================================================================================ diff --git a/project/vim_org/lua-support.txt b/project/vim_org/lua-support.txt index fcef01e..2a26af4 100644 --- a/project/vim_org/lua-support.txt +++ b/project/vim_org/lua-support.txt @@ -22,7 +22,7 @@ For plug-in managers : https://github.com/WolfgangMehner/lua-support The help file online : https://wolfgangmehner.github.io/vim-plugins/doc/luasupport.html -While this plug-in is conceived as a successor of the original lua-support ( http://vim.sourceforge.net/scripts/script.php?script_id=1763 ), backwards compatibility is not guaranteed. +While this plug-in is conceived as a successor of the original lua-support ( https://www.vim.org/scripts/script.php?script_id=1763 ), backwards compatibility is not guaranteed. However, we hope that the better configurability through the template library and other new features make for a product which is much better suited to deal with a language like Lua. @@ -34,22 +34,11 @@ This plug-in comes with a help file (luasupport.txt). Read it with GitHub -------------------------------------------------------- -Lua-Support is on GitHub: +Lua-Support is on GitHub. We are happy to receive your questions, suggestions, and bug reports here: https://github.com/WolfgangMehner/vim-plugins (Please help us keep track of all the issues and name your report/request "Lua-Support: <title>") - -MAILING LIST --------------------------------------------------------- -You can subscribe to the vim-plugins-list mailing list to post your questions or -suggestions for improvement or to report bugs. The list will also be used to -announce new releases ( c.vim / perl-support / bash-support / lua-support ). -Visit the following page for subscribing to the mailing list: - - http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list - -The vim-plugins-list list is very low on traffic. ================================================================================ ===== install details ================================================================================ diff --git a/project/vim_org/perl-support.txt b/project/vim_org/perl-support.txt index 96415d1..c9b2685 100644 --- a/project/vim_org/perl-support.txt +++ b/project/vim_org/perl-support.txt @@ -44,23 +44,12 @@ can be configured or customized to match your needs. GitHub -------------------------------------------------------- -Perl-Support is on GitHub: +Perl-Support is on GitHub. We are happy to receive your questions, suggestions, and bug reports here: https://github.com/WolfgangMehner/vim-plugins (Please help us keep track of all the issues and name your report/request "Perl-Support: <title>") -MAILING LIST --------------------------------------------------------- -You can subscribe to the vim-plugins-list mailing list to post your questions or -suggestions for improvement or to report bugs. The list will also be used to -announce new releases ( c.vim / perl-support / bash-support / vim-support ). -Visit the following page for subscribing to the mailing list: - - http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list - -The vim-plugins-list list is very low on traffic. - ___________________ Thank you for rating perl-support ! ================================================================================ diff --git a/project/vim_org/vim-support.txt b/project/vim_org/vim-support.txt index d555097..81c6353 100644 --- a/project/vim_org/vim-support.txt +++ b/project/vim_org/vim-support.txt @@ -28,16 +28,13 @@ This plug-in comes with a help file (vimsupport.txt). Read it with Editing actions differ for different modes! There are a lot of features which can be configured or customized to match your needs. -MAILING LIST +GitHub -------------------------------------------------------- -You can subscribe to the vim-plugins-list mailing list to post your questions or -suggestions for improvement or to report bugs. The list will also be used to -announce new releases ( c.vim / perl-support / bash-support / vim-support ). -Visit the following page for subscribing to the mailing list: +Vim-Support is on GitHub. We are happy to receive your questions, suggestions, and bug reports here: - http://lug.fh-swf.de/cgi-bin/mailman/listinfo/vim-plugins-list + https://github.com/WolfgangMehner/vim-plugins -The vim-plugins-list list is very low on traffic. +(Please help us keep track of all the issues and name your report/request "Vim-Support: <title>") ================================================================================ ===== install details ================================================================================ diff --git a/syntax/bashhelp.vim b/syntax/bashhelp.vim new file mode 100644 index 0000000..0decab1 --- /dev/null +++ b/syntax/bashhelp.vim @@ -0,0 +1,21 @@ +"=============================================================================== +" +" File: bashhelp.vim +" +" Description: Syntax for Bash's built-in help. +" +" Import man page syntax. +" +" VIM Version: 7.4+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Organization: +" Version: 1.0 +" Created: 16.11.2017 +" Revision: --- +" License: Copyright (c) 2017, Wolfgang Mehner +"=============================================================================== + +runtime! syntax/man.vim + +" nothing noteworthy will happen in Vim +" save in Neovim, because filetype is not "man" diff --git a/syntax/gitsbranch.vim b/syntax/gitsbranch.vim deleted file mode 100644 index 0fdca98..0000000 --- a/syntax/gitsbranch.vim +++ /dev/null @@ -1,28 +0,0 @@ -" Vim syntax file -" Language: git output : branch -" Maintainer: Wolfgang Mehner <wolfgang-mehner@web.de> -" Last Change: 23.12.2012 - -if exists("b:current_syntax") - finish -endif - -syn sync fromstart -syn case match - -"------------------------------------------------------------------------------- -" Syntax -"------------------------------------------------------------------------------- - -" top-level categories: -" - GitBranchCurrent - -syn match GitBranchCurrent "^\*\s.\+$" - -"------------------------------------------------------------------------------- -" Highlight -"------------------------------------------------------------------------------- - -highlight default link GitBranchCurrent GitHighlight1 - -let b:current_syntax = "gitsbranch" diff --git a/syntax/gitscommit.vim b/syntax/gitscommit.vim deleted file mode 100644 index 7c55aaa..0000000 --- a/syntax/gitscommit.vim +++ /dev/null @@ -1,36 +0,0 @@ -" Vim syntax file -" Language: git output : commit -" Maintainer: Wolfgang Mehner <wolfgang-mehner@web.de> -" Last Change: 19.03.2013 - -if exists("b:current_syntax") - finish -endif - -syn sync fromstart -syn case match - -"------------------------------------------------------------------------------- -" Syntax -"------------------------------------------------------------------------------- - -" top-level categories: -" - GitCommitLineNwarn -" - GitCommitLine2warn -" - GitCommitLine1warn - -syn match GitCommitLineNwarn "^.\{,76}\zs.*$" -syn match GitCommitLine2warn "^\%2l.*$" -syn match GitCommitLine1warn "^\%1l.\{,50}\zs.*" - -syn match GitComment "^#.*$" - -"------------------------------------------------------------------------------- -" Highlight -"------------------------------------------------------------------------------- - -highlight default link GitCommitLine1warn GitWarning -highlight default link GitCommitLine2warn GitWarning -highlight default link GitCommitLineNwarn GitWarning - -let b:current_syntax = "gitscommit" diff --git a/syntax/gitsdiff.vim b/syntax/gitsdiff.vim deleted file mode 100644 index 66b3e8a..0000000 --- a/syntax/gitsdiff.vim +++ /dev/null @@ -1,63 +0,0 @@ -" Vim syntax file -" Language: git output : diff -" Maintainer: Wolfgang Mehner <wolfgang-mehner@web.de> -" Last Change: 19.03.2013 - -if exists("b:current_syntax") - finish -endif - -syn sync fromstart -syn case match - -"------------------------------------------------------------------------------- -" Syntax -"------------------------------------------------------------------------------- - -" top-level categories: -" - GitDiffRegion - -syn region GitDiffRegion start=/^diff / end=/^\%(diff \)\@=/ contains=GitDiffHeader,GitDiffLines,GitMergeLines fold -syn region GitDiffLines start=/^@@ / end=/^\%(@@ \)\@=\|^\%(diff \)\@=/ contains=GitDiffRange,GitDiffLineP,GitDiffLineM fold contained -syn region GitMergeLines start=/^@@@ / end=/^\%(@@@ \)\@=\|^\%(diff \)\@=/ contains=GitMergeRange,GitMergeLineP,GitMergeLineM,GitMergeConflict fold contained - -syn match GitDiffHeader "^\w.*$" contained -syn match GitDiffHeader "^--- .*$" contained -syn match GitDiffHeader "^+++ .*$" contained - -syn match GitWhiteTab " \+\ze\t" contained -syn match GitTrailingWhite "\s\+$" contained -syn match GitTrailingWhiteM "..\zs\s\+$" contained -syn match GitDiffTodo "\cTODO" contained - -syn match GitDiffRange "^@@[^@]\+@@" contained -syn match GitDiffLineP "^+.*$" contained contains=GitWhiteTab,GitTrailingWhite,GitDiffTodo -syn match GitDiffLineM "^-.*$" contained - -syn match GitMergeRange "^@@@[^@]\+@@@" contained -syn match GitMergeLineP "^+[+ ].*$" contained contains=GitTrailingWhiteM,GitDiffTodo -syn match GitMergeLineM "^-[- ].*$" contained -syn match GitMergeLineP "^ +.*$" contained contains=GitTrailingWhiteM,GitDiffTodo -syn match GitMergeLineM "^ -.*$" contained -syn match GitMergeConflict "^++<<<<<<< .\+" contained -syn match GitMergeConflict "^++=======" contained -syn match GitMergeConflict "^++>>>>>>> .\+" contained - -"------------------------------------------------------------------------------- -" Highlight -"------------------------------------------------------------------------------- - -highlight default link GitDiffHeader GitHeading -highlight default link GitDiffRange GitHighlight3 -highlight default link GitWhiteTab GitSevere -highlight default link GitTrailingWhite GitSevere -highlight default link GitTrailingWhiteM GitTrailingWhite -highlight default link GitDiffTodo Todo -highlight default link GitDiffLineP GitAdd -highlight default link GitDiffLineM GitRemove -highlight default link GitMergeRange GitHighlight3 -highlight default link GitMergeLineP GitAdd -highlight default link GitMergeLineM GitRemove -highlight default link GitMergeConflict GitConflict - -let b:current_syntax = "gitsdiff" diff --git a/syntax/gitsgrep.vim b/syntax/gitsgrep.vim deleted file mode 100644 index 61a18be..0000000 --- a/syntax/gitsgrep.vim +++ /dev/null @@ -1,34 +0,0 @@ -" Vim syntax file -" Language: git output : grep -" Maintainer: Wolfgang Mehner <wolfgang-mehner@web.de> -" Last Change: 07.07.2013 - -if exists("b:current_syntax") - finish -endif - -syn sync fromstart -syn case match - -"------------------------------------------------------------------------------- -" Syntax -"------------------------------------------------------------------------------- - -" top-level categories: -" - GitGrepFileLines - -syn region GitGrepFileLines start=/^\z([^:]\+:\)/ end=/^\%(\z1\)\@!/ contains=GitGrepPath fold keepend - -syn match GitGrepPath "^[^:]\+" contained nextgroup=GitGrepSep1 -syn match GitGrepSep1 ":" contained nextgroup=GitGrepLineNr -syn match GitGrepLineNr "\d\+" contained nextgroup=GitGrepSep2 -syn match GitGrepSep2 ":" contained - -"------------------------------------------------------------------------------- -" Highlight -"------------------------------------------------------------------------------- - -highlight default link GitGrepPath Directory -highlight default link GitGrepLineNr LineNr - -let b:current_syntax = "gitsgrep" diff --git a/syntax/gitslog.vim b/syntax/gitslog.vim deleted file mode 100644 index 575477f..0000000 --- a/syntax/gitslog.vim +++ /dev/null @@ -1,49 +0,0 @@ -" Vim syntax file -" Language: git output : log (uses: diff) -" Maintainer: Wolfgang Mehner <wolfgang-mehner@web.de> -" Last Change: 19.03.2013 - -if exists("b:current_syntax") - finish -endif - -" use 'GitDiffRegion' contained in 'GitLogCommit' -syn include <sfile>:p:h/gitsdiff.vim - -"syn sync minlines=100 -syn sync fromstart -syn case match - -"------------------------------------------------------------------------------- -" Syntax -"------------------------------------------------------------------------------- - -" top-level categories: -" - GitLogCommit -" - GitStash -" - GitAnnoTag - -syn region GitLogCommit start=/^commit\s/ end=/^\%(commit\s\)\@=/ contains=GitLogHash,GitLogInfo,GitDiffRegion fold keepend -syn match GitLogHash "^commit\s.\+$" contained contains=GitLogDeco -syn match GitLogDeco "(\zs.*\ze)" contained contains=GitLogRef -syn match GitLogRef "[^,%s]" contained -syn match GitLogInfo "^\w\+:\s.\+$" contained -syn match GitLogInfo "^Notes:\s*$" contained -syn match GitLogInfo "^Notes\s(.*):\s*$" contained - -syn region GitStash start=/^stash@{\d\+}:\s/ end=/^\%(stash@{\d\+}:\s\)\@=/ contains=GitStashName,GitDiffRegion fold keepend -syn match GitStashName "^stash@{\d\+}:\s.\+$" contained - -syn region GitAnnoTag start=/^tag\s/ end=/^\%(commit\)\@=/ contains=GitTagName,GitLogInfo fold keepend -syn match GitTagName "^tag\s.\+$" contained - -"------------------------------------------------------------------------------- -" Highlight -"------------------------------------------------------------------------------- - -highlight default link GitLogHash GitHighlight2 -highlight default link GitLogRef GitHighlight1 -highlight default link GitLogInfo GitHighlight1 -highlight default link GitTagName GitHighlight2 - -let b:current_syntax = "gitslog" diff --git a/syntax/gitssshort.vim b/syntax/gitssshort.vim deleted file mode 100644 index ff76a92..0000000 --- a/syntax/gitssshort.vim +++ /dev/null @@ -1,47 +0,0 @@ -" Vim syntax file -" Language: git output : status --short -" Maintainer: Wolfgang Mehner <wolfgang-mehner@web.de> -" Last Change: 30.12.2012 - -if exists("b:current_syntax") - finish -endif - -syn sync fromstart -syn case match - -"------------------------------------------------------------------------------- -" Syntax -"------------------------------------------------------------------------------- - -" top-level categories: -" - GitStagedFile -" - GitModifiedFile -" - GitUntrackedFile -" - GitIgnoredFile -" - GitUnmergedFile - -" The expressions are designed to distinguish between staged, modified and -" unmerged files. This should work, since a modified file is never prefixed -" by 'AA' or 'DD'. - -syn match GitStagedFile "^[MARC] \s.\+" -syn match GitStagedFile "^D \s.\+" -syn match GitModifiedFile "^[ MARC][MD]\s.\+" -syn match GitModifiedFile "^DM\s.\+" -syn match GitUntrackedFile "^??" -syn match GitIgnoredFile "^!!" -syn match GitUnmergedFile "^\%(AA\|DD\)\s.\+" -syn match GitUnmergedFile "^\%([AD]U\|U[ADU]\)\s.\+" - -"------------------------------------------------------------------------------- -" Highlight -"------------------------------------------------------------------------------- - -highlight default link GitStagedFile GitAdd -highlight default link GitModifiedFile GitRemove -highlight default link GitUntrackedFile GitRemove -highlight default link GitIgnoredFile GitRemove -highlight default link GitUnmergedFile GitRemove - -let b:current_syntax = "gitssshort" diff --git a/syntax/gitsstatus.vim b/syntax/gitsstatus.vim deleted file mode 100644 index f3b9d4b..0000000 --- a/syntax/gitsstatus.vim +++ /dev/null @@ -1,96 +0,0 @@ -" Vim syntax file -" Language: git output : status (uses: diff) -" Maintainer: Wolfgang Mehner <wolfgang-mehner@web.de> -" Last Change: 19.03.2013 - -if exists("b:current_syntax") - finish -endif - -" use 'GitDiffRegion' as a top-level category -runtime! syntax/gitsdiff.vim -unlet b:current_syntax - -syn sync fromstart -syn case match - -"------------------------------------------------------------------------------- -" Syntax -"------------------------------------------------------------------------------- - -" top-level categories: -" - GitStatusHashRegion -" - GitStatusBareRegion -" containing status lines starting with a hash (X = "") or without (X = "B"): -" - GitStagedRegionX -" - GitModifiedRegionX -" - GitUntrackedRegionX -" - GitIgnoredRegionX -" - GitUntrackedRegionX -" imported: -" - GitDiffRegion - -syn region GitStatusHashRegion start=/^#/ end=/^#\@!/ contains=GitStagedRegion,GitModifiedRegion,GitUntrackedRegion,GitIgnoredRegion,GitUnmergedRegion fold -syn region GitStatusBareRegion start=/^[^#]\%1l/ end=/^\%(diff\)\@=/ contains=GitStagedRegionB,GitModifiedRegionB,GitUntrackedRegionB,GitIgnoredRegionB,GitUnmergedRegionB fold - -syn region GitStagedRegion start=/^# Changes to be committed:/ end=/^\%(# \w\)\@=\|^#\@!/ contains=GitStatusHeader,GitStatusComment,GitStagedFile fold contained -syn match GitStagedFile "^#\s\+\zs[[:alnum:][:space:]]\+:\s.\+" contained - -syn region GitStagedRegionB start=/^Changes to be committed:/ end=/^\%(\w\)\@=/ contains=GitStatusHeaderB,GitStatusCommentB,GitStagedFileB fold contained -syn match GitStagedFileB "^\s\+\zs[[:alnum:][:space:]]\+:\s.\+" contained - -" the header for uncommitted changes changed somewhere along the way: -" - the first alternative is the old version -" - for the new, "bare" version, we only need the new one -syn region GitModifiedRegion start=/^# Changed but not updated:/ end=/^\%(# \w\)\@=\|^#\@!/ contains=GitStatusHeader,GitStatusComment,GitModifiedFile fold contained -syn region GitModifiedRegion start=/^# Changes not staged for commit:/ end=/^\%(# \w\)\@=\|^#\@!/ contains=GitStatusHeader,GitStatusComment,GitModifiedFile fold contained -syn match GitModifiedFile "^#\s\+\zs[[:alnum:][:space:]]\+:\s.\+" contained - -syn region GitModifiedRegionB start=/^Changes not staged for commit:/ end=/^\%(\w\)\@=/ contains=GitStatusHeaderB,GitStatusCommentB,GitModifiedFileB fold contained -syn match GitModifiedFileB "^\s\+\zs[[:alnum:][:space:]]\+:\s.\+" contained - -syn region GitUntrackedRegion start=/^# Untracked files:/ end=/^\%(# \w\)\@=\|^#\@!/ contains=GitStatusHeader,GitStatusComment,GitUntrackedFile fold contained -syn match GitUntrackedFile "^#\s\+\zs[^([:space:]].*$" contained - -syn region GitUntrackedRegionB start=/^Untracked files:/ end=/^\%(\w\)\@=/ contains=GitStatusHeaderB,GitStatusCommentB,GitUntrackedFileB fold contained -syn match GitUntrackedFileB "^\s\+\zs[^([:space:]].*$" contained - -syn region GitIgnoredRegion start=/^# Ignored files:/ end=/^\%(# \w\)\@=\|^#\@!/ contains=GitStatusHeader,GitStatusComment,GitIgnoredFile fold contained -syn match GitIgnoredFile "^#\s\+\zs[^([:space:]].*$" contained - -syn region GitIgnoredRegionB start=/^Ignored files:/ end=/^\%(\w\)\@=/ contains=GitStatusHeaderB,GitStatusCommentB,GitIgnoredFileB fold contained -syn match GitIgnoredFileB "^\s\+\zs[^([:space:]].*$" contained - -syn region GitUnmergedRegion start=/^# Unmerged paths:/ end=/^\%(# \w\)\@=\|^#\@!/ contains=GitStatusHeader,GitStatusComment,GitUnmergedFile fold contained -syn match GitUnmergedFile "^#\s\+\zs[[:alnum:][:space:]]\+:\s.\+" contained - -syn region GitUnmergedRegionB start=/^Unmerged paths:/ end=/^\%(\w\)\@=/ contains=GitStatusHeaderB,GitStatusCommentB,GitUnmergedFileB fold contained -syn match GitUnmergedFileB "^\s\+\zs[[:alnum:][:space:]]\+:\s.\+" contained - -syn match GitStatusHeader "^# \zs.\+:$" contained -syn match GitStatusComment "^#\s\+\zs([^)]*)$" contained - -syn match GitStatusHeaderB "^\S.*:$" contained -syn match GitStatusCommentB "^\s\+\zs([^)]*)$" contained - -"------------------------------------------------------------------------------- -" Highlight -"------------------------------------------------------------------------------- - -highlight default link GitStatusHeader GitHeading -highlight default link GitStatusComment GitComment -highlight default link GitStagedFile GitAdd -highlight default link GitModifiedFile GitRemove -highlight default link GitUntrackedFile GitRemove -highlight default link GitIgnoredFile GitRemove -highlight default link GitUnmergedFile GitRemove - -highlight default link GitStatusHeaderB GitHeading -highlight default link GitStatusCommentB GitComment -highlight default link GitStagedFileB GitAdd -highlight default link GitModifiedFileB GitRemove -highlight default link GitUntrackedFileB GitRemove -highlight default link GitIgnoredFileB GitRemove -highlight default link GitUnmergedFileB GitRemove - -let b:current_syntax = "gitsstatus" diff --git a/vim-support/README.md b/vim-support/README.md index 34c4e0d..6c9925e 100644 --- a/vim-support/README.md +++ b/vim-support/README.md @@ -1,4 +1,4 @@ -README for vim-support.vim (Version 2.4.1beta) / July 09 2017 +README for vim-support.vim (Version 2.5beta) / February 10 2018 ================================================================================ [INSTALLATION][sec_install] @@ -9,14 +9,13 @@ README for vim-support.vim (Version 2.4.1beta) / July 09 2017 [CREDITS][sec_credits] -VimScript Support implements a VimScript-IDE for Vim/gVim. It has been written -to considerably speed up writing code in a consistent style. This is done by -inserting complete statements, comments, idioms, and code snippets. Reading the -Vim documentation is integrated. There are many additional hints and options -which can improve speed and comfort when writing VimScript. Please read the -documentation. +VimScript Support implements a VimScript-IDE for Vim/gVim/Neovim. It has been +written to considerably speed up writing code in a consistent style. This is +done by inserting complete statements, comments, idioms, and code snippets. +There are many additional hints and options which can improve speed and comfort +when writing VimScript. Please read the documentation. -This plugin can be used with Vim version 7.x. +This plug-in can be used with Vim version 7.3+ and Neovim 0.2.1+. -------------------------------------------------------------------------------- @@ -28,7 +27,7 @@ INSTALLATION A system-wide installation for all users can also be done. This will have further effects on how the plug-in works. For a step-by-step instruction, as well as an explanation of the other consequences, please see the help file -'doc/vimsupport.txt' or look up the documentation via: +`doc/vimsupport.txt` or look up the documentation via: :help vimsupport-system-wide @@ -36,14 +35,14 @@ well as an explanation of the other consequences, please see the help file (1) LINUX ---------------------------------------------------------------------- -The subdirectories in the zip archive vim-support.zip mirror the directory -structure which is needed below the local installation directory $HOME/.vim/ -(find the value of $HOME with `:echo $HOME` from inside Vim). +The subdirectories in the zip archive `vim-support.zip` mirror the directory +structure which is needed below the local installation directory `$HOME/.vim/` +(find the value of `$HOME` with `:echo $HOME` from inside Vim). -(1.0) Save the template files in '$HOME/.vim/vim-support/templates/Templates' if - you have changed any of them. +(1.0) Save the template files in `$HOME/.vim/vim-support/templates/` if you + have changed any of them. -(1.1) Copy the zip archive vim-support.zip to $HOME/.vim and run +(1.1) Copy the zip archive `vim-support.zip` to `$HOME/.vim` and run unzip vim-support.zip @@ -53,54 +52,59 @@ structure which is needed below the local installation directory $HOME/.vim/ $HOME/.vim/doc/... $HOME/.vim/plugin/vim-support.vim -(1.2) Loading of plugin files must be enabled. If not use +(1.2) Loading of plug-in files must be enabled. If not use :filetype plugin on - This is the minimal content of the file '$HOME/.vimrc'. Create one if there - is none or use the files in $HOME/.vim/vim-support/rc as a starting point. + This is the minimal content of the file `$HOME/.vimrc`. Create one if there + is none or use the file in `$HOME/.vim/vim-support/rc` as a starting point. -(1.3) Set at least some personal details. Use the map \ntw inside a Vim buffer +(1.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME/.vim/doc/ + +(1.4) Set at least some personal details. Use the map \ntw inside a Vim buffer or the menu entry: Vim -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): - SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) - SetMacro( 'AUTHORREF', 'fgm' ) - SetMacro( 'EMAIL', 'mehner.fritz@web.de' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) + SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) + SetMacro( 'AUTHORREF', 'WM' ) + SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/.vim/templates/vim.templates to customize or add to your + Use the file `$HOME/.vim/templates/vim.templates` to customize or add to your Vim template library. It can also be set up via the wizard. - (Read more about the template system in the plugin documentation) + (Read more about the template system in the plug-in documentation.) -(1.4) Make the plugin help accessible by typing the following command on the - Vim command line: - - :helptags $HOME/.vim/doc/ +(1.5) Consider additional settings in the file `$HOME/.vimrc`. The files + `customization.vimrc` and `customization.gvimrc` are replacements or + extensions for your `.vimrc` and `.gvimrc`. You may want to use parts of + them. The files are documented. -(1.5) Consider additional settings in the file '$HOME/.vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your .vimrc and .gvimrc. You may want to use parts of them. The files - are documented. + Some settings are specifically for VimScript buffers and should be placed in + the filetype plug-in. You may copy the file `vim-support/rc/vim.vim` into the + directory `$HOME/.vim/ftplugin/`, or use the settings there as additions to + your own filetype plug-in. (2) WINDOWS ---------------------------------------------------------------------- -The subdirectories in the zip archive vim-support.zip mirror the directory -structure which is needed below the local installation directory $HOME/vimfiles/ -(find the value of $HOME with `:echo $HOME` from inside Vim). +The subdirectories in the zip archive `vim-support.zip` mirror the directory +structure which is needed below the local installation directory `$HOME/vimfiles/` +(find the value of `$HOME` with `:echo $HOME` from inside Vim). -(2.0) Save the template files in '$HOME/vimfiles/vim-support/templates/Templates' - if you have changed any of them. +(2.0) Save the template files in `$HOME/vimfiles/vim-support/templates/` if you + have changed any of them. -(2.1) Copy the zip archive vim-support.zip to $HOME/vimfiles and run +(2.1) Copy the zip archive `vim-support.zip` to `$HOME/vimfiles` and run unzip vim-support.zip @@ -110,41 +114,46 @@ structure which is needed below the local installation directory $HOME/vimfiles/ $HOME/vimfiles/doc/... $HOME/vimfiles/plugin/vim-support.vim -(2.2) Loading of plugin files must be enabled. If not use +(2.2) Loading of plug-in files must be enabled. If not use :filetype plugin on - This is the minimal content of the file '$HOME/_vimrc'. Create one if there - is none or use the files in $HOME/vimfiles/vim-support/rc as a starting point. + This is the minimal content of the file `$HOME/_vimrc`. Create one if there + is none or use the file in `$HOME/vimfiles/vim-support/rc` as a starting point. -(2.3) Set at least some personal details. Use the map \ntw inside a Vim buffer +(2.3) Make the plug-in help accessible by typing the following command on the + Vim command line: + + :helptags $HOME\vimfiles\doc\ + +(2.4) Set at least some personal details. Use the map \ntw inside a Vim buffer or the menu entry: Vim -> Snippets -> template setup wizard - It will help you set up the file _runtimepath_/templates/personal.templates . + It will help you set up the file `_runtimepath_/templates/personal.templates`. The file is read by all plug-ins supporting this feature to get your personal details. Here is the minimal personalization (my settings as an example): - SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) - SetMacro( 'AUTHORREF', 'fgm' ) - SetMacro( 'EMAIL', 'mehner.fritz@web.de' ) - SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) + SetMacro( 'AUTHOR', 'Wolfgang Mehner' ) + SetMacro( 'AUTHORREF', 'WM' ) + SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/vimfiles/templates/vim.templates to customize or add to + Use the file `$HOME/vimfiles/templates/vim.templates` to customize or add to your Vim template library. It can also be set up via the wizard. - (Read more about the template system in the plugin documentation) + (Read more about the template system in the plug-in documentation.) -(2.4) Make the plugin help accessible by typing the following command on the - Vim command line: - - :helptags $HOME\vimfiles\doc\ +(2.5) Consider additional settings in the file `$HOME/_vimrc`. The files + `customization.vimrc` and `customization.gvimrc` are replacements or + extensions for your `_vimrc` and `_gvimrc`. You may want to use parts of + them. The files are documented. -(2.5) Consider additional settings in the file '$HOME/_vimrc'. The files - customization.vimrc and customization.gvimrc are replacements or extensions - for your _vimrc and _gvimrc. You may want to use parts of them. The files - are documented. + Some settings are specifically for VimScript buffers and should be placed in + the filetype plug-in. You may copy the file `vim-support/rc/vim.vim` into the + directory `$HOME/vimfiles/ftplugin/`, or use the settings there as additions + to your own filetype plug-in. (3) ADDITIONAL REMARKS @@ -152,23 +161,16 @@ structure which is needed below the local installation directory $HOME/vimfiles/ There are a lot of features and options which can be used and influenced: - * use of template files and macros + * use of the extendible template library * using and managing personal code snippets * using additional plugins -Look at the VimScript Support help with: +Actions differ for different modes. Please read the documentation: :help vimsupport - +-----------------------------------------------+ - | +-------------------------------------------+ | - | | ** PLEASE READ THE DOCUMENTATION ** | | - | | Actions differ for different modes! | | - | +-------------------------------------------+ | - +-----------------------------------------------+ - Any problems? See the TROUBLESHOOTING section at the end of the help file -'doc/vimsupport.txt'. +`doc/vimsupport.txt`. -------------------------------------------------------------------------------- @@ -177,16 +179,22 @@ RELEASE NOTES ================================================================================ [sec_release]: #release-notes -RELEASE NOTES FOR VERSION 2.4.1beta +RELEASE NOTES FOR VERSION 2.5beta ---------------------------------------------------------------------- -- Add configuration variables 'g:Vim_Ctrl_j' and 'g:Vim_Ctrl_d' to control the - creation of the CTRL+J and CTRL+D maps. +- Add configuration variables `g:Vim_Ctrl_j` and `g:Vim_Ctrl_d` to control the + creation of the `CTRL+J` and `CTRL+D` maps. +- Remove `g:Vim_CreateMenusDelayed`, use `g:Vim_LoadMenus` instead. +- Remove the definition of the map `SHIFT+F1`. Add it to your filetype plug-in + if you want to use it. - Minor changes. +Note: Copy the sample filetype plug-in from `vim-support/rc` to `ftplugin`, or +add the commands there to your own one. + RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- --> see file 'vim-support/doc/ChangeLog' +-> see file `vim-support/doc/ChangeLog` -------------------------------------------------------------------------------- @@ -209,9 +217,6 @@ FILES plugin/vim-support.vim The VimScript plugin for Vim/gVim. - vim-support/codesnippets/* - Some VimScript code snippets as a starting point. - vim-support/templates/Templates VimScript main template file. vim-support/templates/*.templates @@ -226,6 +231,9 @@ ___The settings are explained in the files themselves.___ syntax/template.vim Additional files for working with templates. + vim-support/codesnippets/* + Some VimScript code snippets as a starting point. + vim-support/doc/vim-hotkeys.pdf Reference card for the key mappings. The mappings can be used with the non-GUI Vim, where the menus are not @@ -245,6 +253,10 @@ ___The settings are explained in the files themselves.___ The file is commented. Append it to your .vimrc if you like. + vim-support/rc/vim.vim + Example filetype plug-in for VimScript: + defines additional maps + vim-support/rc/*.templates Sample template files for customization. Used by the template setup wizard. @@ -256,15 +268,6 @@ CREDITS ================================================================================ [sec_credits]: #credits -Fritz Mehner thanks: ----------------------------------------------------------------------- - -Many thanks to Wolfgang Mehner (wolfgang-mehner at web.de) for his template - engine Template Support. - -Wolfgang Mehner thanks: ----------------------------------------------------------------------- - -This plug-in has been developed together with Fritz Mehner, who maintained - it until 2015. +This plug-in has been developed together with Fritz Mehner, who maintained it +until 2015. diff --git a/vim-support/README.standalone.md b/vim-support/README.standalone.md index fb54a6c..99d6f96 100644 --- a/vim-support/README.standalone.md +++ b/vim-support/README.standalone.md @@ -3,8 +3,9 @@ Preface This repository is mainly for the use with plug-in managers. -The development happens here: -[WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) +Have a look at the [Screenshot Page](https://wolfgangmehner.github.io/vim-plugins/vimsupport.html). + +The development happens in [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins). -------------------------------------------------------------------------------- diff --git a/vim-support/doc/vim-hotkeys.tex b/vim-support/doc/vim-hotkeys.tex index f96c0ca..79e51be 100644 --- a/vim-support/doc/vim-hotkeys.tex +++ b/vim-support/doc/vim-hotkeys.tex @@ -6,12 +6,12 @@ %% %% Version: see \Pluginversion %% Created: 22.01.2012 -%% Revision: 09.07.2017 +%% Revision: 17.02.2018 %% %% Author: Wolfgang Mehner (WM), wolfgang-mehner@web.de %% Dr. Fritz Mehner (fgm), mehner.fritz@web.de %% Copyright: Copyright (c) 2012-2015, Dr. Fritz Mehner -%% Copyright (c) 2016-2017, Wolfgang Mehner +%% Copyright (c) 2016-2018, Wolfgang Mehner %% %%===================================================================================== @@ -30,7 +30,7 @@ \setlength\parindent{0pt} -\newcommand{\Pluginversion}{2.4.1} +\newcommand{\Pluginversion}{2.5} \newcommand{\Rep}{{\scriptsize{[n]}}} %%---------------------------------------------------------------------- @@ -76,11 +76,8 @@ \vspace{1mm}% \textbf{\textsc{\Huge{Hot keys}}}\\ \vspace{1mm}% -Key mappings for Vim and gVim\\ -{\tiny \texttt{http://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ -\vspace{1.0mm} -{\normalsize (i)} insert mode, {\normalsize (n)} normal mode, {\normalsize (v)} visual mode,\\ -{\normalsize (T)} tab-completion +Key mappings for Vim/gVim/Neovim\\ +{\tiny \texttt{https://www.vim.org}\hspace{1.5mm}---\hspace{1.5mm}\textbf{Wolfgang Mehner}, \texttt{wolfgang-mehner@web.de}}\\ \vspace{1.0mm} % %%====================================================================== @@ -89,38 +86,39 @@ %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{58mm}|} %%---------------------------------------------------------------------- -%% show plugin help +%% show plugin help [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\underline{H}elp}}\\[1.0ex] -\hline \verb'\he' & English dictionary \hfill (n, i)\\ -\hline \verb'\hk' \verb'<S-F1>' & help (Vim functions) \hfill (n, i)\\ -\hline \verb'\hp' & help (vim-support) \hfill (n, i)\\ +\hline \verb'\he' & English dictionary \\ +\hline \verb'\hk' & help (Vim functions) \\ +\hline \verb'\hp' & help (vim-support) \\ \hline %%---------------------------------------------------------------------- -%% menu comments +%% menu comments [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\underline{C}omments}} \\[1.0ex] -\hline \Rep\verb'\cl' & end-of-line comment \hfill (n, v, i)\\ -\hline \Rep\verb'\cj' & adjust end-of-line comments \hfill (n, v, i)\\ -\hline \verb'\cs' & set end-of-line comment col. \hfill (n) \\ -\hline \Rep\verb'\cc' & comment code \hfill (n, i, v)\\ -\hline \Rep\verb'\co' & uncomment code \hfill (n, i, v)\\ -\hline \verb'\ca' & function description (auto) \hfill (n, i, v)\\ +\hline \Rep\verb'\cl' & end-of-line comment \hfill (v)\\ +\hline \Rep\verb'\cj' & adjust end-of-line comments \hfill (v)\\ +\hline \verb'\cs' & set end-of-line comment col. \\ +\hline \Rep\verb'\cc' & comment code \hfill (v)\\ +\hline \Rep\verb'\co' & uncomment code \hfill (v)\\ +\hline \verb'\ca' & function description (auto) \\ % -\hline \verb'\cfr' & frame comment \hfill (n, i)\\ -\hline \verb'\cfu' & function description \hfill (n, i)\\ -\hline \verb'\ch' & file description \hfill (n, i)\\ -\hline \verb'\cd' & date \hfill (n, i)\\ -\hline \verb'\ct' & date \& time \hfill (n, i)\\ +\hline \verb'\cfr' & frame comment \\ +\hline \verb'\cfu' & function description \\ +\hline \verb'\ch' & file description \\ +\hline \verb'\cd' & date \\ +\hline \verb'\ct' & date \& time \\ \hline % -\hline \verb'\ck' & keyword comments \hfill (n, i, T)\\ -\hline \verb'\cma' & plugin macros \hfill (n, i, T)\\ +\hline \verb'\ck' & keyword comments \hfill (T)\\ +\hline \verb'\cma' & plugin macros \hfill (T)\\ \hline \end{tabular}\\ %%~~~~~ TABULAR : end ~~~~~~~~~~ +% ]]]2 % %%====================================================================== %% table, middle part [[[1 @@ -129,57 +127,58 @@ %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{58mm}|} %%---------------------------------------------------------------------- -%% menu statements +%% menu statements [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\underline{S}tatements}}\\[1.0ex] -\hline \verb'\sv' & \verb'let' variable \hfill (n, i)\\ -\hline \verb'\sl' & \verb'let' list \hfill (n, i)\\ -\hline \verb'\sd' & \verb'let' dictionary \hfill (n, i)\\ -\hline \verb'\sf' & \verb'for' \hfill (n, v, i)\\ -\hline \verb'\sif' & \verb'if'$\ldots$\verb'endif' \hfill (n, v, i)\\ -\hline \verb'\sie' & \verb'if'$\ldots$\verb'else'$\ldots$\verb'endif' \hfill (n, v, i)\\ -\hline \verb'\sei' & \verb'elseif' \hfill (n, i)\\ -\hline \verb'\sel' & \verb'else' \hfill (n, i)\\ -\hline \verb'\sw' & \verb'while' \hfill (n, v, i)\\ -\hline \verb'\st' & \verb'try'$\ldots$\verb'catch' \hfill (n, v, i)\\ +\hline \verb'\sv' & \verb'let' variable \\ +\hline \verb'\sl' & \verb'let' list \\ +\hline \verb'\sd' & \verb'let' dictionary \\ +\hline \verb'\sf' & \verb'for' \hfill (s)\\ +\hline \verb'\sif' & \verb'if'$\ldots$\verb'endif' \hfill (s)\\ +\hline \verb'\sie' & \verb'if'$\ldots$\verb'else'$\ldots$\verb'endif' \hfill (s)\\ +\hline \verb'\sei' & \verb'elseif' \\ +\hline \verb'\sel' & \verb'else' \\ +\hline \verb'\sw' & \verb'while' \hfill (s)\\ +\hline \verb'\st' & \verb'try'$\ldots$\verb'catch' \hfill (s)\\ \hline %%---------------------------------------------------------------------- -%% menu idioms +%% menu idioms [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\underline{I}dioms}} \\[1.0ex] -\hline \verb'\ib' & builtin functions \hfill (n, i, T)\\ -\hline \verb'\ii' & iterators \hfill (n, v, i, T)\\ -\hline \verb'\if' & function \hfill (n, v, i)\\ +\hline \verb'\ib' & builtin functions \hfill (T)\\ +\hline \verb'\ii' & iterators \hfill (s, T)\\ +\hline \verb'\if' & function \hfill (s)\\ \hline %%---------------------------------------------------------------------- -%% menu regex menu +%% menu regex menu [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{Regular E\underline{x}pressions}} \\[1.0ex] -\hline \verb'\xc' & capture \hfill (n, i, v)\\ -\hline \verb'\xbc' & branch \hfill (n, i, v)\\ -\hline \verb'\xbn' & branch, no capture \hfill (n, i, v)\\ -\hline \verb'\xw' & word \hfill (n, i)\\ -\hline \verb'\xcc' & character classes \hfill (n, i, T)\\ -\hline \verb'\xs' & switches \hfill (n, i, T)\\ +\hline \verb'\xc' & capture \hfill (s)\\ +\hline \verb'\xbc' & branch \hfill (s)\\ +\hline \verb'\xbn' & branch, no capture \hfill (s)\\ +\hline \verb'\xw' & word \hfill (s)\\ +\hline \verb'\xcc' & character classes \hfill (T)\\ +\hline \verb'\xs' & switches \hfill (T)\\ \hline %%---------------------------------------------------------------------- -%% menu Perl +%% menu Perl [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\underline{P}erl}} \\[1.0ex] -\hline \verb'\ps' & Perl snippet \hfill (n, i)\\ -\hline \verb'\pd' & \texttt{Vim::DoCommand()} \hfill (n, i)\\ -\hline \verb'\pe' & \texttt{Vim::Eval()} \hfill (n, i)\\ -\hline \verb'\pm' & \texttt{Vim::Msg( "" ) } \hfill (n, i)\\ -\hline \verb'\pmc' & \texttt{Vim::Msg( "", "Comment" )} \hfill (n, i)\\ -\hline \verb'\pme' & \texttt{Vim::Msg( "", "Warning" )} \hfill (n, i)\\ -\hline \verb'\pmw' & \texttt{Vim::Msg( "", "ErrorMsg")} \hfill (n, i)\\ +\hline \verb'\ps' & Perl snippet \\ +\hline \verb'\pd' & \texttt{Vim::DoCommand()} \\ +\hline \verb'\pe' & \texttt{Vim::Eval()} \\ +\hline \verb'\pm' & \texttt{Vim::Msg( "" ) } \\ +\hline \verb'\pmc' & \texttt{Vim::Msg( "", "Comment" )} \\ +\hline \verb'\pme' & \texttt{Vim::Msg( "", "Warning" )} \\ +\hline \verb'\pmw' & \texttt{Vim::Msg( "", "ErrorMsg")} \\ \hline \end{tabular}\\ %%~~~~~ TABULAR : end ~~~~~~~~~~ +% ]]]2 % %%====================================================================== %% table, right part [[[1 @@ -188,55 +187,61 @@ %%~~~~~ TABULAR : begin ~~~~~~~~~~ \begin{tabular}[]{|p{11mm}|p{58mm}|} %%---------------------------------------------------------------------- -%% menu Documentation +%% menu Documentation [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\underline{D}ocumentation}} \\[1.0ex] -\hline \verb'\dcc' & table-of-contents, chapter \hfill (n, i)\\ -\hline \verb'\dcs' & table-of-contents, section \hfill (n, i)\\ -\hline \verb'\dcu' & table-of-contents, subsection \hfill (n, i)\\ -\hline \verb'\dtc' & text, chapter \hfill (n, i)\\ -\hline \verb'\dts' & text, section \hfill (n, i)\\ -\hline \verb'\dtu' & text, subsection \hfill (n, i)\\ -\hline \verb'\df' & function description \hfill (n, i)\\ -\hline \verb'\de' & example \hfill (n, v, i)\\ +\hline \verb'\dcc' & table-of-contents, chapter \\ +\hline \verb'\dcs' & table-of-contents, section \\ +\hline \verb'\dcu' & table-of-contents, subsection \\ +\hline \verb'\dtc' & text, chapter \\ +\hline \verb'\dts' & text, section \\ +\hline \verb'\dtu' & text, subsection \\ +\hline \verb'\df' & function description \\ +\hline \verb'\de' & example \hfill (s)\\ \hline %%---------------------------------------------------------------------- -%% snippet menu +%% snippet menu [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{S\underline{n}ippet}} \\[1.0ex] -\hline \verb'\nr' & read code snippet \hfill (n, i) \\ -\hline \verb'\nw' & write code snippet \hfill (n, v, i)\\ -\hline \verb'\nv' & view code snippet \hfill (n, i) \\ -\hline \verb'\ne' & edit code snippet \hfill (n, i) \\ +\hline \verb'\nr' & read code snippet \\ +\hline \verb'\nw' & write code snippet \hfill (v)\\ +\hline \verb'\nv' & view code snippet \\ +\hline \verb'\ne' & edit code snippet \\ % -\hline \verb'\ntl' & edit local templates \hfill (n, i)\\ -\hline \verb'\ntc' & edit custom templates \hfill (n, i)\\ -\hline \verb'\ntp' & edit personal templates \hfill (n, i)\\ -\hline \verb'\ntr' & reread the templates \hfill (n, i)\\ -\hline \verb'\ntw' & template setup wizard \hfill (n, i)\\ -\hline \verb'\nts' & choose template style \hfill (n, i, T)\\ +\hline \verb'\ntl' & edit local templates \\ +\hline \verb'\ntc' & edit custom templates \\ +\hline \verb'\ntp' & edit personal templates \\ +\hline \verb'\ntr' & reread the templates \\ +\hline \verb'\ntw' & template setup wizard \\ +\hline \verb'\nts' & choose template style \hfill (T)\\ % \hline %%---------------------------------------------------------------------- -%% menu run +%% menu run [[[2 %%---------------------------------------------------------------------- \hline \multicolumn{2}{|r|}{\textsl{\underline{R}un}} \\[1.0ex] -\hline \verb'\rh' & hardcopy buffer to postscript \hfill (n, v, i)\\ -\hline \verb'\rs' & plugin settings \hfill (n, i)\\ +\hline \verb'\rh' & hardcopy buffer to postscript \hfill (v)\\ +\hline \verb'\rs' & plugin settings \\ \hline -\end{tabular}\\ +\end{tabular}\\[1.0ex] %%~~~~~ TABULAR : end ~~~~~~~~~~ % -%\begin{minipage}[b]{75mm}% -%\scriptsize{% -%\vspace{10mm} -%\hrulefill\\ -%$^1$ {system-wide installation only}\\ -%}% -%\end{minipage}\\ +%%---------------------------------------------------------------------- +%% box Footnotes [[[2 +%%---------------------------------------------------------------------- +\begin{minipage}[b]{72mm}% +\scriptsize{% +all hotkeys work in normal and insert mode \\ +visual mode: {\normalsize (v)} use the range, +{\normalsize (s)} surround range \\ +tab-completion: {\normalsize (T)} specialized, +{\normalsize (F)} filenames +}% +\end{minipage} +% ]]]2 % \end{center}% \end{multicols}% diff --git a/vim-support/rc/customization.gvimrc b/vim-support/rc/customization.gvimrc index b2a3066..73ff4d7 100644 --- a/vim-support/rc/customization.gvimrc +++ b/vim-support/rc/customization.gvimrc @@ -1,15 +1,21 @@ -"=================================================================================== -" FILE: .gvimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.gvimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" VERSION: 1.0 -" CREATED: 04.04.2009 -" REVISION: $Id: customization.gvimrc,v 1.1 2012/02/11 16:37:29 mehner Exp $ -"=================================================================================== +"=============================================================================== " -"=================================================================================== +" File: customization.gvimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 16.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== " GENERAL SETTINGS -"=================================================================================== +"=============================================================================== + set cmdheight=2 " Make command line two lines high set mousehide " Hide the mouse when typing text @@ -19,39 +25,38 @@ highlight lCursor guibg=Cyan guifg=NONE highlight NonText guibg=grey80 highlight Constant gui=NONE guibg=grey95 highlight Special gui=NONE guibg=grey95 -" + let c_comment_strings=1 " highlight strings inside C comments -" + "------------------------------------------------------------------------------- " Moving cursor to other windows -" -" shift down : change window focus to lower one (cyclic) -" shift up : change window focus to upper one (cyclic) -" shift left : change window focus to one on left -" shift right : change window focus to one on right -"------------------------------------------------------------------------------- -nmap <s-down> <c-w>w -nmap <s-up> <c-w>W -nmap <s-left> <c-w>h -nmap <s-right> <c-w>l " +" shift-down : change window focus to lower one (cyclic) +" shift-up : change window focus to upper one (cyclic) +" shift-left : change window focus to one on left +" shift-right : change window focus to one on right "------------------------------------------------------------------------------- -" some additional hot keys -"------------------------------------------------------------------------------- -" S-F3 - call gvim file browser +nnoremap <s-down> <c-w>w +nnoremap <s-up> <c-w>W +nnoremap <s-left> <c-w>h +nnoremap <s-right> <c-w>l + "------------------------------------------------------------------------------- - map <silent> <s-F3> :silent browse confirm e<CR> -imap <silent> <s-F3> <Esc>:silent browse confirm e<CR> +" Some additional hot keys " +" shift-F3 : call gvim file browser "------------------------------------------------------------------------------- -" toggle insert mode <--> 'normal mode with the <RightMouse>-key + noremap <silent> <s-F3> :silent browse confirm e<CR> +inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR> + "------------------------------------------------------------------------------- -" -nmap <RightMouse> <Insert> -imap <RightMouse> <ESC> -" +" toggle insert mode <--> normal mode with the <RightMouse>-key "------------------------------------------------------------------------------- -" use font with clearly distinguishable brackets : ()[]{} + +nnoremap <RightMouse> <Insert> +inoremap <RightMouse> <ESC> + +"------------------------------------------------------------------------------- +" use font with clearly distinguishable brackets: ()[]{} "------------------------------------------------------------------------------- "set guifont=Luxi\ Mono\ 14 -" diff --git a/vim-support/rc/customization.vimrc b/vim-support/rc/customization.vimrc index 69afe8c..c241d18 100644 --- a/vim-support/rc/customization.vimrc +++ b/vim-support/rc/customization.vimrc @@ -1,52 +1,59 @@ -"=================================================================================== -" FILE: .vimrc -" DESCRIPTION: suggestion for a personal configuration file ~/.vimrc -" AUTHOR: Dr.-Ing. Fritz Mehner -" CREATED: 04.04.2009 -" REVISION: $Id: customization.vimrc,v 1.1 2012/02/11 16:37:29 mehner Exp $ -"=================================================================================== +"=============================================================================== " -"=================================================================================== +" File: customization.vimrc +" +" Description: suggestion for a personal configuration file ~/.vimrc +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Dr. Fritz Mehner (fgm), mehner.fritz@web.de +" Revision: 15.04.2019 +" License: Copyright (c) 2009-2018, Dr. Fritz Mehner +" Copyright (c) 2019, Wolfgang Mehner +"=============================================================================== + +"=============================================================================== " GENERAL SETTINGS -"=================================================================================== +"=============================================================================== "------------------------------------------------------------------------------- " Use Vim settings, rather then Vi settings. " This must be first, because it changes other options as a side effect. "------------------------------------------------------------------------------- set nocompatible -" + "------------------------------------------------------------------------------- " Enable file type detection. Use the default filetype settings. " Also load indent files, to automatically do language-dependent indenting. "------------------------------------------------------------------------------- filetype plugin on filetype indent on -" + "------------------------------------------------------------------------------- " Switch syntax highlighting on. "------------------------------------------------------------------------------- -syntax on -" +syntax on + +"------------------------------------------------------------------------------- " Platform specific items: " - central backup directory (has to be created) " - default dictionary -" Uncomment your choice. -if has("win16") || has("win32") || has("win64") || +" Uncomment your choice. +" +" Using a backupdir under UNIX/Linux: you may want to include a line similar to: +" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; +" in one of your shell startup files (e.g. $HOME/.profile). +"------------------------------------------------------------------------------- +if has("win16") || has("win32") || has("win64") || \ has("win95") || has("win32unix") - " -" runtime mswin.vim -" set backupdir =$VIM\vimfiles\backupdir -" set dictionary=$VIM\vimfiles\wordlists/german.list +" runtime mswin.vim +" set backupdir =$VIM\vimfiles\backupdir +" set dictionary=$VIM\vimfiles\wordlists/german.list else -" set backupdir =$HOME/.vim.backupdir -" set dictionary=$HOME/.vim/wordlists/german.list +" set backupdir =$HOME/.vim.backupdir +" set dictionary=$HOME/.vim/wordlists/german.list,$HOME/.vim/wordlists/english.list endif -" -" Using a backupdir under UNIX/Linux: you may want to include a line similar to -" find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; -" in one of your shell startup files (e.g. $HOME/.profile) -" + "------------------------------------------------------------------------------- " Various settings "------------------------------------------------------------------------------- @@ -57,12 +64,12 @@ set backspace=indent,eol,start " backspacing over everything in insert mode set backup " keep a backup file set browsedir=current " which directory to use for the file browser set complete+=k " scan the files given with the 'dictionary' option +set formatoptions+=j " remove comment leader when joining lines set history=50 " keep 50 lines of command line history set hlsearch " highlight the last used search pattern set incsearch " do incremental searching set listchars=tab:>.,eol:\$ " strings to use in 'list' mode set mouse=a " enable the use of the mouse -set nowrap " do not wrap lines set popt=left:8pc,right:3pc " print options set ruler " show the cursor position all the time set shiftwidth=2 " number of spaces to use for each step of indent @@ -72,151 +79,144 @@ set tabstop=2 " number of spaces that a <Tab> counts for set visualbell " visual bell instead of beeping set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions set wildmenu " command-line completion in an enhanced mode -" -"=================================================================================== +set nowrap " do not wrap lines + +"------------------------------------------------------------------------------- +" Highlight paired brackets +"------------------------------------------------------------------------------- +"highlight MatchParen ctermbg=blue guibg=lightyellow + +"=============================================================================== " BUFFERS, WINDOWS -"=================================================================================== -" +"=============================================================================== + "------------------------------------------------------------------------------- -" The current directory is the directory of the file in the current window. +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). "------------------------------------------------------------------------------- if has("autocmd") - autocmd BufEnter * :lchdir %:p:h + augroup MyResetCursor + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + augroup END endif -" + "------------------------------------------------------------------------------- -" close window (conflicts with the KDE setting for calling the process manager) +" Change the working directory to the directory containing the current file "------------------------------------------------------------------------------- - noremap <C-Esc> :close<CR> -inoremap <C-Esc> <C-C>:close<CR> -" +if has("autocmd") + augroup MySetLocalDir + autocmd BufEnter * :lchdir %:p:h + augroup END +endif + "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- - noremap <silent> <s-tab> :if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -inoremap <silent> <s-tab> <C-C>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" +"nnoremap <silent> <s-tab> :if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> +"inoremap <silent> <s-tab> <C-C>:if !&readonly && &modifiable && &modified <CR> +" \ :write<CR> :endif<CR> :bprevious<CR> + "------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q (KDE): Write all changed buffers and exit Vim +" Leave the editor with Ctrl-q: Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nnoremap <C-q> :wqall<CR> -" -"------------------------------------------------------------------------------- -" When editing a file, always jump to the last known cursor position. -" Don't do it when the position is invalid or when inside an event handler -" (happens when dropping a file on gvim). + "------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif -endif " has("autocmd") +" Some additional hot keys " -"------------------------------------------------------------------------------- -" some additional hot keys -"------------------------------------------------------------------------------- " F2 - write file without confirmation " F3 - call file explorer Ex -" F4 - show tag under curser in the preview window (tagfile must exist!) +" F4 - show tag under cursor in the preview window (tagfile must exist!) " F5 - open quickfix error window " F6 - close quickfix error window " F7 - display previous error -" F8 - display next error -"------------------------------------------------------------------------------- -" -map <silent> <F2> :write<CR> -map <silent> <F3> :Explore<CR> -nmap <silent> <F4> :exe ":ptag ".expand("<cword>")<CR> -map <silent> <F5> :copen<CR> -map <silent> <F6> :cclose<CR> -map <silent> <F7> :cp<CR> -map <silent> <F8> :cn<CR> -" -imap <silent> <F2> <Esc>:write<CR> -imap <silent> <F3> <Esc>:Explore<CR> -imap <silent> <F4> <Esc>:exe ":ptag ".expand("<cword>")<CR> -imap <silent> <F5> <Esc>:copen<CR> -imap <silent> <F6> <Esc>:cclose<CR> -imap <silent> <F7> <Esc>:cp<CR> -imap <silent> <F8> <Esc>:cn<CR> -" -"------------------------------------------------------------------------------- -" Fast switching between buffers -" The current buffer will be saved before switching to the next one. -" Choose :bprevious or :bnext -"------------------------------------------------------------------------------- -" - map <silent> <s-tab> <Esc>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -imap <silent> <s-tab> <Esc>:if &modifiable && !&readonly && - \ &modified <CR> :write<CR> :endif<CR>:bprevious<CR> -" -"------------------------------------------------------------------------------- -" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim -"------------------------------------------------------------------------------- -nmap <C-q> :wqa<CR> -" -"------------------------------------------------------------------------------- -" comma always followed by a space +" F8 - display next error +" F12 - list buffers and prompt for a buffer name "------------------------------------------------------------------------------- -inoremap , ,<Space> -" + +noremap <silent> <F2> :write<CR> +noremap <silent> <F3> :Explore<CR> +nnoremap <silent> <F4> :execute ":ptag ".expand("<cword>")<CR> +noremap <silent> <F5> :copen<CR> +noremap <silent> <F6> :cclose<CR> +noremap <silent> <F7> :cprevious<CR> +noremap <silent> <F8> :cnext<CR> +noremap <F12> :buffer <C-D> +noremap <S-F12> :sbuffer <C-D> + +inoremap <silent> <F2> <Esc>:write<CR> +inoremap <silent> <F3> <Esc>:Explore<CR> +inoremap <silent> <F4> <Esc>:execute ":ptag ".expand("<cword>")<CR> +inoremap <silent> <F5> <Esc>:copen<CR> +inoremap <silent> <F6> <Esc>:cclose<CR> +inoremap <silent> <F7> <Esc>:cprevious<CR> +inoremap <silent> <F8> <Esc>:cnext<CR> +inoremap <F12> <C-C>:buffer <C-D> +inoremap <S-F12> <C-C>:sbuffer <C-D> + "------------------------------------------------------------------------------- -" autocomplete parenthesis, brackets and braces +" Always wrap lines in the quickfix buffer "------------------------------------------------------------------------------- -inoremap ( ()<Left> -inoremap [ []<Left> -inoremap { {}<Left> -" -vnoremap ( s()<Esc>P<Right>% -vnoremap [ s[]<Esc>P<Right>% -vnoremap { s{}<Esc>P<Right>% -" +"autocmd BufReadPost quickfix setlocal wrap | setlocal linebreak + +"=============================================================================== +" AUTOCOMPLETE BRACKETS, QUOTES +"=============================================================================== + "------------------------------------------------------------------------------- -" autocomplete quotes (visual and select mode) +" Autocomplete parenthesis, brackets and braces "------------------------------------------------------------------------------- -xnoremap ' s''<Esc>P<Right> -xnoremap " s""<Esc>P<Right> -xnoremap ` s``<Esc>P<Right> -" + +inoremap ( ()<Left> +inoremap [ []<Left> +inoremap { {}<Left> + +" surround content +vnoremap ( s()<Esc>P<Right>% +vnoremap [ s[]<Esc>P<Right>% +vnoremap { s{}<Esc>P<Right>% + +" surround content with additional spaces +vnoremap ) s(<Space><Space>)<Esc><Left>P<Right><Right>% +vnoremap ] s[<Space><Space>]<Esc><Left>P<Right><Right>% +vnoremap } s{<Space><Space>}<Esc><Left>P<Right><Right>% + "------------------------------------------------------------------------------- -" Change the working directory to the directory containing the current file +" Autocomplete quotes "------------------------------------------------------------------------------- -if has("autocmd") - autocmd BufEnter * :lchdir %:p:h -endif " has("autocmd") -" -"=================================================================================== + +" surround content (visual and select mode) +vnoremap ' s''<Esc>P<Right> +vnoremap " s""<Esc>P<Right> +vnoremap ` s``<Esc>P<Right> + +"=============================================================================== " VARIOUS PLUGIN CONFIGURATIONS -"=================================================================================== -" +"=============================================================================== + "------------------------------------------------------------------------------- -" c.vim +" Vim-Support +" +" the settings are documented here: +" :help vimsupport-configuration "------------------------------------------------------------------------------- -" -" --empty -- -" + +"let g:Vim_LoadMenus = 'auto' +"let g:Vim_RootMenu = '&Vim' +"let g:Vim_MapLeader = '\' + "------------------------------------------------------------------------------- " taglist.vim : toggle the taglist window -" taglist.vim : define the title texts for make -" taglist.vim : define the title texts for qmake "------------------------------------------------------------------------------- - noremap <silent> <F11> <Esc><Esc>:Tlist<CR> -inoremap <silent> <F11> <Esc><Esc>:Tlist<CR> + noremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> +inoremap <silent> <F11> <Esc><Esc>:TlistToggle<CR> let Tlist_GainFocus_On_ToggleOpen = 1 -let Tlist_Close_On_Select = 1 - -let tlist_make_settings = 'make;m:makros;t:targets' -let tlist_qmake_settings = 'qmake;t:SystemVariables' - -if has("autocmd") - " ---------- qmake : set filetype for *.pro ---------- - autocmd BufNewFile,BufRead *.pro set filetype=qmake -endif " has("autocmd") - +let Tlist_Close_On_Select = 1 diff --git a/vim-support/rc/vim.vim b/vim-support/rc/vim.vim new file mode 100644 index 0000000..fb391f4 --- /dev/null +++ b/vim-support/rc/vim.vim @@ -0,0 +1,39 @@ +" ------------------------------------------------------------------------------ +" +" Vim filetype plugin file +" +" Language : VimL / VimScript +" Plugin : vim-support.vim +" Revision : 12.10.2017 +" Maintainer : Wolfgang Mehner <wolfgang-mehner@web.de> +" +" ------------------------------------------------------------------------------ + +" Only do this when not done yet for this buffer +if exists("b:did_vim_support_ftplugin") + finish +endif +let b:did_vim_support_ftplugin = 1 + +" ---------- Set "maplocalleader" as configured using "g:Vim_MapLeader" ----- +call Vim_SetMapLeader () + +" maps defined here will use "g:Vim_MapLeader" as <LocalLeader> +" example: +"map <buffer> <LocalLeader>eg :echo "Example Map :)"<CR> + +" ---------- Keyword help ---------------------------------------------------- + +if has( 'gui_running' ) + nmap <buffer> <S-F1> <Plug>VimSupportKeywordHelp + imap <buffer> <S-F1> <Plug>VimSupportKeywordHelp +else + " <SHIFT-F1> is problematic in the terminal + nmap <buffer> <F1> <Plug>VimSupportKeywordHelp + imap <buffer> <F1> <Plug>VimSupportKeywordHelp +endif +" these maps have to remap, do not use nnoremap + +" ---------- Reset "maplocalleader" ------------------------------------------ +call Vim_ResetMapLeader () + diff --git a/vim-support/templates/regex.templates b/vim-support/templates/regex.templates index 0571106..fe02034 100644 --- a/vim-support/templates/regex.templates +++ b/vim-support/templates/regex.templates @@ -44,7 +44,7 @@ == ENDTEMPLATE == == Regex.word == insert, map:xw, sc:w == -\<<CURSOR>\> +\<<SPLIT><CURSOR>\> == ENDTEMPLATE == == Regex.character classes == expandmenu, expandright:value, insert, map:xcc, sc:l ==