luasupport.txt Lua Support Jul 23 2016
Lua Support lua-support luasupport
Plug-in version 1.0
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.
See the chapter |luasupport-introduction| for a quick overview and a short
guide to this documentation.
Lua is: Copyright 1994-2015 Lua.org, PUC-Rio.
0. TABLE OF CONTENTS luasupport-support-contents
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|
2.1.2 Comment Lines |luasupport-usage-comments-lines|
2.1.3 Automated Comments |luasupport-usage-comments-auto|
2.2 Regex |luasupport-usage-regex|
2.3 Snippets |luasupport-usage-snippets|
2.4 Run and Compile |luasupport-usage-run|
2.4.1 Using QuickFix |luasupport-usage-qf|
2.5 Hardcopy |luasupport-usage-hardcopy|
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|
4. Configuration |luasupport-configuration|
4.1 Executables |luasupport-config-executable|
4.1.1 Direct Run |luasupport-config-direct-run|
4.1.2 Output Redirection |luasupport-config-output|
4.1.3 Xterm |luasupport-config-xterm|
4.2 Menus |luasupport-config-menus|
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|
5. System-wide Installation |luasupport-system-wide|
A. Troubleshooting - Known Issues |luasupport-troubleshooting|
B. Release Note
s - Change Log |luasupport-release-notes|
C. Credits |luasupport-credits|
1. INTRODUCTION luasupport-introduction
After the first Lua file (*.lua) has been opened, the menu "Lua" 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 Lua.
(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. |luasupport-usage-comments-lines| - Automatically add comments for functions and their parameters. |luasupport-usage-comments-auto| - Open the online documentation for a given function. |luasupport-usage-help| - Run or compile the code. |luasupport-usage-run| - Invoke the syntax checker "luac -p". |luasupport-usage-run| - Set the interpreter/compiler executable on-the-fly. |luasupport-usage-run| - Manage code snippets. |luasupport-usage-snippets| - An extendible template library. |luasupport-templates| - Make integration. |luasupport-usage-toolbox| 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 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|).
2. USAGE luasupport-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.
2.1 COMMENTS luasupport-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 insert long comment Comments.insert long comment<LocalLeader>
cil remove long comment Comments.remove long comment<LocalLeader>
crl automatic function Comments.func. desc. (auto)<LocalLeader>
ca description ----------------------------------------------------------------------------
2.1.1 End-of-Line Comments luasupport-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:Lua_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 entry of the table can be documented.
2.1.2 Comment Lines luasupport-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;
The map \cil inserts a long comment:--[[ -- BlockCommentNo_1 --
...
--]] -- BlockCommentNo_1 --
In visual mode, the selected lines are surrounded by a long comment, preventing their execution. To remove the inner-most long comment, use \crl.
2.1.3 Automated Comments luasupport-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 placing the cursor in the line defining the function, use "Comments -> function description (auto)". The appearance can be change in the template library. Example: Consider the function definition:function compare ( op1, op2 )
end
After placing the cursor on the function definition line, invoke the auto comment. The result will look like this:------------------------------------------------------------------------
-- Name: compare
-- Purpose:
<CURSOR IS PLACED HERE>
-- Description:
{+DESCRIPTION+}
-- Parameters: op1 -
{+DESCRIPTION+}
({+TYPE+}
)-- op2 -
{+DESCRIPTION+}
({+TYPE+}
)-- Returns:
{+RETURNS+}
------------------------------------------------------------------------
function compare ( op1, op2 )
end
After typing a brief description, use<
to jump to the various tags:CTRL-J
>and fill in the information (see Sec. |luasupport-templates-jump-tags|).
{+TAG+}
2.2 REGEX luasupport-usage-regex
The menu regex helps with writing patterns. It contains all the elements of
patterns, including all character classes. Most of the menu entries are
defined in the template library. The entry "Regex -> character classes
-> printable char." inserts no text for Lua 5.1, since this feature was
introduced in Lua 5.2.
The menu entry "Regex -> esc. magic char." is not part of the template
library. It can be used to escape the character under (in normal mode) or
behind (in insert mode) the cursor. If it is one of the magic characters, a
"%" will be inserted.
Feature Menu Entry Map
----------------------------------------------------------------------------
escape magic character Regex.esc. magic char. <LocalLeader>
xe
----------------------------------------------------------------------------
2.3 SNIPPETS luasupport-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 by 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:Lua_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.4 RUN AND COMPILE luasupport-usage-run
The file in the current buffer can be run or compiled with a keystroke. (See Section |luasupport-config-executable| for the configuration.) Feature Menu Entry Map ---------------------------------------------------------------------------- run the code Run.run<LocalLeader>
rr compile the code Run.compile<LocalLeader>
rc 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 output method for "run" Run.output method<LocalLeader>
ro change "direct run" Run.direct run<LocalLeader>
rd change the interpreter Run.set executable<LocalLeader>
rse 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|. The functionality is also available through commands. These commands can also be used to set different maps in the ftplugin. Command Explanation ---------------------------------------------------------------------------- :Lua<args>
run the script with arguments :LuaCompile compile the script :LuaCheck run the code checker :LuaOutputMethod [<method>
] set (or print) the output method :LuaDirectRun [<yes_no>
] set (or print) the option "direct run" :LuaExecutable [<exec>
] set (or print) the interpreter :LuaCompilerExec [<exec>
] set (or print) the compiler ---------------------------------------------------------------------------- The output from running the script can be made accessible in several ways. The menu entry "Run -> output method" is used to select the method. Some methods can be used interactively and support input via the command line, while other methods are non-interactive but support |quickfix
| (see |luasupport-config-output|). If the output method "buffer" is used, the scripts output is echoed into a buffer "Lua Output". If the Lua interpreter terminated the script because of an error, the trace will be made accessible via the quickfix list. The output might still contain error locations, even if the script terminated successfully, for example from using "pcall(...)". In this case the content of the "Lua Output" buffer can be loaded into the quickfix list using the map \qf or the menu entry "Run -> buffer 'Lua Output' -> load into quickfix". The interpreter and compiler executables can be changed on-the-fly, using the maps, menu entries or ex-commands::LuaExecutable lua5.1
:LuaCompilerExec luac5.1
Executable scripts can be run directly, without using the interpreter set via |:LuaExecutable|. Use the map, menu entry, or the ex-command::LuaDirectRun yes
(see |luasupport-config-direct-run|) The extension for compiled chunks can be changed using the global variable |g:Lua_CompiledExtension|, the default is "luac". 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 |luasupport-usage-qf|)
2.4.1 Using QuickFix luasupport-usage-qf Vim's QuickFix facility is described here: |quickfix
|. 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
You can now use F5 and F6 to open and close the quickfix window and F7 and F8 to jump to the errors.<silent>
<F8>
:cnext<CR>
2.5 HARDCOPY luasupport-usage-hardcopy
The current buffer, or a range in it, can be quickly printed into a file,
using the menu entry "Run -> hardcopy to filename.ps".
Feature Menu Entry Map
----------------------------------------------------------------------------
hardcopy to postscript Run.hardcopy to ... <LocalLeader>
rh
----------------------------------------------------------------------------
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.
The printheader on top of each page can be set via |g:Lua_Printheader|.
2.6 HELP luasupport-usage-help
The menu "Help" speeds up the access to various resources, such as the online documentation of Lua functions or an English dictionary. Feature Menu Entry Map ---------------------------------------------------------------------------- open English dictionary Help.English<LocalLeader>
he open online reference Help.Lua function, browser<LocalLeader>
hl for a library function open Vim help for a 5.1 Help.Lua 51 function, Vim help<LocalLeader>
h1 library function open Vim help for a 5.2 Help.Lua 52 function, Vim help<LocalLeader>
h2 library function open Vim help for a 5.3 Help.Lua 53 function, Vim help<LocalLeader>
h3 library function open plug-in help Help.help (Lua support)<LocalLeader>
hs ---------------------------------------------------------------------------- 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.) For file handle methods help will be show as well. Every method call of the formwill open the help for the function
<var-name>
:flush ( )file:flush
and similarly for all file handle methods. Similarly, the help can be read in Vim's help format, using the maps "\h1", "\h2", and "\h3", for Lua 5.1, 5.2, and 5.3 respectively. Example: Place the cursor on "sin" and invoke the map:a = math.sin ( r * pi )
The following URL will be opened in your browser (using "\hl"):http://www.lua.org/manual/5.2/manual.html#pdf-math.sin
or the following help topic will be shown (using "\h2")::help lua52-math.sin
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 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 installed (<PATH_TO_PLUG>
/plugin/lua-support.vim) and add this line to the .vimrc:call mmtemplates#config#Add ( 'C', '
The first parameter adds the file to your C 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 '\ntL' in this example. The name of the pointer to the Lua state is set to "L" in all the templates, just as it is named in the Lua reference manual. It can be changed in your C-Support template customization file (see |csupport-templates|), by setting the macro |LUA_STATE| :<PATH_TO_PLUG>
/lua-support/templates-c-api/Templates', 'Lua', 'ntL' )SetMacro( 'LUA_STATE', '
Use this menu entry to set up the file: C/C++ -> Snippets -> template setup wizard<name>
' )
2.8 TOOLBOX luasupport-usage-toolbox
More functionality, not directly related to Lua, 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 comes with its own documentation, see |toolbox| and |toolbox-make|.
3. TEMPLATES luasupport-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
Lua Support (see |g:Lua_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|
3.1 INTRODUCTION luasupport-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 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.
3.2 JUMP TAGS luasupport-templates-jump-tags
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 -<
delete optional tag -CTRL-J
><
---------------------------------------------------------------------------- Use theCTRL-D
><
to jump to the next tag. The maps works in normal and insert mode. UseCTRL-J
><
to delete optional tags on the same line, for example:CTRL-D
>string.match (
The optional argument "init" can be written down after jumping to the tag using<+str+>
,<+pattern+>
, [+init+] )<
or deleted together with the comma usingCTRL-J
><
.CTRL-D
>
3.3 SPLIT TAGS luasupport-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<
to jump to the else-part.CTRL-J
>
3.4 AUXILIARY FUNCTIONS luasupport-templates-aux
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 "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. 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".
4. CONFIGURATION luasupport-configuration
The basic configuration is done via a number of global variables, which can be
set in the .vimrc file.
Variable Default Description
----------------------------------------------------------------------------
|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_CompilerExec| 'luac' the luac executable (^1)
|g:Lua_CompiledExtension| 'luac' extension used for compile chunks
|g:Lua_LoadMenus| 'auto' when to load the menus ('startup',
'auto' or 'manual')
|g:Lua_RootMenu| '&Lua' name and shortcut of the root menu
|g:Lua_MapLeader| '' the |maplocalleader
| used for maps
|g:Lua_InsertFileHeader| 'yes' insert a file header automatically
|g:Lua_LineEndCommentColumn| standard column used for end-of-
49 line comments
|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:Templates_PersonalizationFile|
(see below) the personalization template file
|g:Lua_Printheader| '...' printheader used for hardcopy
|g:Lua_UseToolbox| 'yes' use the toolbox
|g:Lua_UseTool_make| 'yes' use the make tool
g:Xterm_Executable 'xterm' the xterm executable (^2)
g:Xterm_Options '...' the xterm default settings (^2)
----------------------------------------------------------------------------
Further customization is carried out in the template library:
- |luasupport-config-template-cstm|
- |luasupport-config-browser|
(^1)
The Unix defaults are as follows:
|g:Lua_BinPath| - -empty-
|g:Lua_Executable| - g:Lua_BinPath + lua
|g:Lua_CompilerExec| - g:Lua_BinPath + luac
the Windows defaults are as follows:
|g:Lua_BinPath| - -empty-
|g:Lua_Executable| - g:Lua_BinPath + lua
|g:Lua_CompilerExec| - g:Lua_BinPath + luac
(^2) UNIX only, see |luasupport-config-xterm|
4.1 EXECUTABLES luasupport-config-executable
g:Lua_BinPath The path to the executables is set by g:Lua_BinPath:let g:Lua_BinPath = '/usr/local/bin/'
Since lua and luac 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:Lua_BinPath = 'C:\Program Files\Lua\bin\'
The defaults for |g:Lua_Executable|, and |g:Lua_CompilerExec| are derived from g:Lua_BinPath. However, the setting g:Lua_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:Lua_Executable The executable is set by g:Lua_Executable. For Windows, set up the executable similar to this:let g:Lua_Executable = 'C:\Program Files\Lua\bin\lua.exe'
While Vim is running, the interpreter can be changed on the fly using the menu entries or the map "\rse" (see |luasupport-usage-run|). g:Lua_CompilerExec The compiler is set by g:Lua_CompilerExec. For Windows, set up the executable similar to this:let g:Lua_CompilerExec = 'C:\Program Files\Lua\bin\luac.exe'
While Vim is running, the compiler can be changed on the fly using the menu entries or the map "\rsc" (see |luasupport-usage-run|). g:Lua_CompiledExtension 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.
4.1.1 Direct Run luasupport-config-direct-run g:Lua_DirectRun When running a script using ":Lua<args>
", the default behavior is to call the interpreter set via |g:Lua_Executable| and pass the scriptname and the optional arguments. For executable scripts, this can be changed by setting:g:Lua_DirectRun = 'yes'
Subsequently, executable scripts will be used as the executable directly. This can be useful when working with different versions of Lua, or when using own applications to interpret Lua scripts. The possible settings are listed below: Value Meaning ---------------------------------------------------------------------------- 'yes' use executable scripts themselves as the executable 'no' (default) all scripts are run using |g:Lua_Executable| ---------------------------------------------------------------------------- The behavior can be changed on the fly using the menu entry or the map "\rd" (see |luasupport-usage-run|).
4.1.2 Output Redirection luasupport-config-output
g:Lua_OutputMethod
The initial method for output redirection can be set via g:Lua_OutputMethod:
let g:Lua_OutputMethod = 'buffer'
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
'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 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|)
----------------------------------------------------------------------------
4.1.3 Xterm luasupport-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.
4.2 MENUS luasupport-config-menus
g:Lua_LoadMenus The creation of the menus is controlled by g:Lua_LoadMenus. The default setting:let g:Lua_LoadMenus = 'auto'
causes the templates to be loaded and the menus to be created when the first Lua file is opened. The menus appear right away after starting Vim with the setting:let g:Lua_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:Lua_LoadMenus = 'manual'
Now the menus can only be loaded by using the tool menu entry "Tools.Load Lua Support". g:Lua_RootMenu The name and shortcut of the root menu is set via g:Lua_RootMenu. The character prefixed by '&' will be the shortcut. Example:let g:Lua_RootMenu = 'Lu&a'
Sets the shortcut to 'a'.
4.3 MAPS luasupport-config-maps
g:Lua_MapLeader All the maps the plug-in creates use |maplocalleader
|. It can be changed by setting the variable g:Lua_MapLeader. If it contains the empty string, Vim's default (backslash) is used. Example:let g:Lua_MapLeader = '#'
Sets the mapleader to '#'. Lua_SetMapLeader() Lua_ResetMapLeader() The configured mapleader can also be used in the ftplugin, by calling the functions Lua_SetMapLeader() and Lua_ResetMapLeader(). The maps created between the two calls will use |g:Lua_MapLeader| as the |<LocalLeader>
|:call Lua_SetMapLeader ()
map
<buffer>
<LocalLeader>
eg :echo "Example Map :)"<CR>
call Lua_ResetMapLeader ()
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. 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.". Example:let g:Lua_LineEndCommentColumn = 59
4.5 SNIPPETS luasupport-config-snippets
g:Lua_SnippetDir The variable g:Lua_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:Lua_SnippetDir = $HOME.'/.vim/lua/codesnippets/'
or (Windows):s:Lua_SnippetDir = $HOME.'/vimfiles/lua/codesnippets'
For a sytem-wide installation, the default will be:s:Lua_SnippetDir = $VIM.'/vimfiles/lua/codesnippets'
Example: To set a different code snippet directory, add this line to your vimrc:let g:Lua_SnippetDir = $HOME.'/myvim/lua/codesnippets/'
g:Lua_SnippetBrowser Code snippets can either be selected in a file browser, by setting:let g:Lua_SnippetBrowser = 'gui'
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:The default for the local template file is:
<RUNTIMEPATH>
/plugin/lua-support.vimg:Lua_LocalTemplateFile
= '
There is no global template file. System-wide installation (|luasupport-system-wide|): The default for the global template file is:<RUNTIMEPATH>
/lua-support/templates/Templates'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
|: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:
<RUNTIMEPATH>
/templates/personal.templatescall 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
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 'printheader' while printing the hardcopy. See the documentation of the option 'printheader' for the possible contents of g:Lua_Printheader. 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
g:Lua_UseToolbox g:Lua_UseTool_make The loading of the toolbox can be prevented by adding this setting to the vimrc:let g:Lua_UseToolbox = 'no'
A single tool can be disabled by setting "g:Lua_UseTool_<toolname>
", in case of the "make" tool:let g:Lua_UseTool_make = 'no'
5. SYSTEM-WIDE INSTALLATION luasupport-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 a name and mail. So in case of a system-wide installation, every user should use the customization options, which allow to put customization files into each users' home directory. 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 Lua Support Copy the archive lua-support.zip to this new directory and unpack it:unzip lua-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 |luasupport-config-template-lib|):let g:Lua_GlobalTemplateFile =
\ '/usr/share/vim/site/lua-support/templates/Templates'
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|)
A. 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). This behavior can be changed: :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 :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 lua-support/README.md. * How can I see what was loaded? - Use ':scriptnames' from the Vim command line. * Lua is not running. - Is "lua" executable from the command line? - Is the $PATH variable set correctly? - Are the settings correct? See: :help |luasupport-config-executable| - 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=\"
B. RELEASE NOTE
S - CHANGE LOG luasupport-release-notes
See files 'lua-support/README.md' and 'lua-support/doc/ChangeLog'.
C. CREDITS luasupport-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 Luis Carvalho (Kozure): - 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 )
vim:tw=78:expandtab:ts=2:ft=help:norl:
Generated by vim2html (modified) on So 14. Aug 17:16:25 CEST 2016