lua-users home
lua-l archive

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


On Wed, Jul 27, 2011 at 02:31, Dirk Laurie <dpl@sun.ac.za> wrote:
> On Tue, Jul 19, 2011 at 03:07:57AM +0200, Steve Litt wrote:
>>
>> 7) Use Python's space delimited blocks instead of end. I like the way
>> Python does it. But seeing as nobody else does, I'll shut up. Vim has
>> excellent syntax highlighting, making this a trivial point.
>>
>
> The most useful thing about Vim's Lua syntax highlighting is that `end`
> is a different color (same as `function`) at the end of a function than
> elsewhere.  This makes it much easier to track where the many `end`s
> come from.  But an already excellent implementation could be even better
> if `do` ... `end also differed from `if` ... `end`.
>
> I'm using a hack: in ~/.vim/syntax/lua.vim (which, if present, is
> preferred to the system-wide one), I've changed this line:
>
>>  HiLink luaCond        Structure   " was: Conditional
>
> (The "Structure" class has a color of its own, used only to highlight
> `{` and `}`.)
>
> This makes the three kinds of `end` all different, but `then` and
> `else` also get highlighted differently, whereas only `if` IMHO needs
> to be: it's the `if` that gets paired with the `end`. But  short of
> learning how to write syntax files, as opposed to patching them from
> a position of ignorance, I can't see how.
>
> Dirk
>
>
>

I don't use Vim, but I use a fairly simple method to make it clear
which 'end' corresponds to what when there are several:
if foo then
  while bar then
    something = function(...)
      doThings(...)
    end --function
  end --while bar
end --if foo

A lot of things people suggest "to make the code more readable" can be
implemented with just good comments.

-- 
Sent from my toaster.