0

Currently we can use many different languages to write a (neo)vim plugin. I heard that the vim language is actually pretty slow which was surprising me. I don't have the links of the websites anymore but is that true, than lua is actually faster than the vim language? Which programming lanugage would you suggest in order to write a vim plugin?

1
  • Your question was closed as primarily opinion-based—we prefer questions that can be answered with facts, citations, code, etc. Which programming lanugage would you suggest in order to write a vim plugin? is an opinion-poll. is that true, than lua is actually faster than the vim language? might be a valid question, with the right framing/care.
    – D. Ben Knoble
    Mar 6 '21 at 17:35
3

VimScript is still standard. It's supported by both Vim and Neovim and doesn't need any external dependencies or setup. This makes it #1 choice under any circumstances.

However, as VimScript is purely interpreted, it could become very slow on loops with a huge number of iterations (or, better to say, other languages can use JIT-compilers etc. not to get so slow on such loops). But it would be an issue only for huge and (over-)complicated code. After all, a Vim plugin is not RTOS or something.

Another point is VimScript syntax is a bit weird. But that's a price to pay for being both "programming language" and "command language" at the same time (think of /bin/sh).

Lua is quite nice language on its own. It painlessly supports external modules written in C and other common languages. It's small, fast and tightly integrated into Neovim. It could be a magnificent choice but... it will never be natively supported by Vim. So all Lua plugins out there are written for Neovim only.

Vim proposes Vim9Script to cure current VimScript problems but it's yet unstable. Also, Neovim will probably have poor or no support for it.

It's also possible to write plugins in other languages (e.g. Python; Lua for Vim) but using "a foreign language" usually results in complicated setup, long chain of dependencies and performance loss.

2
  • it is worth pointing out that vim does support Lua plugins, but it does not have neovim's extensive API.
    – Mass
    Mar 5 '21 at 20:11
  • @Mass Yes, as any other "foreign" language.
    – Matt
    Mar 5 '21 at 20:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.