Hacker News new | ask | show | jobs
by runningskull 2353 days ago
I’m torn by the idea of replacing vimscript with lua. I honestly enjoy both languages (vimscript is not as bad as its reputation!) but they each shine in different use-cases. Lua is more ergonomic for writing programs/plugins, but vimscript is more ergonomic for interactive use (and maybe config files, more below).

For non-vimmers, a good analogy is the shell: would you want to replace sh with a more robust language like lua? Few people seem to enjoy writing larger programs in sh, and are quick to jump to perl/python/ruby once a script crosses some complexity threshold. However, I doubt many people would want to give up sh for interactive use. Mainly[0] due to omitting “cruft” like parens/quotes/commas, and also pipe syntax. Minimal example:

    ls -laht | grep foo
is nicer than

    grep(ls(‘laht’), ‘foo’)
especially when you’re doing thousands of commands of varying complexity every day.

Vimscript is similar, again mainly due to omitting “cruft” like parens/quotes/commas, and also some specific sugar. Minimal examples:

    iabbr cosnt const
is nicer than

    iabbr(‘cosnt’, ‘const’) 
and

    s/foo/bar/g
is nicer than

    sub(‘foo’, ‘bar’, ‘g’)
especially when you’re doing hundreds (thousands?) of commands of varying complexity every day.

Besides setting options, the vast majority of the “meat” of my config file boils down to these types of commands, and is thus much more readable with the cruft omitted, even though I only have to type it once.

This could probably be addressed with some light syntax sugar on top of lua, and I think I remember seeing some comments from the Neovim folks about this very thing, but I’m not able to find anything concrete at the moment. Does anyone know where this stands?

[0] Of course, another issue (for both shell-scripting and vim) is the huge amount of tools built on top of the existing language, which we may be remiss to abandon. For shells, it’s probably practically impossible. For vim, I suspect it is possible, though it would be painful enough to merit a long hard think.

1 comments

I you are having your editor change "cosnt" to "const", or "isntall" to "install", you are programming your fingers to be unable to type them correctly. You will regret it, but it will be too late.