diff --git a/README.md b/README.md index eeec1d6..d94c480 100644 --- a/README.md +++ b/README.md @@ -7,27 +7,9 @@ The development happens here: [WolfgangMehner/vim-plugins](https://github.com/WolfgangMehner/vim-plugins) -Preview Version -================================================================================ - -___This is a preview version!___ - -This version is a preview, containing a reworked template engine. -Please report any problems. - -The new features of Perl-Support and the template engine are: - -- No need to edit stock templates anymore, by doing the personalization/ - customization in separate files -- Setup wizard for customization and personalization file -- More to come ... - -_Please read the release notes below._ - - -------------------------------------------------------------------------------- -README for perl-support.vim (Version 5.4pre) / January 05 2016 +README for perl-support.vim (Version 5.4) / March 13 2016 ================================================================================ * INSTALLATION @@ -45,7 +27,7 @@ profiler can be done with a keystroke. There are many additional hints and options which can improve speed and comfort when writing Perl. Please read the documentation. -This plugin can be used with Vim version 7.x. +This plug-in can be used with Vim version 7.x. -------------------------------------------------------------------------------- @@ -56,7 +38,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/perlsupport.txt` or look up the documentation via: :help perlsupport-system-wide @@ -64,14 +46,14 @@ well as an explanation of the other consequences, please see the help file (1) LINUX ---------------------------------------------------------------------- -The subdirectories in the zip archive perl-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 `perl-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/perl-support/templates/Templates' if +(1.0) Save the template files in `$HOME/.vim/perl-support/templates/Templates` if you have changed any of them. -(1.1) Copy the zip archive perl-support.zip to $HOME/.vim and run +(1.1) Copy the zip archive `perl-support.zip` to `$HOME/.vim` and run unzip perl-support.zip @@ -81,19 +63,19 @@ structure which is needed below the local installation directory $HOME/.vim/ $HOME/.vim/doc/... $HOME/.vim/plugin/perl-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/perl-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/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) Set at least some personal details. Use the map `\ntw` inside a Perl buffer or the menu entry: Perl -> 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): @@ -102,33 +84,33 @@ 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/perl.templates to customize or add to your - Perl template library. It can also be set up via the wizard. + Use the file `$HOME/.vim/templates/perl.templates` to customize or add to + your Perl 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 +(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. +(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 perl-support.zip mirror the directory +The subdirectories in the zip archive `perl-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/perl-support/templates/Templates' +(2.0) Save the template files in `$HOME/vimfiles/perl-support/templates/Templates` if you have changed any of them. -(2.1) Copy the zip archive perl-support.zip to $HOME/vimfiles and run +(2.1) Copy the zip archive `perl-support.zip` to `$HOME/vimfiles` and run unzip perl-support.zip @@ -138,19 +120,19 @@ $HOME/vimfiles/ (find the value of $HOME with ":echo $HOME" from inside Vim). $HOME/vimfiles/doc/... $HOME/vimfiles/plugin/perl-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/perl-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/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) Set at least some personal details. Use the map `\ntw` inside a Perl buffer or the menu entry: Perl -> 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): @@ -159,20 +141,24 @@ $HOME/vimfiles/ (find the value of $HOME with ":echo $HOME" from inside Vim). SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/vimfiles/templates/perl.templates to customize or add to + Use the file `$HOME/vimfiles/templates/perl.templates` to customize or add to your Perl 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 +(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. +(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. + Compare `:help perlsupport-troubleshooting`. (3) ADDITIONAL REMARKS @@ -186,9 +172,9 @@ There are a lot of features and options which can be used and influenced: * the Perl module list * reading Perl documentation with integrated calls to perldoc * removing the root menu - * using additional plugins + * using additional plug-ins -Look at the perlsupport help with: +Look at the Perl Support help with: :help perlsupport @@ -200,7 +186,7 @@ Look at the perlsupport help with: +-----------------------------------------------+ Any problems? See the TROUBLESHOOTING section at the end of the help file -'doc/perlsupport.txt'. +`doc/perlsupport.txt`. -------------------------------------------------------------------------------- @@ -208,19 +194,22 @@ Any problems? See the TROUBLESHOOTING section at the end of the help file RELEASE NOTES ================================================================================ -RELEASE NOTES FOR VERSION 5.4pre +RELEASE NOTES FOR VERSION 5.4 ---------------------------------------------------------------------- - Add 'g:Perl_CustomTemplateFile'. - Add template personalization file and setup wizard. +- Rename setting 'g:Perl_Perl' into 'g:Perl_Executable'. + ('g:Perl_Perl' still works for backwards compatibility.) +- Respect 'g:Xterm_Executable' and 'g:Xterm_Options'. + ('g:Perl_XtermDefaults' still works for backwards compatibility.) - Remove unused 'g:Perl_GuiTemplateBrowser' and 'g:Perl_MenuHeader'. - New and reworked templates. - Change map "\vs" -> "\vps", in favor of a more consistent naming scheme. - Minor changes. - RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- --> see file 'perl-support/doc/ChangeLog' +-> see file `perl-support/doc/ChangeLog` -------------------------------------------------------------------------------- @@ -327,25 +316,25 @@ ___The settings are explained in the files themselves.___ ADDITIONAL TIPS ================================================================================ -(1) You may want to use a central hidden directory for all your backup files (see also - rc/customization.vimrc ): +(1) You may want to use a central hidden directory for all your backup files + (see also `rc/customization.vimrc`): - 1.1 Add the following line to .vimrc (see also rc/customization.vimrc ): + 1.1 Add the following line to `.vimrc` (see also rc/customization.vimrc ): set backupdir =$HOME/.vim.backupdir - 1.2 Create $HOME/.vim.backupdir . + 1.2 Create `$HOME/.vim.backupdir`. - 1.3 Add the following line to your shell initialization file ~/.profile : + 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 shure to backup in shorter terms ! + Be shure to backup in shorter terms! (2) gVim. Toggle 'insert mode' <--> 'normal mode' with the right mouse button - (see mapping in file customization.gvimrc). + (see mapping in file `customization.gvimrc`). (3) gVim. Use tear off menus. diff --git a/autoload/mmtemplates/config.vim b/autoload/mmtemplates/config.vim index 82ab47b..07df6ff 100644 --- a/autoload/mmtemplates/config.vim +++ b/autoload/mmtemplates/config.vim @@ -42,7 +42,7 @@ if &cp || ( exists('g:TemplatesConfig_Version') && g:TemplatesConfig_Version != finish endif -let s:TemplatesConfig_Version = '1.0beta' " version number of this script; do not change +let s:TemplatesConfig_Version = '1.0' " version number of this script; do not change "------------------------------------------------------------------------------- " --- Find Newest Version --- {{{2 diff --git a/autoload/mmtemplates/core.vim b/autoload/mmtemplates/core.vim index a22a67c..23f4ca5 100644 --- a/autoload/mmtemplates/core.vim +++ b/autoload/mmtemplates/core.vim @@ -42,7 +42,7 @@ if &cp || ( exists('g:Templates_Version') && g:Templates_Version != 'searching' finish endif " -let s:Templates_Version = '1.0beta' " version number of this script; do not change +let s:Templates_Version = '1.0' " version number of this script; do not change " "---------------------------------------------------------------------- " --- Find Newest Version --- {{{2 @@ -1385,6 +1385,7 @@ let s:FileReadNameSpace_0_9 = { \ 'SetMap' : 'ss', \ 'SetShortcut' : 'ss', \ 'SetMenuEntry' : 'ss', + \ 'SetExpansion' : 'sss\?', \ \ 'MenuShortcut' : 'ss', \ } @@ -1605,6 +1606,34 @@ function! s:SetMenuEntry ( name, menu_entry ) " endfunction " ---------- end of function s:SetMenuEntry ---------- " +"---------------------------------------------------------------------- +" s:SetExpansion : Set the expansion of a list menu (template function). {{{2 +"------------------------------------------------------------------------------- + +function! s:SetExpansion ( name, expand_left, ... ) + + let expand_left = a:expand_left + if a:0 >= 1 | let expand_right = a:1 + else | let expand_right = '' + endif + + " check for valid name and format + if ! has_key ( s:library.templates, a:name.'!!type' ) + return s:ErrorMsg ( 'The template does not exist: '.a:name ) + endif + + let templ_menu = s:library.templates[ a:name.'!!menu' ] + + if templ_menu.entry != 2 + let templ_menu.entry = 2 + let templ_menu.expand_list = '' + endif + + let templ_menu.expand_left = expand_left + let templ_menu.expand_right = expand_right + +endfunction " ---------- end of function s:SetExpansion ---------- + "---------------------------------------------------------------------- " s:IncludeFile : Read a template file (template function). {{{2 "---------------------------------------------------------------------- @@ -1912,7 +1941,9 @@ function! s:IncludeFile ( templatefile, ... ) call remove ( s:t_runtime.state_stack, -1 ) " endfunction " ---------- end of function s:IncludeFile ---------- -" +" }}}2 +"---------------------------------------------------------------------- + "---------------------------------------------------------------------- " mmtemplates#core#ReadTemplates : Read a template file. {{{1 "---------------------------------------------------------------------- @@ -4991,8 +5022,8 @@ function! mmtemplates#core#EditTemplateFiles ( library, file ) " ================================================== " if ! available - " :TODO:18.12.2014 20:01:WM: start setup wizard - return + return s:ErrorMsg ( 'This template file is not avaiable. Use the wizard to set it up', + \ 'or follow the instructions of your plug-in for setting up this file.' ) endif " " ================================================== diff --git a/doc/perlsupport.txt b/doc/perlsupport.txt index fb29131..5b445eb 100644 --- a/doc/perlsupport.txt +++ b/doc/perlsupport.txt @@ -1,8 +1,8 @@ -*perlsupport.txt* Perl Support Jan 08 2016 +*perlsupport.txt* Perl Support Jul 22 2016 Perl Support *perl-support* *perlsupport* - Plug-in version 5.4pre + Plug-in version 5.4 for Vim version 7.0 and above Wolfgang Mehner Fritz Mehner @@ -1337,7 +1337,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:Perl_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 @@ -1766,13 +1766,14 @@ g:Perl_InsertFileHeader 'yes' g:Perl_CreateMenusDelayed 'yes' g:Perl_PerlTags 'off' g:Perl_PerltidyBackup 'off' -g:Perl_Perl "/usr/bin/perl" or "C:/Perl/bin/perl.exe" +g:Perl_Executable "/usr/bin/perl" or "C:/Perl/bin/perl.exe" g:Perl_DirectRun 'no' g:Perl_PerlModuleList root_dir.'perl-support/modules/perl-modules.list' g:Perl_PerlModuleListGenerator root_dir.'perl-support/scripts/pmdesc3.pl' g:Perl_OutputGvim "vim" -g:Perl_XtermDefaults "-fa courier -fs 12 -geometry 80x24" +g:Xterm_Executable "xterm" +g:Xterm_Options "-fa courier -fs 12 -geometry 80x24" g:Perl_Debugger "perl" g:Perl_TimestampFormat '%Y%m%d.%H%M%S' g:Perl_LineEndCommColDefault 49 @@ -1813,7 +1814,9 @@ The variable root_dir will automatically be set to one of the following values: g:Perl_PerlTags : switch use of Perl::Tags on/off ( 'on', 'off' ) g:Perl_Perltidy : use perltidy as standard beautifier g:Perl_PerltidyBackup : write a backup file before running perltidy - g:Perl_Perl : the Perl executable + g:Perl_Executable : the Perl executable + g:Perl_Perl : the Perl executable (included for backwards + compatibility only) g:Perl_DirectRun : run script via shebang 3. group: g:Perl_PerlModuleList : The name of the Perl module list (text file, @@ -1823,7 +1826,10 @@ The variable root_dir will automatically be set to one of the following values: g:Perl_OutputGvim : when script is running output goes to the vim command line ("vim"), to a buffer ("buffer") or to an xterm ("xterm"). - g:Perl_XtermDefaults : the xterm defaults + g:Xterm_Executable : the xterm executable + 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_TimestampFormat : trailing time stamp for a file g:Perl_LineEndCommColDefault : default starting column for line end comments @@ -2052,7 +2058,7 @@ The use of Perl 6 (or another interpreter) can be enabled in two way. The interpreter which runs ascript from inside Vim can be set globally in ~/.vimrc by > - let g:Perl_Perl = '/usr/bin/perl6' + let g:Perl_Executable = '/usr/bin/perl6' < Drawback for the moment: syntax checking does not work. @@ -2097,6 +2103,13 @@ 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: Perl -> Snippets -> template setup wizard +Further template files can be added using the call: > + call mmtemplates#config#Add ( 'perl', '/some.templates', 'example', 'nte' ) +The first parameter adds the file to your Perl 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 *perlsupport-templates-files* ------------------------------------------------------------------------------ @@ -2525,6 +2538,10 @@ for the system - Script set executable (file access permission under LINUX/UNIX) ? - Script syntax correct ? - Necessary modules installed ? + - Under Windows, make sure the options 'shell', 'shellcmdflag', + 'shellquote', and 'shellxquote' are set correctly. If "cmd.exe" is used as + the 'shell', 'shellxquote' must be set to a double quote: + :set shellxquote=\" * Some hotkeys (e.g. x-F9) do not work. - The hotkeys might be in use by your graphical desktop environment. diff --git a/doc/templatesupport.txt b/doc/templatesupport.txt index 2751b8f..b6197d0 100644 --- a/doc/templatesupport.txt +++ b/doc/templatesupport.txt @@ -1,8 +1,8 @@ -*templatesupport.txt* MM Template Support Mar 06 2016 +*templatesupport.txt* MM Template Support Mar 26 2016 MM Template Support *template-support* - Plug-in version 1.0beta + Plug-in version 1.0 for Vim version 7.0 and above Wolfgang Mehner @@ -2496,6 +2496,67 @@ Example: > MenuShortcut ( "Comments.Frames.", "r" ) Sets the shortcut for the submenu "Frames", not "Comments". +------------------------------------------------------------------------------ + *template-support-SetExpansion()* +Set the menu expansion of the template 'name': + + SetExpansion ( name, expandleft [ , expandright ] ) ~ + +This changes the way menus for lists are expanded, offering more options than +the expansion set via the template options (see |template-support-lists-menu|). +Within 'expandleft' and 'expandright' the following macros are replaced for +every list entry: + + Value usage with lists + ---------------------------------------------------------------------------- + *|KEY|* the list element + *|VALUE|* same as *|KEY|* + ---------------------------------------------------------------------------- + + Value usage with dictionaries + ---------------------------------------------------------------------------- + *|KEY|* the key + *|VALUE|* the value + ---------------------------------------------------------------------------- + +The name of the template appears in the template definition between the first +pair of == , the menu is part of the name, also whitespaces contained within +the name. + +Example: > + +Consider this template definition: +> + == LIST: list_headers == list == + "stdlib", + "stdio", + "string", + == ENDLIST == + + == Include.standard include == expandmenu, below, sc:g == + |PickList( "header file: ", "list_headers" )| + #include <|PICK|.h> + == ENDTEMPLATE == +< +For the template a submenu is created with entries: + stdlib + stdio + string + +A different list expansion is set using: > + SetExpansion ( "Include.global include", "|VALUE|.h" ) +< +Now the following list is created, *|VALUE|* is replaced for every list entry: + stdlib.h + stdstdio.h + stdstring.h + +The name is found in the head of the template: +> + == Include.standard include == below, sc:g == + ^ ^ + |------ the name ------| +< ------------------------------------------------------------------------------ *template-support-SetFormat()* Set the format of 'item' to 'format': @@ -2561,6 +2622,28 @@ Consider this template definition: Then you can set a different map using: > SetMap ( "Include.global include", "igl" ) < +------------------------------------------------------------------------------ + *template-support-SetMenuEntry()* +Set the menu entry of the template 'name' to 'entry': + + SetMenuEntry ( name, entry ) ~ + +This changes the menu entry of the template to 'entry'. By default the name +itself is used as the menu entry. The name of the template appears in the +template definition between the first pair of == , the menu is part of the +name, also whitespaces contained within the name. + +Example: > + +Consider this template definition: +> + == Include.global include == below, sc:g == + ^ ^ + |----- the name -----| +< +Then you can set a different menu entry using: > + SetMenuEntry ( "Include.global include", "#include <>" ) +< ------------------------------------------------------------------------------ *template-support-SetPath()* Set the resource 'name' to the given path. @@ -2872,7 +2955,7 @@ D. CHANGE LOG *template-support-change-log* ============================================================================== ------------------------------------------------------------------------------ - RELEASE NOTES FOR VERSION 1.0beta + RELEASE NOTES FOR VERSION 1.0 ------------------------------------------------------------------------------ ** Added a system for introducing changes to the template library. ** @@ -2894,7 +2977,7 @@ D. CHANGE LOG *template-support-change-log* templates or jumping via . - Add: Template options "expandleft" and "expandright". Extended the option "expandmenu". -- Add: Functions 'SetMap', 'SetShortcut', and 'SetMenuEntry'. +- Add: Functions 'SetMap', 'SetShortcut', 'SetMenuEntry', and 'SetExpansion'. - Change: If a template is redefined, the options are read again. - Change: During the creation of the submenu for a list-picking template, all special characters are escaped correctly. (The characters "\" and "|" were diff --git a/perl-support/README.md b/perl-support/README.md index 51f12ab..6238a42 100644 --- a/perl-support/README.md +++ b/perl-support/README.md @@ -1,4 +1,4 @@ -README for perl-support.vim (Version 5.4pre) / January 05 2016 +README for perl-support.vim (Version 5.4) / March 13 2016 ================================================================================ * INSTALLATION @@ -16,7 +16,7 @@ profiler can be done with a keystroke. There are many additional hints and options which can improve speed and comfort when writing Perl. Please read the documentation. -This plugin can be used with Vim version 7.x. +This plug-in can be used with Vim version 7.x. -------------------------------------------------------------------------------- @@ -27,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/csupport.txt' or look up the documentation via: +`doc/perlsupport.txt` or look up the documentation via: :help perlsupport-system-wide @@ -35,14 +35,14 @@ well as an explanation of the other consequences, please see the help file (1) LINUX ---------------------------------------------------------------------- -The subdirectories in the zip archive perl-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 `perl-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/perl-support/templates/Templates' if +(1.0) Save the template files in `$HOME/.vim/perl-support/templates/Templates` if you have changed any of them. -(1.1) Copy the zip archive perl-support.zip to $HOME/.vim and run +(1.1) Copy the zip archive `perl-support.zip` to `$HOME/.vim` and run unzip perl-support.zip @@ -52,19 +52,19 @@ structure which is needed below the local installation directory $HOME/.vim/ $HOME/.vim/doc/... $HOME/.vim/plugin/perl-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/perl-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/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) Set at least some personal details. Use the map `\ntw` inside a Perl buffer or the menu entry: Perl -> 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): @@ -73,33 +73,33 @@ 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/perl.templates to customize or add to your - Perl template library. It can also be set up via the wizard. + Use the file `$HOME/.vim/templates/perl.templates` to customize or add to + your Perl 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 +(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. +(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 perl-support.zip mirror the directory +The subdirectories in the zip archive `perl-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/perl-support/templates/Templates' +(2.0) Save the template files in `$HOME/vimfiles/perl-support/templates/Templates` if you have changed any of them. -(2.1) Copy the zip archive perl-support.zip to $HOME/vimfiles and run +(2.1) Copy the zip archive `perl-support.zip` to `$HOME/vimfiles` and run unzip perl-support.zip @@ -109,19 +109,19 @@ $HOME/vimfiles/ (find the value of $HOME with ":echo $HOME" from inside Vim). $HOME/vimfiles/doc/... $HOME/vimfiles/plugin/perl-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/perl-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/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) Set at least some personal details. Use the map `\ntw` inside a Perl buffer or the menu entry: Perl -> 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): @@ -130,20 +130,24 @@ $HOME/vimfiles/ (find the value of $HOME with ":echo $HOME" from inside Vim). SetMacro( 'EMAIL', 'wolfgang-mehner@web.de' ) SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) - Use the file $HOME/vimfiles/templates/perl.templates to customize or add to + Use the file `$HOME/vimfiles/templates/perl.templates` to customize or add to your Perl 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 +(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. +(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. + Compare `:help perlsupport-troubleshooting`. (3) ADDITIONAL REMARKS @@ -157,9 +161,9 @@ There are a lot of features and options which can be used and influenced: * the Perl module list * reading Perl documentation with integrated calls to perldoc * removing the root menu - * using additional plugins + * using additional plug-ins -Look at the perlsupport help with: +Look at the Perl Support help with: :help perlsupport @@ -171,7 +175,7 @@ Look at the perlsupport help with: +-----------------------------------------------+ Any problems? See the TROUBLESHOOTING section at the end of the help file -'doc/perlsupport.txt'. +`doc/perlsupport.txt`. -------------------------------------------------------------------------------- @@ -179,19 +183,22 @@ Any problems? See the TROUBLESHOOTING section at the end of the help file RELEASE NOTES ================================================================================ -RELEASE NOTES FOR VERSION 5.4pre +RELEASE NOTES FOR VERSION 5.4 ---------------------------------------------------------------------- - Add 'g:Perl_CustomTemplateFile'. - Add template personalization file and setup wizard. +- Rename setting 'g:Perl_Perl' into 'g:Perl_Executable'. + ('g:Perl_Perl' still works for backwards compatibility.) +- Respect 'g:Xterm_Executable' and 'g:Xterm_Options'. + ('g:Perl_XtermDefaults' still works for backwards compatibility.) - Remove unused 'g:Perl_GuiTemplateBrowser' and 'g:Perl_MenuHeader'. - New and reworked templates. - Change map "\vs" -> "\vps", in favor of a more consistent naming scheme. - Minor changes. - RELEASE NOTES FOR OLDER VERSIONS ---------------------------------------------------------------------- --> see file 'perl-support/doc/ChangeLog' +-> see file `perl-support/doc/ChangeLog` -------------------------------------------------------------------------------- @@ -298,25 +305,25 @@ ___The settings are explained in the files themselves.___ ADDITIONAL TIPS ================================================================================ -(1) You may want to use a central hidden directory for all your backup files (see also - rc/customization.vimrc ): +(1) You may want to use a central hidden directory for all your backup files + (see also `rc/customization.vimrc`): - 1.1 Add the following line to .vimrc (see also rc/customization.vimrc ): + 1.1 Add the following line to `.vimrc` (see also rc/customization.vimrc ): set backupdir =$HOME/.vim.backupdir - 1.2 Create $HOME/.vim.backupdir . + 1.2 Create `$HOME/.vim.backupdir`. - 1.3 Add the following line to your shell initialization file ~/.profile : + 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 shure to backup in shorter terms ! + Be shure to backup in shorter terms! (2) gVim. Toggle 'insert mode' <--> 'normal mode' with the right mouse button - (see mapping in file customization.gvimrc). + (see mapping in file `customization.gvimrc`). (3) gVim. Use tear off menus. diff --git a/perl-support/release.lua b/perl-support/release.lua deleted file mode 100644 index 3149d5a..0000000 --- a/perl-support/release.lua +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/env lua --- --------------------------------------------------------------------------------- --- FILE: release.lua --- USAGE: lua perl-support/release.lua [] --- 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, --- COMPANY: --- VERSION: 1.0 --- CREATED: 18.02.2015 --- REVISION: --- --------------------------------------------------------------------------------- --- - -function escape_shell ( text ) - return string.gsub ( text, '[%(%);&=\' ]', function ( m ) return '\\' .. m end ) -end ---------- end of function escape_shell ---------- - -local args = { ... } - -local outfile = 'perl-support.zip' - --- files for the zip-archive -local filelist = { - 'autoload/mmtemplates/', - 'autoload/mmtoolbox/make.vim', - 'autoload/mmtoolbox/tools.vim', - 'autoload/perlsupportprofiling.vim', - 'autoload/perlsupportregex.vim', - 'doc/perlsupport.txt', - 'doc/templatesupport.txt', - 'doc/toolbox.txt', - 'doc/toolboxmake.txt', - 'ftplugin/make.vim', - 'ftplugin/perl.vim', - 'ftplugin/pod.vim', - 'ftplugin/qf.vim', - 'plugin/perl-support.vim', - 'syntax/template.vim', - 'perl-support/codesnippets/', - 'perl-support/doc/ChangeLog', - 'perl-support/doc/perl-hot-keys.pdf', - 'perl-support/doc/perl-hot-keys.tex', - 'perl-support/doc/pmdesc3.text', - 'perl-support/modules/', - 'perl-support/rc/', - 'perl-support/scripts/', - 'perl-support/templates/', - 'perl-support/wordlists/', - 'perl-support/README.md', -} --- :TODO:18.02.2015 10:27:WM: change to README.md - --- additional files for the stand-alone repository -local filelist_repo = { - 'perl-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 perl-support/README.standalone.md perl-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 ===\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 ' ) - print ( '' ) - print ( '\tcheck - check the release' ) - print ( '\tzip - create archive' ) - print ( '\tcp-repo - copy the repository' ) - print ( '\thelp - print help' ) - print ( '' ) - -end diff --git a/perl-support/templates/idioms.templates b/perl-support/templates/idioms.templates index e6645ea..865239e 100644 --- a/perl-support/templates/idioms.templates +++ b/perl-support/templates/idioms.templates @@ -15,6 +15,10 @@ my % = ( <+key1+> => <+val1+>, <+key2+> => <+val2+>, ); +== ENDTEMPLATE == + +== SEP: Idioms.sep_data == + == Idioms.regex == map:ir, sc:r, insert == my $rgx_ = qr/<+regexp+>/; == Idioms.match == map:im, sc:m, insert == @@ -23,11 +27,19 @@ $ =~ m/<+regexp+>/xm $ =~ s/<+pattern+>/<+replacement+>/xm == Idioms.translate == map:it, sc:t, insert == $ =~ tr/<+searchlist+>/<+replacementlist+>/ +== ENDTEMPLATE == + +== SEP: Idioms.sep_regex == + == Idioms.subroutine == map:isu, sc:s == sub |?FUNCTION_NAME| { my ( $par1 ) = @_; return ; } ## --- end sub |FUNCTION_NAME| +== ENDTEMPLATE == + +== SEP: Idioms.sep_io == + == Idioms.print == map:ip, sc:p, insert == print "\n"; == Idioms.open input file == map:ii, sc:i == diff --git a/plugin/perl-support.vim b/plugin/perl-support.vim index 1db09ed..c1223dc 100644 --- a/plugin/perl-support.vim +++ b/plugin/perl-support.vim @@ -58,16 +58,16 @@ if exists("g:Perl_PluginVersion") || &compatible finish endif -let g:Perl_PluginVersion= "5.4pre" +let g:Perl_PluginVersion= "5.4" " "=== FUNCTION ================================================================ -" NAME: Perl_SetGlobalVariable {{{1 +" NAME: s:ApplyDefaultSetting {{{1 " DESCRIPTION: Define a global variable and assign a default value if nor " already defined " PARAMETERS: name - global variable " default - default value "=============================================================================== -function! s:perl_SetGlobalVariable ( name, default ) +function! s:ApplyDefaultSetting ( name, default ) if !exists('g:'.a:name) exe 'let g:'.a:name." = '".a:default."'" else @@ -77,19 +77,22 @@ function! s:perl_SetGlobalVariable ( name, default ) exe 'let g:'.a:name." = '".a:default."'" endif endif -endfunction " ---------- end of function s:perl_SetGlobalVariable ---------- +endfunction " ---------- end of function s:ApplyDefaultSetting ---------- " "=== FUNCTION ================================================================ -" NAME: Perl_SetLocalVariable {{{1 +" NAME: s:GetGlobalSetting {{{1 " DESCRIPTION: Assign a value to a local variable if a corresponding global " variable exists -" PARAMETERS: name - name of a global variable +" PARAMETERS: varname - name of a global variable +" glbname - name of the global variable (string, optional) "=============================================================================== -function! s:perl_SetLocalVariable ( name ) - if exists('g:'.a:name) - exe 'let s:'.a:name.' = g:'.a:name - endif -endfunction " ---------- end of function s:perl_SetLocalVariable ---------- +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 ---------- " "------------------------------------------------------------------------------ " @@ -100,7 +103,7 @@ endfunction " ---------- end of function s:perl_SetLocalVariable ---------- let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") " -let s:Perl_Perl = '' " the Perl interpreter used +let s:Perl_Executable = '' " the Perl interpreter used let s:Perl_Perl_is_executable = 0 " the Perl interpreter used let g:Perl_Installation = '*undefined*' let g:Perl_PluginDir = '' @@ -136,8 +139,8 @@ if s:MSWIN \ $HOME.'/vimfiles/autoload/mmtoolbox/' ] end " - let s:Perl_Perl = 'C:/Perl/bin/perl.exe' - let g:Perl_FilenameEscChar = '' + let s:Perl_Executable = 'C:/Perl/bin/perl.exe' + let g:Perl_FilenameEscChar = '' " else " ========== Linux/Unix ====================================================== @@ -161,8 +164,8 @@ else \ $HOME.'/.vim/autoload/mmtoolbox/' ] endif " - let s:Perl_Perl = '/usr/bin/perl' - let g:Perl_FilenameEscChar = ' \%#[]' + let s:Perl_Executable = '/usr/bin/perl' + let g:Perl_FilenameEscChar = ' \%#[]' " " ============================================================================== endif @@ -170,10 +173,10 @@ endif " g:Perl_CodeSnippets is used in autoload/perlsupportgui.vim " let s:Perl_CodeSnippets = g:Perl_PluginDir.'/perl-support/codesnippets/' -call s:perl_SetGlobalVariable( 'Perl_CodeSnippets', s:Perl_CodeSnippets ) +call s:ApplyDefaultSetting( 'Perl_CodeSnippets', s:Perl_CodeSnippets ) " " -call s:perl_SetGlobalVariable( 'Perl_PerlTags', 'off' ) +call s:ApplyDefaultSetting( 'Perl_PerlTags', 'off' ) " if !exists("g:Perl_Dictionary_File") let g:Perl_Dictionary_File = g:Perl_PluginDir.'/perl-support/wordlists/perl.list' @@ -189,7 +192,6 @@ let s:Perl_Ctrl_j = 'on' let s:Perl_TimestampFormat = '%Y%m%d.%H%M%S' let s:Perl_PerlModuleList = g:Perl_PluginDir.'/perl-support/modules/perl-modules.list' -let s:Perl_XtermDefaults = "-fa courier -fs 12 -geometry 80x24" let s:Perl_Debugger = "perl" let s:Perl_ProfilerTimestamp = "no" let s:Perl_LineEndCommColDefault = 49 @@ -202,78 +204,90 @@ let s:Perl_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page 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' let s:Perl_PerltidyBackup = "no" " -call s:perl_SetGlobalVariable ( 'Perl_MapLeader', '' ) +call s:ApplyDefaultSetting ( 'Perl_MapLeader', '' ) let s:Perl_RootMenu = '&Perl' " let s:Perl_AdditionalTemplates = mmtemplates#config#GetFt ( 'perl' ) let s:Perl_UseToolbox = 'yes' -call s:perl_SetGlobalVariable ( 'Perl_UseTool_make', 'yes' ) +call s:ApplyDefaultSetting ( 'Perl_UseTool_make', 'yes' ) " "------------------------------------------------------------------------------ -" -" Look for global variables (if any), to override the defaults. -" -call s:perl_SetLocalVariable('Perl_Perl ') -call s:perl_SetLocalVariable('Perl_DirectRun ') -call s:perl_SetLocalVariable('Perl_InsertFileHeader ') -call s:perl_SetLocalVariable('Perl_CreateMenusDelayed ') -call s:perl_SetLocalVariable('Perl_Ctrl_j ') -call s:perl_SetLocalVariable('Perl_Debugger ') -call s:perl_SetLocalVariable('Perl_GlobalTemplateFile ') -call s:perl_SetLocalVariable('Perl_LocalTemplateFile ') -call s:perl_SetLocalVariable('Perl_CustomTemplateFile ') -call s:perl_SetLocalVariable('Perl_GuiSnippetBrowser ') -call s:perl_SetLocalVariable('Perl_LineEndCommColDefault ') -call s:perl_SetLocalVariable('Perl_LoadMenus ') -call s:perl_SetLocalVariable('Perl_NYTProf_browser ') -call s:perl_SetLocalVariable('Perl_NYTProf_html ') -call s:perl_SetLocalVariable('Perl_PerlcriticOptions ') -call s:perl_SetLocalVariable('Perl_PerlcriticSeverity ') -call s:perl_SetLocalVariable('Perl_PerlcriticVerbosity ') -call s:perl_SetLocalVariable('Perl_PerlModuleList ') -call s:perl_SetLocalVariable('Perl_PerlModuleListGenerator') -call s:perl_SetLocalVariable('Perl_PerltidyBackup ') -call s:perl_SetLocalVariable('Perl_PodcheckerWarnings ') -call s:perl_SetLocalVariable('Perl_Printheader ') -call s:perl_SetLocalVariable('Perl_ProfilerTimestamp ') -call s:perl_SetLocalVariable('Perl_TemplateOverriddenMsg ') -call s:perl_SetLocalVariable('Perl_TimestampFormat ') -call s:perl_SetLocalVariable('Perl_UseToolbox ') -call s:perl_SetLocalVariable('Perl_XtermDefaults ') -" -" Initialize global variables, if they do not already exist. -" -call s:perl_SetGlobalVariable( "Perl_OutputGvim",'vim' ) -call s:perl_SetGlobalVariable( "Perl_PerlRegexSubstitution",'$~' ) -" -let s:Perl_Perl_is_executable = executable(s:Perl_Perl) -" -" set default geometry if not specified -" -if match( s:Perl_XtermDefaults, "-geometry\\s\\+\\d\\+x\\d\\+" ) < 0 - let s:Perl_XtermDefaults = s:Perl_XtermDefaults." -geometry 80x24" + +" look for global variables (if any), to override the defaults + +call s:GetGlobalSetting('Perl_Executable','Perl_Perl') +call s:GetGlobalSetting('Perl_Executable') +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_Debugger') +call s:GetGlobalSetting('Perl_GlobalTemplateFile') +call s:GetGlobalSetting('Perl_LocalTemplateFile') +call s:GetGlobalSetting('Perl_CustomTemplateFile') +call s:GetGlobalSetting('Perl_GuiSnippetBrowser') +call s:GetGlobalSetting('Perl_LineEndCommColDefault') +call s:GetGlobalSetting('Perl_LoadMenus') +call s:GetGlobalSetting('Perl_NYTProf_browser') +call s:GetGlobalSetting('Perl_NYTProf_html') +call s:GetGlobalSetting('Perl_PerlcriticOptions') +call s:GetGlobalSetting('Perl_PerlcriticSeverity') +call s:GetGlobalSetting('Perl_PerlcriticVerbosity') +call s:GetGlobalSetting('Perl_PerlModuleList') +call s:GetGlobalSetting('Perl_PerlModuleListGenerator') +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') + +" initialize global variables, if they do not already exist + +call s:ApplyDefaultSetting( "Perl_OutputGvim",'vim' ) +call s:ApplyDefaultSetting( "Perl_PerlRegexSubstitution",'$~' ) + +" xterm + +let s:Perl_XtermDefaults = "-fa courier -fs 12 -geometry 80x24" + +" check 'g:Perl_XtermDefaults' for backwards compatibility +if ! exists ( 'g:Xterm_Options' ) + call s:GetGlobalSetting ( 'Perl_XtermDefaults' ) + " set default geometry if not specified + if match( s:Perl_XtermDefaults, "-geometry\\s\\+\\d\\+x\\d\\+" ) < 0 + let s:Perl_XtermDefaults = s:Perl_XtermDefaults." -geometry 80x24" + endif endif -" -" Flags for perldoc -" + +call s:GetGlobalSetting ( 'Xterm_Executable' ) +call s:ApplyDefaultSetting ( 'Xterm_Options', s:Perl_XtermDefaults ) + +" flags for perldoc + if has("gui_running") let s:Perl_perldoc_flags = "" else - " Display docs using plain text converter. + " display docs using plain text converter let s:Perl_perldoc_flags = "-otext" endif -" + " escape the printheader -" -let s:Perl_Printheader = escape( s:Perl_Printheader, ' %' ) -let s:Perl_PerlExecutableVersion = '' -" +let s:Perl_Printheader = escape( s:Perl_Printheader, ' %' ) + +" Perl executable and interface version +let s:Perl_Perl_is_executable = executable(s:Perl_Executable) +let s:Perl_InterfaceVersion = '' + "------------------------------------------------------------------------------ " Control variables (not user configurable) "------------------------------------------------------------------------------ @@ -753,7 +767,9 @@ function! Perl_perldoc() setlocal bufhidden=delete setlocal syntax=OFF endif - " + + let error_list = [] + " search order: library module --> builtin function --> FAQ keyword " let delete_perldoc_errors = "" @@ -762,9 +778,9 @@ function! Perl_perldoc() let delete_perldoc_errors = " 2>/dev/null" endif setlocal modifiable - " - " controll repeated search - " + + " control repeated search + if item == s:Perl_PerldocSearchWord " last item : search ring : if s:Perl_PerldocTry == 'module' @@ -788,7 +804,10 @@ function! Perl_perldoc() let command=":%!perldoc ".s:Perl_perldoc_flags." ".item.delete_perldoc_errors silent exe command if v:shell_error != 0 - let s:Perl_PerldocTry = 'function' + let s:Perl_PerldocTry = 'function' + if empty ( error_list) || error_list[-1] != getline ( 1 ) + let error_list += getline ( 1, '$' ) + endif endif if s:MSWIN call s:perl_RemoveSpecialCharacters() @@ -800,7 +819,10 @@ function! Perl_perldoc() " -otext has to be ahead of -f and -q silent exe ":%!perldoc ".s:Perl_perldoc_flags." -f ".item.delete_perldoc_errors if v:shell_error != 0 - let s:Perl_PerldocTry = 'faq' + let s:Perl_PerldocTry = 'faq' + if empty ( error_list) || error_list[-1] != getline ( 1 ) + let error_list += getline ( 1, '$' ) + endif endif endif " @@ -808,19 +830,26 @@ function! Perl_perldoc() if s:Perl_PerldocTry == 'faq' silent exe ":%!perldoc ".s:Perl_perldoc_flags." -q ".item.delete_perldoc_errors if v:shell_error != 0 - let s:Perl_PerldocTry = 'error' + let s:Perl_PerldocTry = 'error' + if empty ( error_list) || error_list[-1] != getline ( 1 ) + let error_list += getline ( 1, '$' ) + endif endif endif " " no documentation found if s:Perl_PerldocTry == 'error' - let zz= "No documentation found for perl module, perl function or perl FAQ keyword\n" - let zz=zz." '".item."' " - silent put! =zz " delete into black hole register "_ - normal! 2j"_dd - let s:Perl_PerldocTry = 'module' - let s:Perl_PerldocSearchWord = "" + normal! gg"_dG + let zz = "No documentation found for perl module, perl function or perl FAQ keyword\n" + \ ." '".item."'\n\n" + \ ."perldoc reports:\n " + \ .join( error_list, "\n " ) + silent put! = zz + " delete into black hole register "_ + normal! G"_dd + let s:Perl_PerldocTry = 'module' + let s:Perl_PerldocSearchWord = "" endif if s:UNIX " remove windows line ends @@ -908,11 +937,11 @@ function! Perl_perldoc_generate_module_list() echohl Search echo " ... generating Perl module list ... " if s:MSWIN - silent exe ":!".s:Perl_Perl." ".fnameescape(s:Perl_PerlModuleListGenerator)." > ".shellescape(s:Perl_PerlModuleList) + silent exe ":!".s:Perl_Executable." ".fnameescape(s:Perl_PerlModuleListGenerator)." > ".shellescape(s:Perl_PerlModuleList) silent exe ":!sort ".fnameescape(s:Perl_PerlModuleList)." /O ".fnameescape(s:Perl_PerlModuleList) else " direct STDOUT and STDERR to the module list file : - silent exe ":!".s:Perl_Perl." ".shellescape(s:Perl_PerlModuleListGenerator)." -s &> ".s:Perl_PerlModuleList + silent exe ":!".s:Perl_Executable." ".shellescape(s:Perl_PerlModuleListGenerator)." -s &> ".s:Perl_PerlModuleList endif redraw! echo " DONE " @@ -926,11 +955,15 @@ endfunction " ---------- end of function Perl_perldoc_generate_module_list - " RETURNS: "=============================================================================== function! Perl_Settings ( verbose ) - " + if s:MSWIN | let sys_name = 'Windows' elseif s:UNIX | let sys_name = 'UN*X' else | let sys_name = 'unknown' | endif - " + + call s:CheckPerltidy () + let perl_exe_status = s:Perl_Perl_is_executable ? '' : ' (not executable)' + let perltidy_status = s:Perl_perltidy_module_executable == 'yes' ? '' : ' ('.s:perltidy_short_message.')' + let txt = " Perl-Support settings\n\n" " template settings: macros, style, ... if exists ( 'g:Perl_Templates' ) @@ -983,29 +1016,41 @@ function! Perl_Settings ( verbose ) \ .' insert file header : "'.s:Perl_InsertFileHeader."\"\n" endif let txt .= "\n" + " ----- perlcritic -------------------------- + let txt .= " perl interpreter : ".s:Perl_Executable.perl_exe_status."\n" + if executable("perlcritic") + let txt .= " perlcritic : perlcritic -severity ".s:Perl_PerlcriticSeverity + \ .' ['.s:PCseverityName[s:Perl_PerlcriticSeverity].']' + \ ." -verbosity ".s:Perl_PerlcriticVerbosity + \ ." ".s:Perl_PerlcriticOptions."\n" + else + let txt .= " perlcritic : perlcritic (not executable)\n" + endif + let txt .= " perltidy : perltidy".perltidy_status."\n" + if !empty(s:Perl_InterfaceVersion) + let txt = txt." Perl interface version : ".s:Perl_InterfaceVersion."\n" + endif " ----- output ------------------------------ - let txt = txt." current output dest. : ".g:Perl_OutputGvim."\n" - if !s:MSWIN - let txt = txt.' xterm defaults : '.s:Perl_XtermDefaults."\n" + if a:verbose >= 1 + let txt = txt." direct run : ".s:Perl_DirectRun."\n" + let txt = txt." output method : ".g:Perl_OutputGvim."\n" endif - " ----- perlcritic -------------------------- - let txt = txt." perlcritic : perlcritic -severity ".s:Perl_PerlcriticSeverity - \ .' ['.s:PCseverityName[s:Perl_PerlcriticSeverity].']' - \ ." -verbosity ".s:Perl_PerlcriticVerbosity - \ ." ".s:Perl_PerlcriticOptions."\n" - if !empty(s:Perl_PerlExecutableVersion) - let txt = txt." Perl interface version : ".s:Perl_PerlExecutableVersion."\n" - endif - 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" - let txt = txt."_________________________________________________________________________\n" - let txt = txt." Perl-Support, Version ".g:Perl_PluginVersion." / Wolfgang Mehner / wolfgang-mehner@web.de\n\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 + 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" + if a:verbose == 2 split PerlSupport_Settings.txt put = txt @@ -1038,7 +1083,7 @@ function! Perl_SyntaxCheck () " " Errorformat from compiler/perl.vim (VIM distribution). " - exe ':set makeprg='.s:Perl_Perl.'\ -cW' + exe ':set makeprg='.s:Perl_Executable.'\ -cW' exe ':set errorformat= \%-G%.%#had\ compilation\ errors., \%-G%.%#syntax\ OK, @@ -1125,7 +1170,7 @@ let s:Perl_OutputBufferNumber = -1 function! Perl_Check_Interpreter () if !s:Perl_Perl_is_executable echohl WarningMsg - echomsg '(possibly default) Perl interpreter "'.s:Perl_Perl.'" not executable' + echomsg '(possibly default) Perl interpreter "'.s:Perl_Executable.'" not executable' echohl None return 0 endif @@ -1170,7 +1215,7 @@ function! Perl_Run () if executable(l:fullname) && s:Perl_DirectRun == 'yes' exe "!".shellescape(l:fullname).l:arguments else - exe '!'.s:Perl_Perl.' '.l:switches.shellescape(l:fullname).l:arguments + exe '!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).l:arguments endif " endif @@ -1208,7 +1253,7 @@ function! Perl_Run () if executable(l:fullname) && s:Perl_DirectRun == 'yes' exe "%!".shellescape(l:fullname).l:arguments else - exe '%!'.s:Perl_Perl.' '.l:switches.shellescape(l:fullname).l:arguments + exe '%!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).l:arguments endif " setlocal nomodifiable @@ -1227,13 +1272,13 @@ function! Perl_Run () " if s:MSWIN " MSWIN : same as "vim" - exe '!'.s:Perl_Perl.' '.l:switches.shellescape(l:fullname).l:arguments + exe '!'.s:Perl_Executable.' '.l:switches.shellescape(l:fullname).l:arguments else " Linux if executable(l:fullname) == 1 && s:Perl_DirectRun == 'yes' - silent exe '!xterm -title '.shellescape(l:fullname).' '.s:Perl_XtermDefaults.' -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).l:arguments else - silent exe '!xterm -title '.shellescape(l:fullname).' '.s:Perl_XtermDefaults.' -e '.s:Perl_Wrapper.' '.s:Perl_Perl.' '.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).l:arguments endif :redraw! endif @@ -1270,12 +1315,12 @@ function! Perl_Debugger () return endif if s:MSWIN - exe '!'. s:Perl_Perl .' -d '.shellescape( filename.l:arguments ) + exe '!'. s:Perl_Executable .' -d '.shellescape( filename.l:arguments ) else if has("gui_running") || &term == "xterm" - silent exe "!xterm ".s:Perl_XtermDefaults.' -e ' . s:Perl_Perl . l:switches .' -d '.shellescape(filename).l:arguments.' &' + 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_Perl. l:switches . ' -d '.shellescape(filename).l:arguments + silent exe '!clear; ' .s:Perl_Executable. l:switches . ' -d '.shellescape(filename).l:arguments endif endif endif @@ -1318,7 +1363,7 @@ endfunction " ---------- end of function Perl_Debugger ---------- "=============================================================================== function! Perl_XtermSize () let regex = '-geometry\s\+\d\+x\d\+' - let geom = matchstr( s:Perl_XtermDefaults, regex ) + let geom = matchstr( g:Xterm_Options, regex ) let geom = matchstr( geom, '\d\+x\d\+' ) let geom = substitute( geom, 'x', ' ', "" ) let answer= Perl_Input(" xterm size (COLUMNS LINES) : ", geom ) @@ -1326,7 +1371,7 @@ function! Perl_XtermSize () let answer= Perl_Input(" + xterm size (COLUMNS LINES) : ", geom ) endwhile let answer = substitute( answer, '\s\+', "x", "" ) " replace inner whitespaces - let s:Perl_XtermDefaults = substitute( s:Perl_XtermDefaults, regex, "-geometry ".answer , "" ) + let g:Xterm_Options = substitute( g:Xterm_Options, regex, "-geometry ".answer , "" ) endfunction " ---------- end of function Perl_XtermSize ---------- " "=== FUNCTION ================================================================ @@ -1516,53 +1561,72 @@ function! Perl_JumpCtrlJ () return '' endfunction " ---------- end of function Perl_JumpCtrlJ ---------- +"=== FUNCTION ================================================================ +" NAME: s:CheckPerltidy {{{1 +" DESCRIPTION: check whether perltidy(1) is executable and correctly set up +" PARAMETERS: - +" RETURNS: - +"=============================================================================== + let s:Perl_perltidy_startscript_executable = 'no' let s:Perl_perltidy_module_executable = 'no' -"=== FUNCTION ================================================================ -" NAME: Perl_Perltidy {{{1 -" DESCRIPTION: run perltidy(1) as a compiler -" PARAMETERS: mode - n:normal / v:visual -" RETURNS: -"=============================================================================== -function! Perl_Perltidy (mode) +let s:perltidy_long_message = '' +let s:perltidy_short_message = '' + +function! s:CheckPerltidy () - let Sou = expand("%") " name of the file in the current buffer - if (&filetype != 'perl') && - \ ( a:mode != 'v' || input( "'".Sou."' seems not to be a Perl file. Continue (y/n) : " ) != 'y' ) - echomsg "'".Sou."' seems not to be a Perl file." - return - endif - " " check if perltidy start script is executable - " if s:Perl_perltidy_startscript_executable == 'no' - if !executable("perltidy") - echohl WarningMsg - echo 'perltidy does not exist or is not executable!' - echohl None - return - else + if executable("perltidy") let s:Perl_perltidy_startscript_executable = 'yes' + else + let s:perltidy_long_message = 'perltidy does not exist or is not executable!' + let s:perltidy_short_message = 'not executable' + return endif endif - " + " check if perltidy module is executable " WORKAROUND: after upgrading Perl the module will no longer be found - " if s:Perl_perltidy_module_executable == 'no' let perltidy_version = system("perltidy -v") if match( perltidy_version, 'copyright\c' ) >= 0 && \ match( perltidy_version, 'Steve\s\+Hancock' ) >= 0 let s:Perl_perltidy_module_executable = 'yes' else - echohl WarningMsg - echo 'The module Perl::Tidy can not be found! Please reinstall perltidy.' - echohl None + let s:perltidy_long_message = 'The module Perl::Tidy can not be found! Please reinstall perltidy.' + let s:perltidy_short_message = 'module Perl::Tidy not found' return endif endif - " +endfunction " ---------- end of function s:CheckPerltidy ---------- + +"=== FUNCTION ================================================================ +" NAME: Perl_Perltidy {{{1 +" DESCRIPTION: run perltidy(1) as a compiler +" PARAMETERS: mode - n:normal / v:visual +" RETURNS: +"=============================================================================== +function! Perl_Perltidy (mode) + + let Sou = expand("%") " name of the file in the current buffer + if (&filetype != 'perl') && + \ ( a:mode != 'v' || input( "'".Sou."' seems not to be a Perl file. Continue (y/n) : " ) != 'y' ) + echomsg "'".Sou."' seems not to be a Perl file." + return + endif + + " check if perltidy is available + call s:CheckPerltidy () + + if s:Perl_perltidy_module_executable != 'yes' + echohl WarningMsg + echo s:perltidy_long_message + echohl None + return + endif + " ----- normal mode ---------------- if a:mode=="n" if Perl_Input("reformat whole file [y/n/Esc] : ", "y", '' ) != "y" @@ -2441,7 +2505,7 @@ function! Perl_InitializePerlInterface( ) # --------------------------------------------------------------- # find out the version of the Perl interface # --------------------------------------------------------------- - VIM::DoCommand("let s:Perl_PerlExecutableVersion = \"$^V\""); + VIM::DoCommand("let s:Perl_InterfaceVersion = \"$^V\""); VIM::DoCommand("let g:Perl_InterfaceInitialized = 'yes'"); # # --------------------------------------------------------------- diff --git a/syntax/template.vim b/syntax/template.vim index 6dcb50b..9ef4fb8 100644 --- a/syntax/template.vim +++ b/syntax/template.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: mm template engine : template library " Maintainer: Wolfgang Mehner -" Last Change: 30.08.2014 +" Last Change: 27.03.2016 " Version: 1.0 if version < 600 @@ -54,6 +54,7 @@ syn match Function "SetProperty\ze\s*(" syn match Function "SetMap\ze\s*(" syn match Function "SetShortcut\ze\s*(" syn match Function "SetMenuEntry\ze\s*(" +syn match Function "SetExpansion\ze\s*(" " functions: standard template syn match Function "|\zsDefaultMacro\ze("