lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2008/8/20 Peter Odding <xolox@home.nl>:
> This is going to be a long message so if you're not interested in Vim,
> 'nothing to see here, move along'. Otherwise, please bear with me :)
>
> So I've been busy learning Vim for a while now, especially Vim script
> because it allows me to script my development environment. One very nice
> feature of Vim is support for file type plug-ins. Unfortunately the Lua file
> type plug-in [1] was last updated in 2001 and isn't very useful. I've been
> working on a more full featured Lua file type plug-in for a few months now,
> and I'm getting pretty happy with the results. I'm considering submitting
> the plug-in for inclusion in the Vim runtime files but before I do that I
> want to make sure that:
>
>  * The plug-in works for more than one person...
>  * Lua-l agrees with the configuration defaults I've chosen
>  * There's no missing features that would be great to include
>
> An overview of the significant things my file type plug-in will do to your
> beloved Vim configuration (when your editing Lua source code):
>
>  * The 'includeexpr' option is set so that the gf (go to file) mapping knows
> how to resolve Lua module names using the $LUA_PATH.
>
>  * The 'include' option is set so that Vim follows dofile(), loadfile() and
> require() calls when looking for identifiers in included files (this works
> together with the 'includeexpr' option).
>
>  * An automatic command is installed that runs 'luac -p' when you save your
> Lua scripts. If luac reports any errors they are shown in the quick-fix list
> and Vim jumps to the line of the first error.
>
>  * <F1> on a Lua function or 'method' call will try to open the relevant
> documentation in the Lua Reference for Vim [2].
>
>  * The 'usercomplete' option is set to allow completion of Lua 5.1 keywords,
> global variables and library members.
>
>  * A bunch of 'text object' mappings are included so you can jump between
> blocks and functions.
>
>  * A pretty nifty hack of the matchit plug-in is included: When the cursor
> is on a 'function' or 'return' keyword the % mapping cycles between the
> relevant 'function', 'return' and 'end' keywords. Likewise for branching
> statements (if, elseif, else, end) and looping statements (for, while,
> repeat, until, end).
>
> If you've read this far, thanks for your time! There's bound to be bugs and
> it's ~370 lines of code excluding the generated completion list, so I might
> have overlooked some things. Anyways, if you want to try it out, drop the
> attached lua.vim script in your local /ftplugin/ directory (e.g.
> $HOME/vimfiles/ftplugin/lua.vim under Windows or ~/.vim/ftplugin/lua.vim
> under UNIX) and start editing some Lua source code. I hope you like it!
>
> All feedback welcome,

I'm not a very advanced vim user, so I don't know how to test most of
the features you added. However here are a few glitches on Vim 7.1 on
Windows:

- the % jump on function/if/for/etc. just doesn't work (is there
something to do to turn it on?)
- when saving my file, with no luac in the path, the logical cursor is
moved to the first non-white character of the current line, which is
very annoying
- also in the same condition as above, in insert mode, the visual
cursor is moved to the end of the status line (where the successful
saving is reported), which makes it impossible to know what the
current mode and logical cursor position
- i agree with Taylor Venable, the automatic compilation and error
reporting is rather annoying when you are used to save often
incomplete files

If you want me to test your other features on Windows, please tell me how.